赞 | 0 |
VIP | 0 |
好人卡 | 2 |
积分 | 1 |
经验 | 3218 |
最后登录 | 2013-6-27 |
在线时间 | 114 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 114 小时
- 注册时间
- 2010-12-3
- 帖子
- 74
|
4楼
楼主 |
发表于 2010-12-14 20:44:28
|
只看该作者
原來如此...謝謝各位大人的回覆.
再請問一下.
在使用倉庫腳本後,出現錯誤為
undefined method`last_click='for#<Scene_Reserve:0x116df38
如何能在倉庫腳本加個修改後,使他符合鼠標腳本?
倉庫腳本如下.#================================================= =============================
#
# 倉庫ver1.1
#
# 漢化 by 約束
#
# RPG中存放多餘物品的倉庫。
# 本腳本與黑獅子的腳本相似
# 參考於MQ0_PartyReserve所做。
#
# 使用方法
# 事件中的「腳本」裡填入reserve_system即可啟動此腳本。
#
# 不可存放物品
# 不想可以存放事件/劇情所需物品時
# 在物品的備註欄中填入非存放即可
# 如此即可使物品不可存入倉庫。
#
# 另外、為能使用TYPE74RX-T様的「限定特定物平的所持數上限」腳本
# 而寫了專門應對的方法
# 如果有用到以上所述腳本、請使RX_T_ITEM為true狀態
#
#================================================= =============================
module BBL_RESERVE_SYSTEM
#================================================= =============================
# 設定項目開始
#================================================= =============================
# 如果不希望保管物品根據以下範疇區分的情況時請填入false
ITEM_DISCRETION = true
# ITEM_DISCRETION在true的狀態時請在以下填入範疇名
# 從左開始依次為物品、武器、防具、金錢(順序不可改變)
# ※如果不希望有金錢保管功能時將金錢從範疇內消去
# 例) ["物品", "武器", "防具"]
DISCRETION_NAME = ["物品", "武器", "防具", "金錢"]
# 操作說明文
# 如果不需要時、消除""內文字即可
COMMAND_EXPLANATION = "空格:分別存入D:全部存入"
# 使用倉庫時的按鍵
RESERVE_KEY = Input::C # 分別存入
RESERVE_ALL_KEY = Input::Z # 全部存入
# 金錢選項窗口的用語
# 從左開始依次為保存和提取
GOLD_COMMAND_NAME = ["保存", "提取"]
# 所持金錢的用語
GOLD_NAME = "持有金額"
# 保存金錢的用語
RESERVE_GOLD_NAME = "保管金額"
# 使用了TYPE74RX-T様的「限定特定物平的所持數上限」腳本
# 請在以下改為true即可
RX_T_ITEM = false
#================================================= =============================
# 設定項目完畢
#================================================= =============================
end
$imported = {} if $imported == nil
class Game_Party
alias bbl_initialize initialize
#------------------------------------------------- -------------------------
# ○ 定義實例變量 (追加定義)
#------------------------------------------------- -------------------------
attr_reader :keep_gold # 保存金錢
#------------------------------------------------- -------------------------
# ● 初期化對象
#------------------------------------------------- -------------------------
def initialize
bbl_initialize
@keep_items = {} # 保管品hash (物品ID)
@keep_weapons = {} # 保管品hash (武器ID)
@keep_armors = {} # 保管品hash (防具ID)
@keep_gold = 0 # 保管金錢
end
#------------------------------------------------- -------------------------
# ○ 獲取保存物品的排序
#------------------------------------------------- -------------------------
def keeping_items
result = []
for i in @keep_items.keys.sort
result.push($data_items) if @keep_items > 0
end
for i in @keep_weapons.keys.sort
result.push($data_weapons) if @keep_weapons > 0
end
for i in @keep_armors.keys.sort
result.push($data_armors) if @keep_armors > 0
end
return result
end
#------------------------------------------------- -------------------------
# ○ 獲取保存物品的所持數量
#------------------------------------------------- -------------------------
def keeping_item_number(item)
case item
when RPG::Item
number = @keep_items[item.id]
when RPG::Weapon
number = @keep_weapons[item.id]
when RPG::Armor
number = @keep_armors[item.id]
end
return number == nil ? 0 : number
end
#------------------------------------------------- -------------------------
# ○ 保存物品的增加 (減少)
# item : 物品
# n : 個數
#------------------------------------------------- -------------------------
def gain_keeping_item(item, n)
number = keeping_item_number(item)
case item
when RPG::Item
@keep_items[item.id] = [[number + n, 0].max, 99].min
when RPG::Weapon
@keep_weapons[item.id] = [[number + n, 0].max, 99].min
when RPG::Armor
@keep_armors[item.id] = [[number + n, 0].max, 99].min
end
end
#------------------------------------------------- -------------------------
# ○ 保存物品的減少
# item : 物品
# n : 個數
#------------------------------------------------- -------------------------
def lose_keeping_item(item, n)
gain_keeping_item(item, -n)
end
#------------------------------------------------- -------------------------
# ● 保管金額的增加 (減少)
# n : 金額
#------------------------------------------------- -------------------------
def gain_keeping_gold(n)
@keep_gold = [[@keep_gold + n, 0].max, 9999999].min
end
#------------------------------------------------- -------------------------
# ● 保管金額的減少
# n : 金額
#------------------------------------------------- -------------------------
def lose_keeping_gold(n)
gain_keeping_gold(-n)
end
end
#================================================= =============================
# ■ Game_Interpreter
#================================================= =============================
class Game_Interpreter
#------------------------------------------------- -------------------------
# ● 呼出倉庫
#------------------------------------------------- -------------------------
def reserve_system
$scene = Scene_Reserve.new
return true
end
end
class Scene_Reserve < Scene_Base
#------------------------------------------------- -------------------------
# ● 開始處理
#------------------------------------------------- -------------------------
def start
super
create_menu_background
@not_gold = true if BBL_RESERVE_SYSTEM::DISCRETION_NAME.size < 4
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
@item_window = Window_Reserve_main.new(0, 112, 272, 248)
@reserve_window = Window_Reserve.new(272, 112, 272, 248)
else
@item_window = Window_Reserve_main.new(0, 56, 272, 304)
@reserve_window = Window_Reserve.new(272, 56, 272, 304)
end
@help_window = Window_Help.new
@item_window.help_window = @help_window
@reserve_window.help_window = @help_window
@command_window = Window_ReserveCommand.new(544, BBL_RESERVE_SYSTEM::DISCRETION_NAME,
BBL_RESERVE_SYSTEM::DISCRETION_NAME.size, 1, 4)
@command_window.y = 56
@command_window.active = true
@gold_command_window = Window_ReserveCommand.new(192, BBL_RESERVE_SYSTEM::GOLD_COMMAND_NAME, 1, 0)
@gold_command_window.opacity = 0
@gold_command_window.x = 32
@gold_command_window.y = @item_window.y + 64
@gold_command_window.visible = false
@item_window.active = false
@reserve_window.active = false
@item_window.index = -1
@reserve_window.index = -1
@item_cursor = 0
@reserve_cursor = 0
@item_window.mode = 1
@reserve_window.mode = 1
@number_window = Window_GoldInput.new
@number_window.visible = false
@number_window.y = @gold_command_window.y + @gold_command_window.height
@gold_window = Window_HandGold.new(0, 416 - 56)
@gold_reserve_window = Window_ReserveGold.new(272, 416 - 56)
unless BBL_RESERVE_SYSTEM::ITEM_DISCRETION
@command_window.active = false
@command_window.visible = false
@item_window.index = 0
@item_window.active
end
if $imported["HelpExtension"]
adjust_window_size
else
adjust_gold_window_size
end
end
#------------------------------------------------- -------------------------
# ● 完畢處理
#------------------------------------------------- -------------------------
def terminate
super
dispose_menu_background
@item_window.dispose
@reserve_window.dispose
@command_window.dispose
@help_window.dispose
@gold_command_window.dispose
@gold_window.dispose
@gold_reserve_window.dispose
@number_window.dispose
end
#------------------------------------------------- -------------------------
# ● 刷新畫面
#------------------------------------------------- -------------------------
def update
super
update_menu_background
@command_window.update if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
if @item_window.index >= 0
@item_window.active = true
@reserve_window.active = false
elsif @reserve_window.index >= 0
@item_window.active = false
@reserve_window.active = true
end
if @command_window.active == true
command_selection
elsif @item_window.active == true
select_item
elsif @reserve_window.active == true
select_keeping_item
elsif @gold_command_window.active == true
select_gold_command
elsif @number_window.active == true
select_number
end
item_mode = @command_window.index + 1
if item_mode != @item_window.mode
@item_window.mode = item_mode
end
if item_mode != @reserve_window.mode
@reserve_window.mode = item_mode
end
end
#------------------------------------------------- -------------------------
# ● 指令窗口選項的刷新
#------------------------------------------------- -------------------------
def command_selection
@help_window.set_text(BBL_RESERVE_SYSTEM::COMMAND_EXPLANATION)
if Input.trigger?(Input::C)
if @command_window.index == 3
Sound.play_decision
@command_window.active = false
@gold_command_window.visible = true
@gold_command_window.active = true
@gold_command_window.index = 0
else
Sound.play_decision
@command_window.active = false
@item_window.active = true
@item_window.index = 0
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
end
end
#------------------------------------------------- -------------------------
# ● 所持物品選項的刷新
#------------------------------------------------- -------------------------
def select_item
@item_window.update
@reserve_window.update
if Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_KEY)
@item_window.gain_item
@item_window.refresh
@reserve_window.refresh
if @item_window.item == nil
@item_window.index -= 1 if @item_window.index > 0
end
elsif Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_ALL_KEY)
@item_window.gain_item_all
@item_window.refresh
@reserve_window.refresh
if @item_window.item == nil
@item_window.index -= 1 if @item_window.index > 0
end
elsif Input.trigger?(Input::B)
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
Sound.play_cancel
@item_window.active = false
@item_window.index = -1
@command_window.active = true
else
Sound.play_cancel
$scene = Scene_Map.new
end
elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::LEFT)
Sound.play_cursor
@item_cursor = @item_window.index
@item_window.active = false
@reserve_window.active
@item_window.index = -1
@reserve_window.index = @reserve_cursor
end
end
#------------------------------------------------- -------------------------
# ● 保管物品選項的刷新
#------------------------------------------------- -------------------------
def select_keeping_item
@item_window.update
@reserve_window.update
if Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_KEY)
@reserve_window.reserve_item
@item_window.refresh
@reserve_window.refresh
if @reserve_window.item == nil
@reserve_window.index -= 1 if @reserve_window.index > 0
end
elsif Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_ALL_KEY)
@reserve_window.reserve_item_all
@item_window.refresh
@reserve_window.refresh
if @reserve_window.item == nil
@reserve_window.index -= 1 if @reserve_window.index > 0
end
elsif Input.trigger?(Input::B)
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
Sound.play_cancel
@reserve_window.active = false
@reserve_window.index = -1
@command_window.active = true
else
Sound.play_cancel
$scene = Scene_Map.new
end
elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::LEFT)
Sound.play_cursor
@reserve_cursor = @reserve_window.index
@reserve_window.active = false
@item_window.active
@reserve_window.index = -1
@item_window.index = @item_cursor
end
end
#------------------------------------------------- -------------------------
# ● 金錢指令窗口選項的刷新
#------------------------------------------------- -------------------------
def select_gold_command
@gold_command_window.update
if Input.trigger?(Input::C)
Sound.play_decision
@gold_command_window.active = false
@gold_command_window.visible = false
@number_window.visible = true
@number_window.active = true
if @gold_command_window.index == 0
@number_window.mode = 0 # 存入
@number_window.x = 32
else
@number_window.mode = 1 # 提取
@number_window.x = 304
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
@gold_command_window.active = false
@gold_command_window.visible = false
@command_window.active = true
end
end
#------------------------------------------------- -------------------------
# ● 填寫金額的刷新
#------------------------------------------------- -------------------------
def select_number
@number_window.update
if Input.trigger?(Input::C)
if @number_window.mode == 0
if @number_window.number > $game_party.gold
Sound.play_buzzer
@number_window.number = $game_party.gold
else
Sound.play_decision
gold = @number_window.number
$game_party.lose_gold(gold)
$game_party.gain_keeping_gold(gold)
@number_window.number = 0
@gold_window.refresh
@gold_reserve_window.refresh
end
elsif @number_window.mode == 1
if @number_window.number > $game_party.keep_gold
Sound.play_buzzer
@number_window.number = $game_party.keep_gold
else
Sound.play_decision
gold = @number_window.number
$game_party.gain_gold(gold)
$game_party.lose_keeping_gold(gold)
@number_window.number = 0
@gold_window.refresh
@gold_reserve_window.refresh
end
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
@number_window.visible = false
@number_window.active = false
@number_window.number = 0
@number_window.index = 6
@gold_command_window.visible = true
@gold_command_window.active = true
end
end
if $imported["HelpExtension"]
#------------------------------------------------- -------------------------
# ● 調整窗口大小用於KGC的擴張幫助窗口
#------------------------------------------------- -------------------------
def adjust_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@command_window.y = @help_window.height
@item_window.y = @command_window.height + @help_window.height
@reserve_window.y = @command_window.height + @help_window.height
sy = @help_window.height + @command_window.height + @gold_window.height
sy = @help_window.height + @command_window.height if @not_gold
@item_window.height = 416 - sy
@reserve_window.height = 416 - sy
@gold_command_window.y = @item_window.y
if @not_gold
@gold_window.visible = false
@gold_reserve_window.visible = false
end
end
end
#------------------------------------------------- -------------------------
# ● 調整窗口大小
#------------------------------------------------- -------------------------
def adjust_gold_window_size
sy = @help_window.height + @command_window.height + @gold_window.height
sy = @help_window.height + @command_window.height if @not_gold
@item_window.height = 416 - sy
@reserve_window.height = 416 - sy
if @not_gold
@gold_window.visible = false
@gold_reserve_window.visible = false
end
end
end
#================================================= =============================
# ■ Window_Reserve
#------------------------------------------------- -----------------------------
# 顯示倉庫中物品一覽
#================================================= =============================
class Window_Reserve < Window_Selectable
#------------------------------------------------- -------------------------
# ● 定義實例變量
#------------------------------------------------- -------------------------
attr_reader :mode # 模式
#------------------------------------------------- -------------------------
# ● 初期化對象
# x : 窗口的 X 坐標
# y : 窗口的 Y 坐標
# width : 窗口的寬度
# height : 窗口的高度
#------------------------------------------------- -------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@column_max = 1
self.index = -1
@mode = 0
@total = 0
@value = 0
refresh
end
#------------------------------------------------- -------------------------
# ● 獲取物品
#------------------------------------------------- -------------------------
def item
return @data[self.index]
end
#------------------------------------------------- -------------------------
# ● 刷新
#------------------------------------------------- -------------------------
def refresh
@data = []
for item in $game_party.keeping_items
next unless include?(item)
@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
#------------------------------------------------- -------------------------
# ● 項目的描畫
# index : 項目編號
#------------------------------------------------- -------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.keeping_item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf("%2d", number), 2)
self.contents.font.size = 14
rect.width -= 20
self.contents.draw_text(rect, "×", 2)
self.contents.font.size = 20
end
end
#------------------------------------------------- -------------------------
# ● 刷新幫助文本
#------------------------------------------------- -------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
#------------------------------------------------- -------------------------
# ● 模式的設定
# mode : 新模式
#------------------------------------------------- -------------------------
def mode=(mode)
if @mode != mode
@mode = mode
refresh
end
end
#------------------------------------------------- -------------------------
# ● 物品在許可狀態時是否顯示
#------------------------------------------------- -------------------------
def enable?(item)
if BBL_RESERVE_SYSTEM::RX_T_ITEM
rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(item, "所持可能數")
if rx_limit > 0
if $game_party.item_number(item) == rx_limit
return false
end
end
end
if $game_party.item_number(item) == 99
return false
else
return true
end
end
#------------------------------------------------- -------------------------
# ● 物品是否存在於名單
# item : 物品
#------------------------------------------------- -------------------------
def include?(item)
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
case @mode
when 1 # 物品
return false unless item.is_a?(RPG::Item)
when 2 # 武器
return false unless item.is_a?(RPG::Weapon)
when 3 # 防具
return false unless item.is_a?(RPG::Armor)
when 4 # 金錢
return false
end
return true
else
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return true
end
end
#------------------------------------------------- -------------------------
# ● 取出保管中物品
#------------------------------------------------- -------------------------
def reserve_item
return if item == nil
if BBL_RESERVE_SYSTEM::RX_T_ITEM
rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(item, "所持可能數")
end
return Sound.play_buzzer if $game_party.item_number(item) == 99
if rx_limit == 0
rx_limit = nil
end
if $game_party.item_number(item) == rx_limit
Sound.play_buzzer
else
Sound.play_use_item
$game_party.lose_keeping_item(item, 1)
$game_party.gain_item(item, 1)
end
end
#------------------------------------------------- -------------------------
# ● 將保管中物品全部取出
#------------------------------------------------- -------------------------
def reserve_item_all
return if item == nil
if BBL_RESERVE_SYSTEM::RX_T_ITEM
rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(item, "所持可能數")
end
return Sound.play_buzzer if $game_party.item_number(item) == 99
if rx_limit == 0
rx_limit = nil
end
if $game_party.item_number(item) == rx_limit
Sound.play_buzzer
else
Sound.play_use_item
@total = $game_party.keeping_item_number(item) + $game_party.item_number(item)
if rx_limit != nil
if rx_limit > 0
if @total > rx_limit
@value = @total - rx_limit
end
end
else
if @total > 99
@value = @total - 99
end
end
$game_party.gain_item(item, $game_party.keeping_item_number(item))
$game_party.lose_keeping_item(item, $game_party.keeping_item_number(item))
$game_party.gain_keeping_item(item, @value)
@total = 0
@value = 0
end
end
end
#================================================= =============================
# ■ Window_Reserve
#------------------------------------------------- -----------------------------
# 顯示倉庫中所持物品一覽
#================================================= =============================
class Window_Reserve_main < Window_Selectable
#------------------------------------------------- -------------------------
# ● 定義實例變量
#------------------------------------------------- -------------------------
attr_reader :mode # 模式
#------------------------------------------------- -------------------------
# ● 初期化對象
# x : 窗口的 X 坐標
# y : 窗口的 Y 坐標
# width : 窗口的寬度
# height : 窗口的高度
#------------------------------------------------- -------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@column_max = 1
self.index = -1
@mode = 0
@total = 0
@value = 0
refresh
end
#------------------------------------------------- -------------------------
# ● 物品的獲取
#------------------------------------------------- -------------------------
def item
return @data[self.index]
end
#------------------------------------------------- -------------------------
# ● 刷新
#------------------------------------------------- -------------------------
def refresh
@data = []
for item in $game_party.items
next unless include?(item)
@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
#------------------------------------------------- -------------------------
# ● 項目的描畫
# index : 項目編號
#------------------------------------------------- -------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf("%2d", number), 2)
self.contents.font.size = 14
rect.width -= 20
self.contents.draw_text(rect, "×", 2)
self.contents.font.size = 20
end
end
#------------------------------------------------- -------------------------
# ● 刷新幫助文本
#------------------------------------------------- -------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
#------------------------------------------------- -------------------------
# ● 模式的設定
# mode : 新模式
#------------------------------------------------- -------------------------
def mode=(mode)
if @mode != mode
@mode = mode
refresh
end
end
#------------------------------------------------- -------------------------
# ● 物品在許可狀態時是否顯示
#------------------------------------------------- -------------------------
def enable?(item)
if $game_party.keeping_item_number(item) == 99
return false
else
return true
end
end
#------------------------------------------------- -------------------------
# ○ 物品是否存在於名單
# item : 物品
#------------------------------------------------- -------------------------
def include?(item)
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
case @mode
when 1 # 物品
return false unless item.is_a?(RPG::Item)
return false if item.note.include?("非存放")
when 2 # 武器
return false unless item.is_a?(RPG::Weapon)
return false if item.note.include?("非存放")
when 3 # 防具
return false unless item.is_a?(RPG::Armor)
return false if item.note.include?("非存放")
when 4 # 金錢
return false
end
return true
else
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return false if item.note.include?("非存放")
return true
end
end
#------------------------------------------------- -------------------------
# ● 所持有物品的保存
#------------------------------------------------- -------------------------
def gain_item
return if item == nil
if $game_party.keeping_item_number(item) == 99
Sound.play_buzzer
else
Sound.play_use_item
$game_party.gain_keeping_item(item, 1)
$game_party.lose_item(item, 1)
end
end
#------------------------------------------------- -------------------------
# ● 所持有物品全部保存
#------------------------------------------------- -------------------------
def gain_item_all
return if item == nil
if $game_party.keeping_item_number(item) == 99
Sound.play_buzzer
else
Sound.play_use_item
@total = $game_party.keeping_item_number(item) + $game_party.item_number(item)
if @total > 99
@value = @total - 99
end
$game_party.gain_keeping_item(item, $game_party.item_number(item))
$game_party.lose_item(item, $game_party.item_number(item))
$game_party.gain_item(item, @value)
@total = 0
@value = 0
end
end
end
#================================================= =============================
# ■ Window_GoldInput
#------------------------------------------------- -----------------------------
# 用於填寫所持金錢的窗口。
#================================================= =============================
class Window_GoldInput < Window_Base
#------------------------------------------------- -------------------------
# ● 定義實例變量
#------------------------------------------------- -------------------------
attr_reader :mode # 模式
attr_accessor :index # 索引
#------------------------------------------------- -------------------------
# ● 初期化對象
# digits_max : 行數
#------------------------------------------------- -------------------------
def initialize
super(32, 208, 544, 64)
@number = 0
@digits_max = 7
@index = @digits_max - 1
@mode = 0
self.opacity = 0
self.active = false
self.z += 9999
refresh
update_cursor
end
#------------------------------------------------- -------------------------
# ● 數值的獲取
#------------------------------------------------- -------------------------
def number
return @number
end
#------------------------------------------------- -------------------------
# ● 模式的獲取
# 0:保存 1:提取
#------------------------------------------------- -------------------------
def mode=(mode)
@mode = mode
return @mode
end
#------------------------------------------------- -------------------------
# ● 數值的設定
# number : 新數值
#------------------------------------------------- -------------------------
def number=(number)
@number = [[number, 0].max, 10 ** @digits_max - 1].min
refresh
end
#------------------------------------------------- -------------------------
# ● 行數的獲取
#------------------------------------------------- -------------------------
def digits_max
return @digits_max
end
#------------------------------------------------- -------------------------
# ● 行數的設定
# digits_max : 新行數
#------------------------------------------------- -------------------------
def digits_max=(digits_max)
@digits_max = digits_max
refresh
end
#------------------------------------------------- -------------------------
# ● 光標向右移動
# wrap : 可以往復循環移動
#------------------------------------------------- -------------------------
def cursor_right(wrap)
if @index < @digits_max - 1 or wrap
@index = (@index + 1) % @digits_max
end
end
#------------------------------------------------- -------------------------
# ● 光標向左移動
# wrap : 可以往復循環移動
#------------------------------------------------- -------------------------
def cursor_left(wrap)
if @index > 0 or wrap
@index = (@index + @digits_max - 1) % @digits_max
end
end
#------------------------------------------------- -------------------------
# ● 刷新畫面
#------------------------------------------------- -------------------------
def update
super
if self.active
if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
Sound.play_cursor
place = 10 ** (@digits_max - 1 - @index)
n = @number / place % 10
@number -= n * place
n = (n + 1) % 10 if Input.repeat?(Input::UP)
n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
@number += n * place
refresh
end
last_index = @index
if Input.repeat?(Input::RIGHT)
if @index == @digits_max - 1
Sound.play_cursor
if @mode == 0
if @number == $game_party.gold
@number = 0
else
@number = $game_party.gold
end
elsif @mode == 1
if @number == $game_party.keep_gold
@number = 0
else
@number = $game_party.keep_gold
end
end
refresh
else
cursor_right(Input.trigger?(Input::RIGHT))
end
end
if Input.repeat?(Input::LEFT)
if @index == 0
Sound.play_cursor
if @mode == 0
if @number == $game_party.gold
@number = 0
else
@number = $game_party.gold
end
elsif @mode == 1
if @number == $game_party.keep_gold
@number = 0
else
@number = $game_party.keep_gold
end
end
refresh
else
cursor_left(Input.trigger?(Input::LEFT))
end
end
if @index != last_index
Sound.play_cursor
end
update_cursor
end
end
#------------------------------------------------- -------------------------
# ● 刷新
#------------------------------------------------- -------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
s = sprintf("%0*d", @digits_max, @number)
for i in 0...@digits_max
self.contents.draw_text(24 + i * 16, 0, 16, WLH, s[i,1], 1)
end
self.contents.font.color = system_color
self.contents.draw_text(24 + (i + 1) * 16, 0, 16, WLH, Vocab::gold)
end
#------------------------------------------------- -------------------------
# ● 光標的刷新
#------------------------------------------------- -------------------------
def update_cursor
self.cursor_rect.set(24 + @index * 16, 0, 16, WLH)
end
end
#================================================= =============================
# ■ Window_ReserveGold
#------------------------------------------------- -----------------------------
# 顯示保存金額的窗口。
#================================================= =============================
class Window_ReserveGold < Window_Base
#------------------------------------------------- -------------------------
# ● 初期化對象
# x : 窗口的 X 坐標
# y : 窗口的 Y 坐標
#------------------------------------------------- -------------------------
def initialize(x, y)
super(x, y, 272, WLH + 32)
refresh
end
#------------------------------------------------- -------------------------
# ● 刷新
#------------------------------------------------- -------------------------
def refresh
self.contents.clear
draw_currency_value($game_party.keep_gold, 104, 0, 120)
self.contents.font.color = system_color
self.contents.draw_text(16, 0, 120, WLH, BBL_RESERVE_SYSTEM::RESERVE_GOLD_NAME)
end
end
#================================================= =============================
# ■ Window_HandGold
#------------------------------------------------- -----------------------------
# 顯示所持金額的窗口。
#================================================= =============================
class Window_HandGold < Window_Base
#------------------------------------------------- -------------------------
# ● 初期化對象
# x : 窗口的 X 坐標
# y : 窗口的 Y 坐標
#------------------------------------------------- -------------------------
def initialize(x, y)
super(x, y, 272, WLH + 32)
refresh
end
#------------------------------------------------- -------------------------
# ● 刷新
#------------------------------------------------- -------------------------
def refresh
self.contents.clear
draw_currency_value($game_party.gold, 104, 0, 120)
self.contents.font.color = system_color
self.contents.draw_text(16, 0, 120, WLH, BBL_RESERVE_SYSTEM::GOLD_NAME)
end
end
#================================================= =============================
# ■ Window_ReserveCommand
#------------------------------------------------- -----------------------------
# 進行倉庫指令選擇的窗口。
#================================================= =============================
class Window_ReserveCommand < Window_Selectable
#------------------------------------------------- -------------------------
# ● 定義實例變量
#------------------------------------------------- -------------------------
attr_reader :commands # 指令
#------------------------------------------------- -------------------------
# ● 初期化對象
# width : 窗口的寬度
# commands : 指令字符串的排序
# column_max : 行數(在2 以上時,橫向選項)
# row_max : 列數 (0:切合指令個數)
# spacing : 項目橫向排列時空白的部分
#------------------------------------------------- -------------------------
def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
if row_max == 0
row_max = (commands.size + column_max - 1) / column_max
end
super(0, 0, width, row_max * WLH + 32, spacing)
@commands = commands
@item_max = commands.size
@column_max = column_max
refresh
self.index = 0
end
#------------------------------------------------- -------------------------
# ● 刷新
#------------------------------------------------- -------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#------------------------------------------------- -------------------------
# ● 項目的描畫
# index : 項目編號
# enabled : 有效標誌。 false 時會描繪為半透明狀
#------------------------------------------------- -------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index], 1)
end
end |
|