#============================================================================== # ■ VXAce-RGSS3-1 用語辞典[ウィンドウクラス] by Claimh #------------------------------------------------------------------------------ # 用語辞典の表示内容を記述するウィンドウを定義する。 #============================================================================== #============================================================================== # ■ Window_DictInfo [用語の説明文を表示するウィンドウ] #============================================================================== class Window_DictInfo < Window_Selectable attr_reader :page #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize rect = ($game_party.in_battle or SceneManager.scene_is?(Scene_Map)) ? Rect.new(50, 50, Graphics.width - 100, Graphics.height - 100) : Dictionary.d_info_rect(fitting_height(1), fitting_height(3)) super(rect.x, rect.y, rect.width, rect.height) self.z = 255 @data = nil @page = 0 @arrow_up = Arrow_DictInfoUp.new @arrow_dw = Arrow_DictInfoDw.new update_arrow self.visible = $game_party.in_battle ? false : Dictionary.d_info_visible end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose super @arrow_up.dispose @arrow_dw.dispose end #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 #-------------------------------------------------------------------------- def process_handling return unless open? && active return process_ok if ok_enabled? && Input.trigger?(:C) return process_cancel if cancel_enabled? && Input.trigger?(:B) return call_handler(:pagedown) if handle?(:pagedown) && Input.trigger?(:DOWN) return call_handler(:pageup) if handle?(:pageup) && Input.trigger?(:UP) return call_handler(:pageright) if handle?(:pageright) && Input.trigger?(:RIGHT) return call_handler(:pageleft) if handle?(:pageleft) && Input.trigger?(:LEFT) end #-------------------------------------------------------------------------- # ● カーソル移動 #-------------------------------------------------------------------------- def process_cur(symbol) Sound.play_cursor call_handler(symbol) 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=nil, 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 名無し change_color(normal_color) draw_text(0, (contents_height - line_height)/2, contents_width, line_height, "- no data -", 1) return end # サブ画像を描画 @data.draw_sub_g(self.contents, contents_width, contents_height) # 用語名を描画 self.contents.font.color = normal_color x = Dictionary::TYPE_ICON ? (@data.type_icon? ? 24 : 0) : 0 draw_text(x, 0, 200, line_height, @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 draw_text(contents_width - 80, 0, 40, line_height, (@page+1).to_s, 2) draw_text(contents_width - 45, 0, 20, line_height, "/", 2) draw_text(contents_width - 40, 0, 40, line_height, @data.max_page.to_s, 2) end # 説明文を描画 if @data.info == "" draw_text(0, (contents_height - line_height)/2, contents_width, line_height, "- no data -", 1) else DictFunc.draw_info_text(self.contents, 10, 30, contents_width-10-16, line_height, @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 super update_arrow 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_party.in_battle ? Rect.new(Graphics.width-78, 50, 0, Graphics.height-6) : 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_party.in_battle ? Graphics.width-144 : 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(fitting_height(1)) super(rect.x, rect.y, rect.width, rect.height) self.index = 0 self.z = 200 refresh end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max Dictionary.d_category_column end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max $game_system.dictionary.size end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? return $game_system.dictionary[@index].size > 0 end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) id = $game_system.dictionary.keys[index] draw_text(item_rect_for_text(index), $game_system.dictionary[id].name) 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, Graphics.height-fitting_height(1), 180, fitting_height(1)) self.visible = Dictionary::SHOW_COLLECT change_color(system_color) draw_text( 0, 0, 80, line_height, "収集率:") change_color(normal_color) max_cnt=[0, 0] if category == -1 $game_system.dictionary.keys.each do |i| c = count(i) max_cnt[0] += c[0] max_cnt[1] += c[1] end else max_cnt = count(category) end draw_text(78, 0, 40, line_height, (max_cnt[1]*100/max_cnt[0]).truncate.to_s, 2) draw_text(118, 0, 20, line_height, "%") end #-------------------------------------------------------------------------- # ● カテゴリ内の収集率計算 #-------------------------------------------------------------------------- def count(ct) max = 0 cnt = 0 data = $game_system.dictionary[ct] data.keys.each do |j| max += 1 cnt += 1 if data[j].show_flg end return [max, cnt] end end #============================================================================== # ■ Window_Dictionary [用語の一覧表項目を表示するウィンドウ] #============================================================================== class Window_Dictionary < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize rect = Dictionary.d_words_rect(fitting_height(1), fitting_height(3)) super(rect.x, rect.y, rect.width, rect.height) self.index = -1 self.active = false @ct_index = -1 @ct_id = nil @word_frame = Dictionary::INFO_TIMEOUT end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max Dictionary.d_words_column end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max @commands ? @commands.size : 0 end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? return false if current_dict.nil? return false if current_dict.name == "" return current_dict.show_flg end #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 #-------------------------------------------------------------------------- def process_handling return unless open? && active return process_ok if ok_enabled? && Input.trigger?(:C) return process_cancel if cancel_enabled? && Input.trigger?(:B) return call_handler(:pagedown) if handle?(:pagedown) && Input.trigger?(:R) return call_handler(:pageup) if handle?(:pageup) && Input.trigger?(:L) 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 = [] $game_system.dictionary[@ct_id].keys.each do |id| data = $game_system.dictionary[@ct_id][id] next if Dictionary::VISIBLE_ONLY and !data.show_flg @commands.push(data) end create_contents refresh end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) data = @commands[index] rect = item_rect(index) rect.x += 4 rect.width -= 8 # 表示許可フラグがONか? if data.show_flg and data.name != "" # 着色情報に従い用語名を表示する change_color(data.txt_color(normal_color)) draw_text(rect, data.name.split(/\\n/)[0]) else # 未許可なので、表示しない change_color(normal_color) draw_text(rect, "-------") 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 super return unless active if Dictionary.d_info_visible # infoが常時表示なら unless Dictionary::INFO_TIMEOUT.nil? or current_dict.nil? if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) @word_frame = Dictionary::INFO_TIMEOUT elsif current_dict.color != 0 @word_frame -= 1 if @word_frame <= 0 ## timeout発生なら概読へ update_dict_color @word_frame = 0 end end end end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.refresh(current_dict, @help_window.page) end end