I am using Mr.Mo's interactive mouse system.
I set it up so that menus were compatible. Basically I first used his method, then went a bit further adding a "on_click" method (this is far back, I can't remember much about it sorry).
Basically, each selectable window has an on_click method like:
class Scene_Title < SDK::Scene_Base
def command_click
case @command_window.index
when 0 # New game
command_new_game
when 1 # Continue
command_continue
when 2 # Shutdown
command_shutdown
end
end
end
That would be for Scene_Title.
I did this for Scene_Menu as well. But, while this works for scene_title, it doesn't work in any other scene. There must be something in Scene_Title that I haven't added to Scene_Menu, but I can't find it.
When I say it doesn't work: The cursor appears for one frame then completely disappears, and doesn't reappear when I move the mouse over the window or anything.
Here's what I mean:
http://img.photobucket.com/albums/v108/dudemaster/scr_errs.png
(Why is it I can script OK, but when it comes to explaining how these scripts work, I'm completely stumped? )
Bad scripting warning! Erm yeah, everything's all over the place. Not the best example of scripting.
Here is my Scene_Title:
Here's my Scene_Menu:
Here's the interactive mouse system's window_selectable edit (with the edits I made for the command_click method):
I set it up so that menus were compatible. Basically I first used his method, then went a bit further adding a "on_click" method (this is far back, I can't remember much about it sorry).
Basically, each selectable window has an on_click method like:
class Scene_Title < SDK::Scene_Base
def command_click
case @command_window.index
when 0 # New game
command_new_game
when 1 # Continue
command_continue
when 2 # Shutdown
command_shutdown
end
end
end
That would be for Scene_Title.
I did this for Scene_Menu as well. But, while this works for scene_title, it doesn't work in any other scene. There must be something in Scene_Title that I haven't added to Scene_Menu, but I can't find it.
When I say it doesn't work: The cursor appears for one frame then completely disappears, and doesn't reappear when I move the mouse over the window or anything.
Here's what I mean:
http://img.photobucket.com/albums/v108/dudemaster/scr_errs.png
(Why is it I can script OK, but when it comes to explaining how these scripts work, I'm completely stumped? )
Bad scripting warning! Erm yeah, everything's all over the place. Not the best example of scripting.
Here is my Scene_Title:
Code:
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================
class Scene_Title < SDK::Scene_Base
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
return if main_battle_test? # Battle Test & Return if in Battle Test Mode
super
end
#--------------------------------------------------------------------------
# * Main Processing : Battle Test Check
#--------------------------------------------------------------------------
def main_battle_test?
# If battle test
if $BTEST
battle_test
return true
end
return false
end
#--------------------------------------------------------------------------
# * Main Processing : Variable Initialization
#--------------------------------------------------------------------------
def main_variable
super
# Load Database
main_database
# Continue Enabled Test
main_test_continue
end
#--------------------------------------------------------------------------
# * Main Processing : Database Initialization
#--------------------------------------------------------------------------
def main_database
# Load database
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
$game_bank = 0#Game_Bank.new
# Make system object
$game_system = Game_System.new
$bm_counter = 0#666
end
#--------------------------------------------------------------------------
# * Main Test Initialization
#--------------------------------------------------------------------------
def main_test_continue
# Set Continued Enabled Flag Off
@continue_enabled = false
# Checks For Save Files
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
# Sets Continued Enable Flag On
@continue_enabled = true
end
end
end
#--------------------------------------------------------------------------
# * Main Processing : Sprite Initialization
#--------------------------------------------------------------------------
def main_sprite
super
# Make title graphic
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)#RPG::Cache.panorama('006-mountains01', 0)
end
#--------------------------------------------------------------------------
# * Main Processing : Window Initialization
#--------------------------------------------------------------------------
def main_window
super
# Make command window
s1 = "New Game"
s2 = "Continue"
s3 = "Shutdown"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
@command_window.cursor_height = 32
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
if @continue_enabled
@command_window.index = 1
else
@command_window.disable_item(1)
end
end
#--------------------------------------------------------------------------
# * Main Processing : Audio Initialization
#--------------------------------------------------------------------------
def main_audio
super
# Play title BGM
#$game_system.bgm_play($data_system.title_bgm)
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
#@sprite.x += 1
# If C button was pressed
if Input.trigger?(Keys::MOUSE_LEFT)
# Branch by command window cursor position
case @command_window.index
when 0 # New game
command_new_game
when 1 # Continue
command_continue
when 2 # Shutdown
command_shutdown
end
end
end
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
commandnewgame_audio # Audio Control
commandnewgame_gamedata # Game Data Setup
commandnewgame_partysetup # Party Setup
commandnewgame_mapsetup # Map Setup
commandnewgame_sceneswitch # Scene Switch
end
#--------------------------------------------------------------------------
# * Command: New Game : Audio Control
#--------------------------------------------------------------------------
def commandnewgame_audio
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
end
#--------------------------------------------------------------------------
# * Command: New Game : Game Data Setup
#--------------------------------------------------------------------------
def commandnewgame_gamedata
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
end
#--------------------------------------------------------------------------
# * Command: New Game : Party Setup
#--------------------------------------------------------------------------
def commandnewgame_partysetup
# Set up initial party
$game_party.setup_starting_members
end
#--------------------------------------------------------------------------
# * Command: New Game : Map Setup
#--------------------------------------------------------------------------
def commandnewgame_mapsetup
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
end
#--------------------------------------------------------------------------
# * Command: New Game : Scene Switch
#--------------------------------------------------------------------------
def commandnewgame_sceneswitch
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Command: Continue
#--------------------------------------------------------------------------
def command_continue
# If continue is disabled
unless @continue_enabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to load screen
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# * Command: Shutdown
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown
$scene = nil
end
#--------------------------------------------------------------------------
# * Battle Test
#--------------------------------------------------------------------------
def battle_test
battletest_database
commandnewgame_gamedata
battletest_setup
battletest_sceneswitch
end
#--------------------------------------------------------------------------
# * Battle Test : Load Database
#--------------------------------------------------------------------------
def battletest_database
# Load database (for battle test)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
end
#--------------------------------------------------------------------------
# * Battle Test : Setup
#--------------------------------------------------------------------------
def battletest_setup
# Set up party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
end
#--------------------------------------------------------------------------
# * Battle Test : Scene Switch
#--------------------------------------------------------------------------
def battletest_sceneswitch
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
end
end
Here's my Scene_Menu:
Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu < SDK::Scene_Base
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
#def initialize#(menu_index = 0)
#@menu_index = menu_index
# @menu_index = 0
#end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = "Inventory"
s2 = "Spellbook"
s3 = "Armoury"
s4 = "Classes"
s5 = "Skill Levels"
s6 = "Guilds"
s7 = "Log Out"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.x = 12
@command_window.y = 12
@spr = Sprite.new
@spr.z = 10001
@spr.bitmap = RPG::Cache.picture('new_large_hud4')
@spriteset = Spriteset_Map.new
#@command_window.cursor_height = 32
#@command_window.index = 0#@menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
# Make play time window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 466+12-12-5
@playtime_window.y = 404-76
@playtime_window.z = 10000
@playtime_window.back_opacity = 0
# Make steps window
@steps_window = Window_Steps.new
@steps_window.x = 0+12
@steps_window.y = 320+32-5-76-1-2
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 0+12
@gold_window.y = 411-76-1
@gold_window.width -= 2
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 160+12+1
@status_window.y = 0+12
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
@spriteset.dispose
@spr.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
def command_click
if @command_window.active == true
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
$scene = Scene_Advancement.new
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
end
Here's the interactive mouse system's window_selectable edit (with the edits I made for the command_click method):
Code:
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# This window class contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :index # cursor position
attr_reader :help_window # help window
#--------------------------------------------------------------------------
# * Object Initialization
# x : window x-coordinate
# y : window y-coordinate
# width : window width
# height : window height
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 1
@index = -1
@cursor_height = 16
@freeze = false
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
return if self.visible == false
$mouse.update
#If the mouse clicks
if Input.trigger?(Input::MOUSE_PRIMARY) and $mouse.over?(self)
#@freeze = (not @freeze)
$scene.command_click
#elsif Input.trigger?(Input::MOUSE_SECONDARY) and $mouse.over?(self)
# @freeze = false
end
# If the cursor is over the window
if $mouse.over?(self)
self.active = true
if !@freeze
x = $mouse.x - self.x - 16
y = $mouse.y - self.y - 16
y -= $game_temp.choice_start*@cursor_height if $game_temp != nil
# Calculate cursor width
cursor_width = self.width / @column_max - 48
# Cursor Height
@index = (((y / @cursor_height).floor) * @column_max) + ((x / cursor_width).floor)
@index = @index > @item_max-1 ? @item_max-1 : @index
end
else
self.active = false
self.index = -1 if !@freeze
end
# If cursor is movable
if self.active and @item_max > 0 and @index >= 0
# If pressing down on the directional buttons
if Input.repeat?(Input::DOWN)
# If column count is 1 and directional button was pressed down with no
# repeat, or if cursor position is more to the front than
# (item count - column count)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
# Move cursor down
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
# If the up directional button was pressed
if Input.repeat?(Input::UP)
# If column count is 1 and directional button was pressed up with no
# repeat, or if cursor position is more to the back than column count
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
# Move cursor up
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
# If the right directional button was pressed
if Input.repeat?(Input::RIGHT)
# If column count is 2 or more, and cursor position is closer to front
# than (item count -1)
if @column_max >= 2 and @index < @item_max - 1
# Move cursor right
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
# If the left directional button was pressed
if Input.repeat?(Input::LEFT)
# If column count is 2 or more, and cursor position is more back than 0
if @column_max >= 2 and @index > 0
# Move cursor left
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
# If R button was pressed
if Input.repeat?(Input::R)
# If bottom row being displayed is more to front than bottom data row
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
# Move cursor 1 page back
$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 L button was pressed
if Input.repeat?(Input::L)
# If top row being displayed is more to back than 0
if self.top_row > 0
# Move cursor 1 page forward
$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
# Update help text (update_help is defined by the subclasses)
if self.active and @help_window != nil
update_help
end
# Update cursor rectangle
update_cursor_rect
end
end