#============================================================================== # □ ロールコマンド(2012/06/04) #------------------------------------------------------------------------------ #  コマンドウィンドウをロールさせます。 #============================================================================== #============================================================================== # ☆ カスタマイズここから、 #============================================================================== # ロールの速度を設定します。小さいほど速くなります。 $cc_roll_command_roll_wait = 8.0 #============================================================================== # ☆ カスタマイズここまで。 #============================================================================== #============================================================================== # □ Window_Command #------------------------------------------------------------------------------ #  一般的なコマンド選択を行うウィンドウです。 #============================================================================== class Window_Command < Window_Selectable #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- alias cc_roll_command_initialize initialize def initialize(x, y) @scroll_count = 0 cc_roll_command_initialize(x, y) end #-------------------------------------------------------------------------- # ○ フレーム更新 #-------------------------------------------------------------------------- def update super update_roll if @scroll_count end #-------------------------------------------------------------------------- # ○ コマンドロールの速度の取得 #-------------------------------------------------------------------------- def roll_distance item_height end #-------------------------------------------------------------------------- # ○ コマンドロールの更新 #-------------------------------------------------------------------------- def update_roll if @scroll_count != 0 @scroll_count -= roll_distance / $cc_roll_command_roll_wait if @scroll_count > 0 @scroll_count += roll_distance / $cc_roll_command_roll_wait if @scroll_count < 0 refresh end end #-------------------------------------------------------------------------- # ○ 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number [item_max, 3].max end #-------------------------------------------------------------------------- # ○ 項目数の取得 #-------------------------------------------------------------------------- def item_max [@list.size, 1].max end #-------------------------------------------------------------------------- # ○ アライメントの取得 #-------------------------------------------------------------------------- def alignment return 1 end #-------------------------------------------------------------------------- # ○ 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) i = (index + @index - visible_line_number / 2 - 1) change_color(normal_color, command_enabled?(i % item_max)) draw_text(item_rect_for_text(index), command_name(i % item_max), alignment) end #-------------------------------------------------------------------------- # ○ 全項目の描画 #-------------------------------------------------------------------------- def draw_all_items (visible_line_number + 3 - visible_line_number % 2).times{|i| draw_item(i) } unless @list.empty? end #-------------------------------------------------------------------------- # ○ 項目を描画する矩形の取得(テキスト用) #-------------------------------------------------------------------------- def item_rect_for_text(index) rect = super(index) center = (visible_line_number + 3 - visible_line_number % 2) / 2 roll_adjust = @scroll_count / roll_distance contents.font.size = [Font.default_size - ((index - center + roll_adjust).abs) * 4, 8].max rect.y += (Font.default_size - contents.font.size).abs / 2 + @scroll_count - item_height * (3 - visible_line_number % 2) / 2 rect.height -= (index - center + roll_adjust).abs * 4 rect end #-------------------------------------------------------------------------- # ○ カーソル位置が画面内になるようにスクロール #-------------------------------------------------------------------------- def ensure_cursor_visible self.oy = 0 cursor_rect.y = (visible_line_number - 1) / 2.0 * item_height end #-------------------------------------------------------------------------- # ○ 先頭の行の設定 #-------------------------------------------------------------------------- def top_row=(row) end #-------------------------------------------------------------------------- # ○ カーソルの更新 #-------------------------------------------------------------------------- def update_cursor if @cursor_all cursor_rect.set(0, 0, contents.width, row_max * item_height) self.top_row = 0 elsif @index < 0 cursor_rect.empty else cursor_rect.set(item_rect(@index)) ensure_cursor_visible refresh end end #-------------------------------------------------------------------------- # ○ カーソルを下に移動 #-------------------------------------------------------------------------- def cursor_down(wrap = false) if index < item_max - col_max || (wrap && col_max == 1) select((index + col_max) % item_max) @scroll_count = roll_distance Sound.play_cursor end end #-------------------------------------------------------------------------- # ○ カーソルを上に移動 #-------------------------------------------------------------------------- def cursor_up(wrap = false) if index >= col_max || (wrap && col_max == 1) select((index - col_max + item_max) % item_max) @scroll_count = -roll_distance Sound.play_cursor end end end #============================================================================== # □ Window_HorzCommand #------------------------------------------------------------------------------ #  横選択形式のコマンドウィンドウです。 #============================================================================== class Window_HorzCommand < Window_Command #-------------------------------------------------------------------------- # ○ コマンドロールの速度の取得 #-------------------------------------------------------------------------- def roll_distance (item_width + spacing) end #-------------------------------------------------------------------------- # ○ 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) i = (index + @index - col_max / 2 - 1) change_color(normal_color, command_enabled?(i % item_max)) draw_text(item_rect_for_text(index), command_name(i % item_max), alignment) end #-------------------------------------------------------------------------- # ○ 全項目の描画 #-------------------------------------------------------------------------- def draw_all_items (col_max + 2).times{|i| draw_item(i) } unless @list.empty? end #-------------------------------------------------------------------------- # ○ 項目を描画する矩形の取得(テキスト用) #-------------------------------------------------------------------------- def item_rect_for_text(index) rect = item_rect(index) rect.x += 4 + @scroll_count - (item_width + spacing) * (3 - col_max % 2) / 2 rect.width -= 8 center = (col_max + 3 - col_max % 2) / 2 roll_adjust = @scroll_count.abs / roll_distance rect.y += (index - center + roll_adjust).abs * 2 rect.height -= (index - center + roll_adjust).abs * 4 contents.font.size = [Font.default_size - (index - center + roll_adjust).abs * 4, 8].max rect end #-------------------------------------------------------------------------- # ○ カーソル位置が画面内になるようにスクロール #-------------------------------------------------------------------------- def ensure_cursor_visible cursor_rect.x = (col_max - 1) / 2.0 * (item_width + spacing) end #-------------------------------------------------------------------------- # ○ カーソルを右に移動 #-------------------------------------------------------------------------- def cursor_right(wrap = false) if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?)) select((index + 1) % item_max) @scroll_count = roll_distance Sound.play_cursor end end #-------------------------------------------------------------------------- # ○ カーソルを左に移動 #-------------------------------------------------------------------------- def cursor_left(wrap = false) if col_max >= 2 && (index > 0 || (wrap && horizontal?)) select((index - 1 + item_max) % item_max) @scroll_count = -roll_distance Sound.play_cursor end end end #============================================================================== # □ Window_ChoiceList #------------------------------------------------------------------------------ #  イベントコマンド[選択肢の表示]に使用するウィンドウです。 #============================================================================== class Window_ChoiceList < Window_Command #-------------------------------------------------------------------------- # ○ 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect_for_text(index) i = (index + @index - visible_line_number / 2 - 1) rect.y -= (Font.default_size - contents.font.size).abs / 2 draw_text_ex(rect.x, rect.y, command_name(i % item_max)) end end