赞 | 0 |
VIP | 0 |
好人卡 | 9 |
积分 | 1 |
经验 | 15515 |
最后登录 | 2022-1-17 |
在线时间 | 1083 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 70
- 在线时间
- 1083 小时
- 注册时间
- 2013-3-29
- 帖子
- 2394
|
zxcvgfds007 发表于 2013-9-13 14:32
谢谢,真的成功了,
另外我再请教个问题, - #==============================================================================
- # ■ VX-RGSS-22 アイテム画面-改 [Ver.1.0.0] by Claimh
- #------------------------------------------------------------------------------
- # アイテム画面(戦闘以外)を改変します。
- #------------------------------------------------------------------------------
- # ◆アイテム分類
- # アイテム : 通常アイテム
- # 装備品 : 武器・防具
- # 貴重品 : 価格=0のアイテム
- # ◆捨てる
- # Xボタンでアイテムを捨てることができます。
- #==============================================================================
- module ItemEx
- # アイテム分類で貴重品の項を使用する
- USE_PRECIAS = true
-
- # 捨てるあり
- USE_LOSE = true
-
- # 貴重品の放棄を許可する
- USE_LOSE_PRE = true
- end
- #==============================================================================
- # ■ ItemExData
- #------------------------------------------------------------------------------
- # RPG::Item/Weapon/Armor用の共通クラス
- #==============================================================================
- class ItemExData
- # 初期化
- def initialize(d)
- @item = d
- end
- # RPG::Item/Weapon/Armorデータ参照
- def d
- return @item
- end
- # アイテム所持数
- def number
- return $game_party.item_number(@item)
- end
- # アイテム破棄
- def lose(n)
- $game_party.lose_item(@item, n)
- end
- # アイテム使用可能?
- def can_use?
- case @item
- when RPG::Item; return $game_party.item_can_use?(@item)
- when RPG::Weapon; return false
- when RPG::Armor; return false
- end
- end
- # アイテム破棄可能?
- def can_lose?
- return (ItemEx::USE_LOSE_PRE or @item.price != 0)
- end
- end
- #==============================================================================
- # ■ Window_ItemCmd
- #==============================================================================
- class Window_ItemCmd < Window_Selectable
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super(0, WLH+32, 544, WLH+32)
- @commands = ["アイテム", "装備品"]
- @commands.push("貴重品") if ItemEx::USE_PRECIAS
- @item_max = @column_max = @commands.size
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 項目の描画
- # index : 項目番号
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- rect.x += 4
- rect.width -= 8
- self.contents.draw_text(rect.x, 0, rect.width, WLH, @commands[index])
- end
- #--------------------------------------------------------------------------
- # ● ヘルプテキスト更新
- #--------------------------------------------------------------------------
- def update_help
- @help_window.ct = @index
- end
- end
- #==============================================================================
- # ■ Window_ItemList
- #==============================================================================
- class Window_ItemList < Window_Selectable
- MAX = ItemEx::USE_PRECIAS ? 3 : 2
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super(0, 112, 544, 306)
- @column_max = 2
- [url=home.php?mod=space&uid=370741]@Index[/url] = 0
- @idx = [0, 0, 0]
- @ct = 0
- all_refresh
- self.ct = @ct
- end
- #--------------------------------------------------------------------------
- # ● 解放
- #--------------------------------------------------------------------------
- def dispose
- super
- for b in @bitmap
- b.dispose unless b.nil?
- end
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウ内容の作成
- #--------------------------------------------------------------------------
- def create_contents
- end
- #--------------------------------------------------------------------------
- # ● カテゴリ変更
- #--------------------------------------------------------------------------
- def ct=(c)
- save_idx
- @ct = c
- self.contents = @bitmap[c]
- @item_max = @data[c].size
- @idx[c] = @item_max - 1 if @idx[c] >= @item_max
- @idx[c] = 0 if @idx[c] < 0
- load_idx
- end
- #--------------------------------------------------------------------------
- # ● index保存
- #--------------------------------------------------------------------------
- def save_idx
- @idx[@ct] = self.index
- end
- def load_idx
- self.index = @idx[@ct]
- end
- #--------------------------------------------------------------------------
- # ● アイテムの取得
- #--------------------------------------------------------------------------
- def item
- return i_item(@index)
- end
- def i_item(i)
- return @data[@ct][i]
- end
- #--------------------------------------------------------------------------
- # ● 全リフレッシュ
- #--------------------------------------------------------------------------
- def all_refresh
- @bitmap = []
- @data = []
- for c in 0...MAX
- data_refresh(c)
- end
- end
- #--------------------------------------------------------------------------
- # ● データリフレッシュ
- #--------------------------------------------------------------------------
- def data_refresh(c)
- @data[c] = []
- for d in $game_party.items
- case c
- when 0 # アイテム
- next if !d.is_a?(RPG::Item)
- next if ItemEx::USE_PRECIAS and d.price == 0
- @data[c].push(ItemExData.new(d))
- when 1 # 武器防具
- next if !d.is_a?(RPG::Weapon) and !d.is_a?(RPG::Armor)
- @data[c].push(ItemExData.new(d))
- when 2 # 貴重品
- next if !d.is_a?(RPG::Item)
- next if !ItemEx::USE_PRECIAS or d.price != 0
- @data[c].push(ItemExData.new(d))
- end
- if d.is_a?(RPG::Item) and d.id == $game_party.last_item_id
- @idx[c] = @data[c].size - 1
- load_idx if @ct == c
- end
- end
- @bitmap[c].dispose unless @bitmap[c].nil?
- @item_max = @data[c].size
- @bitmap[c] = Bitmap.new(width - 32, @item_max > 0 ? (row_max*WLH) : WLH)
- refresh(c)
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh(c)
- self.ct = c
- for i in 0...@item_max
- draw_item(i, false)
- end
- end
- #--------------------------------------------------------------------------
- # ● 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(i, clear=true)
- itm = i_item(i)
- rect = item_rect(i)
- x = rect.x + 4
- y = rect.y
- if clear
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- end
- rect.width -= 4
- draw_item_name(itm.d, rect.x, rect.y, itm.can_use?)
- self.contents.draw_text(rect, sprintf(":%2d", itm.number), 2)
- end
- #--------------------------------------------------------------------------
- # ● ヘルプテキスト更新
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.d.description)
- end
- end
- #==============================================================================
- # ■ Window_ItemNumber
- #==============================================================================
- class Window_ItemNumber < Window_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- # x : ウィンドウの X 座標
- # y : ウィンドウの Y 座標
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 300, WLH*2 + 32)
- @item = nil
- [url=home.php?mod=space&uid=25307]@Max[/url] = 1
- [url=home.php?mod=space&uid=27178]@Number[/url] = 1
- self.visible = false
- self.z += 10
- self.opacity = 200
- end
- #--------------------------------------------------------------------------
- # ● アイテム、最大個数の設定
- #--------------------------------------------------------------------------
- def set(item, max)
- @item = item
- @max = max
- @number = 1
- self.visible = true
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 入力された個数の設定
- #--------------------------------------------------------------------------
- def number
- return @number
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.draw_text(0, 0, 200, WLH, "捨てる数:")
- draw_item_name(@item, 4, WLH)
- self.contents.font.color = normal_color
- self.contents.draw_text(212, WLH, 20, WLH, "×")
- self.contents.draw_text(244, WLH, 20, WLH, @number.to_s, 2)
- self.cursor_rect.set(240, WLH, 28, WLH)
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- if self.active
- last_number = @number
- if Input.repeat?(Input::RIGHT) and @number < @max
- @number += 1
- end
- if Input.repeat?(Input::LEFT) and @number > 1
- @number -= 1
- end
- if Input.repeat?(Input::UP) and @number < @max
- @number = [@number + 10, @max].min
- end
- if Input.repeat?(Input::DOWN) and @number > 1
- @number = [@number - 10, 1].max
- end
- if @number != last_number
- Sound.play_cursor
- refresh
- end
- end
- end
- end
- #==============================================================================
- # ■ Scene_Item
- #------------------------------------------------------------------------------
- # アイテム画面の処理を行うクラスです。
- #==============================================================================
- class Scene_Item < Scene_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(index=0)
- @index = index
- end
- #--------------------------------------------------------------------------
- # ● 開始処理
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- @viewport = Viewport.new(0, 0, 544, 416)
- @cmd_window = Window_ItemCmd.new
- @cmd_window.viewport = @viewport
- @item_window = Window_ItemList.new
- @item_window.viewport = @viewport
- @num_window = Window_ItemNumber.new(122, 200)
- @help_window = Window_Help.new
- @help_window.viewport = @viewport
- @target_window = Window_MenuStatus.new(0, 0)
- hide_target_window
- #
- @target_window.visible = @target_window.active = false
- @item_window.active = false
- @num_window.active = false
- @item_window.help_window = @help_window
- @cmd_window.help_window = @item_window
- end
- #--------------------------------------------------------------------------
- # ● 終了処理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @viewport.dispose
- @cmd_window.dispose
- @item_window.dispose
- @num_window.dispose
- @help_window.dispose
- @target_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 元の画面へ戻る
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Menu.new(@index)
- end
- #----------------------------------------------------------------------------
- # ● フレーム更新
- #----------------------------------------------------------------------------
- def update
- if @cmd_window.active
- update_cmd
- elsif @item_window.active
- update_list
- elsif @num_window.active
- update_num
- elsif @target_window.active
- update_target
- end
- end
- #----------------------------------------------------------------------------
- # ● フレーム更新 : cmd
- #----------------------------------------------------------------------------
- def update_cmd
- @cmd_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- @cmd_window.active = false
- @item_window.active = true
- end
- end
- #----------------------------------------------------------------------------
- # ● フレーム更新 : list
- #----------------------------------------------------------------------------
- def update_list
- @item_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @cmd_window.active = true
- @item_window.active = false
- @help_window.set_text("")
- elsif Input.trigger?(Input::C)
- if @item_window.item.nil? or !@item_window.item.can_use?
- Sound.play_buzzer
- return
- end
- @item = @item_window.item.d
- if @item != nil
- $game_party.last_item_id = @item.id
- end
- if $game_party.item_can_use?(@item)
- Sound.play_decision
- determine_item
- else
- Sound.play_buzzer
- end
- elsif Input.trigger?(Input::X) and ItemEx::USE_LOSE
- if @item_window.item.nil? or !@item_window.item.can_lose?
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- @item = @item_window.item
- @num_window.set(@item.d, @item.number)
- @item_window.active = false
- @num_window.visible = @num_window.active = true
- end
- end
- #----------------------------------------------------------------------------
- # ● フレーム更新 : num
- #----------------------------------------------------------------------------
- def update_num
- @num_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @item_window.active = true
- @num_window.visible = @num_window.active = false
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- @item.lose(@num_window.number)
- if @item.number > 0
- @item_window.draw_item(@item_window.index, true)
- else
- @item_window.data_refresh(@cmd_window.index)
- $game_party.last_item_id = 0
- end
- @item_window.active = true
- @num_window.visible = @num_window.active = false
- end
- end
- #--------------------------------------------------------------------------
- # ● ターゲット選択の更新
- #--------------------------------------------------------------------------
- def update_target
- @target_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- if $game_party.item_number(@item) == 0 # アイテムを使い切った場合
- @item_window.data_refresh(@cmd_window.index) # ウィンドウの内容を再作成
- end
- hide_target_window
- elsif Input.trigger?(Input::C)
- if not $game_party.item_can_use?(@item)
- Sound.play_buzzer
- else
- determine_target
- end
- end
- end
- end
复制代码 |
|