#============================================================================== # ■ VXAce-RGSS3-22 ワイドアイコンコマンド [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # ・アイコンタイプのアクターコマンドです。 # ・コマンド数は5つまで推奨 #============================================================================== #============================================================================== # ■ Window_ActorIconCmd #============================================================================== class Window_ActorIconCmd < Window_HorzCommand # アクターポジションに合わせる # true : Game_Actor#screen_x, screen_yに合わせる ACTPOS = true # 固定ポジション(ACTPOS=false用) FIXPOS = [0, 0] # [x, y] # スキルタイプのアイコン SKL_ICON = [0, 115, 119, 14] ITM_ICON = 261 # アイテムのアイコン # 背景色 BACK_COLOR = Color.new(0,0,0,128) #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0) self.openness = 0 self.opacity = 0 deactivate @actor = nil end #-------------------------------------------------------------------------- # ● 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number return 2 end #-------------------------------------------------------------------------- # ● 下端パディングの更新 #-------------------------------------------------------------------------- def update_padding_bottom end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def item_width return 24 end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width item_width * col_max + standard_padding * 2 end #-------------------------------------------------------------------------- # ● 1 ページに表示できる行数の取得 #-------------------------------------------------------------------------- def page_row_max return 1 end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max return 5 end #-------------------------------------------------------------------------- # ● 横に項目が並ぶときの空白の幅を取得 #-------------------------------------------------------------------------- def spacing return 0 end #-------------------------------------------------------------------------- # ● ウィンドウ内容の高さを計算 #-------------------------------------------------------------------------- def contents_height item_height * 2 end #-------------------------------------------------------------------------- # ● ウィンドウ内容の幅を計算 #-------------------------------------------------------------------------- def contents_width [super, item_width * col_max].max end #-------------------------------------------------------------------------- # ● 項目の選択 #-------------------------------------------------------------------------- def select(index) super(index) redraw_cmd_name if item_max > 0 end #-------------------------------------------------------------------------- # ● ずらすX位置 #-------------------------------------------------------------------------- def icon_start_x return 0 if col_max <= item_max (item_width * (col_max - item_max) / 2.0).truncate end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得 #-------------------------------------------------------------------------- def item_rect(index) rect = super(index) rect.x += icon_start_x rect.y += item_height rect end #-------------------------------------------------------------------------- # ● コマンド名を描画する矩形の取得 #-------------------------------------------------------------------------- def cmd_rect rect = item_rect(top_col) rect.x -= icon_start_x rect.y = 0 rect.width = item_width * col_max rect end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list return unless @actor add_attack_command add_skill_commands add_guard_command add_item_command end #-------------------------------------------------------------------------- # ● 攻撃コマンドをリストに追加 #-------------------------------------------------------------------------- def add_attack_command weapon = @actor.weapons icon = weapon.empty? ? $data_skills[@actor.attack_skill_id].icon_index : weapon[0].icon_index add_command([Vocab::attack, icon], :attack, @actor.attack_usable?) end #-------------------------------------------------------------------------- # ● スキルコマンドをリストに追加 #-------------------------------------------------------------------------- def add_skill_commands @actor.added_skill_types.sort.each do |stype_id| name = $data_system.skill_types[stype_id] add_command([name, SKL_ICON[stype_id]], :skill, true, stype_id) end end #-------------------------------------------------------------------------- # ● 防御コマンドをリストに追加 #-------------------------------------------------------------------------- def add_guard_command icon = $data_skills[@actor.guard_skill_id].icon_index add_command([Vocab::guard, icon], :guard, @actor.guard_usable?) end #-------------------------------------------------------------------------- # ● アイテムコマンドをリストに追加 #-------------------------------------------------------------------------- def add_item_command add_command([Vocab::item, ITM_ICON], :item) end #-------------------------------------------------------------------------- # ● コマンド名の再描画 #-------------------------------------------------------------------------- def redraw_cmd_name contents.clear_rect(cmd_rect) draw_cmd_name end #-------------------------------------------------------------------------- # ● コマンド名の描画 #-------------------------------------------------------------------------- def draw_cmd_name return if @index < 0 change_color(normal_color, command_enabled?(@index)) rect = cmd_rect contents.fill_rect(rect, BACK_COLOR) draw_text(rect, command_name(@index)[0], alignment) end #-------------------------------------------------------------------------- # ● 全項目の描画 #-------------------------------------------------------------------------- def draw_all_items draw_cmd_name super end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) draw_icon(command_name(index)[1], rect.x, rect.y, command_enabled?(index)) end #-------------------------------------------------------------------------- # ● 決定ハンドラの呼び出し #-------------------------------------------------------------------------- def call_ok_handler close super end #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- def setup(actor) @actor = actor clear_command_list make_command_list select(0) refresh if ACTPOS self.x = actor.screen_x - 70 self.y = actor.screen_y - 150 - self.height else self.x = FIXPOS[0] self.y = FIXPOS[1] end show.activate.open end end