#==============================================================================
# WECOC'S "MOSAIC" SHOP SYSTEM v1.0
#------------------------------------------------------------------------------
# By: Wecoc
#------------------------------------------------------------------------------
# This shop script displays objects as a mosaic and not on a list.
# It has configurable parts, using the module NewShopWecoc.
# I attached some possible options. Hope you like the script.
# The script requires Window_Selectable +
=begin
------------------------------
VERSION 1
COLUMN_MAX = 4
ROW_HEIGHT = 64
SHOW_OWN_BIG = true
TEXT_SIZE = 16
TEXT_BOLD = true
SHOW_BIG_PSTATUS = true
SHOW_OWN_SMALL = false
SHOW_SMALL_PSTATUS = false
SHOW_NUMBER = true
------------------------------
VERSION 2
COLUMN_MAX = 10
ROW_HEIGHT = 32
SHOW_OWN_BIG = false
TEXT_SIZE = 14
TEXT_BOLD = true
SHOW_BIG_PSTATUS = false
SHOW_OWN_SMALL = true
SHOW_SMALL_PSTATUS = true
SHOW_NUMBER = false
------------------------------
VERSION 3
COLUMN_MAX = 3
ROW_HEIGHT = 45
SHOW_OWN_BIG = true
TEXT_SIZE = 20
TEXT_BOLD = false
SHOW_BIG_PSTATUS = false
SHOW_OWN_SMALL = false
SHOW_SMALL_PSTATUS = false
SHOW_NUMBER = false
=end
#==============================================================================
#------------------------------------------------------------------------------
# MODULE GLOBALS
#------------------------------------------------------------------------------
module NewShopWecoc
# -------------------------
COLUMN_MAX = 4 # Indicates how many columns have Window_Buy and Window_Sell
ROW_HEIGHT = 64 # Indicates how the cursor measured (row height)
# -------------------------
# If true, the item's name will appear on the mosaic,
# and under it how many you own.
SHOW_OWN_BIG = true
# Text size of the name of the item and "Own: x" and if bold or not
TEXT_SIZE = 16
TEXT_BOLD = true
# Only if SHOW_OWN_BIG es activated. If SHOW_BIG_PSTATUS is true, it says
# if the weapon or armor is better that which actors wear.
SHOW_BIG_PSTATUS = true
MINUS = Color.new(255, 0, 0) # Color when it's worse
EQUAL = Color.new(255, 255, 0) # Color when it's equal
PLUS = Color.new( 0, 255, 0) # Color when it's better
OFF = Color.new(100, 110, 120) # Color when actor can't wear it
# -------------------------
# If true it will display how many items you own with a small number
SHOW_OWN_SMALL = false
# If true it says if the weapon or armor is better that which PLAYER wears
SHOW_SMALL_PSTATUS = false
# If true, number_window (Window_ShopNumber) works as always.
# If false it does not work and you can just buy items one by one.
SHOW_NUMBER = false
end
#------------------------------------------------------------------------------
# Window_ShopBuy
#------------------------------------------------------------------------------
class Window_ShopBuy < Window_Selectable
# initialize considering COLUMN_MAX y ROW_HEIGHT
def initialize(shop_goods)
super(0, 128, 640, 352)
@column_max = NewShopWecoc::COLUMN_MAX
self.rowHeight=NewShopWecoc::ROW_HEIGHT
@shop_goods = shop_goods
refresh
self.index = 0
end
def item
return @data[self.index]
end
# refresh with @row_height correction
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
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * @row_height)
for i in 0...@item_max
draw_item(i)
end
end
end
# draw_item (the most configurable part)
def draw_item(index)
item = @data[index]
case item
when RPG::Item # Item
number = $game_party.item_number(item.id)
when RPG::Weapon # Weapon
number = $game_party.weapon_number(item.id)
for i in 0...$game_party.actors.size
number += 1 if $game_party.actors[i].weapon_id == item.id
end
when RPG::Armor # Armor
number = $game_party.armor_number(item.id)
for i in 0...$game_party.actors.size
number += 1 if $game_party.actors[i].armor1_id == item.id
number += 1 if $game_party.actors[i].armor2_id == item.id
number += 1 if $game_party.actors[i].armor3_id == item.id
number += 1 if $game_party.actors[i].armor4_id == item.id
end
end
if item.price <= $game_party.gold and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
if NewShopWecoc::SHOW_OWN_BIG # SHOW_OWN_BIG = true
cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
cursor_height = NewShopWecoc::ROW_HEIGHT
column_max = NewShopWecoc::COLUMN_MAX
x = index % column_max * 640 / column_max
y = index / column_max * cursor_height
rect = Rect.new(x, y, self.width - 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+2, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.font.size = NewShopWecoc::TEXT_SIZE #16
self.contents.font.bold = NewShopWecoc::TEXT_BOLD
self.contents.draw_text(x + 30, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 30, y+20, 212, 32, "Own: "+number.to_s, 0)
self.contents.font.size = 25
if NewShopWecoc::SHOW_BIG_PSTATUS # SHOW_BIG_PSTATUS = true
case item
when RPG::Weapon # Weapon
for i in 0...$game_party.actors.size
itemcomp = $game_party.actors[i].weapon_id
if $game_party.actors[i].equippable?(item)
if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
elsif $data_weapons[itemcomp].price == item.price # EQUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
elsif $data_weapons[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
end
else # You can't equip
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::OFF
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
end
end
when RPG::Armor # Armor
for i in 0...$game_party.actors.size
case item.kind
when 0 ; itemcomp = $game_party.actors[i].armor1_id
when 1 ; itemcomp = $game_party.actors[i].armor2_id
when 2 ; itemcomp = $game_party.actors[i].armor3_id
when 3 ; itemcomp = $game_party.actors[i].armor4_id
end
if $game_party.actors[i].equippable?(item)
if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
elsif $data_armors[itemcomp].price == item.price # EQUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
elsif $data_armors[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
end
else # You can't equip
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::OFF
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
end
end
end
end
else # SHOW_OWN_BIG = false
cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
cursor_height = NewShopWecoc::ROW_HEIGHT
column_max = NewShopWecoc::COLUMN_MAX
x = index%column_max * 640/column_max + cursor_width/2-12
y = index/column_max * cursor_height + cursor_height/2-12
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, bitmap, Rect.new(0, 0, 24, 24), opacity)
if NewShopWecoc::SHOW_OWN_SMALL # SHOW_OWN_SMALL = true
self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
self.contents.font.bold = NewShopWecoc::TEXT_BOLD
self.contents.draw_text(x+18, y+5, 32, 32, number.to_s, 0)
end
if NewShopWecoc::SHOW_SMALL_PSTATUS # SHOW_SMALL_PSTATUS = true
self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
self.contents.font.bold = NewShopWecoc::TEXT_BOLD
case item
when RPG::Weapon # Weapon
itemcomp = $game_party.actors[0].weapon_id
if $game_party.actors[0].equippable?(item)
if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
elsif $data_weapons[itemcomp].price == item.price # EQUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
elsif $data_weapons[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+18, y-10, 32, 32, "-", 0)
end
end
when RPG::Armor # Armor
case item.kind
when 0 ; itemcomp = $game_party.actors[0].armor1_id
when 1 ; itemcomp = $game_party.actors[0].armor2_id
when 2 ; itemcomp = $game_party.actors[0].armor3_id
when 3 ; itemcomp = $game_party.actors[0].armor4_id
end
if $game_party.actors[0].equippable?(item)
if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
elsif $data_armors[itemcomp].price == item.price # EQUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
elsif $data_armors[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+18, y-14, 32, 32, "-", 0)
end
end
end
end
end
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#------------------------------------------------------------------------------
# Window_ShopSell
#------------------------------------------------------------------------------
class Window_ShopSell < Window_Selectable
# initialize considering COLUMN_MAX y ROW_HEIGHT
def initialize
super(0, 128, 640, 352)
@column_max = NewShopWecoc::COLUMN_MAX
self.rowHeight=NewShopWecoc::ROW_HEIGHT
refresh
self.index = 0
end
def item
return @data[self.index]
end
# refresh with @row_height correction
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * @row_height)
for i in 0...@item_max
draw_item(i)
end
end
end
# draw_item (the most configurable part)
def draw_item(index)
item = @data[index]
case item
when RPG::Item # Item
number = $game_party.item_number(item.id)
when RPG::Weapon # Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor # Armor
number = $game_party.armor_number(item.id)
end
if item.price > 0
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
if NewShopWecoc::SHOW_OWN_BIG # SHOW_OWN_BIG = true
cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
cursor_height = NewShopWecoc::ROW_HEIGHT
column_max = NewShopWecoc::COLUMN_MAX
x = index % column_max * 640 / column_max
y = index / column_max * cursor_height
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+2, y+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.font.size = NewShopWecoc::TEXT_SIZE #16
self.contents.font.bold = NewShopWecoc::TEXT_BOLD
self.contents.draw_text(x + 30, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 30, y+20, 212, 32, "Own: "+number.to_s, 0)
self.contents.font.size = 25
if NewShopWecoc::SHOW_BIG_PSTATUS # SHOW_BIG_PSTATUS = true
case item
when RPG::Weapon
for i in 0...$game_party.actors.size
itemcomp = $game_party.actors[i].weapon_id
if $game_party.actors[i].equippable?(item)
if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
elsif $data_weapons[itemcomp].price == item.price # EQUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
elsif $data_weapons[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
end
else # You can't equip
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::OFF
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
end
end
when RPG::Armor
for i in 0...$game_party.actors.size
case item.kind
when 0 ; itemcomp = $game_party.actors[i].armor1_id
when 1 ; itemcomp = $game_party.actors[i].armor2_id
when 2 ; itemcomp = $game_party.actors[i].armor3_id
when 3 ; itemcomp = $game_party.actors[i].armor4_id
end
if $game_party.actors[i].equippable?(item)
if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
elsif $data_armors[itemcomp].price == item.price # EQUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
elsif $data_armors[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
end
else # You can't equip
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::OFF
end
self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
end
end
end
end
else # SHOW_OWN_BIG = false
cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
cursor_height = NewShopWecoc::ROW_HEIGHT
column_max = NewShopWecoc::COLUMN_MAX
x = index%column_max * 640/column_max + cursor_width/2-12
y = index/column_max * cursor_height + cursor_height/2-12
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, bitmap, Rect.new(0, 0, 24, 24), opacity)
if NewShopWecoc::SHOW_OWN_SMALL # SHOW_OWN_SMALL = true
self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
self.contents.font.bold = NewShopWecoc::TEXT_BOLD
self.contents.draw_text(x+18, y+5, 32, 32, number.to_s, 0)
end
if NewShopWecoc::SHOW_SMALL_PSTATUS # SHOW_SMALL_PSTATUS = true
self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
self.contents.font.bold = NewShopWecoc::TEXT_BOLD
case item
when RPG::Weapon # Weapon
itemcomp = $game_party.actors[0].weapon_id
if $game_party.actors[0].equippable?(item)
if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
elsif $data_weapons[itemcomp].price == item.price # EQUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
elsif $data_weapons[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+18, y-10, 32, 32, "-", 0)
end
end
when RPG::Armor # Armor
case item.kind
when 0 ; itemcomp = $game_party.actors[0].armor1_id
when 1 ; itemcomp = $game_party.actors[0].armor2_id
when 2 ; itemcomp = $game_party.actors[0].armor3_id
when 3 ; itemcomp = $game_party.actors[0].armor4_id
end
if $game_party.actors[0].equippable?(item)
if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::PLUS
end
self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
elsif $data_armors[itemcomp].price == item.price # IGUAL
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::EQUAL
end
self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
elsif $data_armors[itemcomp].price > item.price # MINUS
if self.contents.font.color != disabled_color
self.contents.font.color = NewShopWecoc::MINUS
end
self.contents.draw_text(x+18, y-14, 32, 32, "-", 0)
end
end
end
end
end
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#------------------------------------------------------------------------------
# Window_ShopGold
#------------------------------------------------------------------------------
class Window_ShopGold < Window_Base
def initialize
@buying = true
super(230,0,120,64)
self.z = 9980
self.contents = Bitmap.new(width - 32, height - 32)
end
def refresh
self.contents.clear
if @item == nil
return
end
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
self.contents.font.color = normal_color
if @item.price == 0
self.contents.font.color = disabled_color
end
if ($game_party.gold < @item.price) and buying?
self.contents.font.color = disabled_color
end
if number == 99 and buying?
self.contents.font.color = disabled_color
end
if buying?
gold = $data_system.words.gold
self.contents.draw_text(0,0,120-32,32,@item.price.to_s+gold,1)
else
gold = $data_system.words.gold
self.contents.draw_text(0,0,120-32,32,(@item.price/2).to_s+gold,1)
end
end
def buying?
return @buying
end
def buying=(value)
@buying = value
end
def item=(value)
@item=value
end
end
#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop
def main
# Window_Help - Window with the description of each object
@help_window = Window_Help.new
# Window_ShopCommand - "Buy", "Sell", "Leave"
@command_window = Window_ShopCommand.new
# Window_Gold - Window with the money group owns
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# Window_Base - Empty window for when you're not buying or selling
@dummy_window = Window_Base.new(0, 128, 640, 352)
# Window_ShopBuy - Window with the objects to buy
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# Window_ShopSell - Window with the objects to sell
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# Window_ShopNumber - It shows the number of objects to buy or sell
@number_window = Window_ShopNumber.new
@number_window.z = 1000
@number_window.active = false
@number_window.visible = false
# Window_ShopGold - Window with the price of each object
@shopgold_window = Window_ShopGold.new
@shopgold_window.visible = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@shopgold_window.dispose
@number_window.dispose
end
def update
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
if @command_window.active
update_command
return
end
if @buy_window.active
update_buy
return
end
if @sell_window.active
update_sell
return
end
if @number_window.active
update_number
return
end
end
def update_command
if Input.trigger?(Input::B) # Cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C) # Accept
case @command_window.index
when 0 # Buy
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@shopgold_window.buying = true
shopgold_position # Price window position
@shopgold_window.visible = true
@shopgold_window.refresh
when 1 # Sell
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
@shopgold_window.buying = false
shopgold_position # Price window position
@shopgold_window.visible = true
@shopgold_window.refresh
when 2 # Leave
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
return
end
end
def update_buy
if Input.press?(Input.dir4) # Moving around the window
@shopgold_window.buying = true
shopgold_position # Price window position
@shopgold_window.visible = true
@shopgold_window.refresh
end
if Input.trigger?(Input::B) # Cancel
$game_system.se_play($data_system.cancel_se)
@shopgold_window.visible = false
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@help_window.set_text("")
return
end
if Input.trigger?(Input::C) # Accept
@item = @buy_window.item
if @item == nil or @item.price > $game_party.gold
$game_system.se_play($data_system.buzzer_se)
return
end
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
if number == 99
$game_system.se_play($data_system.buzzer_se)
return
end
if NewShopWecoc::SHOW_NUMBER # Number Window
$game_system.se_play($data_system.decision_se)
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
@buy_window.active = false
@shopgold_window.visible = false
else
$game_system.se_play($data_system.shop_se)
case @item
when RPG::Item
$game_party.gain_item(@item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(@item.id, 1)
when RPG::Armor
$game_party.gain_armor(@item.id, 1)
end
$game_party.lose_gold(@item.price)
@buy_window.refresh
@gold_window.refresh
@shopgold_window.refresh
end
end
end
def update_sell
if Input.press?(Input.dir4) # Moving around the window
@shopgold_window.buying = false
shopgold_position # Price window position
@shopgold_window.visible = true
@shopgold_window.refresh
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@shopgold_window.visible = false
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @sell_window.item
if @item == nil or @item.price == 0
$game_system.se_play($data_system.buzzer_se)
return
end
if NewShopWecoc::SHOW_NUMBER # Number Window
$game_system.se_play($data_system.decision_se)
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
max = number
@sell_window.active = false
@shopgold_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
else
$game_system.se_play($data_system.shop_se)
$game_party.gain_gold(@item.price / 2)
case @item
when RPG::Item
$game_party.lose_item(@item.id, 1)
when RPG::Weapon
$game_party.lose_weapon(@item.id, 1)
when RPG::Armor
$game_party.lose_armor(@item.id, 1)
end
@gold_window.refresh
@sell_window.refresh
@shopgold_window.item = @sell_window.item
@shopgold_window.refresh
end
end
end
def update_number
if Input.trigger?(Input::B) # Cancel
$game_system.se_play($data_system.cancel_se)
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # Buy
@buy_window.active = true
@buy_window.visible = true
when 1 # Sell
@sell_window.active = true
@sell_window.visible = true
end
return
end
if Input.trigger?(Input::C) # Accept
$game_system.se_play($data_system.shop_se)
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # Buy
$game_party.lose_gold(@number_window.number * @item.price)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.gain_armor(@item.id, @number_window.number)
end
@gold_window.refresh
@buy_window.refresh
@shopgold_window.refresh
@buy_window.active = true
@shopgold_window.visible = true
when 1 # Sell
$game_party.gain_gold(@number_window.number * (@item.price / 2))
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
@gold_window.refresh
@sell_window.refresh
@shopgold_window.item = @sell_window.item
@shopgold_window.refresh
@sell_window.active = true
@shopgold_window.visible = true
end
return
end
end
def shopgold_position # Window position (centered with the cursor)
if @buy_window.visible == true # Buy
@shopgold_window.item = @buy_window.item
cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
cursor_height = NewShopWecoc::ROW_HEIGHT
column_max = NewShopWecoc::COLUMN_MAX
window_width = @shopgold_window.width
index = @buy_window.index
@shopgold_window.x = index%column_max * 640/column_max +
cursor_width/2-(window_width/2)+16
@shopgold_window.x = [@shopgold_window.x, 5].max
@shopgold_window.x = [@shopgold_window.x, 640-5-@shopgold_window.width].min
@shopgold_window.y = index/column_max*cursor_height-
@buy_window.top_row*cursor_height+76
else # Sell
@shopgold_window.item = @sell_window.item
cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
cursor_height = NewShopWecoc::ROW_HEIGHT
column_max = NewShopWecoc::COLUMN_MAX
window_width = @shopgold_window.width
index = @sell_window.index
@shopgold_window.x = index%column_max * 640/column_max +
cursor_width/2-(window_width/2)+16
@shopgold_window.x = [@shopgold_window.x, 5].max
@shopgold_window.x = [@shopgold_window.x, 640-5-@shopgold_window.width].min
@shopgold_window.y = index/column_max*cursor_height-
@sell_window.top_row*cursor_height+76
end
end
end