CODE
#_______________________________________________________________________________
# MOG Main Menu V2.0
#_______________________________________________________________________________
# By Moghunter
# http://www.atelier-rgss.com
#_______________________________________________________________________________
module MOG
#Tipo de fundo.
# 0 = Imagens em movimento.
# 1 = Mapa de fundo.
MENU_BACKGROUND = 0
#Transition Time.
MNTT = 10
#Transition Type (Name)
MNTP = "006-Stripe02"
#Velocidade do cursor
CURSOR_SPEED = 15
end
#===============================================================================
# Game_Actor
#===============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# Now Exp
#--------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end
#--------------------------------------------------------------------------
# Next Exp
#--------------------------------------------------------------------------
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
#===============================================================================
# Game_Map
#===============================================================================
class Game_Map
attr_reader :map_id
#--------------------------------------------------------------------------
# Mpname
#--------------------------------------------------------------------------
def mpname
$mpname = load_data("Data/MapInfos.rxdata")
$mpname[@map_id].name
end
end
#===============================================================================
# Window Base
#===============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# Nada
#--------------------------------------------------------------------------
def nada
face = RPG::Cache.picture("")
end
#--------------------------------------------------------------------------
# Drw_Face
#--------------------------------------------------------------------------
def drw_face(actor,x,y)
face = RPG::Cache.picture(actor.name + "_fc") rescue nada
cw = face.width
ch = face.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 20 , y - ch, face, src_rect)
end
#--------------------------------------------------------------------------
# draw name
#--------------------------------------------------------------------------
def draw_name(actor, x, y)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x, y, 48, 32, actor.name, 2)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(x, y, 48, 32, actor.name, 2)
end
#--------------------------------------------------------------------------
# Draw Maphp3
#--------------------------------------------------------------------------
def draw_maphp3(actor, x, y)
back = RPG::Cache.picture("BAR0")
cw = back.width
ch = back.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 65, y - ch + 30, back, src_rect)
meter = RPG::Cache.picture("HP_Bar")
cw = meter.width * actor.hp / actor.maxhp
ch = meter.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 65, y - ch + 30, meter, src_rect)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x + 81, y - 1, 48, 32, actor.hp.to_s, 2)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(x + 80, y - 2, 48, 32, actor.hp.to_s, 2)
end
#--------------------------------------------------------------------------
# draw_mexp2
#--------------------------------------------------------------------------
def draw_mexp2(actor, x, y)
bitmap2 = RPG::Cache.picture("Exp_Back")
cw = bitmap2.width
ch = bitmap2.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 60 , y - ch + 30, bitmap2, src_rect)
if actor.next_exp != 0
rate = actor.now_exp.to_f / actor.next_exp
else
rate = 1
end
bitmap = RPG::Cache.picture("Exp_Meter")
if actor.level < 99
cw = bitmap.width * rate
else
cw = bitmap.width
end
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 60 , y - ch + 30, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# draw_lvl
#--------------------------------------------------------------------------
def draw_lvl(actor, x, y)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x + 161, y + 7, 24, 32, actor.level.to_s, 1)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(x + 160, y + 6, 24, 32, actor.level.to_s, 1)
end
end
#===============================================================================
# Window MenuStatus2
#===============================================================================
class Window_MenuStatus2 < Window_Selectable
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 415, 290)
self.contents = Bitmap.new(width - 32, height - 32)
self.windowskin = RPG::Cache.windowskin("")
self.opacity = 0
self.z = 15
refresh
self.active = false
self.index = -1
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = i * 136
y = 30
actor = $game_party.actors[i]
self.contents.font.name = "Georgia"
if $mog_rgss_TP_System != nil
draw_actor_tp(actor ,x - 150,y + 75,4)
else
nil
end
draw_name(actor,x + 10,y - 35)
drw_face(actor,x - 13,y + 100)
draw_lvl(actor,x - 90,y + 115)
draw_maphp3(actor,x- 32, y + 145)
draw_mexp2(actor,x - 40, y + 175 )
end
end
#--------------------------------------------------------------------------
# Update_cursor_rect
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(5, @index * 26, self.width - 10, 40)
end
end
end
#===============================================================================
# Window_Gold 2
#===============================================================================
class Window_Gold2 < Window_Base
#--------------------------------------------------------------------------
# Initiazlize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.windowskin = RPG::Cache.windowskin("")
self.opacity = 0
self.z = 15
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#===============================================================================
# Window_PlayTime 2
#===============================================================================
class Window_PlayTime2 < Window_Base
#--------------------------------------------------------------------------
# Initiazlize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.windowskin = RPG::Cache.windowskin("")
self.opacity = 0
self.z = 15
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#===============================================================================
# Window_Map_Name
#===============================================================================
class Window_Map_Name < Window_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.windowskin = RPG::Cache.windowskin("")
self.opacity = 0
self.z = 15
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_map.mpname.to_s, 1)
end
end
#===============================================================================
# Scene Menu
#===============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# Main
#--------------------------------------------------------------------------
def main
s1 = ""
s2 = ""
s3 = ""
s4 = ""
s5 = ""
s6 = ""
s7 = ""
@command_window = Window_Command.new(60, [s1, s2, s3, s4, s5, s6, s7])
@command_window.index = @menu_index
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
@command_window.visible = false
@command_window.x = -640
@mnlay = Sprite.new
@mnlay.bitmap = RPG::Cache.picture("Mn_lay")
@mnlay.z = 10
@mnlay.opacity = 0
@mnlay.x = -100
if MOG::MENU_BACKGROUND == 0
@mnback = Plane.new
@mnback.bitmap = RPG::Cache.picture("Mn_back")
@mnback.blend_type = 0
@mnback.z = 5
@mnback2 = Plane.new
@mnback2.bitmap = RPG::Cache.picture("Mn_back")
@mnback2.blend_type = 0
@mnback2.z = 5
@mnback2.opacity = 60
else
@spriteset = Spriteset_Map.new
end
@cursor_x = -20
@cursor_y = 20
@mnsel = Sprite.new
@mnsel.bitmap = RPG::Cache.picture("Mn_Sel")
@mnsel.z = 20
@mnsel.x = @cursor_x
@mnsel.y = @cursor_y
@mnop = 150
if $game_system.save_disabled
@command_window.disable_item(4)
end
@playtime_window = Window_PlayTime2.new
@playtime_window.x = 10
@playtime_window.y = 395
@playtime_window.contents_opacity = 0
@mapname_window = Window_Map_Name.new
@mapname_window.x = 505
@mapname_window.y = 0
@mapname_window.contents_opacity = 0
@gold_window = Window_Gold2.new
@gold_window.x = 15
@gold_window.y = 375
@gold_window.contents_opacity = 0
@status_window = Window_MenuStatus2.new
@status_window.x = 280
@status_window.y = 80
@status_window.contents_opacity = 0
if MOG::MENU_BACKGROUND == 0
Graphics.transition(MOG::MNTT, "Graphics/Transitions/" + MOG::MNTP)
else
Graphics.transition
end
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
for i in 0..10
if MOG::MENU_BACKGROUND == 0
@mnback.oy += 1
@mnback.ox += 1
@mnback2.oy += 1
@mnback2.ox -= 1
end
@status_window.x += 10
@status_window.contents_opacity -= 25
@mnsel.opacity -= 25
@mnsel.zoom_x += 0.03
@mnlay.x -= 10
@mnlay.opacity -= 25
@mapname_window.x += 5
@mapname_window.contents_opacity -= 20
@gold_window.contents_opacity -= 25
@playtime_window.contents_opacity -= 25
Graphics.update
end
Graphics.freeze
@command_window.dispose
@playtime_window.dispose
@gold_window.dispose
@status_window.dispose
@mnlay.dispose
if MOG::MENU_BACKGROUND == 0
@mnback.dispose
@mnback2.dispose
else
@spriteset.dispose
end
@mnsel.dispose
@mapname_window.dispose
Graphics.update
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
cursor_update
cursor_animation_update
windows_slide_update
@playtime_window.update
if @command_window.active
@command_window.update
update_command
return
end
if @status_window.active
@status_window.update
update_status
return
end
end
#--------------------------------------------------------------------------
# Windows_slide_update
#--------------------------------------------------------------------------
def windows_slide_update
if MOG::MENU_BACKGROUND == 0
@mnback.oy += 1
@mnback.ox += 1
@mnback2.oy += 1
@mnback2.ox -= 1
end
@mapname_window.contents_opacity += 15
@playtime_window.contents_opacity += 15
@gold_window.contents_opacity += 15
@playtime_window.contents_opacity += 15
if @status_window.x > 165
@status_window.x -= 10
@status_window.contents_opacity += 10
elsif @status_window.x <= 165
@status_window.x = 165
@status_window.contents_opacity = 255
end
end
#--------------------------------------------------------------------------
# Cursor_update
#--------------------------------------------------------------------------
def cursor_update
if @mnsel.x > @cursor_x
@mnsel.x -= MOG::CURSOR_SPEED
if @mnsel.x <= @cursor_x
@mnsel.x = @cursor_x
end
elsif @mnsel.x < @cursor_x
@mnsel.x += MOG::CURSOR_SPEED
if @mnsel.x >= @cursor_x
@mnsel.x = @cursor_x
end
end
if @mnsel.y > @cursor_y
@mnsel.y -= MOG::CURSOR_SPEED
if @mnsel.y <= @cursor_y
@mnsel.y = @cursor_y
end
elsif @mnsel.y < @cursor_y
@mnsel.y += MOG::CURSOR_SPEED
if @mnsel.y >= @cursor_y
@mnsel.y = @cursor_y
end
end
end
#--------------------------------------------------------------------------
# Cursor_Animation
#--------------------------------------------------------------------------
def cursor_animation_update
if @mnsel.zoom_x <= 1.6
@mnsel.zoom_x += 0.03
@mnsel.opacity -= 10
elsif @mnsel.zoom_x > 1.6
@mnsel.zoom_x = 1.0
@mnsel.opacity = 255
end
if @mnlay.x < 0
@mnlay.opacity += 25
@mnlay.x += 10
elsif @mnlay.x >= 0
@mnlay.opacity = 255
@mnlay.x = 0
end
@mnop += 5
@mnop = 120 if @mnop >= 255
end
#--------------------------------------------------------------------------
# Update Command
#--------------------------------------------------------------------------
def update_command
cursor_position_update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 5
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
when 6
$game_system.se_play($data_system.decision_se)
$scene = Scene_Journal.new
end
return
end
end
#--------------------------------------------------------------------------
# cursor_position_update
#--------------------------------------------------------------------------
def cursor_position_update
case @command_window.index
when 0
@cursor_x = 0
@cursor_y = 90
when 1
@cursor_x = 0
@cursor_y = 120
when 2
@cursor_x = 0
@cursor_y = 150
when 3
@cursor_x = 0
@cursor_y = 180
when 4
@cursor_x = 0
@cursor_y = 210
when 5
@cursor_x = 0
@cursor_y = 240
when 6
@cursor_x=0
@cursor_y=270
end
end
#--------------------------------------------------------------------------
# Cursor_st_postion_update
#--------------------------------------------------------------------------
def cursor_st_postion_update
case @status_window.index
when 0
@cursor_x = 180
@cursor_y = 170
when 1
@cursor_x = 315
@cursor_y = 170
when 2
@cursor_x = 450
@cursor_y = 170
when 3
@cursor_x = 500
@cursor_y = 170
end
end
#--------------------------------------------------------------------------
# Update Status
#--------------------------------------------------------------------------
def update_status
cursor_st_postion_update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 1
if $game_party.actors[@status_window.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@status_window.index)
when 2
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@status_window.index)
when 3
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
$mog_rgss_Main_Menu = true