#==============================================================================
# ** MeisMe's Realistic Shop
#------------------------------------------------------------------------------
# Created by MeisMe
# Buxfix by Daniel
# August 8, 2006
# Version 2
#==============================================================================
NORMAL_STATUS = true
#--------------------------------------------------------------------------
# * SDK Log
#--------------------------------------------------------------------------
SDK.log('Realistic Shop', 'MeisMe', 2.0, '')
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Realistic Shop')
class Game_Temp
attr_accessor :buy_rate
attr_accessor :sell_rate
attr_accessor :discount
attr_accessor :tax
attr_accessor :cart_item
attr_accessor :cart_weapon
attr_accessor :cart_armor
attr_accessor :shop_type
alias mim_shop_old_initialize initialize
def initialize
mim_shop_old_initialize
@buy_rate = 100
@sell_rate = 50
@discount = 0
@tax = 7
clear_cart
@shop_type = 0
end
def clear_cart
@cart_item = {}
@cart_weapon = {}
@cart_armor = {}
end
def cart_cleared?
if (@cart_item == {} && @cart_weapon == {} && @cart_armor == {})
return true
end
return false
end
def item_number(item_id)
return @cart_item.include?(item_id) ? @cart_item[item_id] : 0
end
def weapon_number(weapon_id)
return @cart_weapon.include?(weapon_id) ? @cart_weapon[weapon_id] : 0
end
def armor_number(armor_id)
return @cart_armor.include?(armor_id) ? @cart_armor[armor_id] : 0
end
def gain_item(item_id, n)
if item_id > 0
@cart_item[item_id] = [[item_number(item_id) + n, 0].max, 99].min
end
end
def gain_weapon(weapon_id, n)
if weapon_id > 0
@cart_weapon[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
end
end
def gain_armor(armor_id, n)
if armor_id > 0
@cart_armor[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
end
end
def gain_items
for i in 1..$data_items.size
if item_number(i) > 0
$game_party.gain_item(i, item_number(i))
end
end
for i in 1..$data_weapons.size
if weapon_number(i) > 0
$game_party.gain_weapon(i, weapon_number(i))
end
end
for i in 1..$data_armors.size
if armor_number(i) > 0
$game_party.gain_armor(i, armor_number(i))
end
end
end
end
#==============================================================================
class Window_ShopCommand < Window_Selectable
def initialize
super(0, 64, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 3
@column_max = 3
@commands = ["Buy", "Sell", "Exit"]
refresh
self.index = 0
end
def refresh
self.contents.clear
if $game_temp.shop_type == 0
for i in 0...@item_max
draw_item(i)
end
end
if $game_temp.shop_type == 1
self.contents.draw_text(4, 0, 324, 32, "You can only buy at this shop.")
self.index = -1
update_cursor_rect
end
if $game_temp.shop_type == 2
self.contents.draw_text(4, 0, 324, 32, "You can only sell at this shop.")
self.index = -1
update_cursor_rect
end
end
def draw_item(index)
x = 4 + index * 160
self.contents.draw_text(x, 0, 128, 32, @commands[index])
end
def update_cursor_rect
if $game_temp.shop_type == 0
super
end
if $game_temp.shop_type == 1 || $game_temp.shop_type == 2
self.cursor_rect.empty
end
end
end
#==============================================================================
class Window_ShopBuyBG < Window_Base
def initialize
super(0, 128, 320, 352)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 128, 32, 'Item Name')
self.contents.draw_text(4, 0, 284, 32, 'Marked Price', 2)
end
end
#==============================================================================
class Window_ShopBuy < Window_Selectable
def initialize(shop_goods)
super(0, 160, 320, 320)
@shop_goods = shop_goods
refresh
self.index = 0
self.opacity = 0
end
def item
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id) +
$game_temp.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id) +
$game_temp.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id) +
$game_temp.armor_number(item.id)
end
price = [[item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max
if number >= 99
self.contents.font.color = disabled_color
else
self.contents.font.color = normal_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 192, y, 88, 32, price.to_s, 2)
end
end
#==============================================================================
class Window_ShopNumber < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 128, 320, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
@max = 1
@price = 0
@number = 1
end
#--------------------------------------------------------------------------
# * Set Items, Max Quantity, and Price
#--------------------------------------------------------------------------
def set(item, max, price)
@item = item
@max = max
@price = price
@number = 1
refresh
end
#--------------------------------------------------------------------------
# * Set Inputted Quantity
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
clear_icon_sprites if SDK.enabled?('Animated Icons')
self.contents.clear
draw_item_name(@item, 4, 96)
self.contents.font.color = normal_color
self.contents.draw_text(236, 96, 32, 32, "x")
self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2)
self.cursor_rect.set(304, 96, 32, 32)
# Draw total price and currency units
total_price = @price * @number
if SDK.enabled?('Gold Window')
draw_gold(Rect.new(200,160,100,0),total_price)
else
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(0, 160, 288-cx-4, 32, total_price.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(288-cx, 160, cx, 32, $data_system.words.gold, 2)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if self.active
# Cursor right (+1)
if Input.repeat?(Input::RIGHT) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number += 1
refresh
end
# Cursor left (-1)
if Input.repeat?(Input::LEFT) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number -= 1
refresh
end
# Cursor up (+10)
if Input.repeat?(Input::UP) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number = [@number + 10, @max].min
refresh
end
# Cursor down (-10)
if Input.repeat?(Input::DOWN) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number = [@number - 10, 1].max
refresh
end
end
end
end
#==============================================================================
class Window_ShopNumber2 < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 128, 320, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
@max = 1
@number = 1
end
#--------------------------------------------------------------------------
# * Set Items, Max Quantity, and Price
#--------------------------------------------------------------------------
def set(item)
@item = item
@number = 1
refresh
end
#--------------------------------------------------------------------------
# * Set Inputted Quantity
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
clear_icon_sprites if SDK.enabled?('Animated Icons')
self.contents.clear
draw_item_name(@item, 4, 96)
case @item
when RPG::Item
@max = $game_temp.item_number(@item.id)
when RPG::Weapon
@max = $game_temp.weapon_number(@item.id)
when RPG::Armor
@max = $game_temp.armor_number(@item.id)
end
self.contents.font.color = normal_color
self.contents.draw_text(236, 96, 32, 32, "x")
self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2)
self.cursor_rect.set(304, 96, 32, 32)
self.contents.draw_text(248, 128, 24, 32, "#{@max - @number}", 2)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if self.active
# Cursor right (+1)
if Input.repeat?(Input::RIGHT) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number += 1
refresh
end
# Cursor left (-1)
if Input.repeat?(Input::LEFT) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number -= 1
refresh
end
# Cursor up (+10)
if Input.repeat?(Input::UP) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number = [@number + 10, @max].min
refresh
end
# Cursor down (-10)
if Input.repeat?(Input::DOWN) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number = [@number - 10, 1].max
refresh
end
end
end
end
#==============================================================================
class Window_ShopFinalize < Window_Selectable
attr_reader :final_price
def initialize
super(0, 128, 320, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.index = 0
self.active = false
@item_max = 2
@final_price = 0
refresh
end
def refresh
@final_price = 0
base_price = 0
for i in 1..$data_items.size
if $game_temp.item_number(i) > 0
price = $game_temp.item_number(i) * $data_items[i].price
base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max
end
end
for i in 1..$data_weapons.size
if $game_temp.weapon_number(i) > 0
price = $game_temp.weapon_number(i) * $data_weapons[i].price
base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max
end
end
for i in 1..$data_armors.size
if $game_temp.armor_number(i) > 0
price = $game_temp.armor_number(i) * $data_armors[i].price
base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max
end
end
total_price = base_price
discount = 0
if $game_temp.discount != 0
discount = [[total_price * $game_temp.discount / 100, 9999999].min, 0].max
total_price = total_price - discount
end
tax = 0
if $game_temp.tax != 0
tax = [[total_price * $game_temp.tax / 100, 9999999].min, 0].max
end
total_price = total_price + tax
self.contents.clear
word = $data_system.words.gold
cx = contents.text_size(word).width
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 288, 32, 'Finalize this purchase?', 1)
self.contents.draw_text(4, 64, 128, 32, 'Price of Items:')
self.contents.draw_text(4, 96, 128, 32, 'Sales Discount:')
self.contents.draw_text(4, 128, 128, 32, 'Tax Added:')
self.contents.fill_rect(4, 160, 280, 1, normal_color)
self.contents.draw_text(4, 160, 128, 32, 'Grand Total:')
self.contents.draw_text(0, 64, 288, 32, word, 2)
self.contents.draw_text(0, 96, 288, 32, word, 2)
self.contents.draw_text(0, 128, 288, 32, word, 2)
self.contents.draw_text(0, 160, 288, 32, word, 2)
self.contents.font.color = normal_color
self.contents.draw_text(0, 64, 288-cx-2, 32, base_price.to_s, 2)
self.contents.font.color = up_color
self.contents.draw_text(0, 96, 288-cx-2, 32, discount.to_s, 2)
self.contents.font.color = down_color
self.contents.draw_text(0, 128, 288-cx-2, 32, tax.to_s, 2)
self.contents.font.color = normal_color
self.contents.draw_text(0, 160, 288-cx-2, 32, total_price.to_s, 2)
self.contents.draw_text(0, 256, 288, 32, 'No', 1)
if total_price > $game_party.gold
self.contents.font.color = disabled_color
end
self.contents.draw_text(0, 224, 288, 32, 'Yes', 1)
@final_price = total_price
end
def update_cursor_rect
if self.index == 0
cursor_rect.set(0, 224, 288, 32)
else
cursor_rect.set(0, 256, 288, 32)
end
end
end
#==============================================================================
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
# This window displays number of items in possession and the actor's equipment
# on the shop screen.
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ◠オブジェクトåˆæœŸåŒ–
#--------------------------------------------------------------------------
alias shopstatus_initialize initialize
def initialize
super(320, 128, 320, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@item = nil
refresh
end
end
#------------------------------
class Window_ShopStatus2 < Window_Selectable
attr_reader :data
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(320, 128, 320, 352)
refresh
self.index = 0
self.active = false
@data = []
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
clear_icon_sprites if SDK.enabled?('Animated Icons')
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add item
for i in 1...$data_items.size
if $game_temp.item_number(i) > 0
@data.push($data_items[i])
end
end
# Also add weapons and items if outside of battle
for i in 1...$data_weapons.size
if $game_temp.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_temp.armor_number(i) > 0
@data.push($data_armors[i])
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size + 1
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
if item != nil
case item
when RPG::Item
number = $game_temp.item_number(item.id)
when RPG::Weapon
number = $game_temp.weapon_number(item.id)
when RPG::Armor
number = $game_temp.armor_number(item.id)
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
draw_item_name(item, x, y, 240)
self.contents.draw_text(x + 240, y, 16, 32, "x", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
else
x = 4
y = index * 32
self.contents.font.color = @data == [] ? disabled_color :
normal_color
self.contents.draw_text(x, y, 288, 32, 'Finalize Purchase', 1)
end
end
def item
return @data[self.index]
end
def update_help
if item != nil
@help_window.set_text(item.description)
else
@help_window.set_text('Purchase all the goods in your cart.')
end
end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# This class performs shop screen processing.
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window
@help_window = Window_Help.new
# Make command window
@command_window = Window_ShopCommand.new
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# Make dummy window
@dummy_window = Window_Base.new(0, 128, 640, 352)
# Make buy window
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@buyBG = Window_ShopBuyBG.new
@buyBG.visible = false
# Make sell window
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# Make quantity input window
@number_window = Window_ShopNumber.new
@number_window.active = false
@number_window.visible = false
@number_window2 = Window_ShopNumber2.new
@number_window2.active = false
@number_window2.visible = false
# Make status window
if NORMAL_STATUS
@status_window = Window_ShopStatus.new
@status_window.visible = false
end
@status_window2 = Window_ShopStatus2.new
@status_window2.visible = false
@status_window2.help_window = @help_window
@finalize_window = Window_ShopFinalize.new
@finalize_window.visible = false
if $game_temp.shop_type == 1
@command_window.index = 0
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buyBG.visible = true
@buy_window.refresh
@status_window2.visible = true
end
if $game_temp.shop_type == 2
@command_window.index = 1
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
end
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@buyBG.dispose
@sell_window.dispose
@number_window.dispose
@number_window2.dispose
@status_window2.dispose
@finalize_window.dispose
$game_temp.clear_cart
$game_temp.buy_rate = 100
$game_temp.sell_rate = 50
$game_temp.discount = 0
$game_temp.shop_type = 0
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@buyBG.update
@sell_window.update
@number_window.update
@number_window2.update
@status_window2.update
@finalize_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
# If buy window is active: call update_buy
elsif @buy_window.active
update_buy
return
# If sell window is active: call update_sell
elsif @sell_window.active
update_sell
return
# If quantity input window is active: call update_number
elsif @number_window.active
update_number
return
elsif @status_window2.active
update_status
elsif @finalize_window.active
update_finalize
elsif @number_window2.active
update_number2
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # buy
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to buy mode
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@buyBG.visible = true
@status_window2.visible = true
when 1 # sell
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to sell mode
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
when 2 # quit
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to map screen
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when buy window is active)
#--------------------------------------------------------------------------
def update_buy
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
if $game_temp.shop_type == 1
$scene = Scene_Map.new
return
end
# Change windows to initial mode
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@buyBG.visible = false
@status_window2.visible = false
# Erase help text
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get item
@item = @buy_window.item
# Get items in possession count
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
number2 = $game_temp.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
number2 = $game_temp.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
number2 = $game_temp.armor_number(@item.id)
end
# If 99 items are already in possession
if number + number2 >= 99
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Calculate maximum amount possible to buy
max = [99, 99 - number - number2].min
# Change windows to quantity input mode
@buy_window.active = false
@buy_window.visible = false
@buyBG.visible = false
price = [[@item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max
@number_window.set(@item, max, price)
@number_window.active = true
@number_window.visible = true
if NORMAL_STATUS
@status_window2.visible = false
@status_window.visible = true
@status_window.active = true
@status_window.item=nil
@status_window.item=@item
end
end
# If RIGHT was pressed
if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.decision_se)
@buy_window.active = false
@status_window2.active = true
end
end
#--------------------------------------------------------------------------
# * Frame Update (when sell window is active)
#--------------------------------------------------------------------------
def update_sell
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
if $game_temp.shop_type == 2
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
# Change windows to initial mode
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
# Erase help text
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get item
@item = @sell_window.item
# If item is invalid, or item price is 0 (unable to sell)
if @item == nil or @item.price == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Get items in possession count
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
# Maximum quanitity to sell = number of items in possession
max = number
price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max
# Change windows to quantity input mode
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, price)
@number_window.active = true
@number_window.visible = true
@status_window2.visible = true
end
end
#--------------------------------------------------------------------------
# * Frame Update (when quantity input window is active)
#--------------------------------------------------------------------------
def update_number
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Set quantity input window to inactive / invisible
@number_window.active = false
@number_window.visible = false
# Branch by command window cursor position
case @command_window.index
when 0 # buy
# Change windows to buy mode
@buy_window.active = true
@buy_window.visible = true
if NORMAL_STATUS
@status_window2.visible = true
@status_window.visible = false
end
@buyBG.visible = true
when 1 # sell
# Change windows to sell mode
@sell_window.active = true
@sell_window.visible = true
@status_window2.visible = false
end
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Set quantity input window to inactive / invisible
@number_window.active = false
@number_window.visible = false
if NORMAL_STATUS
@status_window2.visible = true
@status_window.visible = false
end
# Branch by command window cursor position
case @command_window.index
when 0 # buy
$game_system.se_play($data_system.equip_se)
case @item
when RPG::Item
$game_temp.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_temp.gain_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_temp.gain_armor(@item.id, @number_window.number)
end
# Refresh each window
@gold_window.refresh
@buy_window.refresh
@status_window2.refresh
# Change windows to buy mode
@buy_window.active = true
@buy_window.visible = true
if NORMAL_STATUS
@status_window2.visible = true
@status_window.visible = false
end
@buyBG.visible = true
when 1 # sell
$game_system.se_play($data_system.shop_se)
# Sell process
price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max
$game_party.gain_gold(@number_window.number * (price))
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.lose_armor(@item.id, @number_window.number)
end
# Refresh each window
@gold_window.refresh
@sell_window.refresh
@status_window2.refresh
# Change windows to sell mode
@sell_window.active = true
@sell_window.visible = true
@status_window2.visible = false
end
return
end
end
def update_status
if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.decision_se)
@buy_window.active = true
@status_window2.active = false
end
if Input.trigger?(Input::C)
if @status_window2.item == nil
if @status_window2.data != []
$game_system.se_play($data_system.decision_se)
@buy_window.visible = false
@buyBG.visible = false
@finalize_window.visible = true
@finalize_window.index = 0
@finalize_window.refresh
@finalize_window.active = true
@status_window2.active = false
return
else
$game_system.se_play($data_system.buzzer_se)
return
end
else
$game_system.se_play($data_system.decision_se)
@status_window2.active = false
@buy_window.visible = false
@buyBG.visible = false
@number_window2.set(@status_window2.item)
if NORMAL_STATUS
@status_window2.visible = false
@status_window.visible = true
@status_window.item=nil
@status_window.item=@status_window2.item
end
@number_window2.visible = true
@number_window2.active = true
end
end
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
if $game_temp.shop_type == 1
$scene = Scene_Map.new
return
end
# Change windows to initial mode
@command_window.active = true
@dummy_window.visible = true
@buy_window.visible = false
@buyBG.visible = false
@status_window2.visible = false
@status_window2.active = false
# Erase help text
@help_window.set_text("")
return
end
end
def update_finalize
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
@buy_window.visible = true
@buy_window.active = false
@buyBG.visible = true
@finalize_window.visible = false
@finalize_window.active = false
@status_window2.active = true
@buy_window.refresh
end
if Input.trigger?(Input::C)
if @finalize_window.index == 0
if @finalize_window.final_price > $game_party.gold
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.shop_se)
$game_party.lose_gold(@finalize_window.final_price)
$game_temp.gain_items
@gold_window.refresh
@buy_window.visible = true
@buy_window.active = true
@buyBG.visible = true
@finalize_window.visible = false
@finalize_window.active = false
@status_window2.active = false
$game_temp.clear_cart
@status_window2.index = 0
@status_window2.refresh
@buy_window.refresh
return
else
$game_system.se_play($data_system.decision_se)
@buy_window.visible = true
@buyBG.visible = true
@finalize_window.visible = false
@finalize_window.active = false
@status_window2.active = true
@buy_window.refresh
return
end
end
end
def update_number2
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@buy_window.visible = true
@buy_window.active = false
@buyBG.visible = true
@finalize_window.visible = false
@finalize_window.active = false
if NORMAL_STATUS
@status_window2.visible = true
@status_window.visible = false
end
@status_window2.active = true
@number_window2.visible = false
@number_window.active = false
@status_window2.refresh
@buy_window.refresh
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.equip_se)
case @status_window2.item
when RPG::Item
$game_temp.gain_item(@status_window2.item.id, -@number_window2.number)
when RPG::Weapon
$game_temp.gain_weapon(@status_window2.item.id, -@number_window2.number)
when RPG::Armor
$game_temp.gain_armor(@status_window2.item.id, -@number_window2.number)
end
@buy_window.visible = true
@buy_window.active = false
@buyBG.visible = true
@finalize_window.visible = false
@finalize_window.active = false
if NORMAL_STATUS
@status_window2.visible = true
@status_window.visible = false
end
@status_window2.active = true
@number_window2.visible = false
@number_window.active = false
@status_window2.refresh
@buy_window.refresh
end
end
end
#==============================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test
#--------------------------------------------------------------------------