#============================================================================
# Destiny Of An Emperor Menu Command
# By Lecode
# For sjmorgan
#----------------------------------------------------------------------------
# TERMS OF USE
#----------------------------------------------------------------------------
# -Credit required
#============================================================================
module Lecode
module DoaE_Menu
Magic_Command_Switch = 5
Food_Name = "Food"
Food_Variable = 10
#- Icons (set 0 to disable)
Food_Icon = 163
Money_Icon = 144
Exp_Icon = 0
Strategist_Icon = 97
#- Help textes
CommandHelp_Textes = [
"Change party's formation", #- Formation
"View one actor's informations",#- General
"View or use items", #- Item
"View actors' equipments", #- Equips
"View or use actors' magic", #- Magic
"View or use actors' tactics", #- Tactics
"Select a strategist", #- Strategist
"View party's information", #- Status
]
end
end
if true
class Scene_Menu < Scene_MenuBase
def start
super
create_help_window
create_command_window
create_status_window
create_general_window
create_party_status_window
create_skill_window
create_equip_window
create_item_window
end
def create_help_window
@window_help = Window_Help.new
@window_help.y = Graphics.height - @window_help.height
end
def create_command_window
@command_window = Window_MenuCommand.new
@command_window.help = @window_help
@command_window.set_handler

formation, method

command_formation))
@command_window.set_handler

general, method

command_personal))
@command_window.set_handler

item, method

command_item))
@command_window.set_handler

equip, method

command_personal))
@command_window.set_handler

magic, method

command_personal))
@command_window.set_handler

tactic, method

command_personal))
@command_window.set_handler

strategist, method

command_personal))
@command_window.set_handler

status, method

command_status))
@command_window.set_handler

cancel, method

return_scene))
@command_window.select(0)
end
def create_status_window
@status_window = Window_MenuStatus.new(@command_window.width, 0)
@status_window.help = @window_help
@status_window.close
end
def create_general_window
@general_window = Window_BattleReport.new
@general_window.set_handler

cancel, method

close_general))
@general_window.close
end
def create_party_status_window
@pt_status_window = Window_PartyStatus.new
@pt_status_window.set_handler

cancel, method

close_party_status))
end
def create_skill_window
x = @status_window.x + @status_window.width
@skill_window = Window_MenuSkill.new(x,0)
@skill_window.help = @window_help
@skill_window.close
@skill_window.set_handler

ok, method

on_skill_select))
@skill_window.set_handler

cancel, method

on_skill_cancel))
end
def create_equip_window
end
def create_item_window
end
def command_formation
@status_window.open
@status_window.select_last
@status_window.activate
@status_window.set_handler

ok, method

on_formation_ok))
@status_window.set_handler

cancel, method

on_formation_cancel))
end
def command_item
SceneManager.call(Scene_Item)
end
def command_personal
@status_window.select_last
@status_window.activate
@status_window.set_handler

ok, method

on_personal_ok))
@status_window.set_handler

cancel, method

on_personal_cancel))
@status_window.open
end
def command_status
@pt_status_window.refresh
@pt_status_window.open
@pt_status_window.activate
end
def command_save
SceneManager.call(Scene_Save)
end
def command_game_end
SceneManager.call(Scene_End)
end
def on_skill_cancel
@skill_window.close
@status_window.activate
end
def close_general
@general_window.deactivate
@general_window.close
@command_window.activate
end
def close_party_status
@pt_status_window.deactivate
@pt_status_window.close
@command_window.activate
end
def on_personal_ok
case @command_window.current_symbol
when :strategist
$game_party.strategist = @status_window.actor
@status_window.refresh
@status_window.activate
when :general
@status_window.close
@general_window.open
@general_window.refresh(@status_window.actor)
@general_window.activate
when :tactic
goto_skill_window

tactic)
when :magic
goto_skill_window

magic)
when :equip
SceneManager.call(Scene_Equip)
end
end
def goto_skill_window(type)
@skill_window.type = type
@skill_window.actor = @status_window.actor
@skill_window.refresh
@skill_window.open
@skill_window.activate
@skill_window.select(0)
end
def on_skill_select
skill = @skill_window.item
actor = @skill_window.actor
unless skill_selectable?(skill)
Sound.play_buzzer
return
end
Sound.play_ok
unless skill_need_selection?(skill)
use_item(actor,skill)
return_to_skill
return
end
@status_window.select_last
@status_window.activate
@status_window.set_handler

ok, method

on_skill_ok))
@status_window.set_handler

cancel, method

return_to_skill))
@skill_window.deactivate
end
def return_to_skill
@status_window.set_handler

ok, method

on_personal_ok))
@status_window.set_handler

cancel, method

on_personal_cancel))
actor = @skill_window.actor
@status_window.select(actor.index)
@status_window.deactivate
@skill_window.activate
end
def use_item(actor,skill)
Sound.play_use_item
actor.use_item(skill)
check_common_event
check_gameover
item_target_actors(skill).each do |target|
skill.repeats.times { target.item_apply(actor, skill) }
end
@status_window.refresh
@status_window.activate
@skill_window.refresh
end
def skill_selectable?(skill)
actor = @skill_window.actor
return false if skill.nil?
return false if !skill.for_friend?
return false if !actor.usable?(skill)
return true
end
def skill_need_selection?(skill)
return false if skill.for_all?
return true
end
def check_common_event
SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
end
def on_skill_ok
skill = @skill_window.item
actor = @skill_window.actor
if actor.usable?(skill)
use_item(actor,skill)
else
@status_window.activate
end
end
def item_target_actors(item)
if !item.for_friend?
[]
elsif item.for_all?
$game_party.members
else
[@status_window.actor]
end
end
def on_skill_cancel
@status_window.activate
@skill_window.deactivate
@status_window.set_handler

ok, method

on_personal_ok))
@status_window.set_handler

cancel, method

on_personal_cancel))
@skill_window.deactivate.close
end
def on_personal_cancel
@status_window.unselect
@status_window.close
@command_window.activate
end
def on_formation_ok
if @status_window.pending_index >= 0
$game_party.swap_order(@status_window.index,
@status_window.pending_index)
@status_window.pending_index = -1
@status_window.redraw_item(@status_window.index)
else
@status_window.pending_index = @status_window.index
end
@status_window.refresh
@status_window.activate
end
def on_formation_cancel
if @status_window.pending_index >= 0
@status_window.pending_index = -1
@status_window.activate
else
@status_window.unselect
@status_window.close
@command_window.activate
end
end
end
class Window_MenuCommand
include Lecode:

oaE_Menu
attr_accessor :help
def initialize
super(0, 0)
self.opacity = 0
@header = Header.new(self)
@Help = nil
self.y += line_height
select_last
end
def make_command_list
add_command(Vocab::formation, :formation, formation_enabled)
add_command("General", :general)
add_command(Vocab::item, :item, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command("Magic", :magic, magic_enabled?)
add_command("Tactics", :tactic, main_commands_enabled)
add_command("Strategist", :strategist, main_commands_enabled)
add_command("Status", :status, main_commands_enabled)
end
def magic_enabled?
!$game_switches[Magic_Command_Switch]
end
def update
super
@header.update
@header.visible = self.visible
@header.openness = self.openness
end
def dispose
super
@header.dispose
end
def select(*args)
super(*args)
return if @help.nil?
@help.set_text(CommandHelp_Textes[@index])
end
def activate
super
return if @help.nil?
@help.set_text(CommandHelp_Textes[@index])
end
class Header < Window_Base
def initialize(main)
@main = main
super(@main.x,@main.y,@main.width,window_height)
self.z -= 1
refresh
end
def window_height
fitting_height(9)
end
def refresh
contents.clear
my_draw_text("Command",:center,0,system_color)
end
end
end
class Window_MenuStatus
include Lecode:

oaE_Menu
attr_accessor :help
alias doae_initialize initialize
def initialize(*args)
@Help = nil
doae_initialize(*args)
self.openness = 0
end
def window_width
180
end
def window_height
fitting_height(9)
end
def item_max
$game_party.members.size
end
def item_height
line_height
end
def actor
$game_party.members[@index]
end
def select(*args)
super(*args)
@help.set_text(actor_text) unless @help.nil?
end
def activate
super
@help.set_text(actor_text) unless @help.nil?
end
def actor_text
text = "#{actor.name} - #{actor.hp} / #{actor.mhp}"
return text if actor.states.empty?
text += "\nStates: "
actor.states.each { |s|
text += s.name
text += s == actor.states.last ? "" : ", "
}
return text
end
def draw_item(index)
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
draw_graphic(actor, rect.x+12, rect.y+32)
rect_ = my_draw_text(actor.name,rect.x+24,rect.y,hp_color(actor))
x = rect.x + 24 + rect_.width + 2
y = rect.y
draw_icon(Strategist_Icon,x,y) if actor == $game_party.strategist
end
def draw_graphic(actor, x, y)
character_name = actor.character_name
character_index = actor.character_index
return unless character_name
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
src_rect.height -= 9
contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
class Window_BaseMenuStatus < Window_Selectable
attr_reader

ending_index
def initialize(x, y)
super(x, y, window_width, window_height)
@pending_index = -1
refresh
end
def window_width
Graphics.width - 160
end
def window_height
Graphics.height
end
def item_max
$game_party.members.size
end
def item_height
(height - standard_padding * 2) / 4
end
def draw_item(index)
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
end
def draw_item_background(index)
if index == @pending_index
contents.fill_rect(item_rect(index), pending_color)
end
end
def process_ok
super
$game_party.menu_actor = $game_party.members[index]
end
def select_last
select($game_party.menu_actor.index || 0)
end
def pending_index=(index)
last_pending_index = @pending_index
@pending_index = index
redraw_item(@pending_index)
redraw_item(last_pending_index)
end
end
class Window_BaseMenuActor < Window_BaseMenuStatus
def initialize
super(0, 0)
self.visible = false
end
def process_ok
$game_party.target_actor = $game_party.members[index] unless @cursor_all
call_ok_handler
end
def select_last
select($game_party.target_actor.index || 0)
end
def select_for_item(item)
@cursor_fix = item.for_user?
@cursor_all = item.for_all?
if @cursor_fix
select($game_party.menu_actor.index)
elsif @cursor_all
select(0)
else
select_last
end
end
end
class Scene_ItemBase < Scene_MenuBase
def create_actor_window
@actor_window = Window_BaseMenuActor.new
@actor_window.set_handler

ok, method

on_actor_ok))
@actor_window.set_handler

cancel, method

on_actor_cancel))
end
end
class Window_PartyStatus < Window_Selectable
include Lecode:

oaE_Menu
def initialize
@allies_window = Window_PartyStatusAllies.new
super(get_x,get_y,window_width,window_height)
self.openness = 0
self.back_opacity += 25
refresh
end
def get_x
Graphics.width/2 - window_width/2
end
def get_y
Graphics.height/2 - window_height/2
end
def window_width
Graphics.width*0.8
end
def window_height
fitting_height(12)
end
def refresh
contents.clear
draw_leader
draw_food
draw_allies
draw_strategist
end
def draw_leader
#- Face
x = 4
y = 4
draw_border(x,y,96,96,normal_color)
draw_actor_face($game_party.leader,x,y)
x += 96 + 8
y += line_height
contents.font.size = Font.default_size+4
my_draw_text("Leader",x,y,system_color)
contents.font.size = Font.default_size
y += line_height
my_draw_text($game_party.leader.name,x,y,normal_color)
end
def draw_food
bx = 96+8+130
x = bx
y = 4 + line_height
draw_border(x,y,150,line_height*6,normal_color)
text = "Level "+$game_party.leader.level.to_s
w = text_size(text).width
x += 150/2 - w/2
x -= 6
y -= 14
contents.font.size = Font.default_size+4
my_draw_text(text,x,y,system_color)
contents.font.size = Font.default_size+2
#- Money
x = bx + 6
y += line_height
contents.font.bold = true
draw_icon(Money_Icon,x,y)
my_draw_text("Money",x+24,y,normal_color)
contents.font.bold = false
y += line_height/2 + 6
x = bx + 150
text = $game_party.gold.to_s
w = text_size(text).width + 6
x -= w
my_draw_text(text,x,y,normal_color)
#- Food
x = bx + 6
y += line_height
contents.font.bold = true
draw_icon(Food_Icon,x,y)
my_draw_text(Food_Name,x+24,y,normal_color)
contents.font.bold = false
y += line_height/2 + 6
x = bx + 150
text = $game_variables[Food_Variable].to_s
w = text_size(text).width + 6
x -= w
my_draw_text(text,x,y,normal_color)
#- Exp
x = bx + 6
y += line_height
contents.font.bold = true
draw_icon(Exp_Icon,x,y)
my_draw_text("Experience",x+24,y,normal_color)
contents.font.bold = false
y += line_height/2 + 6
x = bx + 150
text = $game_party.leader.exp.to_s
w = text_size(text).width + 6
x -= w
my_draw_text(text,x,y,normal_color)
end
def draw_allies
x = 4
y = 4 + line_height*5
draw_border(x,y,210,line_height*6 + 4,normal_color)
@allies_window.x = self.x + x + 4
@allies_window.y = self.y + y + 2
@allies_window.refresh
end
def draw_strategist
x = 210 + 12
y = 4 + line_height*7
contents.font.size = Font.default_size+4
my_draw_text("Strategist",x,y,system_color)
contents.font.size = Font.default_size
y += line_height
my_draw_text($game_party.strategist.name,x,y,normal_color)
y += line_height
rect = my_draw_text("TP ",x,y,system_color)
my_draw_text($game_party.strategist.tp,x+rect.width+2,y,normal_color)
y += line_height
rect = my_draw_text("MP ",x,y,system_color)
my_draw_text($game_party.strategist.mmp,x+rect.width+2,y,normal_color)
end
def update
super
@allies_window.openness = self.openness
@allies_window.visible = self.visible
@allies_window.update
end
def activate
super
@allies_window.activate
@allies_window.select(0)
end
def deactivate
super
@allies_window.deactivate
@allies_window.unselect
end
def dispose
super
@allies_window.dispose
end
end
class Window_PartyStatusAllies < Window_Selectable
include Lecode:

oaE_Menu
def initialize
super(0,0,window_width,window_height)
self.openness = 0
self.opacity = 0
self.z += 1
refresh
end
def window_width
220
end
def window_height
fitting_height(6)
end
def col_max
return 1
end
def item_max
@data ? @data.size : 1
end
def item
@data && index >= 0 ? @data[index] : nil
end
def make_item_list
@data = $game_party.members
end
def draw_item(index)
actor = @data[index]
if actor
rect = item_rect(index)
rect.width -= 4
draw_icon(Strategist_Icon,rect.x,rect.y) if $game_party.strategist == actor
my_draw_text(actor.name,rect.x+24,rect.y,normal_color)
text = "#{actor.hp} / #{actor.mhp}"
x = rect.x+rect.width-text_size(text).width-4
my_draw_text(text,x,rect.y,text_color(3))
end
end
def refresh
make_item_list
create_contents
draw_all_items
end
end
class Window_MenuSkill < Window_Selectable
attr_accessor :type
attr_accessor :actor
attr_accessor :help
def initialize(x,y)
@type = :tactic
@actor = nil
@Help = nil
y += line_height
@header = Window_Header.new
super(x,y,window_width,window_height)
self.openness = 0
self.opacity = 0
end
def window_width
204
end
def window_height
fitting_height(8)
end
def col_max
return 1
end
def item_max
@data ? @data.size : 1
end
def item
@data && index >= 0 ? @data[index] : nil
end
def make_item_list
@data = []
return if @actor.nil?
if @type == :tactic
@data = @actor.skills.select{ |s| s.tactic? }
else
@data = @actor.skills.select{ |s| s.magic? }
end
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, true)
end
end
def refresh
@header.x = self.x
@header.y = self.y - line_height
@header.refresh(@actor,@type)
make_item_list
create_contents
draw_all_items
end
def select(*args)
super(*args)
return if @help.nil?
if item.nil?
@help.clear
return
end
@help.set_text(item.description)
end
def activate
super
return if @help.nil?
if item.nil?
@help.clear
return
end
@help.set_text(item.description)
end
def update
super
@header.openness = self.openness
end
def process_ok
if current_item_enabled?
Input.update
call_ok_handler
else
end
end
class Window_Header < Window_Base
def initialize
super(0,0,204,fitting_height(9))
self.openness = 0
self.z -= 1
end
def refresh(actor,type)
contents.clear
text = type == :tactic ? "Tactics" : "Magics"
my_draw_text(text,0,0,system_color)
#-
if type == :tactic
text = "TP left: #{$game_party.tp}"
else
text = "MP left: #{actor.mp}"
end
text = text.to_s
w = text_size(text).width
x = contents_width - w - 4
my_draw_text(text,x,y,system_color)
end
end
end
end