cloud read
Member
ok I'm using the Pokemon Starter Kit and need help with the Main Menu. I have the Press start working but after that the menu box is empty. Please help me.
#==============================================================================
# â– Window_Base
#------------------------------------------------------------------------------
#  ゲームä¸ã®ã™ã¹ã¦ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®ã‚¹ãƒ¼ãƒ‘ークラスã§ã™ã€‚
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ◠オブジェクトåˆæœŸåŒ–
# x : ウィンドウ㮠X 座標
# y : ウィンドウ㮠Y 座標
# width : ウィンドウã®å¹…
# height : ウィンドウã®é«˜ã•
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super()
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
self.x = x
self.y = y
self.width = width
self.height = height
self.z = 100
end
#--------------------------------------------------------------------------
# ◠解放
#--------------------------------------------------------------------------
def dispose
# ウィンドウ内容ã®ãƒ“ットマップãŒè¨å®šã•ã‚Œã¦ã„ã‚Œã°è§£æ”¾
if self.contents != nil
self.contents.dispose
end
super
end
#--------------------------------------------------------------------------
# â— æ–‡å—色å–å¾—
# n : æ–‡å—è‰²ç•ªå· (0~7)
#--------------------------------------------------------------------------
def text_color(n)
case n
when 0
return Color.new(255, 255, 255, 255)
when 1
return Color.new(128, 128, 255, 255)
when 2
return Color.new(255, 128, 128, 255)
when 3
return Color.new(128, 255, 128, 255)
when 4
return Color.new(128, 255, 255, 255)
when 5
return Color.new(255, 128, 255, 255)
when 6
return Color.new(255, 255, 128, 255)
when 7
return Color.new(192, 192, 192, 255)
else
normal_color
end
end
#--------------------------------------------------------------------------
# ◠通常文å—色ã®å–å¾—
#--------------------------------------------------------------------------
def normal_color
return Color.new(255, 255, 255, 255)
end
#--------------------------------------------------------------------------
# ◠無効文å—色ã®å–å¾—
#--------------------------------------------------------------------------
def disabled_color
return Color.new(255, 255, 255, 128)
end
#--------------------------------------------------------------------------
# ◠システム文å—色ã®å–å¾—
#--------------------------------------------------------------------------
def system_color
return Color.new(192, 224, 255, 255)
end
#--------------------------------------------------------------------------
# ◠ピンãƒæ–‡å—色ã®å–å¾—
#--------------------------------------------------------------------------
def crisis_color
return Color.new(255, 255, 64, 255)
end
#--------------------------------------------------------------------------
# ◠戦闘ä¸èƒ½æ–‡å—色ã®å–å¾—
#--------------------------------------------------------------------------
def knockout_color
return Color.new(255, 64, 0)
end
#--------------------------------------------------------------------------
# ◠フレーム更新
#--------------------------------------------------------------------------
def update
#super
# ウィンドウスã‚ンãŒå¤‰æ›´ã•ã‚ŒãŸå ´åˆã€å†è¨å®š
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
end
#--------------------------------------------------------------------------
# ◠グラフィックã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# â— åå‰ã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y, state=false)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 120, 32, actor.name,align=0, state)
end
#--------------------------------------------------------------------------
# ◠クラスã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_class(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 236, 32, actor.class_name)
end
#--------------------------------------------------------------------------
# ◠レベルã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_level(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, "Lv")
self.contents.font.color = normal_color
self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
end
#--------------------------------------------------------------------------
# â— æ画用ã®ã‚¹ãƒ†ãƒ¼ãƒˆæ–‡å—列作æˆ
# actor : アクター
# width : æ画先ã®å¹…
# need_normal : [æ£å¸¸] ãŒå¿…è¦ã‹ã©ã†ã‹ (true / false)
#--------------------------------------------------------------------------
def make_battler_state_text(battler, width, need_normal)
# 括弧ã®å¹…ã‚’å–å¾—
brackets_width = self.contents.text_size("[]").width
# ステートåã®æ–‡å—列を作æˆ
text = ""
for i in battler.states
if $data_states[i].rating >= 1
if text == ""
text = $data_states[i].name
else
new_text = text + "/" + $data_states[i].name
text_width = self.contents.text_size(new_text).width
if text_width > width - brackets_width
break
end
text = new_text
end
end
end
# ステートåã®æ–‡å—列ãŒç©ºã®å ´åˆã¯ "[æ£å¸¸]" ã«ã™ã‚‹
if text == ""
if need_normal
text = "[Normal]"
end
else
# 括弧をã¤ã‘ã‚‹
text = "[" + text + "]"
end
# 完æˆã—ãŸæ–‡å—列を返ã™
return text
end
#--------------------------------------------------------------------------
# ◠ステートã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
# width : æ画先ã®å¹…
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 120)
text = make_battler_state_text(actor, width, true)
self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
self.contents.draw_text(x, y, width, 32, text)
end
#--------------------------------------------------------------------------
# â— EXP ã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_exp(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 24, 32, "E")
self.contents.font.color = normal_color
self.contents.draw_text(x + 24, y, 84, 32, actor.exp_s, 2)
self.contents.draw_text(x + 108, y, 12, 32, "/", 1)
self.contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)
end
#--------------------------------------------------------------------------
# â— HP ã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
# width : æ画先ã®å¹…
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 144)
# æ–‡å—列 "HP" ã‚’æç”»
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
# MaxHP ã‚’æç”»ã™ã‚‹ã‚¹ãƒšãƒ¼ã‚¹ãŒã‚ã‚‹ã‹è¨ˆç®—
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
# HP ã‚’æç”»
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
# MaxHP ã‚’æç”»
if flag
self.contents.font.color = normal_color
self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
end
end
#--------------------------------------------------------------------------
# â— SP ã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
# width : æ画先ã®å¹…
#--------------------------------------------------------------------------
def draw_actor_sp(actor, x, y, width = 144)
# æ–‡å—列 "SP" ã‚’æç”»
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
# MaxSP ã‚’æç”»ã™ã‚‹ã‚¹ãƒšãƒ¼ã‚¹ãŒã‚ã‚‹ã‹è¨ˆç®—
if width - 32 >= 108
sp_x = x + width - 108
flag = true
elsif width - 32 >= 48
sp_x = x + width - 48
flag = false
end
# SP ã‚’æç”»
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
# MaxSP ã‚’æç”»
if flag
self.contents.font.color = normal_color
self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
end
end
#--------------------------------------------------------------------------
# ◠パラメータã®æç”»
# actor : アクター
# x : æ画先 X 座標
# y : æ画先 Y 座標
# type : パラメータã®ç¨®é¡ž (0~6)
#--------------------------------------------------------------------------
def draw_actor_parameter(actor, x, y, type)
case type
when 0
parameter_name = $data_system.words.atk
parameter_value = actor.atk
when 1
parameter_name = $data_system.words.pdef
parameter_value = actor.pdef
when 2
parameter_name = $data_system.words.mdef
parameter_value = actor.mdef
when 3
parameter_name = $data_system.words.str
parameter_value = actor.str
when 4
parameter_name = $data_system.words.dex
parameter_value = actor.dex
when 5
parameter_name = $data_system.words.agi
parameter_value = actor.agi
when 6
parameter_name = $data_system.words.int
parameter_value = actor.int
end
self.contents.font.color = system_color
parameter_name = ""
self.contents.draw_text(x, y, 120, 32, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
end
#--------------------------------------------------------------------------
# ◠アイテムåã®æç”»
# item : アイテãƒ
# x : æ画先 X 座標
# y : æ画先 Y 座標
#--------------------------------------------------------------------------
def draw_item_name(item, x, y)
return if item == nil
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
#define enemy bar
def draw_enemy_hp_meter(enemy, x, y, width = 96, pos = 7)
if enemy.hp == 0
self.contents.fill_rect(x, y, enemy.hp,8, Color.new(0, 0, 0, 255))
end
bitmap=RPG::Cache.picture("limit_gradient")
cw=bitmap.width
ch=bitmap.height
src_rect=Rect.new(0,0,cw,ch)
dest_rect=Rect.new(88,50,width * enemy.hp / enemy.maxhp,6)
self.contents.stretch_blt(dest_rect,bitmap,src_rect)
self.contents.font.color = enemy.hp == 0 ? knockout_color :
enemy.hp <= enemy.maxhp / 4 ? crisis_color : normal_color
self.contents.font.size = 24
self.contents.draw_text( x + 135, y + 20, 48, 32, enemy.hp.to_s + "/" + enemy.maxhp.to_s, 2)
end
def draw_enemy_name(enemy, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 280, 65, enemy.name)
end
end
#==============================================================================
# â– Window_SaveFile
#------------------------------------------------------------------------------
#  This window shows the status of an individual save file within the
# Save or Load scenes.
#==============================================================================
class Window_SaveFile < Window_Base
# -------------------
def initialize(file_index, filename, position)
y = 24 + position * 800
super(24, y, 186, 140)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
self.windowskin = RPG::Cache.windowskin("pokesys")
self.z = 99999
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end
#-------------------------------------------------------------
# â— Draw the contents of the Save File window
#--------------------------------------------------------------------------
def refresh
self.contents.clear
#begin setup
x = 0
y = 4
w = 200
h = 32
self.contents.font.color = normal_color
# draw location
$location = "Beginners Town"
self.contents.draw_text(x,y,w,h, $pkmn.location)
# draw actor name
self.contents.draw_text(x,y+24,w,h,"Player ")
self.contents.draw_text(x+18,y+24,w,h, $pkmn.trainername,2)
# draw no. of badges
self.contents.draw_text(x,y+48,w,h, "Badges")
self.contents.draw_text(x+128,y+48,w,h, $pkmn.badges_size.to_s)
#end of setup
end
#--------------------------------------------------------------------------
# â— Set the value of the @selected instance variable to the
# value passed to this method, and then calls the update_cursor_rect
# method to reflect this change.
# selected : New value of the @selected instance variable
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
end
end
#==============================================================================
# â– Window_Message
#------------------------------------------------------------------------------
# ã€€æ–‡ç« è¡¨ç¤ºã«ä½¿ã†ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã§ã™ã€‚
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ◠オブジェクトåˆæœŸåŒ–
#--------------------------------------------------------------------------
def initialize
super(80, 304, 480, 160)
self.contents = Bitmap.new(width, height)
self.visible = false
self.z = 9998
@fade_in = false
@fade_out = false
@contents_showing = false
@cursor_width = 0
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ◠解放
#--------------------------------------------------------------------------
def dispose
terminate_message
$game_temp.message_window_showing = false
if @input_number_window != nil
@input_number_window.dispose
end
super
end
#--------------------------------------------------------------------------
# ◠メッセージ終了処ç†
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
self.contents.clear
# 表示ä¸ãƒ•ãƒ©ã‚°ã‚’クリア
@contents_showing = false
# メッセージ コールãƒãƒƒã‚¯ã‚’呼ã¶
if $game_temp.message_proc != nil
$game_temp.message_proc.call
end
# æ–‡ç« ã€é¸æŠžè‚¢ã€æ•°å€¤å…¥åŠ›ã«é–¢ã™ã‚‹å¤‰æ•°ã‚’クリア
$game_temp.message_text = nil
$game_temp.message_proc = nil
$game_temp.choice_start = 99
$game_temp.choice_max = 0
$game_temp.choice_cancel_type = 0
$game_temp.choice_proc = nil
$game_temp.num_input_start = 99
$game_temp.num_input_variable_id = 0
$game_temp.num_input_digits_max = 0
# ゴールドウィンドウを開放
if @gold_window != nil
@gold_window.dispose
@gold_window = nil
end
end
#--------------------------------------------------------------------------
# ◠リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
x = y = 0
@cursor_width = 0
# é¸æŠžè‚¢ãªã‚‰å—下ã’ã‚’è¡Œã†
if $game_temp.choice_start == 0
x = 8
end
# 表示待ã¡ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãŒã‚ã‚‹å ´åˆ
if $game_temp.message_text != nil
text = $game_temp.message_text
# 制御文å—処ç†
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 便宜上ã€"\\\\" ã‚’ "\000" ã«å¤‰æ›
text.gsub!(/\\\\/) { "\000" }
# "\\C" ã‚’ "\001" ã«ã€"\\G" ã‚’ "\002" ã«å¤‰æ›
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\002" }
# c ã« 1 æ–‡å—ã‚’å–å¾— (æ–‡å—ãŒå–å¾—ã§ããªããªã‚‹ã¾ã§ãƒ«ãƒ¼ãƒ—)
while ((c = text.slice!(/./m)) != nil)
# \\ ã®å ´åˆ
if c == "\000"
# 本æ¥ã®æ–‡å—ã«æˆ»ã™
c = "\\"
end
# \C[n] ã®å ´åˆ
if c == "\001"
# æ–‡å—色を変更
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
# 次ã®æ–‡å—ã¸
next
end
# \G ã®å ´åˆ
if c == "\002"
# ゴールドウィンドウを作æˆ
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
# 次ã®æ–‡å—ã¸
next
end
# 改行文å—ã®å ´åˆ
if c == "\n"
# é¸æŠžè‚¢ãªã‚‰ã‚«ãƒ¼ã‚½ãƒ«ã®å¹…ã‚’æ›´æ–°
if y >= $game_temp.choice_start
@cursor_width = [@cursor_width, x].max
end
# y ã« 1 ã‚’åŠ ç®—
y += 1
x = 0
# é¸æŠžè‚¢ãªã‚‰å—下ã’ã‚’è¡Œã†
if y >= $game_temp.choice_start
x = 10
end
# 次ã®æ–‡å—ã¸
next
end
# æ–‡å—ã‚’æç”»
self.contents.draw_text(4 + x, 32 * y - 4, 40, 32, c)
# x ã«æç”»ã—ãŸæ–‡å—ã®å¹…ã‚’åŠ ç®—
x += self.contents.text_size(c).width
end
end
# é¸æŠžè‚¢ã®å ´åˆ
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
# 数値入力ã®å ´åˆ
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + $game_temp.num_input_start * 32
end
end
#--------------------------------------------------------------------------
# method reset_window
#--------------------------------------------------------------------------
def reset_window
if $game_temp.in_battle
self.windowskin = RPG::Cache.windowskin("battleshow")
self.width = 480
self.height = 96
self.y = $height - self.height
self.x = 0
else
self.width = ($width - 32)
self.height = ($height / 4) + 6
self.x = ($width / 2) - (self.width / 2)
self.y = ($height - self.height) - (self.height / 8)
case $game_system.message_position
when 0 # top
self.windowskin = RPG::Cache.windowskin("pokesys")
self.width = 124
self.height = 96
self.x = 16
self.y = 16
when 1 # middle
self.windowskin = RPG::Cache.windowskin("signshow")
self.y = ($height - self.height) - (self.height / 8)
when 2 # bottom
self.windowskin = RPG::Cache.windowskin("speechshow")
self.y = ($height - self.height) - (self.height / 8)
end
end
if $game_system.message_frame == 0
self.opacity = 255
else
self.opacity = 0
end
self.back_opacity = 255
end
#--------------------------------------------------------------------------
# method update
#--------------------------------------------------------------------------
def update
super
# フェードインã®å ´åˆ
if @fade_in
self.contents_opacity += 24
if @input_number_window != nil
@input_number_window.contents_opacity += 24
end
if self.contents_opacity == 255
@fade_in = false
end
return
end
# 数値入力ä¸ã®å ´åˆ
if @input_number_window != nil
@input_number_window.update
# 決定
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_variables[$game_temp.num_input_variable_id] =
@input_number_window.number
$game_map.need_refresh = true
# 数値入力ウィンドウを解放
@input_number_window.dispose
@input_number_window = nil
terminate_message
end
return
end
# メッセージ表示ä¸ã®å ´åˆ
if @contents_showing
# é¸æŠžè‚¢ã®è¡¨ç¤ºä¸ã§ãªã‘ã‚Œã°ãƒãƒ¼ã‚ºã‚µã‚¤ãƒ³ã‚’表示
if $game_temp.choice_max == 0
self.pause = true
end
# ã‚ャンセル
if Input.trigger?(Input::B)
if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
$game_system.se_play($data_system.cancel_se)
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
end
end
# 決定
if Input.trigger?(Input::C)
if $game_temp.choice_max > 0
$game_system.se_play($data_system.decision_se)
$game_temp.choice_proc.call(self.index)
end
terminate_message
end
return
end
# フェードアウトä¸ä»¥å¤–ã§è¡¨ç¤ºå¾…ã¡ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‹é¸æŠžè‚¢ãŒã‚ã‚‹å ´åˆ
if @fade_out == false and $game_temp.message_text != nil
@contents_showing = true
$game_temp.message_window_showing = true
reset_window
refresh
Graphics.frame_reset
self.visible = true
self.contents_opacity = 0
if @input_number_window != nil
@input_number_window.contents_opacity = 0
end
@fade_in = true
return
end
# 表示ã™ã¹ãメッセージãŒãªã„ãŒã€ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ãŒå¯è¦–状態ã®å ´åˆ
if self.visible
@fade_out = true
self.opacity -= 48
if self.opacity == 0
self.visible = false
@fade_out = false
$game_temp.message_window_showing = false
end
return
end
end
#--------------------------------------------------------------------------
# ◠カーソルã®çŸ©å½¢æ›´æ–°
#--------------------------------------------------------------------------
def update_cursor_rect
if @index >= 0
n = $game_temp.choice_start + @index
self.cursor_rect.set(-12, n * 32 - 4, 32, 32)
else
self.cursor_rect.empty
end
end
end