new scene hotkey for babs

Started by Zexion, February 27, 2011, 08:48:00 am

Previous topic - Next topic

Zexion

February 27, 2011, 08:48:00 am Last Edit: February 27, 2011, 08:49:33 am by Zexion
Okay, so I want to make a custom menu, but I don't know how to make scenes that good yet. I need 2 scrollable windows.

The hotkey window acts as a replacement for the normal hud at the top (meaning that it doesn't display the hud during the menu)
The skill menu is the list of skills that the actor(actor 0) can use.

They way the menu works is:
When you get to this menu it has the first hotkey selected, then you can use the up and down arrows to move the the cursor up or down and scroll through the hotkeys. When the player presses enter, it saves the hotkey you chose, and switches the cursor to the skills which you can then move the cursor the same way as hotkeys.
When you select the skill, it will automaticaly places it on the hotkey that you previously selected, and moves the cursor back to that hotkey. Then you are free to move the cursor again.

I need it to show the map, not neccesary though.
here is the hotkey scene:
Spoiler: ShowHide
#==============================================================================
# Scene_Hotkeys
#------------------------------------------------------------------------------
#  This class handles the skill/item hotkey processing.
#==============================================================================

class Scene_Hotkeys
 
 #----------------------------------------------------------------------------
 # Initialization
 #  tone - screen background tone
 #----------------------------------------------------------------------------
 def initialize(tone = Tone.new(0, 0, 0, 0), index = 0)
   # store current screen tint
   @tone = tone
   # store current party leader
   @party_leader = $game_party.actors[index]
 end
 #----------------------------------------------------------------------------
 # main
 #  The main processing method.
 #----------------------------------------------------------------------------
 def main
   # create spriteset
   @spriteset = Spriteset_Map.new
   # create viewport
   @view = Viewport.new(0, 0, 640, 480)
   # set tone to current screen tone
   @view.tone = @tone.clone
   # create HUD if HUD is turned on and HUD active
   @hud = Hud.new if BlizzABS::Config::HUD_ENABLED && $game_system.hud
   # if ASSIGNMENT is turned
   if BlizzABS::Config::HOTKEYS
     # create assignment display
     @hotkeys = Hotkey_Assignment.new
     # set z position
     @hotkeys.z = 5000
   end
   # if MINIMAP is turned on and minimap active
   if BlizzABS::Config::MINIMAP && $game_system.minimap > 0
     # create minimap
     @minimap = Minimap.new
   end
   # create sprite
   @choice = Sprite.new
   # create bitmap
   @choice.bitmap = $BlizzABS.cache.image('menu_arrow')
   # set x, y and z positions
   @choice.x, @choice.y, @choice.z, @choice.opacity = 160, 40, 500, 128
   # set x position offset
   @choice.ox = -8
   # set active flag
   @active = true
   # set index
   @index = 0
   # set up mode flag
   @up_mode = true
   # create modified skill window
   @skill_window = Window_Skill_Hotkey.new($game_player.battler)
   # create modified item window
   @item_window = Window_Item_Hotkey.new
   # set last active
   @last_active = true
   # transtition
   Graphics.transition
   # loop
   loop do
     # update game screen
     Graphics.update
     # update input
     Input.update
     # frame update
     update
     # stop if chosen an option
     break if $scene != self
   end
   # freeze screen
   Graphics.freeze
   # delete spriteset
   @spriteset.dispose
   # delete HUD elements that exist
   [@hud, @hotkeys, @minimap].each {|s| s.dispose if s != nil}
   # delete choice sprite
   @choice.dispose
   # delete skill window
   @skill_window.dispose
   # delete item window
   @item_window.dispose
   # delete viewport
   @view.dispose
   # while real leader is not first actor in party
   while @party_leader != $game_party.actors[0]
     # switch to next actor
     $BlizzABS.player.switch_leader
   end
 end
 #----------------------------------------------------------------------------
 # update
 #  The update processing method.
 #----------------------------------------------------------------------------
 def update
   # update choice sprite
   @choice.update
   # update skill window
   @skill_window.update
   # update item window
   @item_window.update
   # update hotkey assignment display if existing
   @hotkeys.update if @hotkeys != nil
   # move by 2 or 1 whether active in direction depending on @up_mode
   @choice.oy += (@up_mode ? (@active ? 2 : 1) : (@active ? -2 : -1))
   # set new @up_mode if necesseray depending on @up_mode
   @up_mode = (@up_mode ? (@choice.oy < 8) : (@choice.oy <= -8))
   # if select button pressed
   if $game_system.select_button && Input.trigger?(Input::Select)
     # play sound
     $game_system.se_play($data_system.cursor_se)
     # switch to next actor
     $BlizzABS.player.switch_leader
     # switch to next actor
     @skill_window.switch_actor
     # update HUD if existing
     @hud.update if @hud != nil
     # update hotkey assignment display if existing
     @hotkeys.update if @hotkeys != nil
   # if active
   elsif @active
     # set choice offset always to a number divisable with 2
     @choice.oy = @choice.oy / 2 * 2
     # update hotkey selection
     update_choice
   # if skill window is active
   elsif @skill_window.active
     # update skill selection
     update_skill
   # if item window is active
   elsif @item_window.active
     # update item selection
     update_item
   end
 end
 #----------------------------------------------------------------------------
 # update_choice
 #  Updates input during the hotkey selection.
 #----------------------------------------------------------------------------
 def update_choice
   # set x position
   @choice.x = 160 + @index * 32
   # if pressed B
   if Input.trigger?(Input::B)
     # play cancel sound
     $game_system.se_play($data_system.cancel_se)
     # create map scene
     $scene = Scene_Map.new
   # if C is pressed
   elsif Input.trigger?(Input::C)
     # play sound
     $game_system.se_play($data_system.decision_se)
     # not active
     @active = false
     # the one that was active the last time is now active
     @skill_window.active = @last_active
     @item_window.active = (!@last_active)
   # if RIGHT is being pressed
   elsif Input.repeat?(Input::RIGHT)
     # if RIGHT is pressed or index is less than 9
     if Input.trigger?(Input::RIGHT) || @index < 9
       # play sound
       $game_system.se_play($data_system.cursor_se)
       # set new index
       @index = (@index + 1) % 10
     end
   # if LEFT is being pressed
   elsif Input.repeat?(Input::LEFT)
     # if LEFT is pressed or index is equal or greater than 1
     if Input.trigger?(Input::LEFT) || @index >= 1
       # play sound
       $game_system.se_play($data_system.cursor_se)
       # set new index
       @index = (@index + 9) % 10
     end
   end
 end
 #----------------------------------------------------------------------------
 # update_skill
 #  Updates input during the skill selection.
 #----------------------------------------------------------------------------
 def update_skill
   # set last active
   @last_active = true
   # if B is pressed
   if Input.trigger?(Input::B)
     # play cancel sound
     $game_system.se_play($data_system.cancel_se)
     # set active
     @active = true
     # skill window is not active
     @skill_window.active = false
     # delete cursor
     @skill_window.cursor_rect.empty
   # if C is pressd
   elsif Input.trigger?(Input::C)
     # play sound
     $game_system.se_play($data_system.decision_se)
     # if last position
     if @skill_window.index == @skill_window.item_max - 1
       # remove hotkey assigmnent from skill
       $game_player.skill_hotkeys[(@index+1)%10] = 0
     else
       # set skill to hotkey
       $game_player.skill_hotkeys[(@index+1)%10] = @skill_window.skill.id
     end
     # remove hotkey assigmnent from item
     $game_player.item_hotkeys[(@index+1)%10] = 0
     # draw hotkey display if hotkey display exists
     @hotkeys.draw(@index+1) if @hotkeys != nil
     # set active
     @active = true
     # skill window is not active
     @skill_window.active = false
     # delete cursor
     @skill_window.cursor_rect.empty
   # if RIGHT or LEFT is pressed
   elsif Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
     # play sound
     $game_system.se_play($data_system.cursor_se)
     # item window is active
     @item_window.active = true
     # skill window is not active
     @skill_window.active = false
     # delete cursor
     @skill_window.cursor_rect.empty
   end
 end
 #----------------------------------------------------------------------------
 # update_item
 #  Updates input during the item selection.
 #----------------------------------------------------------------------------
 def update_item
   # set last active
   @last_active = false
   # if B is pressed
   if Input.trigger?(Input::B)
     # play cancel sound
     $game_system.se_play($data_system.cancel_se)
     # set active
     @active = true
     # item window is not active
     @item_window.active = false
     # delete cursor
     @item_window.cursor_rect.empty
   # if C is pressed
   elsif Input.trigger?(Input::C)
     # play sound
     $game_system.se_play($data_system.decision_se)
     # if last position
     if @item_window.index == @item_window.item_max - 1
       # remove hotkey assigmnent from item
       $game_player.item_hotkeys[(@index+1)%10] = 0
     else
       # set item to hotkey
       $game_player.item_hotkeys[(@index+1)%10] = @item_window.item.id
     end
     # remove hotkey assigmnent from skill
     $game_player.skill_hotkeys[(@index+1)%10] = 0
     # draw hotkey display if hotkey display exists
     @hotkeys.draw(@index+1) if @hotkeys != nil
     # set active
     @active = true
     # item window is not active
     @item_window.active = false
     # delete cursor
     @item_window.cursor_rect.empty
   # if RIGHT or LEFT is pressed
   elsif Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
     # play sound
     $game_system.se_play($data_system.cursor_se)
     # skill window is active
     @skill_window.active = true
     # item window is not active
     @item_window.active = false
     # delete cursor
     @item_window.cursor_rect.empty
   end
 end
 
end