Editing Menu

Started by Vexus, February 09, 2015, 09:07:38 am

Previous topic - Next topic

Vexus

March 19, 2015, 10:08:28 am #20 Last Edit: March 19, 2015, 11:27:22 am by Vexus
This has nothing to do with the menu but with the title screen but didn't see any point in making a new thread so.....

I am making a new title scene ontop of the default one and require some help.

I made it so when you click on new game instead of going into to the game, you go into a "new" title screen. This new one so far gives you the option to pick a difficulty or to go back to the title screen.

"Easy, Normal, Hard, Go Back"

Atm they show vertical, I want to show the first 3 horizontal and the fourth option underneath them unless it's too much work. (I'm thinking on adding a picture for each mode to explain what is different)

Once that is done, a help window shouldn't be too much hard to do.

How would I go in achieving this?

Spoiler: ShowHide
#==============================================================================
# ** Scene_Mode
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Mode
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Make system object
   $game_system = Game_System.new
   # Make title graphic
   @sprite = Sprite.new
   @sprite.bitmap = RPG::Cache.title($data_system.title_name)
   # Make command window
   s1 = "Easy Mode"
   s2 = "Normal Mode"
   s3 = "Hard Mode"
   s4 = "Go Back"
   @command_window = Window_Command.new(192, [s1, s2, s3, s4])
   @command_window.back_opacity = 160
   @command_window.x = 320 - @command_window.width / 2
   @command_window.y = 288
   # Play title BGM
   $game_system.bgm_play($data_system.title_bgm)
   # Stop playing ME and BGS
   Audio.me_stop
   Audio.bgs_stop
   # 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 command window
   @command_window.dispose
   # Dispose of title graphic
   @sprite.bitmap.dispose
   @sprite.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update command window
   @command_window.update
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by command window cursor position
     case @command_window.index
     when 0  # Easy Mode
       command_easy_mode
     when 1  # Normal Mode
       command_normal_mode
     when 2  # Hard Mode
       command_hard_mode
     when 3  # Go Back
       command_go_back
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Command: Easy Mode
 #--------------------------------------------------------------------------
 def command_easy_mode
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # 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
   # Set up initial party
   $game_party.setup_starting_members
   # 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
   # Switch to map screen
   $scene = Scene_Map.new
 end
 #--------------------------------------------------------------------------
 # * Command: Normal Mode
 #--------------------------------------------------------------------------
 def command_normal_mode
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # 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
   # Set up initial party
   $game_party.setup_starting_members
   # 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
   # Switch to map screen
   $scene = Scene_Title.new
 end
 #--------------------------------------------------------------------------
 # * Command: Hard Mode
 #--------------------------------------------------------------------------
 def command_hard_mode
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # 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
   # Set up initial party
   $game_party.setup_starting_members
   # 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
   # Switch to map screen
   $scene = Scene_Title.new
 end
 #--------------------------------------------------------------------------
 # * Command: Go Back
 #--------------------------------------------------------------------------
 def command_go_back
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Stop BGM
   Audio.bgm_stop
   # 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
   # Set up initial party
   $game_party.setup_starting_members
   # 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
   # Switch to map screen
   $scene = Scene_Title.new
 end
end


The coding was taken from scene_title and edited to show those new options and it works. I tried removing redundant lines of codes but don't know if removing anything else would be bad.

[Edit]

This seems to work for horizontal commands but the text on cursor is not working as intended.

Spoiler: ShowHide
#==============================================================================
# Window Horizontal Command
# Created By SephirothSpawn (11.03.05)
# Last Updated: 11.03.05
#==============================================================================

class Window_HorizCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(commands, width = 640, height = 64)
super(0, 0, width, height)
self.contents = Bitmap.new(width - 32, height - 32)
@commands = commands
@item_max = @commands.size
@column_max = @commands.size
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
  draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
#  index : item number
#--------------------------------------------------------------------------
def draw_item(index)
width = self.width - 32
off = width / @item_max
x = 40 + index * off #4
self.contents.draw_text(x, 0, off - 32, 32, @commands[index]) #32, 32
end
#--------------------------------------------------------------------------
# * Disable Item
#  index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end


The first command is aligned "well" while the rest are all to the right like this:

Current Project/s:

KK20

You would need to make a new class extending Window_Selectable to achieve this effect, namely how the window draws the cursor selection rectangle. You'll also need to modify the 'update' method so that pressing left or right would change difficulties and only by pressing up or down would the cursor move to Go Back.

In my Advance Wars Engine, when viewing unit stats, I had to do something along the lines of
Code: Inside some window class

rect = case self.index
when 0 then Rect.new(0, 0, 100, 32)
when 1 then Rect.new(0, 32, 50, 32)
when 2 then Rect.new(0, 64, 50, 32)
when 3 then Rect.new(80, 32, 50, 32)
...

where the cursor location and size is determined based on the window's index variable.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Vexus

Forgive me but I don't have any clue on how to do that myself so I might as well keep them in the same column.  Is it possible instead of having an option to go back, pressing ESC would send you back to the title screen?

Also would you mind checking what is the problem in the script above? The cursor/text are not getting aligned properly.

Thanks
Current Project/s:

KK20

Quote from: Vexus on March 19, 2015, 02:31:40 pm
Is it possible instead of having an option to go back, pressing ESC would send you back to the title screen?

Going off the scene code that you provided:

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update command window
    @command_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se) #<================== You should move your sound effect up here
      # Branch by command window cursor position
      case @command_window.index
      when 0  # Easy Mode
        command_easy_mode
      when 1  # Normal Mode
        command_normal_mode
      when 2  # Hard Mode
        command_hard_mode
      end
    elsif Input.trigger?(Input::B) #<================== Reads as "if the C button was not triggered but the B button was triggered"
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Title.new #<==================== You don't need command_go_back anymore
    end
  end

As for the window, I think it was because it was drawing based of the window's width and not the window content's width.

#--------------------------------------------------------------------------
# * Draw Item
#  index : item number
#--------------------------------------------------------------------------
def draw_item(index)
width = self.contents.width - 32 #<============== only change I made
off = width / @item_max
x = 40 + index * off #4
self.contents.draw_text(x, 0, off - 32, 32, @commands[index]) #32, 32
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Vexus

The go back part works, thanks :)

The other thing however is not working even with that line changed. The text is still not aligning with the cursor itself. I have a feeling there's something wrong in the script itself not overwriting some other script correctly.
Current Project/s:

KK20


#--------------------------------------------------------------------------
# * Draw Item
#  index : item number
#--------------------------------------------------------------------------
def draw_item(index)
off = self.width / @item_max
x = index * off
self.contents.draw_text(x, 0, off - 32, 32, @commands[index], 1) #32, 32
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Vexus

March 20, 2015, 03:32:44 pm #26 Last Edit: March 20, 2015, 06:22:26 pm by Vexus
That....worked!

Thanks haha, adding a picture based on which option is being highlighted shouldn't be much trouble if I mimic the status window script you gave me.

Well, at least that's what I think.

[Edit]

Nope, I don't see how can I make it work.

Any help please?
Current Project/s:

KK20

March 20, 2015, 06:52:15 pm #27 Last Edit: March 20, 2015, 06:54:08 pm by KK20
In your scene class under def main, you will want an instance variable that will hold your Sprite. Also set the coordinates.

@mode_sprite = Sprite.new
@mode_sprite.x, @mode_sprite.y = X_COORD, Y_COORD

And don't forget to dispose it too when changing scenes.

@mode_sprite.dispose


Moving onto the update method, it's the same procedure that I showed you before where you do something different based on the window's cursor index. You will want to change the sprite's bitmap based on the index value.

 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update command window
   @command_window.update

   # Draw the sprite
   @mode_sprite.bitmap = case @command_window.index
   when 0 then RPG::Cache.picture("easymodepic")
   when 1 then RPG::Cache.picture("normalmodepic")
   when 2 then RPG::Cache.picture("hardmodepic")
   end

   # If C button was pressed
   if Input.trigger?(Input::C)
     $game_system.se_play($data_system.decision_se)
     # Branch by command window cursor position
     case @command_window.index
     when 0  # Easy Mode
       command_easy_mode
     when 1  # Normal Mode
       command_normal_mode
     when 2  # Hard Mode
       command_hard_mode
     end
   elsif Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Title.new
   end
 end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Vexus

March 20, 2015, 06:54:37 pm #28 Last Edit: March 21, 2015, 11:24:34 am by Vexus
Gonna check it tomorrow as i'm about to go to sleep.

Thanks

I was getting close-ish... sort of.

Spoiler: ShowHide


Created a new bitmap and was going to try mimicking the same idea in the status screen.

[Edit]

I kept what I did so far plus added what you posted on the previous post and it works.

Thanks :)

Now, I either add text directly in the game based on the position of the cursor or make a picture with text in it and align only the picture.
Current Project/s: