Skip to content

Instantly share code, notes, and snippets.

@TakkunMaker
Created September 13, 2019 12:43
Show Gist options
  • Save TakkunMaker/8838cdd05981106d8da21d7da80b6f8e to your computer and use it in GitHub Desktop.
Save TakkunMaker/8838cdd05981106d8da21d7da80b6f8e to your computer and use it in GitHub Desktop.
#==============================================================================
# ** Chrono Trigger Menu
#------------------------------------------------------------------------------
# Autor: Takkun (a.k.a Faalco)
# Create: IDK
# Version: 1.0a
#==============================================================================
# * Instructions & Info:
# -----------------------------------------------------------------------------
# Paste the script above the main of your project, and make the necessary
# settings.
#
# This script (Only the Chrono Trigger) can be used for commercial and
# non-commercial purposes, credits are welcome but not required.
#
# Any problems before the script can be taken on the topics of the same or by
# personal message us forums in which I participate.
#
#==============================================================================
($imported ||= {})["Chrono Trigger Menu"] = true
#==============================================================================
# ** TAKA Module
#------------------------------------------------------------------------------
# All the settings of this script can be made in this module.
#==============================================================================
module TAKA
ICON = [
260, #Item
14, #Habilidades
170, #Equipamentos
12, #Formação
230, #Salvar
1, #Sair
] #Favor não remover.
# Fonte que mostrará demais informações.
FONT_NORMAL_NAME = "Verdana"
# Tamanho da fonte que mostrará demais informações.
FONT_NORMAL_SIZE = 14
# Ícone que será mostrada na janela de Gold.
ICON_GOLD = 361
end
#==============================================================================
# ** RPG::Class
#------------------------------------------------------------------------------
# The data class for class.
#==============================================================================
module RPG
class Class < BaseItem
#--------------------------------------------------------------------------
# * Class Icon
#--------------------------------------------------------------------------
def class_icon
return @class_icon unless @class_icon.nil?
load_notetag_class_icon
return @class_icon
end
#--------------------------------------------------------------------------
# * Load Note
#--------------------------------------------------------------------------
def load_notetag_class_icon
regex =/<icon:(\d+)>/i
@class_icon = self.note =~ regex ? $1.downcase : 143
end
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a super class of all windows within the game.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Class
#--------------------------------------------------------------------------
def draw_actor_class(actor, x, y, width = 112)
change_color(normal_color)
draw_icon($data_classes[actor.class.id].class_icon.to_i, x, y)
draw_text(x + 25, y, width, line_height, actor.class.name)
end
end
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen.
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Initialize Command Selection Position (Class Method)
#--------------------------------------------------------------------------
def self.init_command_position
@@last_command_symbol = nil
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(140, 170)
select_last
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 298
end
#--------------------------------------------------------------------------
# * Get Window Height
#--------------------------------------------------------------------------
def window_height
fitting_height(1)
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
item_max
end
#--------------------------------------------------------------------------
# * Get Spacing for Items Arranged Side by Side
#--------------------------------------------------------------------------
def spacing
return 0
end
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
def add_main_commands
add_command(Vocab::item, :item, main_commands_enabled)
add_command(Vocab::skill, :skill, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
end
#--------------------------------------------------------------------------
# * Get Rectangle for Drawing Items
#--------------------------------------------------------------------------
def draw_item(index)
item = TAKA::ICON
x = 0
y = 0
for i in item
draw_icon(i, x, y, enabled = true)
x += 45
end
end
#--------------------------------------------------------------------------
# * Get Rectangle for Drawing Items
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = 24
rect.height = 24
rect.x = index * (item_width - spacing)
rect.y = 0
rect
end
#--------------------------------------------------------------------------
# * Processing When OK Button Is Pressed
#--------------------------------------------------------------------------
def process_ok
@@last_command_symbol = current_symbol
super
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
select_symbol(@@last_command_symbol)
end
end
#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
# This window displays the party's gold.
#==============================================================================
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 180
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
icon = draw_icon(TAKA::ICON_GOLD, 0, 0)
self.contents.font.name = TAKA::FONT_NORMAL_NAME
self.contents.font.size = TAKA::FONT_NORMAL_SIZE
draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
end
end
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :pending_index # Pending position (for formation)
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, window_height)
@pending_index = -1
refresh
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 180
end
#--------------------------------------------------------------------------
# * Get Window Height
#--------------------------------------------------------------------------
def window_height
return 350
end
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
$game_party.members.size
end
#--------------------------------------------------------------------------
# * Get Item Height
#--------------------------------------------------------------------------
def item_height
return 108
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
self.contents.font.name = TAKA::FONT_NORMAL_NAME
self.contents.font.size = TAKA::FONT_NORMAL_SIZE
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
draw_actor_infos(actor, rect.x + 5, rect.y + 5)
end
#--------------------------------------------------------------------------
# * Draw Background for Item
#--------------------------------------------------------------------------
def draw_item_background(index)
if index == @pending_index
contents.fill_rect(item_rect(index), pending_color)
end
end
#--------------------------------------------------------------------------
# * Draw Actor Infos
#--------------------------------------------------------------------------
def draw_actor_infos(actor, x, y)
draw_actor_name(actor, x, y)
draw_actor_level(actor, x + 80, y)
draw_nogauge_hp(actor, x, y + line_height * 1)
draw_nogauge_mp(actor, x, y + line_height * 2)
draw_actor_atkdef(actor, x, y + line_height * 3)
end
#--------------------------------------------------------------------------
# * Processing When OK Button Is Pressed
#--------------------------------------------------------------------------
def process_ok
super
$game_party.menu_actor = $game_party.members[index]
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
select($game_party.menu_actor.index || 0)
end
#--------------------------------------------------------------------------
# * Set Pending Position (for Formation)
#--------------------------------------------------------------------------
def pending_index=(index)
last_pending_index = @pending_index
@pending_index = index
redraw_item(@pending_index)
redraw_item(last_pending_index)
end
#--------------------------------------------------------------------------
# * Draw HP
#--------------------------------------------------------------------------
def draw_nogauge_hp(actor, x, y, width = 134)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::hp_a)
draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
hp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# * Draw MP
#--------------------------------------------------------------------------
def draw_nogauge_mp(actor, x, y, width = 134)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::mp_a)
draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
mp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# * Draw Parameters
#--------------------------------------------------------------------------
def draw_param(actor, x, y, param_id)
change_color(normal_color)
draw_text(x, y, 36, line_height, actor.param(param_id), 2)
end
#--------------------------------------------------------------------------
# * Draw MP
#--------------------------------------------------------------------------
def draw_actor_atkdef(actor, x, y)
draw_icon(131, x, y)
draw_param(actor, x + 30, y, 2)
draw_icon(139, x + 80, y)
draw_param(actor, x + 100, y, 3)
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
select($game_party.menu_actor.index || 0)
end
#--------------------------------------------------------------------------
# * Set Pending Position (for Formation)
#--------------------------------------------------------------------------
def pending_index=(index)
last_pending_index = @pending_index
@pending_index = index
redraw_item(@pending_index)
redraw_item(last_pending_index)
end
end
#==============================================================================
# ** Window_Actor_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Actor_Status < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
super(230, 10, Graphics.width / 2, Graphics.height - 20)
@actor = actor
refresh
activate
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_block1 (line_height * 0)
end
#--------------------------------------------------------------------------
# * Draw Block 1
#--------------------------------------------------------------------------
def draw_block1(y)
self.contents.font.name = TAKA::FONT_NORMAL_NAME
self.contents.font.size = TAKA::FONT_NORMAL_SIZE
draw_actor_face(@actor, 0, y)
draw_actor_class(@actor, 106, y)
draw_actor_name(@actor, 106, y + 24)
draw_actor_nickname(@actor, 106, y + 48)
draw_actor_level_f(@actor, 106, y + 72)
draw_actor_icons_v(@actor, 224, y)
draw_equipments(50, y + 110)
draw_parameters(10, y + 240)
draw_exp_info(0, y + 330)
end
#--------------------------------------------------------------------------
# * Draw Level
#--------------------------------------------------------------------------
def draw_actor_level_f(actor, x, y)
change_color(system_color)
draw_text(x, y, 64, line_height, Vocab::level)
change_color(normal_color)
draw_text(x + 64, y, 24, line_height, actor.level, 2)
end
#--------------------------------------------------------------------------
# * Draw State and Buff/Debuff Icons
#--------------------------------------------------------------------------
def draw_actor_icons_v(actor, x, y, height = 96)
icons = (actor.state_icons + actor.buff_icons)[0, height / 24]
icons.each_with_index {|n, i| draw_icon(n, x, y + 24 * i) }
end
#--------------------------------------------------------------------------
# * Draw Parameters
#--------------------------------------------------------------------------
def draw_actor_param(actor, x, y, param_id)
change_color(system_color)
draw_text(x, y, 120, line_height, Vocab::param(param_id))
change_color(normal_color)
draw_text(x + 60, y, 36, line_height, actor.param(param_id), 2)
end
#--------------------------------------------------------------------------
# * Draw Parameters
#--------------------------------------------------------------------------
def draw_parameters(x, y)
draw_actor_param(@actor, x, y, 2)
draw_actor_param(@actor, x + 120, y, 3)
draw_actor_param(@actor, x, y + 24, 4)
draw_actor_param(@actor, x + 120, y + 24, 5)
draw_actor_param(@actor, x, y + 48, 6)
draw_actor_param(@actor, x + 120, y + 48, 7)
end
#--------------------------------------------------------------------------
# * Draw Experience Information
#--------------------------------------------------------------------------
def draw_exp_info(x, y)
s1 = @actor.max_level? ? "-------" : @actor.exp
s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
s_next = sprintf(Vocab::ExpNext, Vocab::level)
change_color(system_color)
draw_text(x + 20, y + line_height * 0 - 10, 180, line_height, Vocab::ExpTotal)
draw_text(x + 20, y + line_height * 0 + 10, 180, line_height, s_next)
change_color(normal_color)
draw_text(x + 200, y + line_height * 0 - 10, 180, line_height, s1)
draw_text(x + 200, y + line_height * 0 + 10, 180, line_height, s2)
end
#--------------------------------------------------------------------------
# * Draw Equipment
#--------------------------------------------------------------------------
def draw_equipments(x, y)
@actor.equips.each_with_index do |item, i|
draw_item_name(item, x, y + line_height * i)
end
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
select($game_party.menu_actor.index || 0)
end
#--------------------------------------------------------------------------
# * Set Pending Position (for Formation)
#--------------------------------------------------------------------------
def pending_index=(index)
last_pending_index = @pending_index
@pending_index = index
redraw_item(@pending_index)
redraw_item(last_pending_index)
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_gold_window
create_menu_status_window
create_command_window
end
#--------------------------------------------------------------------------
# * Create Gold Window
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.x = 50
@gold_window.y = Graphics.height - @gold_window.height - 10
end
#--------------------------------------------------------------------------
# * Create Menu Status Window
#--------------------------------------------------------------------------
def create_menu_status_window
@status_window = Window_Actor_Status.new(@actor)
@status_window.deactivate
@menu_status_window = Window_MenuStatus.new(50, 10)
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_MenuCommand.new
@command_window.set_handler(:item, method(:command_item))
@command_window.set_handler(:skill, method(:command_personal))
@command_window.set_handler(:equip, method(:command_personal))
@command_window.set_handler(:formation, method(:command_formation))
@command_window.set_handler(:save, method(:command_save))
@command_window.set_handler(:game_end, method(:command_game_end))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if @status_window.active == true
if Input.trigger?(:DOWN)
@actor = $game_party.menu_actor_next
on_actor_change
end
if Input.trigger?(:UP)
@actor = $game_party.menu_actor_prev
on_actor_change
end
end
end
#--------------------------------------------------------------------------
# * Change Actors
#--------------------------------------------------------------------------
def on_actor_change
@status_window.actor = @actor
@status_window.activate
end
#--------------------------------------------------------------------------
# * [Skill], [Equipment] and [Status] Commands
#--------------------------------------------------------------------------
def command_personal
@menu_status_window.select_last
@command_window.hide
@status_window.activate
@menu_status_window.activate
@menu_status_window.set_handler(:ok, method(:on_personal_ok))
@menu_status_window.set_handler(:cancel, method(:on_personal_cancel))
end
#--------------------------------------------------------------------------
# * [Formation] Command
#--------------------------------------------------------------------------
def command_formation
@menu_status_window.select_last
@command_window.hide
@status_window.activate
@menu_status_window.activate
@menu_status_window.set_handler(:ok, method(:on_formation_ok))
@menu_status_window.set_handler(:cancel, method(:on_formation_cancel))
end
#--------------------------------------------------------------------------
# * [Cancel] Personal Command
#--------------------------------------------------------------------------
def on_personal_cancel
@menu_status_window.unselect
@status_window.deactivate
@command_window.show
@command_window.activate
end
#--------------------------------------------------------------------------
# * Formation [OK]
#--------------------------------------------------------------------------
def on_formation_ok
if @menu_status_window.pending_index >= 0
$game_party.swap_order(@menu_status_window.index,
@menu_status_window.pending_index)
@menu_status_window.pending_index = -1
@menu_status_window.redraw_item(@menu_status_window.index)
else
@menu_status_window.pending_index = @menu_status_window.index
end
@menu_status_window.show
@command_window.hide
@status_window.activate
@menu_status_window.activate
end
#-------------------------------------------------------------------------
# * Formation [Cancel]
#--------------------------------------------------------------------------
def on_formation_cancel
if @menu_status_window.pending_index >= 0
@menu_status_window.pending_index = -1
@command_window.hide
@status_window.activate
@menu_status_window.activate
else
@command_window.show
@status_window.deactivate
@menu_status_window.unselect
@command_window.activate
end
end
end
#==============================================================================
# ** Scene_MenuBase
#------------------------------------------------------------------------------
# This class performs basic processing related to the menu screen.
#==============================================================================
class Scene_MenuBase < Scene_Base
#--------------------------------------------------------------------------
# * Create Background
#--------------------------------------------------------------------------
def create_background
@background_sprite = Spriteset_Map.new
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super
update_background
end
#--------------------------------------------------------------------------
# * Update Background
#--------------------------------------------------------------------------
def update_background
$game_map.update
$game_timer.update
@background_sprite.update
end
end
#==============================================================================
# ** Scene_End
#------------------------------------------------------------------------------
# This class performs game over screen processing.
#==============================================================================
class Scene_End < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Background
#--------------------------------------------------------------------------
def create_background
super
$game_map.screen.start_tone_change(Tone.new(0, 0, 0, 128),2)
end
#--------------------------------------------------------------------------
# * Return to Calling Scene
#--------------------------------------------------------------------------
def return_scene
$game_map.screen.start_tone_change(Tone.new(0, 0, 0, 0),2)
SceneManager.return
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment