赞 | 1 |
VIP | 0 |
好人卡 | 8 |
积分 | 1 |
经验 | 50472 |
最后登录 | 2017-10-24 |
在线时间 | 1906 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 88
- 在线时间
- 1906 小时
- 注册时间
- 2012-10-5
- 帖子
- 1991
|
- # ————————————————————————————————————
- # 本脚本来自www.66rpg.com,转载请保留此信息
- # ————————————————————————————————————
- #==============================================================================
- # ■ Scene_Warehouse
- #------------------------------------------------------------------------------
- # 商店画面 : 窗口管理
- #==============================================================================
- class Scene_Warehouse < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 开始处理 :生成窗口
- #--------------------------------------------------------------------------
- def start
- super
- create_help_window
- create_command_window
- create_item_window
- create_number_window
- end
- #--------------------------------------------------------------------------
- # ● 生成指令窗口
- #--------------------------------------------------------------------------
- def create_command_window
- @command_window = Window_WarehouseCommand.new(Graphics.width, @purchase_only)
- @command_window.viewport = @viewport
- @command_window.y = @help_window.height
- @command_window.set_handler(:save, method(:command_save))
- @command_window.set_handler(:get, method(:command_get))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- #--------------------------------------------------------------------------
- # ● 生成物品窗口
- #--------------------------------------------------------------------------
- def create_item_window
- y = @command_window.y + @command_window.height
- height = Graphics.height - @command_window.y - @command_window.height
- width = @help_window.width
- @item_window = Window_WarehouseItem.new(0, y, width, height)
-
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.set_action(0)
-
- @item_window.set_handler(:ok, method(:on_ok))
- @item_window.set_handler(:cancel, method(:on_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 生成输入窗口
- #--------------------------------------------------------------------------
- def create_number_window
- @number_window = Window_WarehouseNumber.new((Graphics.width - 304)/2,(Graphics.height - 72)/2,72)
- @number_window.viewport = @viewport
- @number_window.hide
- @number_window.set_handler(:ok, method(:on_num_ok))
- @number_window.set_handler(:cancel, method(:on_num_cancel))
- end
- #==============================================================================
- # ■仓库画面 : 主指令管理
- #==============================================================================
- #--------------------------------------------------------------------------
- # ● 主界面 :存入
- #--------------------------------------------------------------------------
- def command_save
- @item_window.set_action(1)
- @command_window.deactivate # 冻结指令窗口
- @item_window.activate # 激活物品窗口
- @item_window.index = 0
- @item_window.refresh
- @item_window.update_help
- end
- #--------------------------------------------------------------------------
- # ● 主界面 :取出
- #--------------------------------------------------------------------------
- def command_get
- @item_window.set_action(2)
- @command_window.deactivate # 冻结指令窗口
- @item_window.activate # 激活物品窗口
- @item_window.index = 0
- @item_window.refresh
- @item_window.update_help
- end
-
- #==============================================================================
- # ■仓库画面 : 指令管理
- #==============================================================================
-
- #--------------------------------------------------------------------------
- # ● 命令 :确定
- #--------------------------------------------------------------------------
- def on_ok
- item = @item_window.get_item_now
- if @item_window.enable?(item) || @item_window.action == 1
- case @item_window.action
- when 1
- @number_window.save_item
- @number_window.set(item,$game_party.item_number(item))
- when 2
- @number_window.save_item(false)
- i = $game_party.max_item_number(item) - $game_party.item_number(item)
- if i < $game_party.ware_num(item)
- @number_window.set(item, i)
- else
- @number_window.set(item,$game_party.ware_num(item))
- end
- end
- @item_window.deactivate
- @number_window.show
- @number_window.activate
- else
- Sound.play_buzzer
- @help_window.set_text("背包内装不下了~")
- @item_window.activate
- end
- end
- #--------------------------------------------------------------------------
- # ● 命令 :取消
- #--------------------------------------------------------------------------
- def on_cancel
- @item_window.deactivate
- @item_window.set_action(0)
- @item_window.index = -1
- @item_window.contents.clear
- @command_window.activate
- @help_window.clear
- end
-
- #==============================================================================
- # ■仓库画面 : 数值输入指令管理
- #==============================================================================
- #--------------------------------------------------------------------------
- # ● 命令 :存入确定
- #--------------------------------------------------------------------------
- def on_num_ok
- @number_window.hide
- @number_window.deactivate
- case @number_window.action
- when true
- $game_party.ware_add(@number_window.get_item, @number_window.get_num)
- $game_party.lose_item(@number_window.get_item, @number_window.get_num)
- when false
- $game_party.ware_del(@number_window.get_item, @number_window.get_num)
- $game_party.gain_item(@number_window.get_item, @number_window.get_num)
- end
- # 更新画面
- @item_window.refresh
- if @number_window.get_num == @number_window.get_max && @item_window.index != 0
- @item_window.index -= 1
- end
-
- if @item_window.get_data == []
- @command_window.activate
- @item_window.deactivate
- @item_window.index = -1
- @help_window.clear
- else
- @item_window.activate
- end
- @command_window.refresh
- @number_window.refresh
- end
- #--------------------------------------------------------------------------
- # ● 命令 :存入取消
- #--------------------------------------------------------------------------
- def on_num_cancel
- @number_window.refresh
- @number_window.hide
- @number_window.deactivate
- @item_window.activate
- end
- # 定义结束
- end
复制代码- #encoding:utf-8
- # ————————————————————————————————————
- # 本脚本来自www.66rpg.com,转载请保留此信息
- # ————————————————————————————————————
- #==============================================================================
- # ■ Window_WarehouseNumber
- #------------------------------------------------------------------------------
- # 商店画面中,输入“物品买入/卖出数量”的窗口。
- #==============================================================================
- class Window_WarehouseNumber < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(x, y, height)
- super(x, y, window_width, height)
- @item = nil
- [url=home.php?mod=space&uid=25307]@Max[/url] = 1
- [url=home.php?mod=space&uid=27178]@Number[/url] = 1
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- return 304
- end
- #--------------------------------------------------------------------------
- # ● 设置物品、最大值
- #--------------------------------------------------------------------------
- def set(item, max)
- @item = item
- @max = max
- @number = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 设置状态
- #--------------------------------------------------------------------------
- def save_item(action = true)
- @action = action
- end
- #--------------------------------------------------------------------------
- # ● 取得状态
- #--------------------------------------------------------------------------
- def action
- return @action
- end
- #--------------------------------------------------------------------------
- # ● 获得数值
- #--------------------------------------------------------------------------
- def get_num
- return @number
- end
- #--------------------------------------------------------------------------
- # ● 获得物品
- #--------------------------------------------------------------------------
- def get_item
- return @item
- end
- #--------------------------------------------------------------------------
- # ● 获得最大值
- #--------------------------------------------------------------------------
- def get_max
- return @max
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_item_name(@item, 0, item_y)
- draw_number
- end
- #--------------------------------------------------------------------------
- # ● 绘制数量
- #--------------------------------------------------------------------------
- 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
- #--------------------------------------------------------------------------
- # ● 显示物品名称行的 Y 坐标
- #--------------------------------------------------------------------------
- def item_y
- return 8
- end
- #--------------------------------------------------------------------------
- # ● 获取光标的宽度
- #--------------------------------------------------------------------------
- def cursor_width
- figures * 10 + 12
- end
- #--------------------------------------------------------------------------
- # ● 获取光标的 X 坐标
- #--------------------------------------------------------------------------
- def cursor_x
- contents_width - cursor_width - 4
- end
- #--------------------------------------------------------------------------
- # ● 获取数量显示的最大列数
- #--------------------------------------------------------------------------
- def figures
- return 2
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if active
- last_number = @number
- update_number
- if @number != last_number
- Sound.play_cursor
- refresh
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新数量
- #--------------------------------------------------------------------------
- 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
- #--------------------------------------------------------------------------
- # ● 更改数量
- #--------------------------------------------------------------------------
- def change_number(amount)
- @number = [[@number + amount, @max].min, 1].max
- end
- #--------------------------------------------------------------------------
- # ● 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
- end
- end
复制代码 |
|