#--------------------------------------------------------------------------- #辞書機能用スクリプトver.1.1 #by bant #--------------------------------------------------------------------------- # バージョン1.0を使っている方は更新して下さい。 # 更新箇所は次の通りです。 # 92行目周辺 用語集用配列に何もない時への対策。 # 179行目 見出しの数を変えた時用の対策。 # 294行目周辺 用語集用配列に何もない時への対策。 # # 用語集などを作成するためのスクリプトです。 # カスタマイズポイントは一切無く、自分で項目を追加していくため、 # やや中級者向けになっています。 # # 参照項目の追加と順番に並べる方法 # イベントスクリプトで # $game_system.dictionary_words += [2] # を実行すると2番の項目が追加されます。その後に # $game_system.dictionary_words.sort! # を実行すると、項目選択のウインドウに番号順に項目が表示されます。 # 条件分岐のスクリプトで # $game_system.dictionary_words.include?(2) == false # とすると項目がなければという条件になります。 # # 項目を順番に並べる必要がない場合は項目番号は文字列でも構いません。 # #============================================================================== # ■ Game_System #------------------------------------------------------------------------------ #  システム周りのデータを扱うクラスです。BGM などの管理も行います。このクラス # のインスタンスは $game_system で参照されます。 #============================================================================== class Game_System #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :dictionary_words # 用語集用配列 attr_reader :dictionary_add # 用語集追加番号用 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_bant_dictionary initialize def initialize initialize_bant_dictionary @dictionary_words = [1,3]#ここに最初から見る事ができる項目の番号を入れます @dictionary_add = [2]#ここに、内容追加用の項目の番号を入れます end end #============================================================================== # ■ Window_Wordselect #------------------------------------------------------------------------------ #  項目を選ぶ時のウインドウです。 # #============================================================================== class Window_Wordselect < Window_Selectable def initialize super(0,64,640,416) @column_max = 2 self.index = 0 self.active = true refresh end def refresh if self.contents != nil self.contents.clear self.contents = nil end word = nil @data = [] for i in 0...$game_system.dictionary_words.size if word != nil word = nil end case $game_system.dictionary_words[i] when 1 #説明用 word = "項目名"#ここに項目の名前を設定します when 2 #説明追加用 #説明を追加するだけならここは何もいりません when 3 #説明用2 word = "長い説明"#この後にwhen 項目番号、、と続ける事で項目を増やします end if word != nil @data.push(word) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end else self.index = -1 end end def draw_item(index) word = @data[index] self.contents.font.color = normal_color x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 self.contents.draw_text(x, y, 274, 32, word, 0) end #------------------------------------------------------------------------- # ☆説明ウインドウのindex用の配列を作成 #------------------------------------------------------------------------- def true_words t_w = $game_system.dictionary_words - $game_system.dictionary_add return t_w end end #============================================================================== # ■ Window_Wordinfo #------------------------------------------------------------------------------ #  説明文を描画するウインドウです。 # #============================================================================== class Window_Wordinfo < Window_Base def initialize(index) super(0,64,640,416) self.active = true @index = index refresh end def refresh midasi = [] data = [] case @index when 1 #説明用。1は配列$game_system.dictionary_wordsに格納されている数字 content = "説明用" read = "せつめいよう" type = "用語" text = "こういう感じで表示されます" text2 = "これだけの長さの文が表示できます。これだけの長さの文が表示できます" text3 = "イベントスクリプト$game_system.dictionary_words += [2]" text4 = "を実行すると文章を追加できます" midasi.push(content,read,type)# ( )の中に表示する見出しを設定する data.push(text,text2,text3,text4)#( )の中に表示する文章を設定する if $game_system.dictionary_words.include?(2)#( )の数字が4行前の2です。 text5 = "追加する文章1" text6 = "追加する文章2" data.push(text5,text6)# ここは4行前と同じ。表示する文章を設定します。 end when 3 #長い説明用 content = "長い説明" read = "ながいせつめい" type = "説明" text = "9行以上になるとスクロールします" text2 = "右で大きく下にスクロールし、" text3 = "左で大きく上にスクロール。" text4 = "上下で一行ずつスクロールします" text5 = "ここから" text6 = "-" text7 = "-" text8 = "-" text9 = "-" text10 = "-" text11 = "-" text12 = "-" text13 = "-" text14 = "-" text15 = "-" text16 = "-" text17 = "ここまで" midasi.push(content,read,type) data.push(text,text2,text3,text4,text5,text6,text7,text8, text9,text10,text11,text12,text13,text14,text15,text16,text17) #この後にwhen 項目番号、、と続ける事で項目を増やします end @lines = midasi.size + data.size self.contents = Bitmap.new(width - 32,@lines * 32 + 32) midasis = ["名前:","読方:","種別:"] for i in 0..2 self.contents.font.color = system_color self.contents.draw_text(0,i * 32,60,32,midasis[i]) self.contents.font.color = normal_color self.contents.draw_text(60,i * 32,540,32,midasi[i]) end for i in 0...data.size y = midasi.size * 32 + i * 32 + 32 self.contents.font.color = normal_color self.contents.draw_text(0,y,640,32,data[i]) end if data.size <= 8 self.pause = true end end #-------------------------------------------------------------------------- # ☆限界Y座標の計算 #-------------------------------------------------------------------------- def oy_max max = @lines * 32 + 32 - 384 return max end #-------------------------------------------------------------------------- # ☆ウインドウの更新 #-------------------------------------------------------------------------- def update super if Input.repeat?(Input::UP) unless self.oy == 0 self.oy -= 32 end end if Input.repeat?(Input::DOWN) unless self.oy >= oy_max self.oy += 32 end end if Input.trigger?(Input::RIGHT) unless self.oy >= oy_max self.oy += 288 end end if Input.trigger?(Input::LEFT) if self.oy == 0 elsif self.oy <= 288 self.oy = 0 else self.oy -= 288 end end end end #============================================================================== # ■ Window_Infohelp #------------------------------------------------------------------------------ #  説明文を描画するウインドウです。 # 絶対必要というわけではありませんが、カスタマイズ用に作っておきました #============================================================================== class Window_Infohelp < Window_Base def initialize super(0, 0, 640, 64) self.contents = Bitmap.new(width - 32,height - 32) end def set_text(index) if index != @index self.contents.clear case index when 1 #用語選択中 text = "用語を選択して下さい" when 2 #説明表示中 text = "キャンセルボタンで戻ります" end self.contents.draw_text(0,0,608,32,text) @index = index end end end #============================================================================== # ■ Scene_Information #------------------------------------------------------------------------------ #  辞書画面のためのシーンクラスです。 # イベントスクリプト$scene = Scene_Information.newを実行すれば辞書に入ります # 拡張しやすいように、updateを条件分岐してあります #============================================================================== class Scene_Information def main @main_help = Window_Infohelp.new @main_help.set_text(1) @word_select = Window_Wordselect.new # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @main_help.dispose @word_select.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # 用語集選択中 if @word_select.active @word_select.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new#辞書を終了した時にどのシーンにはいるかを設定します end if Input.trigger?(Input::C) if @word_select.index == -1 return end $game_system.se_play($data_system.decision_se) Input.update @main_help.set_text(2) @word_info = Window_Wordinfo.new(@word_select.true_words[@word_select.index]) @word_select.visible = false @word_select.active = false end end # 用語説明ウインドウ表示中 if @word_info != nil @word_info.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @word_info.dispose @word_info = nil @word_select.visible = true @word_select.active = true @main_help.set_text(1) end end end end