#============================================================================== # ■ RGSS3 メニューカスタマイズ オプション # 544×416 縦型用ウィンドウ追加 Ver1.00 by 星潟 #------------------------------------------------------------------------------ # 画面サイズ544×416用の縦型向けのウィンドウを追加します。 # 必要に応じて設定値を変更してください。 # ウィンドウ追加の拡張スクリプトは1種類のみ導入してください。 #============================================================================== module MenuCustomizeAddWindow #空のハッシュを準備(変更不要) Window = {} #-------------------------------------------------------------------------- # ウィンドウ設定(変更不要) #-------------------------------------------------------------------------- def self.set(id,value1,value2,value3 = nil,value4 = nil) unless Window[id] Window[id] ||= {} Window[id][:x] = 0 Window[id][:y] = 0 Window[id][:z] = 0 Window[id][:w] = 48 Window[id][:h] = 48 Window[id][:o] = 255 Window[id][:c] = 1 Window[id][:s] = 24 Window[id][:hw] = 60 Window[id][:ew] = 60 Window[id][:lh] = 24 Window[id][:fs] = 24 Window[id][:data] = {} end if value1.is_a?(Symbol) Window[id][value1] = value2 elsif value1.is_a?(Numeric) Window[id][:data][value1] ||= {} if value2 == :icon && value3 Window[id][:data][value1][value2] ||= value3 else if value3 && value4 Window[id][:data][value1][value2] ||= {} Window[id][:data][value1][value2][value3] = value4 end end end end #以下に追加ウィンドウの設定を1つずつ行っていく #共通して、最初の数字が追加ウィンドウ何番目の設定かを示す #設定例1.現在地ウィンドウ set(0,:x,0)#X座標の指定 set(0,:y,Graphics.height - 160)#Y座標の指定 set(0,:z,0)#Z座標の指定 set(0,:w,160)#横幅の指定 set(0,:h,64)#高さの指定 set(0,:o,255)#不透明度の指定 set(0,:c,1)#桁数(横の項目数)を指定 set(0,:s,24)#横方向の項目間のスペースを指定 set(0,:hw,0)#各項目名の描写幅を指定(:headで指定する内容) set(0,:ew,0)#各項目の末尾部分の描写幅を指定(:endで指定する内容) set(0,:lh,20)#1行の高さを指定 set(0,:fs,20)#フォントサイズを指定 #各項目に関する設定 #括弧内2つ目のデータが0なら1つ目、1なら2つ目の項目が対象となる。 set(0,0,:icon,nil)#アイコンデータ設定(nilの場合は描写しない) set(0,0,:head,:d,"")#データ部分設定 set(0,0,:head,:e,false)#データ部分をスクリプト扱いするかを指定 set(0,0,:head,:c,0)#テキストカラー指定 set(0,0,:head,:a,0)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(0,0,:head,:u,false)#内容の更新を常時行うかを指定 set(0,0,:body,:d,"現在地")#データ部分設定 set(0,0,:body,:e,false)#データ部分をスクリプト扱いするかを指定 set(0,0,:body,:c,16)#テキストカラー指定 set(0,0,:body,:a,0)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(0,0,:body,:u,false)#内容の更新を常時行うかを指定 set(0,0,:end,:d,"")#データ部分設定 set(0,0,:end,:e,false)#データ部分をスクリプト扱いするかを指定 set(0,0,:end,:c,0)#テキストカラー指定 set(0,0,:end,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(0,0,:end,:u,false)#内容の更新を常時行うかを指定 set(0,1,:icon,nil)#アイコンデータ設定(nilの場合は描写しない) set(0,1,:head,:d,"")#データ部分設定 set(0,1,:head,:e,false)#データ部分をスクリプト扱いするかを指定 set(0,1,:head,:c,0)#テキストカラー指定 set(0,1,:head,:a,0)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(0,1,:head,:u,false)#内容の更新を常時行うかを指定 set(0,1,:body,:d,"$game_map.display_name")#データ部分設定 set(0,1,:body,:e,true)#データ部分をスクリプト扱いするかを指定 set(0,1,:body,:c,0)#テキストカラー指定 set(0,1,:body,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(0,1,:body,:u,false)#内容の更新を常時行うかを指定 set(0,1,:end,:d,"")#データ部分設定 set(0,1,:end,:e,false)#データ部分をスクリプト扱いするかを指定 set(0,1,:end,:c,0)#テキストカラー指定 set(0,1,:end,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(0,1,:end,:u,false)#内容の更新を常時行うかを指定 #設定例2.プレイ時間ウィンドウ set(1,:x,0)#X座標の指定 set(1,:y,Graphics.height - 96)#Y座標の指定 set(1,:z,0)#Z座標の指定 set(1,:w,160)#横幅の指定 set(1,:h,48)#高さの指定 set(1,:o,255)#不透明度の指定 set(1,:c,1)#桁数(横の項目数)を指定 set(1,:s,24)#横方向の項目間のスペースを指定 set(1,:hw,0)#各項目名の描写幅を指定(:headで指定する内容) set(1,:ew,0)#各項目の末尾部分の描写幅を指定(:endで指定する内容) set(1,:lh,24)#1行の高さを指定 set(1,:fs,24)#フォントサイズを指定 #各項目に関する設定 #括弧内2つ目のデータが0なら1つ目、1なら2つ目の項目が対象となる。 set(1,0,:icon,280)#アイコンデータ設定(nilの場合は描写しない) set(1,0,:head,:d,"")#データ部分設定 set(1,0,:head,:e,false)#データ部分をスクリプト扱いするかを指定 set(1,0,:head,:c,0)#テキストカラー指定 set(1,0,:head,:a,0)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(1,0,:head,:u,false)#内容の更新を常時行うかを指定 set(1,0,:body,:d,"$game_system.playtime_s")#データ部分設定 set(1,0,:body,:e,true)#データ部分をスクリプト扱いするかを指定 set(1,0,:body,:c,0)#テキストカラー指定 set(1,0,:body,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(1,0,:body,:u,true)#内容の更新を常時行うかを指定 set(1,0,:end,:d,"")#データ部分設定 set(1,0,:end,:e,false)#データ部分をスクリプト扱いするかを指定 set(1,0,:end,:c,0)#テキストカラー指定 set(1,0,:end,:a,0)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(1,0,:end,:u,false)#内容の更新を常時行うかを指定 #設定例3.変数ウィンドウ set(2,:x,0)#X座標の指定 set(2,:y,192)#Y座標の指定 set(2,:z,0)#Z座標の指定 set(2,:w,160)#横幅の指定 set(2,:h,64)#高さの指定 set(2,:o,255)#不透明度の指定 set(2,:c,1)#桁数(横の項目数)を指定 set(2,:s,24)#横方向の項目間のスペースを指定 set(2,:hw,60)#各項目名の描写幅を指定(:headで指定する内容) set(2,:ew,0)#各項目の末尾部分の描写幅を指定(:endで指定する内容) set(2,:lh,20)#1行の高さを指定 set(2,:fs,20)#フォントサイズを指定 #各項目に関する設定 #括弧内2つ目のデータが0なら1つ目、1なら2つ目の項目が対象となる。 set(2,0,:icon,nil)#アイコンデータ設定(nilの場合は描写しない) set(2,0,:head,:d,"変数1")#データ部分設定 set(2,0,:head,:e,false)#データ部分をスクリプト扱いするかを指定 set(2,0,:head,:c,16)#テキストカラー指定 set(2,0,:head,:a,0)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(2,0,:head,:u,false)#内容の更新を常時行うかを指定 set(2,0,:body,:d,"$game_variables[1]")#データ部分設定 set(2,0,:body,:e,true)#データ部分をスクリプト扱いするかを指定 set(2,0,:body,:c,0)#テキストカラー指定 set(2,0,:body,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(2,0,:body,:u,true)#内容の更新を常時行うかを指定 set(2,0,:end,:d,"")#データ部分設定 set(2,0,:end,:e,false)#データ部分をスクリプト扱いするかを指定 set(2,0,:end,:c,0)#テキストカラー指定 set(2,0,:end,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(2,0,:end,:u,false)#内容の更新を常時行うかを指定 set(2,1,:icon,nil)#アイコンデータ設定(nilの場合は描写しない) set(2,1,:head,:d,"変数2")#データ部分設定 set(2,1,:head,:e,false)#データ部分をスクリプト扱いするかを指定 set(2,1,:head,:c,16)#テキストカラー指定 set(2,1,:head,:a,0)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(2,1,:head,:u,false)#内容の更新を常時行うかを指定 set(2,1,:body,:d,"$game_variables[2]")#データ部分設定 set(2,1,:body,:e,true)#データ部分をスクリプト扱いするかを指定 set(2,1,:body,:c,0)#テキストカラー指定 set(2,1,:body,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(2,1,:body,:u,true)#内容の更新を常時行うかを指定 set(2,1,:end,:d,"")#データ部分設定 set(2,1,:end,:e,false)#データ部分をスクリプト扱いするかを指定 set(2,1,:end,:c,0)#テキストカラー指定 set(2,1,:end,:a,2)#左寄り(0)か中央寄り(1)か右寄り(2)かを指定 set(2,1,:end,:u,false)#内容の更新を常時行うかを指定 end class Window_MenuCustomizeDummy < Window_Base #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- alias initialize_menu_customize_add_windows initialize def initialize(command_window,status_window) initialize_menu_customize_add_windows(command_window,status_window) create_menu_customize_add_windows end #-------------------------------------------------------------------------- # 更新 #-------------------------------------------------------------------------- alias update_menu_customize_add_windows update def update update_menu_customize_add_windows @add_windows.each.each {|window| window.update} end #-------------------------------------------------------------------------- # 解放 #-------------------------------------------------------------------------- alias dispose_menu_customize_add_windows dispose def dispose @add_windows.each {|window| window.dispose} @add_windows.clear dispose_menu_customize_add_windows end #-------------------------------------------------------------------------- # ウィンドウの作成 #-------------------------------------------------------------------------- def create_menu_customize_add_windows @add_windows = [] MenuCustomizeAddWindow::Window.keys.each_with_index {|k,i| hash = MenuCustomizeAddWindow::Window[k] w = Window_MenuCustomizeAdd.new(hash) @add_windows.push(w)} end end class Window_MenuCustomizeAdd < Window_Base #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize(hash) super(hash[:x],hash[:y],hash[:w],hash[:h]) self.z = hash[:z] self.opacity = hash[:o] self.viewport = self.viewport contents.font.size = hash[:fs] @data = hash[:data] @item_rect_data = [] c = hash[:c] ? hash[:c] : 1 s = hash[:s] ? hash[:s] : 32 iw = contents_width - s * (c - 1) iw = 0 if iw < 0 iw /= c hw = hash[:hw] ? hash[:hw] : 0 tw = hash[:ew] ? hash[:ew] : 0 lh = hash[:lh] ? hash[:lh] : line_height ks = hash[:data].keys ks.sort! ks.each_with_index {|i,di| dh = hash[:data][i] ih = {} iwn = iw xbb = (di % c) * (iw + s) xb = xbb yb = di / c * lh di = dh[:icon] if di && iwn >= 24 ih[:icon] = Rect.new(xb,yb,24,24) xb += 24 iwn -= 24 end head = dh[:head] if head ih[:head] = Rect.new(xb,yb,hw,lh) xb += hw iwn -= hw end endd = dh[:end] if endd ih[:end] = Rect.new(xbb + iw - tw,yb,tw,lh) iwn -= tw end body = dh[:body] if body ih[:body] = Rect.new(xb,yb,iwn,lh) end @item_rect_data.push(ih)} refresh(true) end #-------------------------------------------------------------------------- # 更新 #-------------------------------------------------------------------------- def update super refresh(false) end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh(forcing = true) @last_data = {} if forcing ks = @data.keys ks.sort! ks.each_with_index {|i,di| dh = @data[i] ih = @item_rect_data[di] r = ih[:icon] if r icon_index = dh[:icon] if forcing or @last_data[:icon] != icon_index @last_data[:icon] = icon_index contents.clear_rect(r) draw_icon(icon_index,r.x,r.y) end end r = ih[:head] if r head = dh[:head] data = (head[:e] && head[:d].is_a?(String)) ? eval(head[:d]) : head[:d] if forcing or (head[:u] && @last_data[:head] != data) @last_data[:head] = data contents.clear_rect(r) change_color(head[:c] ? text_color(head[:c]) : normal_color) draw_text(r,data,head[:a] ? head[:a] : 0) end end r = ih[:body] if r body = dh[:body] data = (body[:e] && body[:d].is_a?(String)) ? eval(body[:d]) : body[:d] if forcing or (body[:u] && @last_data[:body] != data) @last_data[:body] = data contents.clear_rect(r) change_color(body[:c] ? text_color(body[:c]) : normal_color) draw_text(r,data,body[:a] ? body[:a] : 2) end end r = ih[:end] if r endd = dh[:end] data = (endd[:e] && endd[:d].is_a?(String)) ? eval(endd[:d]) : endd[:d] if forcing or (endd[:u] && @last_data[:end] != data) @last_data[:end] = data contents.clear_rect(r) change_color(endd[:c] ? text_color(endd[:c]) : normal_color) draw_text(r,data,endd[:a] ? endd[:a] : 2) end end} end end