#============================================================================== # ■ VX-RGSS2-5 用語辞典[ウィンドウクラス] by Claimh #------------------------------------------------------------------------------ # 用語辞典の表示内容を記述するウィンドウを定義する。 #============================================================================== #============================================================================== # ■ Window_DictInfo [用語の説明文を表示するウィンドウ] #============================================================================== class Window_DictInfo < Window_Base attr_reader :page #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize rect = $game_temp.in_battle ? Rect.new(50, 50, 444, 316) : Dictionary.d_info_rect super(rect.x, rect.y, rect.width, rect.height) self.contents = Bitmap.new(width - 32, height - 32) self.z = 255 @data = nil @page = 0 @arrow_up = Arrow_DictInfoUp.new @arrow_dw = Arrow_DictInfoDw.new update_arrow self.visible = $game_temp.in_battle ? true : Dictionary.d_info_visible end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose super @arrow_up.dispose @arrow_dw.dispose end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def visible=(v) super(v) v ? show_info_arrow : delete_info_arrow end #-------------------------------------------------------------------------- # ● ページup #-------------------------------------------------------------------------- def page_up return if @data.nil? return if @page < 1 Sound.play_cursor refresh(@data, @page-1) end #-------------------------------------------------------------------------- # ● ページdown #-------------------------------------------------------------------------- def page_dw return if @data.nil? return if @page >= (@data.max_page - 1) Sound.play_cursor refresh(@data, @page+1) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(data, page=0) if Dictionary::PAGE_LOCK max = (data.nil? or (page >= data.max_page)) page = 0 if data != @data and max # 最大数を超える場合はページリセット else page = 0 if data != @data # 異なるデータならページリセット end return if data == @data and page == @page ## 同じ内容は再描画しない @data = data @page = page show_info_arrow # アロー表示更新 self.contents.clear return if @data.nil? # データがないので表示なし if !@data.show_flg or @data.name == "" # 表示許可なし or 名無し self.contents.font.color = normal_color self.contents.draw_text(0, self.height / 2 - 32, self.contents.width, WLH, "- unknown -", 1) return end # サブ画像を描画 @data.draw_sub_g(self.contents, self.contents.width, self.contents.height) # 用語名を描画 self.contents.font.color = normal_color x = Dictionary::TYPE_ICON ? (@data.type_icon? ? 24 : 0) : 0 self.contents.draw_text(x, 0, 200, WLH, @data.name.delete("\\n").delete("\\")) # 種類を描画 x = Dictionary::TYPE_ICON ? (@data.type_icon? ? 0 : 150) : 150 @data.draw_type(self.contents, x, 0) # ページを表示 if @data.max_page > 1 self.contents.draw_text(self.contents.width - 80, 0, 40, WLH, (@page+1).to_s, 2) self.contents.draw_text(self.contents.width - 45, 0, 20, WLH, "/", 2) self.contents.draw_text(self.contents.width - 40, 0, 40, WLH, @data.max_page.to_s, 2) end # 説明文を描画 if @data.info == "" self.contents.draw_text(0, self.height / 2 - 32, self.contents.width, WLH, "- no data -", 1) else DictFunc.draw_info_text(self.contents, 10, 30, self.contents.width-32, WLH, @data.page_text[@page]) end end #-------------------------------------------------------------------------- # ● Info情報のページ数からアローを表示するか判断する #-------------------------------------------------------------------------- def show_info_arrow # 最大行数を超えそうなら下カーソルを表示させる if self.visible and !@data.nil? and @data.show_flg and @data.max_page > 1 if @page == 0 @arrow_up.visible = false @arrow_dw.visible = true elsif @page == (@data.max_page - 1) @arrow_up.visible = true @arrow_dw.visible = false else @arrow_up.visible = true @arrow_dw.visible = true end else delete_info_arrow end end #-------------------------------------------------------------------------- # ● Info情報のアローを消す #-------------------------------------------------------------------------- def delete_info_arrow(v=false) @arrow_up.visible = v @arrow_dw.visible = v end #-------------------------------------------------------------------------- # ● アロー更新 #-------------------------------------------------------------------------- def update_arrow @arrow_up.update @arrow_dw.update end end #============================================================================== # ■ Arrow_DictInfoUp [項目ウィンドウに表示するアロー↑] #============================================================================== class Arrow_DictInfoUp < Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super self.bitmap = Cache.system("Window") rect = $game_temp.in_battle ? Rect.new(466, 50, 0, 410) : Dictionary.d_cursor_rect self.x = rect.x self.y = rect.y self.ox = 16 self.oy = 64 self.z = 2500 self.angle = 180 self.visible = false @blink_count = 0 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # 点滅カウントを更新 @blink_count = (@blink_count + 1) % 32 # 転送元の矩形を設定 case @blink_count when 0..7; self.src_rect.set(96, 64, 16, 16) when 8..16; self.src_rect.set(112, 64, 16, 16) when 16..23; self.src_rect.set(112, 80, 16, 16) when 24..31; self.src_rect.set(96, 80, 16, 16) end end end #============================================================================== # ■ Arrow_DictInfoDw [項目ウィンドウに表示するアロー↓] #============================================================================== class Arrow_DictInfoDw < Arrow_DictInfoUp #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super self.bitmap = Cache.system("Window") self.x += 16 self.y = $game_temp.in_battle ? 400 : Dictionary.d_cursor_rect.height self.angle = 0 @blink_count = 0 end end #============================================================================== # ■ Window_DictMenu [項目を表示するウィンドウ] #============================================================================== class Window_DictMenu < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize rect = Dictionary.d_category_rect super(rect.x, rect.y, rect.width, rect.height) @column_max = Dictionary.d_category_column @item_max = $game_system.dictionary.size self.index = 0 self.z = 200 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh return if row_max == 0 # 項目数が 0 でなければビットマップを作成し、全項目を描画 self.contents = Bitmap.new(self.width - 32, row_max * WLH) w = self.width / @column_max for i in 0...$game_system.dictionary.size id = $game_system.dictionary.keys[i] x = i % @column_max * w y = i / @column_max * WLH self.contents.draw_text(x+4, y, self.width-32, WLH, $game_system.dictionary[id].name) end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.data_refresh($game_system.dictionary.keys[@index]) end end #============================================================================== # ■ Window_DictCollect [収集率を表示するウィンドウ] #============================================================================== class Window_DictCollect < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(category=-1) super(0, 416-(WLH+32), 180, WLH+32) self.visible = Dictionary::SHOW_COLLECT self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.color = system_color self.contents.draw_text( 0, 0, 80, WLH, "収集率:") self.contents.font.color = normal_color max = 0 cnt = 0 if category == -1 for i in $game_system.dictionary.keys data = $game_system.dictionary[i] for j in data.keys max += 1 cnt += 1 if data[j].show_flg end end else data = $game_system.dictionary[category] for j in data.keys max += 1 cnt += 1 if data[j].show_flg end end self.contents.draw_text(78, 0, 40, WLH, (cnt*100/max).truncate.to_s, 2) self.contents.draw_text(118, 0, 20, WLH, "%") end end #============================================================================== # ■ Window_Dictionary [用語の一覧表項目を表示するウィンドウ] #============================================================================== class Window_Dictionary < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize rect = Dictionary.d_words_rect super(rect.x, rect.y, rect.width, rect.height) self.contents = Bitmap.new(width - 32, height - 32) self.index = -1 self.active = false @column_max = Dictionary.d_words_column @ct_index = -1 @ct_id = nil end #-------------------------------------------------------------------------- # ● データサイズ #-------------------------------------------------------------------------- def data_size return @item_max end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def data_refresh(ct_id, force=false) return if ct_id == @ct_id and !force self.index = 0 unless force @ct_id = ct_id @commands = [] for id in $game_system.dictionary[@ct_id].keys data = $game_system.dictionary[@ct_id][id] next if Dictionary::VISIBLE_ONLY and !data.show_flg @commands.push(data) end @item_max = @commands.size # 項目数が 0 でなければビットマップを作成し、全項目を描画 if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * WLH) for i in 0...@item_max draw_item(i) end else self.contents.clear end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) data = @commands[index] w = self.width / @column_max ww = WLH / @column_max x = index % @column_max * w y = index / @column_max * WLH # 表示許可フラグがONか? if data.show_flg and data.name != "" # 着色情報に従い用語名を表示する self.contents.font.color = data.txt_color(normal_color) self.contents.draw_text(x+4, y, w-4-ww, WLH, data.name.split(/\\n/)[0]) else # 未許可なので、表示しない self.contents.font.color = normal_color self.contents.draw_text(x+4, y, w-4-ww, WLH, "-------") end end #-------------------------------------------------------------------------- # ● カーソルが当たっている辞書データ参照 #-------------------------------------------------------------------------- def current_dict return nil if @item_size == 0 return @commands[@index] end #-------------------------------------------------------------------------- # ● 未読/更新から既読へ更新 #-------------------------------------------------------------------------- def update_dict_color data = current_dict if data.color == 1 or data.color == 2 data.color = 0 data_refresh(@ct_id, true) end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.refresh(current_dict, @help_window.page) end end