赞 | 60 |
VIP | 0 |
好人卡 | 0 |
积分 | 87 |
经验 | 0 |
最后登录 | 2024-2-2 |
在线时间 | 501 小时 |
Lv4.逐梦者
- 梦石
- 2
- 星屑
- 6687
- 在线时间
- 501 小时
- 注册时间
- 2018-3-23
- 帖子
- 533
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
Lv.2星屑不多请见谅
我想在刷新一个选择物品的窗口的同时把另一个类的窗口提示语内容也刷新,但这两个窗口在不同的类中,想要调用另一个类当中的方法又不想重新显示该窗口(即新增一个对象)该怎么做?
我的想一并刷新的类的代码:- class Window_News_IB < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(show = true)
- if show
- super(0, 0, Graphics.width, fitting_height(1))
- else
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置内容
- #--------------------------------------------------------------------------
- def set_text(text)
- if text != @text
- @text = text
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # ● 写入消息的内容
- #--------------------------------------------------------------------------
- def write_text(items_value, goods_value)
- if items_value == 0
- set_text(Shop_IB::NO_TEXT)
- return
- end
- if goods_value == 0
- set_text(Shop_IB::NO_SELECT_TEXT)
- return
- end
-
- if items_value >= goods_value + Shop_IB::YOUARESORICH
- set_text(Shop_IB::OVER_TEXT)
- return
- end
- if items_value >= goods_value
- set_text(Shop_IB::EQUAL_TEXT)
- return
- end
- if items_value < goods_value
- set_text(Shop_IB::LACK_TEXT)
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 清除
- #--------------------------------------------------------------------------
- def clear
- set_text("")
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_text(4, -2, Graphics.width - 40, 32, @text, 1)
- end
- end
- #==============================================================================
- # ■ Window_Help_IB
- #------------------------------------------------------------------------------
- # 显示物品说明的窗口(只是改动了位置)
- #==============================================================================
- class Window_Help_IB < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(line_number = 2)
- super(0, fitting_height(1), Graphics.width, fitting_height(line_number))
- end
- #--------------------------------------------------------------------------
- # ● 设置内容
- #--------------------------------------------------------------------------
- def set_text(text)
- if text != @text
- @text = text
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # ● 清除
- #--------------------------------------------------------------------------
- def clear
- set_text("")
- end
- #--------------------------------------------------------------------------
- # ● 设置物品
- # item : 技能、物品等
- #--------------------------------------------------------------------------
- def set_item(item)
- set_text(item ? item.description : "")
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_text_ex(4, 0, @text)
- end
- end
复制代码 然后选择物品窗口当中:
- class Window_ItemList_IB < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, sell_items, items_number)
- super(x, y, width, height)
- @data = []
- @items_number = items_number
- end
- #--------------------------------------------------------------------------
- # ● 获取列数
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # ● 获取项目数
- #--------------------------------------------------------------------------
- def item_max
- @data ? @data.size : 1
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- @data && index >= 0 ? @data[index] : nil
- end
- #--------------------------------------------------------------------------
- # ● 获取选择项目的有效状态
- #--------------------------------------------------------------------------
- def current_item_enabled?
- enable?(@data[index])
- end
- #--------------------------------------------------------------------------
- # ● 查询列表中是否含有此物品
- #--------------------------------------------------------------------------
- def include?(item)
- if item.is_a?(RPG::Item) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)
- return true
- else
- return false
- end
- end
- #--------------------------------------------------------------------------
- # ● 查询此物品是否可用
- #--------------------------------------------------------------------------
- def enable?(item)
- $game_party.usable?(item)
- end
- #--------------------------------------------------------------------------
- # ● 生成物品列表
- #--------------------------------------------------------------------------
- def make_item_list
- @data = $game_party.all_items.select {|item| include?(item) }
- @data.push(nil) if include?(nil)
- end
- #--------------------------------------------------------------------------
- # ● 返回上一个选择的位置
- #--------------------------------------------------------------------------
- def select_last
- select(@data.index($game_party.last_item.object) || 0)
- end
- #--------------------------------------------------------------------------
- # ● 绘制项目
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enable?(item))
- draw_item_number(rect, item)
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制物品选择数/个数
- #--------------------------------------------------------------------------
- def draw_item_number(rect, item)
- draw_text(rect, sprintf("%2d/%2d", @items_number[item.id], $game_party.item_number(item)), 2)
- end
- #--------------------------------------------------------------------------
- # ● 更新帮助内容
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_item(item)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- make_item_list
- create_contents
- draw_all_items
- news_refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新提示消息窗口
- #--------------------------------------------------------------------------
- def news_refresh
- @news_refresh = Window_News_IB.new(false)
- @news_refresh.write_text
- end
- end
复制代码 用此种方法做,一刷新就会出现问题:
|
|