赞 | 1 |
VIP | 20 |
好人卡 | 8 |
积分 | 3 |
经验 | 6181 |
最后登录 | 2022-8-5 |
在线时间 | 271 小时 |
Lv2.观梦者 神隐的主犯
- 梦石
- 0
- 星屑
- 289
- 在线时间
- 271 小时
- 注册时间
- 2008-2-22
- 帖子
- 7691
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 八云紫 于 2009-9-4 22:28 编辑
结合 小幽酱 的分类脚本一起使用, 让商店也有分类效果. 仅仅用在默认的商店里.
核心使用的是 小幽酱 的 分类脚本, 该脚本没有任何技术含量, 有 BUG 请联系咱.- class Harts_Window_ItemCommand < Window_Selectable
- def initialize(x = 0, y = 64, w = 160, h = 296)
- super(x, y, w, h)
- @type = true
- self.index = 0
- refresh
- end
-
- alias old_byz_addcommand addcommand
- def addcommand()
- if @type
- old_byz_addcommand
- else
- @commands = []
- for i in $game_temp.shop_goods
- case i[0]
- when 0
- item = $data_items[i[1]]
- when 1
- item = $data_weapons[i[1]]
- when 2
- item = $data_armors[i[1]]
- end
- if [email protected]?(item.desc)
- @commands << item.desc
- end
- end
- @item_max = @commands.size
- end
- end
-
- def setType(bool)
- @type = bool
- refresh()
- end
-
- def getCommand()
- return @commands[self.index]
- end
-
- end
- #==============================================================================
- # ■ Window_ShopBuy
- #------------------------------------------------------------------------------
- # 商店画面、浏览显示可以购买的商品的窗口。
- #==============================================================================
- class Window_ShopBuy < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- #--------------------------------------------------------------------------
- alias old_byz_initialize initialize
- def initialize(x, y, command = nil)
- @command = command
- old_byz_initialize(x, y)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- @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 and item.desc == @command
- @data.push(item)
- end
- end
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
-
- def setCommand(command)
- @command = command
- refresh()
- end
-
- end
- #==============================================================================
- # ■ Window_ShopSell
- #------------------------------------------------------------------------------
- # 商店画面、浏览显示可以卖掉的商品的窗口。
- #==============================================================================
- class Window_ShopSell < Window_Item
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- #--------------------------------------------------------------------------
- alias old_byz_initialize initialize
- def initialize(x, y, w, h)
- @command = nil
- old_byz_initialize(x, y, w, h)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- return if @command == nil
- @data = []
- for item in $game_party.items
- next if @command != item.desc
- @data.push(item)
- if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
- self.index = @data.size - 1
- end
- end
- @data.push(nil) if include?(nil)
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
-
- def setCommand(command)
- @command = command
- refresh()
- end
- end
- #==============================================================================
- # ■ Scene_Shop
- #------------------------------------------------------------------------------
- # 处理商店画面的类。
- #==============================================================================
- class Scene_Shop < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- @type = 0
- create_menu_background
- create_command_window
- @item_type_window = Harts_Window_ItemCommand.new(0, 112, 304, 304)
- @item_type_window.active = false
- @item_type_window.visible = false
- @help_window = Window_Help.new
- @gold_window = Window_Gold.new(384, 56)
- @dummy_window = Window_Base.new(0, 112, 544, 304)
- @buy_window = Window_ShopBuy.new(0, 112)
- @buy_window.active = false
- @buy_window.visible = false
- @buy_window.help_window = @help_window
- @sell_window = Window_ShopSell.new(0, 112, 544, 304)
- @sell_window.active = false
- @sell_window.visible = false
- @sell_window.help_window = @help_window
- @number_window = Window_ShopNumber.new(0, 112)
- @number_window.active = false
- @number_window.visible = false
- @status_window = Window_ShopStatus.new(304, 112)
- @status_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- alias old_byz_terminate terminate
- def terminate
- old_byz_terminate
- @item_type_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @help_window.update
- @item_type_window.update
- @command_window.update
- @gold_window.update
- @dummy_window.update
- @buy_window.update
- @sell_window.update
- @number_window.update
- @status_window.update
- if @command_window.active
- update_command_selection
- elsif @buy_window.active
- update_buy_selection
- elsif @sell_window.active
- update_sell_selection
- elsif @number_window.active
- update_number_input
- elsif @item_type_window.active
- update_type_window()
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新指令窗口
- #--------------------------------------------------------------------------
- def update_command_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- $scene = Scene_Map.new
- elsif Input.trigger?(Input::C)
- case @command_window.index
- when 0 # 购买
- Sound.play_decision
- @command_window.active = false
- @dummy_window.visible = false
- @item_type_window.visible = true
- @item_type_window.active = true
- @item_type_window.setType(false)
- @status_window.visible = true
- @type = 1
- when 1 # 卖出
- if $game_temp.shop_purchase_only
- Sound.play_buzzer
- else
- Sound.play_decision
- @item_type_window.visible = true
- @item_type_window.refresh
- @command_window.active = false
- @dummy_window.visible = false
- @item_type_window.active = true
- @item_type_window.setType(true)
- @type = 2
- end
- when 2 # 取消
- Sound.play_decision
- $scene = Scene_Map.new
- end
- end
- end
- def update_type_window()
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @dummy_window.visible = true
- @item_type_window.active = false
- @command_window.active = true
- @item_type_window.visible = false
- @status_window.visible = false
- if @type == 1
- @buy_window.active = false
- @buy_window.visible = false
- else
- @sell_window.active = false
- @sell_window.visible = false
- end
- @type = 0
- elsif Input.trigger?(Input::C)
- command = @item_type_window.getCommand()
- if @type == 1
- @buy_window.setCommand(command)
- @buy_window.active = true
- @buy_window.visible = true
- else
- @sell_window.setCommand(command)
- @sell_window.active = true
- @sell_window.visible = true
- end
- @item_type_window.active = false
- @item_type_window.visible = false
- end
- end
-
- #--------------------------------------------------------------------------
- # ● 更新选择购买物品
- #--------------------------------------------------------------------------
- def update_buy_selection
- @status_window.item = @buy_window.item
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @item_type_window.active = true
- @item_type_window.visible = true
- @item_type_window.setType(false)
- @buy_window.active = false
- @buy_window.visible = false
- @status_window.item = nil
- @help_window.set_text("")
- return
- end
- if Input.trigger?(Input::C)
- @item = @buy_window.item
- number = $game_party.item_number(@item)
- if @item == nil or @item.price > $game_party.gold or number == 99
- Sound.play_buzzer
- else
- Sound.play_decision
- max = @item.price == 0 ? 99 : $game_party.gold / @item.price
- max = [max, 99 - number].min
- @buy_window.active = false
- @buy_window.visible = false
- @number_window.set(@item, max, @item.price)
- @number_window.active = true
- @number_window.visible = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新选择卖出物品
- #--------------------------------------------------------------------------
- def update_sell_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @item_type_window.active = true
- @item_type_window.visible = true
- @item_type_window.setType(true)
- @sell_window.active = false
- @sell_window.visible = false
- @status_window.item = nil
- @help_window.set_text("")
- elsif Input.trigger?(Input::C)
- @item = @sell_window.item
- @status_window.item = @item
- if @item == nil or @item.price == 0
- Sound.play_buzzer
- else
- Sound.play_decision
- max = $game_party.item_number(@item)
- @sell_window.active = false
- @sell_window.visible = false
- @number_window.set(@item, max, @item.price / 2)
- @number_window.active = true
- @number_window.visible = true
- @status_window.visible = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新输入个数
- #--------------------------------------------------------------------------
- def update_number_input
- if Input.trigger?(Input::B)
- cancel_number_input
- if @type == 1
- @item_type_window.setType(true)
- else
- @item_type_window.setType(false)
- end
- elsif Input.trigger?(Input::C)
- decide_number_input
- if @type == 1
- @item_type_window.setType(true)
- else
- @item_type_window.setType(false)
- end
- end
- end
- end
复制代码 |
|