Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Sliding Menu 1.0, Another menu from me
stripe103
post Jun 1 2010, 10:25 AM
Post #1


PHP ERROR: Couldn't get value from UInteger. Value too large
Group Icon

Group: Revolutionary
Posts: 740
Type: Mapper
RM Skill: Intermediate




Sliding Menu
I'm not good with names no...
Version: 1.0
Author: Stripe103
Date: June 1, 2010



Version History
Version 1.0 (Sep 23, 2009)
Initial Release


Description

Here comes another menu that I've made, but this is looking better.
Instead of having everything in a static page this script slides the windows in.
It is easier to test so download the demo.


Features

Sliding windows
Background continues if you want
Background fades to desired color

Screenshots


Instructions

Just put above main and below the default script and you are ready to go!
Oh and the configuration is in the top of the script.

Script

Script
CODE
#==============================================================================
# * Scene_Menu
#   By: Stripe103
#  Ver: 1.0
#------------------------------------------------------------------------------
# CONFIGURATION
#==============================================================================
#
# FADE TO COLOR
# When you are going into the menu the screen fades to this color.
RED   = -100
GREEN = -100
BLUE  = -100
GREY  = 150
#
# Choose if you want the game to pause when in the menu.
PAUSEMENU = false
#
#==============================================================================

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Sliding Graphics
# Author: Kread-EX
# Version 1.0
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#  TERMS OF USAGE
# #------------------------------------------------------------------------------------------------------------------
# #  You are free to adapt this work to suit your needs.
# #  You can use this work both for commercial and non-commercial work.
# #  Credit is appreciated.
# #------------------------------------------------------------------------------------------------------------------

#===========================================================
# INTRODUCTION
#
# Adds moving capabilities to your sprites and windows. Only useful to scripters.
# Cross-engine (Works for XP and VX).
# Easy to use and no ZeroDivision error.
# Four methods to know:
#
# x_slide(new_x, incrementation) <-- Horizontal sliding
# y_slide(new_y, incrementation) <-- Vertical sliding
# bi_slide(new_x, new_y, x_incrementation, y_incrementation) <-- Dual sliding
# is_sliding? <-- Query to check if sliding.
#===========================================================

#===========================================================
# ** GFX_Slider
#------------------------------------------------------------------------------
# This is mixed into windows and sprites to make them slide.
#===========================================================

module GFX_Slider
  #--------------------------------------------------------------------------
  # * Perform horizontal slide
  #--------------------------------------------------------------------------
  def x_slide(x_dest, inc)
    @x_destination = x_dest
    @x_increment= inc
  end
  #--------------------------------------------------------------------------
  # * Perform vertical slide
  #--------------------------------------------------------------------------
  def y_slide(y_dest, inc)
    @y_destination = y_dest
    @y_increment = inc
  end
  #--------------------------------------------------------------------------
  # * Perform both
  #--------------------------------------------------------------------------
  def bi_slide(x_dest, y_dest, x_inc, y_inc)
    x_slide(x_dest, x_inc)
    y_slide(y_dest, y_inc)
  end
  #--------------------------------------------------------------------------
  # * Update horizontal motion
  #--------------------------------------------------------------------------
  def update_x_slide
    return if @x_destination == nil
    if @x_destination > self.x
      self.x = [self.x + @x_increment, @x_destination].min
    else
      self.x = [self.x - @x_increment, @x_destination].max
    end
    @x_destination = nil if @x_destination == self.x
  end
  #--------------------------------------------------------------------------
  # * Update vertical motion
  #--------------------------------------------------------------------------
  def update_y_slide
    return if @y_destination == nil
    if @y_destination > self.y
      self.y = [self.y + @y_increment, @y_destination].min
    else
      self.y = [self.y - @y_increment, @y_destination].max
    end
    @y_destination = nil if @y_destination == self.y
  end
  #--------------------------------------------------------------------------
  # * Checks if sliding
  #--------------------------------------------------------------------------
  def is_sliding?
    return (@x_destination != nil || @y_destination != nil)
  end
  #--------------------------------------------------------------------------
end

#===========================================================
# ** Window_Base implementation
#===========================================================

class Window_Base < Window
  include GFX_Slider
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  unless method_defined?(:kread_slide_window_init)
    alias_method  :kread_slide_window_init, :initialize
  end
  def initialize(x, y, width, height)
    kread_slide_window_init(x, y, width, height) # Original call
    # When these two variables are different than the coordinates, the window moves.
    @x_destination = nil
    @y_destination = nil
    # Coordinates incrementation.
    @x_increment = 0
    @y_increment = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  unless method_defined?(:kread_slide_window_update)
    alias_method  :kread_slide_window_update, :update
  end
  def update
    kread_slide_window_update  # Original call
    update_x_slide
    update_y_slide
    return if self.is_sliding?
  end
  #--------------------------------------------------------------------------
end

#===========================================================
# ** Sprite implementation
#===========================================================

class Sprite
  include GFX_Slider
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  unless method_defined?(:kread_slide_sprite_init)
    alias_method  :kread_slide_sprite_init, :initialize
  end
  def initialize(viewport = nil)
    kread_slide_sprite_init(viewport) # Original call
    # When these two variables are different than the coordinates, the window moves.
    @x_destination = nil
    @y_destination = nil
    # Coordinates incrementation.
    @x_increment = 0
    @y_increment = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  unless method_defined?(:kread_slide_sprite_update)
    alias_method  :kread_slide_sprite_update, :update
  end
  def update
    kread_slide_sprite_update  # Original call
    update_x_slide
    update_y_slide
    return if self.is_sliding?
  end
  #--------------------------------------------------------------------------
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================
class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
    @end_index = -1
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Save"
    s6 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.x = 240
    @command_window.y = 130
    @command_window.opacity = 0
    @command_window.index = @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 end window
    e1 = "To Title"
    e2 = "Shutdown"
    e3 = "Cancel"
    @end_window = Window_Command.new(160, [e1, e2, e3])
    @end_window.x = 240
    @end_window.y = 480
    @end_window.opacity = 0
    @end_window.index = @end_index
    # Make play time window
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 0
    @playtime_window.opacity = 0
    # Make steps window
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 394
    @steps_window.opacity = 0
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 0
    @gold_window.opacity = 0
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 640
    @status_window.y = 0
    @status_window.opacity = 0
    # Make map background
    @spriteset = Spriteset_Map.new
    # Darken the screen
    @view = Viewport.new(0, 0, 640, 480)
    @view.tone = Tone.new(RED, GREEN, BLUE, GREY)
    # 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
    @end_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
    @spriteset.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update map background if the user wants it
    if PAUSEMENU != true
      @spriteset.update
      $game_map.update
      $game_system.map_interpreter.update
      $game_system.update
      $game_screen.update
    end
    # Update windows
    @command_window.update
    @end_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
    # If end window is active: call update_end
    if @end_window.active
      update_end
      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)
        # Slide the window
        @command_window.x_slide(-240, 20)
        @playtime_window.x_slide(-460, 20)
        @steps_window.x_slide(-460, 20)
        @gold_window.x_slide(0, 20)
        @status_window.x_slide(160, 20)
        # 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)
        # Slide the window
        @command_window.x_slide(-240, 20)
        @playtime_window.x_slide(-460, 20)
        @steps_window.x_slide(-460, 20)
        @gold_window.x_slide(0, 20)
        @status_window.x_slide(160, 20)
        # 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)
        # Slide the window
        @command_window.x_slide(-240, 20)
        @playtime_window.x_slide(-460, 20)
        @steps_window.x_slide(-460, 20)
        @gold_window.x_slide(0, 20)
        @status_window.x_slide(160, 20)
        # 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)
        # Slide window
        @command_window.y_slide(-30, 20)
        @playtime_window.y_slide(-160, 20)
        @steps_window.y_slide(234, 20)
        @gold_window.y_slide(-160, 20)
        @end_window.y_slide(320, 20)
        # Make end window active
        @command_window.active = false
        @end_window.active = true
        @end_window.index = 0
      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)
      # Slide the window
      @command_window.x_slide(240, 20)
      @playtime_window.x_slide(0, 20)
      @steps_window.x_slide(0, 20)
      @gold_window.x_slide(480, 20)
      @status_window.x_slide(640, 20)
      # 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
  #--------------------------------------------------------------------------
  # * Frame Update (when end window is active)
  #--------------------------------------------------------------------------
  def update_end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Slide the window
      @command_window.y_slide(130, 20)
      @playtime_window.y_slide(0, 20)
      @steps_window.y_slide(396, 20)
      @gold_window.y_slide(0, 20)
      @status_window.y_slide(0, 20)
      @end_window.y_slide(480, 20)
      # Make command window active
      @command_window.active = true
      @end_window.active = false
      @end_window.index = -1
      return
    end
    
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @end_window.index
      when 0  # to title
        command_to_title
      when 1  # shutdown
        command_shutdown
      when 2  # quit
        command_cancel
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Process When Choosing [To Title] Command
  #--------------------------------------------------------------------------
  def command_to_title
    # 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)
    # Switch to title screen
    $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  # * Process When Choosing [Shutdown] Command
  #--------------------------------------------------------------------------
  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
  #--------------------------------------------------------------------------
  # *  Process When Choosing [Cancel] Command
  #--------------------------------------------------------------------------
  def command_cancel
    # Play cancel SE
      $game_system.se_play($data_system.decision_se)
      # Slide the window
      @command_window.y_slide(130, 20)
      @playtime_window.y_slide(0, 20)
      @steps_window.y_slide(396, 20)
      @gold_window.y_slide(0, 20)
      @status_window.y_slide(0, 20)
      @end_window.y_slide(480, 20)
      # Make command window active
      @command_window.active = true
      @end_window.active = false
      @end_window.index = -1
  end
end



Credit

  • Stripe103 for the menu itself.
  • Kread-EX for making his "Graphics Slider".


Support

If you have any questions, post in this thread or PM me as always.

Known Compatibility Issues

None for the moment. Post if you find any.

Demo
[DOWNLOAD]
Filetype: .exe
Filesize: 258 Kb
Host: Mediafire


Upcoming features

Making the item, equip, skills and maybe the save screen sliding as well.


__________________________

By Axerax

The rest of my sig



Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies (1 - 4)
stripe103
post Jun 8 2010, 03:24 AM
Post #2


PHP ERROR: Couldn't get value from UInteger. Value too large
Group Icon

Group: Revolutionary
Posts: 740
Type: Mapper
RM Skill: Intermediate




Come on. Is it that bad?


__________________________

By Axerax

The rest of my sig



Go to the top of the page
 
+Quote Post
   
Kread-EX
post Jun 8 2010, 03:34 AM
Post #3


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




It clashes a little with the sub-menus being normal. Also, you deleted the Scene_Save in the demo, so it crashes when you try to save.

But it's a good start. Maybe you should try to make the submenus on the same style.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Locke
post Jun 11 2010, 09:47 PM
Post #4


Level 10
Group Icon

Group: Revolutionary
Posts: 151
Type: Mapper
RM Skill: Intermediate




Nice indeed if i say so


__________________________
We are one (Really i,m not joking)



I've seen many things when mankind rule the land


Which Final Fantasy Character Are You?
Go to the top of the page
 
+Quote Post
   
Blood_RzR
post Jun 11 2010, 09:57 PM
Post #5


Level 3
Group Icon

Group: Member
Posts: 38
Type: Event Designer
RM Skill: Intermediate




hey it's me ragnaroc444, stripes! This is good been looking for a new menu! thanks man!
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 09:39 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker