Class: Window_ShopNumber

Inherits:
Window_Selectable show all
Defined in:
lib/rgss3_default_scripts/Window_ShopNumber.rb

Overview

** Window_ShopNumber


This window is for inputting quantity of items to buy or sell on the shop

screen.

Instance Attribute Summary collapse

Attributes inherited from Window_Selectable

#cursor_all, #cursor_fix, #help_window, #index

Instance Method Summary collapse

Methods inherited from Window_Selectable

#active=, #bottom_row, #bottom_row=, #call_cancel_handler, #call_handler, #call_ok_handler, #call_update_help, #cancel_enabled?, #clear_item, #col_max, #contents_height, #current_item_enabled?, #cursor_down, #cursor_left, #cursor_movable?, #cursor_pagedown, #cursor_pageup, #cursor_right, #cursor_up, #draw_all_items, #draw_item, #ensure_cursor_visible, #handle?, #height=, #horizontal?, #item_height, #item_max, #item_rect, #item_rect_for_text, #item_width, #ok_enabled?, #page_item_max, #page_row_max, #process_cancel, #process_cursor_move, #process_handling, #process_ok, #process_pagedown, #process_pageup, #redraw_current_item, #redraw_item, #row, #row_max, #select, #set_handler, #spacing, #top_row, #top_row=, #unselect, #update_help, #update_padding, #update_padding_bottom

Methods inherited from Window_Base

#activate, #actor_name, #calc_line_height, #change_color, #close, #contents_height, #contents_width, #convert_escape_characters, #create_contents, #crisis_color, #deactivate, #dispose, #draw_actor_class, #draw_actor_face, #draw_actor_graphic, #draw_actor_hp, #draw_actor_icons, #draw_actor_level, #draw_actor_mp, #draw_actor_name, #draw_actor_nickname, #draw_actor_param, #draw_actor_simple_status, #draw_actor_tp, #draw_character, #draw_currency_value, #draw_current_and_max_values, #draw_face, #draw_gauge, #draw_icon, #draw_item_name, #draw_text, #draw_text_ex, #fitting_height, #gauge_back_color, #hide, #hp_color, #hp_gauge_color1, #hp_gauge_color2, #knockout_color, #line_height, #make_font_bigger, #make_font_smaller, #mp_color, #mp_cost_color, #mp_gauge_color1, #mp_gauge_color2, #normal_color, #obtain_escape_code, #obtain_escape_param, #open, #param_change_color, #party_member_name, #pending_color, #power_down_color, #power_up_color, #process_character, #process_draw_icon, #process_escape_character, #process_new_line, #process_new_page, #process_normal_character, #reset_font_settings, #show, #standard_padding, #system_color, #text_color, #text_size, #tp_color, #tp_cost_color, #tp_gauge_color1, #tp_gauge_color2, #translucent_alpha, #update_close, #update_open, #update_padding, #update_tone

Constructor Details

#initialize(x, y, height) ⇒ Window_ShopNumber


  • Object Initialization




16
17
18
19
20
21
22
23
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 16

def initialize(x, y, height)
  super(x, y, window_width, height)
  @item = nil
  @max = 1
  @price = 0
  @number = 1
  @currency_unit = Vocab::currency_unit
end

Instance Attribute Details

#numberObject (readonly)


  • Public Instance Variables




12
13
14
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 12

def number
  @number
end

Instance Method Details

#change_number(amount) ⇒ Object


  • Change Quantity




128
129
130
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 128

def change_number(amount)
  @number = [[@number + amount, @max].min, 1].max
end

#currency_unit=(currency_unit) ⇒ Object


  • Set Currency Unit




44
45
46
47
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 44

def currency_unit=(currency_unit)
  @currency_unit = currency_unit
  refresh
end

#cursor_widthObject


  • Get Cursor Width




87
88
89
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 87

def cursor_width
  figures * 10 + 12
end

#cursor_xObject


  • Get X Coordinate of Cursor




93
94
95
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 93

def cursor_x
  contents_width - cursor_width - 4
end

#draw_numberObject


  • Draw Quantity




60
61
62
63
64
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 60

def draw_number
  change_color(normal_color)
  draw_text(cursor_x - 28, item_y, 22, line_height, "×")
  draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
end

#draw_total_priceObject


  • Draw Total Price




68
69
70
71
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 68

def draw_total_price
  width = contents_width - 8
  draw_currency_value(@price * @number, @currency_unit, 4, price_y, width)
end

#figuresObject


  • Get Maximum Number of Digits for Quantity Display




99
100
101
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 99

def figures
  return 2
end

#item_yObject


  • Y Coordinate of Item Name Display Line




75
76
77
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 75

def item_y
  contents_height / 2 - line_height * 3 / 2
end

#price_yObject


  • Y Coordinate of Price Display Line




81
82
83
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 81

def price_y
  contents_height / 2 + line_height / 2
end

#refreshObject


  • Refresh




51
52
53
54
55
56
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 51

def refresh
  contents.clear
  draw_item_name(@item, 0, item_y)
  draw_number
  draw_total_price
end

#set(item, max, price, currency_unit = nil) ⇒ Object


  • Set Item, Max Quantity, Price, and Currency Unit




33
34
35
36
37
38
39
40
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 33

def set(item, max, price, currency_unit = nil)
  @item = item
  @max = max
  @price = price
  @currency_unit = currency_unit if currency_unit
  @number = 1
  refresh
end

#updateObject


  • Frame Update




105
106
107
108
109
110
111
112
113
114
115
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 105

def update
  super
  if active
    last_number = @number
    update_number
    if @number != last_number
      Sound.play_cursor
      refresh
    end
  end
end

#update_cursorObject


  • Update Cursor




134
135
136
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 134

def update_cursor
  cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
end

#update_numberObject


  • Update Quantity




119
120
121
122
123
124
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 119

def update_number
  change_number(1)   if Input.repeat?(:RIGHT)
  change_number(-1)  if Input.repeat?(:LEFT)
  change_number(10)  if Input.repeat?(:UP)
  change_number(-10) if Input.repeat?(:DOWN)
end

#window_widthObject


  • Get Window Width




27
28
29
# File 'lib/rgss3_default_scripts/Window_ShopNumber.rb', line 27

def window_width
  return 304
end