Class: Scene_Shop
- Inherits:
-
Scene_MenuBase
- Object
- Scene_Base
- Scene_MenuBase
- Scene_Shop
- Defined in:
- lib/rgss3_default_scripts/Scene_Shop.rb
Overview
** Scene_Shop
This class performs shop screen processing.
Instance Method Summary collapse
-
#activate_buy_window ⇒ Object
————————————————————————– * Activate Purchase Window ————————————————————————–.
-
#activate_sell_window ⇒ Object
————————————————————————– * Activate Sell Window ————————————————————————–.
-
#buying_price ⇒ Object
————————————————————————– * Get Purchase Price ————————————————————————–.
-
#command_buy ⇒ Object
————————————————————————– * [Buy] Command ————————————————————————–.
-
#command_sell ⇒ Object
————————————————————————– * [Sell] Command ————————————————————————–.
-
#create_buy_window ⇒ Object
————————————————————————– * Create Purchase Window ————————————————————————–.
-
#create_category_window ⇒ Object
————————————————————————– * Create Category Window ————————————————————————–.
-
#create_command_window ⇒ Object
————————————————————————– * Create Command Window ————————————————————————–.
-
#create_dummy_window ⇒ Object
————————————————————————– * Create Dummy Window ————————————————————————–.
-
#create_gold_window ⇒ Object
————————————————————————– * Create Gold Window ————————————————————————–.
-
#create_number_window ⇒ Object
————————————————————————– * Create Quantity Input Window ————————————————————————–.
-
#create_sell_window ⇒ Object
————————————————————————– * Create Sell Window ————————————————————————–.
-
#create_status_window ⇒ Object
————————————————————————– * Create Status Window ————————————————————————–.
-
#currency_unit ⇒ Object
————————————————————————– Get Currency Unit ————————————————————————–.
-
#do_buy(number) ⇒ Object
————————————————————————– * Execute Purchase ————————————————————————–.
-
#do_sell(number) ⇒ Object
————————————————————————– * Execute Sale ————————————————————————–.
-
#end_number_input ⇒ Object
————————————————————————– * Exit Quantity Input ————————————————————————–.
-
#max_buy ⇒ Object
————————————————————————– * Get Maximum Quantity Buyable ————————————————————————–.
-
#max_sell ⇒ Object
————————————————————————– * Get Maximum Quantity Sellable ————————————————————————–.
-
#money ⇒ Object
————————————————————————– * Get Party Gold ————————————————————————–.
-
#on_buy_cancel ⇒ Object
————————————————————————– * Buy [Cancel] ————————————————————————–.
-
#on_buy_ok ⇒ Object
————————————————————————– * Buy [OK] ————————————————————————–.
-
#on_category_cancel ⇒ Object
————————————————————————– * Category [Cancel] ————————————————————————–.
-
#on_category_ok ⇒ Object
————————————————————————– * Category [OK] ————————————————————————–.
-
#on_number_cancel ⇒ Object
————————————————————————– * Quantity Input [Cancel] ————————————————————————–.
-
#on_number_ok ⇒ Object
————————————————————————– * Quantity Input [OK] ————————————————————————–.
-
#on_sell_cancel ⇒ Object
————————————————————————– * Sell [Cancel] ————————————————————————–.
-
#on_sell_ok ⇒ Object
————————————————————————– * Sell [OK] ————————————————————————–.
-
#prepare(goods, purchase_only) ⇒ Object
————————————————————————– * Prepare ————————————————————————–.
-
#selling_price ⇒ Object
————————————————————————– * Get Sale Price ————————————————————————–.
-
#start ⇒ Object
————————————————————————– * Start Processing ————————————————————————–.
Methods inherited from Scene_MenuBase
#create_background, #create_help_window, #dispose_background, #next_actor, #on_actor_change, #prev_actor, #terminate
Methods inherited from Scene_Base
#check_gameover, #create_main_viewport, #dispose_all_windows, #dispose_main_viewport, #fadeout_all, #main, #perform_transition, #post_start, #pre_terminate, #return_scene, #scene_changing?, #terminate, #transition_speed, #update, #update_all_windows, #update_basic
Instance Method Details
#activate_buy_window ⇒ Object
-
Activate Purchase Window
126 127 128 129 130 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 126 def activate_buy_window @buy_window.money = money @buy_window.show.activate @status_window.show end |
#activate_sell_window ⇒ Object
-
Activate Sell Window
134 135 136 137 138 139 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 134 def activate_sell_window @category_window.show @sell_window.refresh @sell_window.show.activate @status_window.hide end |
#buying_price ⇒ Object
-
Get Purchase Price
290 291 292 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 290 def @buy_window.price(@item) end |
#command_buy ⇒ Object
- Buy
-
Command
143 144 145 146 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 143 def command_buy @dummy_window.hide activate_buy_window end |
#command_sell ⇒ Object
- Sell
-
Command
150 151 152 153 154 155 156 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 150 def command_sell @dummy_window.hide @category_window.show.activate @sell_window.show @sell_window.unselect @sell_window.refresh end |
#create_buy_window ⇒ Object
-
Create Purchase Window
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 86 def create_buy_window wy = @dummy_window.y wh = @dummy_window.height @buy_window = Window_ShopBuy.new(0, wy, wh, @goods) @buy_window. = @buy_window.help_window = @help_window @buy_window.status_window = @status_window @buy_window.hide @buy_window.set_handler(:ok, method(:on_buy_ok)) @buy_window.set_handler(:cancel, method(:on_buy_cancel)) end |
#create_category_window ⇒ Object
-
Create Category Window
100 101 102 103 104 105 106 107 108 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 100 def create_category_window @category_window = Window_ItemCategory.new @category_window. = @category_window.help_window = @help_window @category_window.y = @dummy_window.y @category_window.hide.deactivate @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:on_category_cancel)) end |
#create_command_window ⇒ Object
-
Create Command Window
42 43 44 45 46 47 48 49 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 42 def create_command_window @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only) @command_window. = @command_window.y = @help_window.height @command_window.set_handler(:buy, method(:command_buy)) @command_window.set_handler(:sell, method(:command_sell)) @command_window.set_handler(:cancel, method(:return_scene)) end |
#create_dummy_window ⇒ Object
-
Create Dummy Window
53 54 55 56 57 58 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 53 def create_dummy_window wy = @command_window.y + @command_window.height wh = Graphics.height - wy @dummy_window = Window_Base.new(0, wy, Graphics.width, wh) @dummy_window. = end |
#create_gold_window ⇒ Object
-
Create Gold Window
33 34 35 36 37 38 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 33 def create_gold_window @gold_window = Window_Gold.new @gold_window. = @gold_window.x = Graphics.width - @gold_window.width @gold_window.y = @help_window.height end |
#create_number_window ⇒ Object
-
Create Quantity Input Window
62 63 64 65 66 67 68 69 70 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 62 def create_number_window wy = @dummy_window.y wh = @dummy_window.height @number_window = Window_ShopNumber.new(0, wy, wh) @number_window. = @number_window.hide @number_window.set_handler(:ok, method(:on_number_ok)) @number_window.set_handler(:cancel, method(:on_number_cancel)) end |
#create_sell_window ⇒ Object
-
Create Sell Window
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 112 def create_sell_window wy = @category_window.y + @category_window.height wh = Graphics.height - wy @sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh) @sell_window. = @sell_window.help_window = @help_window @sell_window.hide @sell_window.set_handler(:ok, method(:on_sell_ok)) @sell_window.set_handler(:cancel, method(:on_sell_cancel)) @category_window.item_window = @sell_window end |
#create_status_window ⇒ Object
-
Create Status Window
74 75 76 77 78 79 80 81 82 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 74 def create_status_window wx = @number_window.width wy = @dummy_window.y ww = Graphics.width - wx wh = @dummy_window.height @status_window = Window_ShopStatus.new(wx, wy, ww, wh) @status_window. = @status_window.hide end |
#currency_unit ⇒ Object
Get Currency Unit
284 285 286 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 284 def currency_unit @gold_window.currency_unit end |
#do_buy(number) ⇒ Object
-
Execute Purchase
239 240 241 242 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 239 def do_buy(number) $game_party.lose_gold(number * ) $game_party.gain_item(@item, number) end |
#do_sell(number) ⇒ Object
-
Execute Sale
246 247 248 249 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 246 def do_sell(number) $game_party.gain_gold(number * selling_price) $game_party.lose_item(@item, number) end |
#end_number_input ⇒ Object
-
Exit Quantity Input
253 254 255 256 257 258 259 260 261 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 253 def end_number_input @number_window.hide case @command_window.current_symbol when :buy activate_buy_window when :sell activate_sell_window end end |
#max_buy ⇒ Object
-
Get Maximum Quantity Buyable
265 266 267 268 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 265 def max_buy max = $game_party.max_item_number(@item) - $game_party.item_number(@item) == 0 ? max : [max, money / ].min end |
#max_sell ⇒ Object
-
Get Maximum Quantity Sellable
272 273 274 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 272 def max_sell $game_party.item_number(@item) end |
#money ⇒ Object
-
Get Party Gold
278 279 280 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 278 def money @gold_window.value end |
#on_buy_cancel ⇒ Object
-
Buy [Cancel]
169 170 171 172 173 174 175 176 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 169 def on_buy_cancel @command_window.activate @dummy_window.show @buy_window.hide @status_window.hide @status_window.item = nil @help_window.clear end |
#on_buy_ok ⇒ Object
-
Buy [OK]
160 161 162 163 164 165 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 160 def on_buy_ok @item = @buy_window.item @buy_window.hide @number_window.set(@item, max_buy, , currency_unit) @number_window.show.activate end |
#on_category_cancel ⇒ Object
-
Category [Cancel]
187 188 189 190 191 192 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 187 def on_category_cancel @command_window.activate @dummy_window.show @category_window.hide @sell_window.hide end |
#on_category_ok ⇒ Object
-
Category [OK]
180 181 182 183 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 180 def on_category_ok activate_sell_window @sell_window.select(0) end |
#on_number_cancel ⇒ Object
-
Quantity Input [Cancel]
232 233 234 235 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 232 def on_number_cancel Sound.play_cancel end_number_input end |
#on_number_ok ⇒ Object
-
Quantity Input [OK]
217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 217 def on_number_ok Sound.play_shop case @command_window.current_symbol when :buy do_buy(@number_window.number) when :sell do_sell(@number_window.number) end end_number_input @gold_window.refresh @status_window.refresh end |
#on_sell_cancel ⇒ Object
-
Sell [Cancel]
208 209 210 211 212 213 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 208 def on_sell_cancel @sell_window.unselect @category_window.activate @status_window.item = nil @help_window.clear end |
#on_sell_ok ⇒ Object
-
Sell [OK]
196 197 198 199 200 201 202 203 204 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 196 def on_sell_ok @item = @sell_window.item @status_window.item = @item @category_window.hide @sell_window.hide @number_window.set(@item, max_sell, selling_price, currency_unit) @number_window.show.activate @status_window.show end |
#prepare(goods, purchase_only) ⇒ Object
-
Prepare
11 12 13 14 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 11 def prepare(goods, purchase_only) @goods = goods @purchase_only = purchase_only end |
#selling_price ⇒ Object
-
Get Sale Price
296 297 298 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 296 def selling_price @item.price / 2 end |
#start ⇒ Object
-
Start Processing
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rgss3_default_scripts/Scene_Shop.rb', line 18 def start super create_help_window create_gold_window create_command_window create_dummy_window create_number_window create_status_window create_buy_window create_category_window create_sell_window end |