Sunteți pe pagina 1din 27

# custom menu system

# - stylized with dropdown menus


# includes:
# - unlimited character support
# - quest/key item support (by rpgmaker)
# - organized menus by items, weapons, armors, and key items
# - advanced equip screen (by rpg-advocate)
# - reorganized status screen
# - horizontal menus
# - transparent windows
# - single scene interface [lag reduction]
# - map name window
# - support for deke/near fantastica's day*night system
#
# instruction manual:
#
# step 1 - copy and paste this line into window_base under def initialize
# self.back_opacity = 160
# you can remove this line if you do not wish for transparent menu windows.
#
# step 2 - copy and paste these lines at the end of window_base before the
# last end:
# def draw_actor_face(actor,x,y)
# bitmap = rpg::cache.picture(actor.name + ".png")
# self.contents.blt(x,y,bitmap,rect.new(0,0,100,100))
# end
# this is for faceset support. you can remove this by searching for
# draw_actor_face and removing the line and the def draw_actor_face code.
# if you keep this code, you will require 100x100 png files in the pictures
# directory named after the characters they correspond to.
# example: arshes' face image is called arshes.png
#
# step 3 - add this line:
# @help_window.y = 0
# between these lines:
# @help_window = window_help.new
# and
# @help_window.set_text(@help_text)
# in scene_file. this is mandatory.
#
# step 4 - add this to game_map at the end:
# def name
# $map_infos[@map_id]
# end
# also add this to scene_title after $data_system in def main
# $map_infos = load_data("data/mapinfos.rxdata")
# for key in $map_infos.keys
# $map_infos[key] = $map_infos[key].name
# end
# thats for the map location window.
#
# support for deke/near fantastica's day and night system:
# currently the script has this commented out, so that it doesn't interfere.
# if you wish to support this, run a search in this file for d&n script
# instructions will be there for you to follow.
# also, make sure that the d&n system script is below this one in the list
#
# support for the key items window is as follows:
# create 4 new elements in the database (system tab)
# make them ids 17, 18, 19, and 20 and name them:
# 0017: items
# 0018: weapons
# 0019: armor
# 0020: quest items
# now, in the database, give the corresponding items the corresponding elements
# you'll need to do this for every item and such. if one item has both ids it
# will show in both menus (such as items/quest items)
#
# thats it. enjoy ^^;
# - prexus

class window_item < window_selectable


def initialize(wintype = 1, element_id = 17)
super(0, 64, 640, 352)
@element_id = element_id
@wintype = wintype
@column_max = 2
if $game_temp.in_battle
@column_max = 1
self.x = 308
self.y = 80
self.width = 316
self.height = 196
self.back_opacity = 160
end
self.index = 0
refresh
end
def item
return @data[self.index]
end
def setids(wintype, element_id)
@wintype = wintype
@element_id = element_id
refresh
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
if @wintype == 1
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
if $data_items[i] != nil and
($data_items[i].element_set.include?(@element_id))
@data.push($data_items[i])
end
end
end
elsif @wintype == 2
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
if $data_weapons[i] != nil and
($data_weapons[i].element_set.include?(@element_id))
@data.push($data_weapons[i])
end
end
end
elsif @wintype == 3
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
if $data_armors[i] != nil
@data.push($data_armors[i])
end
end
end
end
@item_max = @data.size
if @item_max > 0
self.contents = bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
item = @data[index]
case item
when rpg::item
number = $game_party.item_number(item.id)
when rpg::weapon
number = $game_party.weapon_number(item.id)
when rpg::armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(rpg::item)
if $game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
disabled_color
end
else
self.contents.font.color = normal_color
end
if $game_temp.in_battle
x = 4
y = index * 32
else
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
end
rect = rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, color.new(0, 0, 0, 0))
bitmap = rpg::cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y, bitmap, rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, "x", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end

class window_mapname < window_base


def initialize
super(0, 0, 160, 96)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "location")
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_map.name.to_s, 2)
end
end

class window_equipleft < window_base


attr_accessor :mode
attr_accessor :changes
def initialize(actor)
super(0, 64, 272, 352)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.z += 100
actor_num = actor.id
@actor = actor
refresh
end
def update_actor(actor)
@actor = actor
actor_num = actor.id
refresh
end
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 4, 32)
draw_actor_parameter(@actor, 4, 64, 0)
draw_actor_parameter(@actor, 4, 96, 1)
draw_actor_parameter(@actor, 4, 128, 2)
draw_actor_parameter(@actor, 4, 192, 3)
draw_actor_parameter(@actor, 4, 224, 4)
draw_actor_parameter(@actor, 4, 256, 5)
draw_actor_parameter(@actor, 4, 288, 6)
if @new_atk != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 64, 40, 32, "?", 1)
self.contents.font.color = @actor.atk < @new_atk ? system_color :
@actor.atk > @new_atk ? disabled_color :
normal_color
self.contents.draw_text(200, 64, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 96, 40, 32, "?", 1)
self.contents.font.color = @actor.pdef < @new_pdef ? system_color :
@actor.pdef > @new_pdef ? disabled_color :
normal_color
self.contents.draw_text(200, 96, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 128, 40, 32, "?", 1)
self.contents.font.color = @actor.mdef < @new_mdef ? system_color :
@actor.mdef > @new_mdef ? disabled_color :
normal_color
self.contents.draw_text(200, 128, 36, 32, @new_mdef.to_s, 2)
end
if @new_str != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 192, 40, 32, "?", 1)
self.contents.font.color = @actor.str < @new_str ? system_color :
@actor.str > @new_str ? disabled_color :
normal_color
self.contents.draw_text(200, 192, 36, 32, @new_str.to_s, 2)
end
if @new_dex != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 224, 40, 32, "?", 1)
self.contents.font.color = @actor.dex < @new_dex ? system_color :
@actor.dex > @new_dex ? disabled_color :
normal_color
self.contents.draw_text(200, 224, 36, 32, @new_dex.to_s, 2)
end
if @new_agi != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 256, 40, 32, "?", 1)
self.contents.font.color = @actor.agi < @new_agi ? system_color :
@actor.agi > @new_agi ? disabled_color :
normal_color
self.contents.draw_text(200, 256, 36, 32, @new_agi.to_s, 2)
end
if @new_int != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 288, 40, 32, "?", 1)
self.contents.font.color = @actor.int < @new_int ? system_color :
@actor.int > @new_int ? disabled_color :
normal_color
self.contents.draw_text(200, 288, 36, 32, @new_int.to_s, 2)
end
end
def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
new_agi, new_int)
flag = false
if new_atk != @new_atk || new_pdef != @new_pdef || new_mdef != @new_mdef
flag = true
end
if new_str != @new_str || new_dex != @new_dex || new_agi != @new_agi
flag = true
end
if new_int != @new_int
flag = true
end
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_str = new_str
@new_dex = new_dex
@new_agi = new_agi
@new_int = new_int
if flag
refresh
end
end
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
self.contents.draw_text(x, y, 112, 32, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
end
end

class window_equipitem < window_selectable


def initialize(actor, equip_type)
super(0, 256, 640, 160)
@actor = actor
@equip_type = equip_type
@column_max = 2
refresh
self.active = false
self.index = -1
end
def item
return @data[self.index]
end
def update_actor(actor, equip_type)
@actor = actor
@equip_type = equip_type
refresh
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
@data.push(nil)
@item_max = @data.size
self.contents = bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max-1
draw_item(i)
end
end
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when rpg::weapon
number = $game_party.weapon_number(item.id)
when rpg::armor
number = $game_party.armor_number(item.id)
end
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, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end

class window_equipitem < window_selectable


alias xrxs_mp1_initialize initialize
def initialize(actor, equip_type)
xrxs_mp1_initialize(actor, equip_type)
self.x = 272
self.width = 368
self.contents = bitmap.new(width - 32, height - 32)
@column_max = 1
refresh
end
def item
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
@data.push(nil)
@item_max = @data.size
self.contents = bitmap.new(width - 32, row_max * 32)
self.contents.font.name = "arial"
self.contents.font.size = 24
for i in 0...@item_max-1
draw_item(i)
end
s = @data.size-1
self.contents.draw_text(4, s*32, 100, 32, "[remove]")
end
def draw_item(index)
item = @data[index]
x = 4
y = index * 32
case item
when rpg::weapon
number = $game_party.weapon_number(item.id)
when rpg::armor
number = $game_party.armor_number(item.id)
end
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, 0)
self.contents.draw_text(x + 288, y, 16, 32, ":", 1)
self.contents.draw_text(x + 304, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end

class window_target < window_selectable


def initialize
super(0, 64, 336, 352)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.z += 10
@item_max = $game_party.actors.size
refresh
end
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 4
y = i * 84
actor = $game_party.actors[i]
draw_actor_name(actor, x, y)
draw_actor_state(actor, x + 144, y)
draw_actor_hp(actor, x, y + 32)
draw_actor_sp(actor, x + 152, y + 32)
end
end
def update_cursor_rect
self.cursor_rect.set(0, @index * 84, self.width - 32, 64)
end
end

class window_menustatus < window_selectable


def initialize
super(0, 0, 128, $game_party.actors.size*32+32)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
self.active = false
self.index = 0
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 4
y = i * 32
actor = $game_party.actors[i]
draw_actor_name(actor, x, y)
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 32, self.width - 32, 32)
end
end
end

class window_status < window_base


def initialize(actor)
super(0, 64, 480, 416)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@actor = actor
refresh
end
def update_actor(actor)
@actor = actor
refresh
end
def refresh
self.contents.clear
draw_actor_face(@actor,0,32)
draw_actor_graphic(@actor, 24, 144)
draw_actor_name(@actor, 4, 0)
draw_actor_class(@actor, 4 + 144, 0)
draw_actor_level(@actor, 96, 32)
draw_actor_state(@actor, 180, 32)
draw_actor_hp(@actor, 96, 112-32, 172)
draw_actor_sp(@actor, 96, 144-32, 172)
draw_actor_parameter(@actor, 96, 224+16, 3)
draw_actor_parameter(@actor, 96, 256+16, 4)
draw_actor_parameter(@actor, 96, 288+16, 5)
draw_actor_parameter(@actor, 96, 320+16, 6)
self.contents.font.color = system_color
self.contents.draw_text(96, 160, 80, 32, "exp")
self.contents.draw_text(96, 192, 80, 32, "next")
self.contents.font.color = normal_color
self.contents.draw_text(96 + 80, 160, 84, 32, @actor.exp_s, 2)
self.contents.draw_text(96 + 80, 192, 84, 32, @actor.next_rest_exp_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(280, 32, 96, 32, "equipment")
draw_item_name($data_weapons[@actor.weapon_id], 280, 64)
draw_item_name($data_armors[@actor.armor1_id], 280, 96)
draw_item_name($data_armors[@actor.armor2_id], 280, 128)
draw_item_name($data_armors[@actor.armor3_id], 280, 160)
draw_item_name($data_armors[@actor.armor4_id], 280, 192)
draw_actor_parameter(@actor, 280, 256+16, 0)
draw_actor_parameter(@actor, 280, 288+16, 1)
draw_actor_parameter(@actor, 280, 320+16, 2)
end
end

class window_skill < window_selectable


def initialize(actor)
super(0, 128, 640, 288)
@actor = actor
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
@column_max = 1
self.x = 308
self.y = 80
self.width = 316
self.height = 196
self.back_opacity = 160
end
end
def skill
return @data[self.index]
end
def update_actor(actor)
@actor = actor
refresh
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 0...@actor.skills.size
skill = $data_skills[@actor.skills[i]]
if skill != nil
@data.push(skill)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
if $game_temp.in_battle
x = 4
y = index * 32
else
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
end
rect = rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, color.new(0, 0, 0, 0))
bitmap = rpg::cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end

class window_skillstatus < window_base


def initialize(actor)
super(0, 64, 640, 64)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@actor = actor
refresh
end
def update_actor(actor)
@actor = actor
refresh
end
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_state(@actor, 140, 0)
draw_actor_hp(@actor, 284, 0)
draw_actor_sp(@actor, 460, 0)
end
end

class window_help < window_base


def initialize
super(0, 416, 640, 64)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
if $game_temp.in_battle
self.y = 0
self.back_opacity = 160
end
end
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
def set_enemy(enemy)
text = enemy.name
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
end
end

class window_equipright < window_selectable


def initialize(actor)
super(272, 64, 368, 192)
self.contents = bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@actor = actor
refresh
self.index = 0
end
def item
return @data[self.index]
end
def update_actor(actor)
@actor = actor
refresh
end
def refresh
self.contents.clear
@data = []
@data.push($data_weapons[@actor.weapon_id])
@data.push($data_armors[@actor.armor1_id])
@data.push($data_armors[@actor.armor2_id])
@data.push($data_armors[@actor.armor3_id])
@data.push($data_armors[@actor.armor4_id])
@item_max = @data.size
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
draw_item_name(@data[0], 92, 32 * 0)
draw_item_name(@data[1], 92, 32 * 1)
draw_item_name(@data[2], 92, 32 * 2)
draw_item_name(@data[3], 92, 32 * 3)
draw_item_name(@data[4], 92, 32 * 4)
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end

class menu_selectable < window_base


attr_reader :index
attr_reader :help_window
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 1
@index = -1
end
def index=(index)
@index = index
if @help_window != nil
update_help
end
update_cursor_rect
end
def row_max
return (@item_max + @column_max - 1) / @column_max
end
def top_row
return self.oy / 32
end
def top_row=(row)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
self.oy = row * 32
end
def page_row_max
return (self.height - 32) / 32
end
def page_item_max
return page_row_max * @column_max
end
def help_window=(help_window)
@help_window = help_window
if @help_window != nil
update_help
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
row = @index / @column_max
if row < self.top_row
self.top_row = row
end
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
cursor_width = self.width / @column_max - 32
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 128
self.cursor_rect.set(y, x, 100, 32)
end
def update
super
if self.active and @item_max > 0 and @index >= 0
if input.repeat?(input::right)
if (@column_max == 1 and input.trigger?(input::left)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if input.repeat?(input::left)
if (@column_max == 1 and input.trigger?(input::up)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
if input.repeat?(input::right)
if @column_max >= 2 and @index < @item_max - 1
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
if input.repeat?(input::left)
if @column_max >= 2 and @index > 0
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
if input.repeat?(input::r)
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
if input.repeat?(input::l)
if self.top_row > 0
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
end
end
end
if @help_window != nil
update_help
end
update_cursor_rect
end
end

class window_menucommand < window_selectable


def initialize(width, commands)
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
self.contents = bitmap.new(width - 32, @item_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
self.index = 0
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index],1)
end
def disable_item(index)
draw_item(index, disabled_color)
end
end

class menu_command < menu_selectable


def initialize(width, commands)
super(0, 0, 700, 500)
@item_max = commands.size
@commands = commands
self.contents = bitmap.new(width - 32, @item_max * 32)
self.contents.font.name = "arial"
self.contents.font.size = 24
self.back_opacity = 0
refresh
self.index = 0
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = rect.new(-16+128*index, 5, 128, 32)
self.contents.fill_rect(rect, color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index],1)
end
def disable_item(index)
draw_item(index, disabled_color)
end
end

# d&n script - if you are using the script, uncomment all of this.
# class window_time < window_base
# def initialize
#super(0, 0, 160, 64)
#self.contents = bitmap.new(width - 32, height - 32)
#self.contents.font.name = "arial" # "time" window font
#self.contents.font.size = 24
#refresh
#end
#def refresh
#self.contents.clear
#@total_sec = graphics.frame_count / graphics.frame_rate
#@minute=$game_time.get_minute.floor
#hour = $game_time.get_hour
#pm_flag= hour >=12 ? true : false
#hour= hour >= 12 ? hour-12 : hour
#day=$game_time.get_day
#month=$game_time.get_month
#year=$game_time.get_year
#if hour.floor==0
#text=sprintf("%02d:%02d",12,@minute)
#else
#text=sprintf("%02d:%02d",hour,@minute)
#end
#if pm_flag
# text += " pm"
#else
#text += " am"
#end
#self.contents.font.color = normal_color
#self.contents.draw_text(4, 0, 120, 32, text, 2)
#end
#def update
#if $game_time.get_minute.floor != @minute
#refresh
#end
#end
#end

class scene_menu
def initialize(menu_index = 0, actor_index = 0, equip_index = 0)
@menu_index = menu_index
@actor_index = actor_index
@equip_index = equip_index
end
def main
@sprite = spriteset_map.new
s1 = $data_system.words.item
s2 = $data_system.words.equip
s3 = $data_system.words.skill
s4 = "status"
s5 = "game"
@dummy_window = window_base.new(0, 0, 640, 64)
@command_window = menu_command.new(640, [s1, s2, s3, s4, s5])
@command_window.index = @menu_index
@command_window.width = 700
@command_window.height = 500
@command_window.y = -5
@command_window.x = -5
@command_window.opacity = 0
@command_window.z += 10
@dummy_window.z += 10
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
@playtime_window = window_playtime.new
@playtime_window.x = 640-@playtime_window.width
@playtime_window.y = 64
@playtime_window.visible = false
@playtime_window.active = false
@mapname_window = window_mapname.new
@mapname_window.x = 640-@mapname_window.width
@mapname_window.y = @playtime_window.y+@playtime_window.height
@mapname_window.visible = false
@mapname_window.active = false
@steps_window = window_steps.new
@steps_window.x = 640-@steps_window.width
@steps_window.y = @playtime_window.y+@playtime_window.height + 96
@steps_window.visible = false
@steps_window.active = false
@gold_window = window_gold.new
@gold_window.x = 640-@gold_window.width
@gold_window.y = @steps_window.y+@steps_window.height
@gold_window.visible = false
@gold_window.active = false
# d&n script
#this is for use with deke/nearfantasticas day night system, uncomment it if
#you have this script.
#@time_window = window_time.new
#@time_window.x = 640-@time_window.width
#@time_window.y = @gold_window.y+@gold_window.height
#@time_window.visible = false
#@time_window.active = false
@help_window = window_help.new
@help_window.x = 0
@help_window.y = 416
@item_window = window_item.new(1, 17)
@item_window.help_window = @help_window
@item_window.visible = false
@item_window.active = false
@drop1 = window_menucommand.new(128,["basic", "weapons", "armor", "quest"])
@drop1.x = 0
@drop1.y = 64
@drop1.visible = false
@drop1.active = false
@drop2 = window_menustatus.new
@drop2.x = 128
@drop2.y = 64
@drop2.visible = false
@drop2.active = false
@drop3 = window_menucommand.new(128,["save","quit"])
@drop3.x = 640-128
@drop3.y = 64
@drop3.visible = false
@drop3.active = false
@target_window = window_target.new
@target_window.visible = false
@target_window.active = false
@actor = $game_party.actors[@actor_index]
@equiphelp_window = window_help.new
@left_window = window_equipleft.new(@actor)
@left_window.visible = false
@left_window.active = false
@right_window = window_equipright.new(@actor)
@right_window.help_window = @equiphelp_window
@right_window.visible = false
@right_window.active = false
@item_window1 = window_equipitem.new(@actor, 0)
@item_window1.help_window = @equiphelp_window
@item_window1.visible = false
@item_window1.active = false
@item_window2 = window_equipitem.new(@actor, 1)
@item_window2.help_window = @equiphelp_window
@item_window2.visible = false
@item_window2.active = false
@item_window3 = window_equipitem.new(@actor, 2)
@item_window3.help_window = @equiphelp_window
@item_window3.visible = false
@item_window3.active = false
@item_window4 = window_equipitem.new(@actor, 3)
@item_window4.help_window = @equiphelp_window
@item_window4.visible = false
@item_window4.active = false
@item_window5 = window_equipitem.new(@actor, 4)
@item_window5.help_window = @equiphelp_window
@item_window5.visible = false
@item_window5.active = false
@equiphelp_window.active = false
@equiphelp_window.visible = false
@right_window.index = @equip_index
@skillstatus_window = window_skillstatus.new(@actor)
@skillstatus_window.visible = false
@skillstatus_window.active = false
@skill_window = window_skill.new(@actor)
@skill_window.help_window = @help_window
@skill_window.visible = false
@skill_window.active = false
@help_window.visible = false
@help_window.active = false
@skilltarget_window = window_target.new
@skilltarget_window.visible = false
@skilltarget_window.active = false
@playerstatus_window = window_status.new(@actor)
@playerstatus_window.visible = false
@playerstatus_window.active = false
graphics.transition
loop do
graphics.update
input.update
update
if $scene != self
break
end
end
graphics.freeze
@help_window.dispose
@item_window.dispose
@target_window.dispose
@drop1.dispose
@drop2.dispose
@drop3.dispose
@dummy_window.dispose
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@mapname_window.dispose
@gold_window.dispose
#you will also have to take out this comment for the d&n script
#@time_window.dispose
@equiphelp_window.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
@skillstatus_window.dispose
@skill_window.dispose
@skilltarget_window.dispose
@playerstatus_window.dispose
end
def equip_refresh
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
item1 = @right_window.item
case @right_window.index
when 0
@eitem_window = @item_window1
newmode = 0
when 1
@eitem_window = @item_window2
newmode = 1
when 2
@eitem_window = @item_window3
newmode = 1
when 3
@eitem_window = @item_window4
newmode = 1
when 4
@eitem_window = @item_window5
newmode = 1
end
if newmode != @left_window.mode
@left_window.mode = newmode
@left_window.refresh
end
if @right_window.active
@left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil)
end
if @eitem_window.active
item2 = @eitem_window.item
last_hp = @actor.hp
old_atk = @actor.atk
old_pdef = @actor.pdef
old_mdef = @actor.mdef
old_str = @actor.str
old_dex = @actor.dex
old_agi = @actor.agi
old_int = @actor.int
old_eva = @actor.eva
@actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
new_str = @actor.str
new_dex = @actor.dex
new_agi = @actor.agi
new_int = @actor.int
new_eva = @actor.eva
@left_window.changes = [0, 0, 0, 0, 0, 0, 0, 0]
if new_atk > old_atk
@left_window.changes[0] = 1
end
if new_atk < old_atk
@left_window.changes[0] = -1
end
if new_pdef > old_pdef
@left_window.changes[1] = 1
end
if new_pdef < old_pdef
@left_window.changes[1] = -1
end
if new_mdef > old_mdef
@left_window.changes[2] = 1
end
if new_mdef < old_mdef
@left_window.changes[2] = -1
end
if new_str > old_str
@left_window.changes[3] = 1
end
if new_str < old_str
@left_window.changes[3] = -1
end
if new_dex > old_dex
@left_window.changes[4] = 1
end
if new_dex < old_dex
@left_window.changes[4] = -1
end
if new_agi > old_agi
@left_window.changes[5] = 1
end
if new_agi < old_agi
@left_window.changes[5] = -1
end
if new_int > old_int
@left_window.changes[6] = 1
end
if new_int < old_int
@left_window.changes[6] = -1
end

@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)


@actor.hp = last_hp
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str,
new_dex, new_agi, new_int)
end
end
def update
@help_window.update
@item_window.update
@target_window.update
@dummy_window.update
@mapname_window.update
@drop1.update
@drop2.update
@drop3.update
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
#you'll also have to take out this comment for the d&n script
#@time_window.update
@left_window.update
@right_window.update
@equiphelp_window.update
@skillstatus_window.update
@skill_window.update
@skilltarget_window.update
@playerstatus_window.update
if @playerstatus_window.active
update_playerstatus
return
end
if @skill_window.active
update_skill
return
end
if @skilltarget_window.active
update_skilltarget
return
end
if @eitem_window != nil
if @eitem_window.visible
equip_refresh
@eitem_window.update
end
end
if @right_window.active
update_right
return
end
if @eitem_window != nil
if @eitem_window.active
update_eitem
return
end
end
if @command_window.active
update_command
return
end
if @drop1.active
update_drop1
return
end
if @drop2.active
update_drop2
return
end
if @drop3.active
update_drop3
return
end
if @item_window.active
update_item
return
end
if @target_window.active
update_target
return
end
end
def update_playerstatus
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
@playerstatus_window.active = false
@playerstatus_window.visible = false
@playtime_window.visible = false
@gold_window.visible = false
@steps_window.visible = false
@mapname_window.visible = false
# d&n script - uncomment this line:
#@time_window.visible = false
@command_window.active = true
return
end
end
def update_skill
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
@skill_window.active = false
@skill_window.visible = false
@skillstatus_window.visible = false
@help_window.visible = false
@command_window.active = true
return
end
if input.trigger?(input::c)
@skill = @skill_window.skill
if @skill == nil or not @actor.skill_can_use?(@skill.id)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
if @skill.scope >= 3
@skill_window.active = false
@skilltarget_window.x = (@skill_window.index + 1) % 2 * 304
@skilltarget_window.visible = true
@skilltarget_window.active = true
if @skill.scope == 4 || @skill.scope == 6
@skilltarget_window.index = -1
elsif @skill.scope == 7
@skilltarget_window.index = @actor_index - 10
else
@skilltarget_window.index = 0
end
else
if @skill.common_event_id > 0
$game_temp.common_event_id = @skill.common_event_id
$game_system.se_play(@skill.menu_se)
@actor.sp -= @skill.sp_cost
@skillstatus_window.refresh
@skill_window.refresh
@skilltarget_window.refresh
$scene = scene_map.new
return
end
end
return
end
end
def update_skilltarget
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
@skill_window.active = true
@skilltarget_window.visible = false
@skilltarget_window.active = false
return
end
if input.trigger?(input::c)
unless @actor.skill_can_use?(@skill.id)
$game_system.se_play($data_system.buzzer_se)
return
end
if @skilltarget_window.index == -1
used = false
for i in $game_party.actors
used |= i.skill_effect(@actor, @skill)
end
end
if @skilltarget_window.index <= -2
target = $game_party.actors[@skilltarget_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
if @skilltarget_window.index >= 0
target = $game_party.actors[@skilltarget_window.index]
used = target.skill_effect(@actor, @skill)
end
if used
$game_system.se_play(@skill.menu_se)
@actor.sp -= @skill.sp_cost
@skillstatus_window.refresh
@skill_window.refresh
@skilltarget_window.refresh
if $game_party.all_dead?
$scene = scene_gameover.new
return
end
if @skill.common_event_id > 0
$game_temp.common_event_id = @skill.common_event_id
$scene = scene_map.new
return
end
end
unless used
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
def update_right
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
@right_window.visible = false
@right_window.active = false
@left_window.visible = false
@equiphelp_window.visible = false
@item_window1.visible = false
@item_window2.visible = false
@item_window3.visible = false
@item_window4.visible = false
@item_window5.visible = false
@eitem_window.visible = false
@command_window.active = true
return
end
if input.trigger?(input::c)
if @actor.equip_fix?(@right_window.index)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@right_window.active = false
@eitem_window.active = true
@eitem_window.index = 0
return
end
end
def update_eitem
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
@right_window.active = true
@eitem_window.active = false
@eitem_window.index = -1
return
end
if input.trigger?(input::c)
$game_system.se_play($data_system.equip_se)
item = @eitem_window.item
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
@right_window.active = true
@eitem_window.active = false
@eitem_window.index = -1
@right_window.refresh
@eitem_window.refresh
return
end
end
def update_command
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)
@command_window.active = false
@drop1.visible = true
@drop1.active = true
return
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@drop2.x = 128
@drop2.visible = true
@drop2.active = true
return
when 2
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@drop2.x = 256
@drop2.visible = true
@drop2.active = true
return
when 3
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@drop2.x = 384
@drop2.visible = true
@drop2.active = true
return
when 4
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@drop3.visible = true
@drop3.active = true
return
end
return
end
end
def update_drop1
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
@drop1.visible = false
@drop1.active = false
@drop1.index = 0
@command_window.active = true
return
end
if input.trigger?(input::c)
case @drop1.index
when 0
@item_window.setids(1,17)
when 1
@item_window.setids(2, 18)
when 2
@item_window.setids(3, 19)
when 3
@item_window.setids(1, 20)
end
@drop1.visible = false
@drop1.active = false
@drop1.index = 0
@item_window.visible = true
@item_window.active = true
@help_window.visible = true
return
end
end
def update_drop2
if input.trigger?(input::b)
$game_system.se_play($data_system.cancel_se)
@drop2.visible = false

S-ar putea să vă placă și