• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
Resource icon

Resource Simple GUI Menu Version 2 (Customizable/Extendable) for Essentials v17.2 2.1

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
Hollow_Ego submitted a new resource:

Simple GUI Menu Version 2 (Customizable/Extendable) for Essentials v17.2 - An easy to use customizable menu base

Simple GUI Menu Version 2 (Customizable/Extendable) for Essentials v17.2

This is a plug&play GUI Menu and was designed as a base, so you can add your own menu items and use your own graphics. It comes with 7 working standard options (Pokedex, Pokemon, Bag, Trainercard, Save, Settings, Exit) and a clock on demand. It also supports debug mode. The icon will be on the bottom right corner and allows for quick access to the debug menu (press down to select it and up to...

Read more about this resource...
 

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
I want to keep the vanilla pause Menu until a certain switch is turned on, how can i make this possible?
 

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
I want to keep the vanilla pause Menu until a certain switch is turned on, how can i make this possible?

That is rather simple. In Scene_Map script section, change your def call_menu to look like this. Of course you have to replace the 1 with the number you use for that switch. You could also use a different condition after the if.

Ruby:
Expand Collapse Copy
def call_menu
    $game_temp.menu_calling = false
    $game_temp.in_menu = true
    $game_player.straighten
    $game_map.update
    
    if $game_switches[1]
      startMenu
    else
      sscene = PokemonPauseMenu_Scene.new
      sscreen = PokemonPauseMenu.new(sscene)
      sscreen.pbStartPokemonMenu
    end
    $game_temp.in_menu = false
  end

It basicallys looks if the given switch is on and if so opens the new menu and if not the default one.
 

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
So, whenever i click the Pokédex button, i get this error:

Ruby:
Expand Collapse Copy
---------------------------
Pokemon Immortal X/Oblivion Y
---------------------------
[Pokémon Essentials version 17.2]

Exception: NoMethodError

Message: undefined method `[]' for nil:NilClass

PScreen_PokedexMain:333:in `pbGetDexList'

PScreen_PokedexMain:330:in `each'

PScreen_PokedexMain:330:in `pbGetDexList'

PScreen_PokedexMain:355:in `pbRefreshDexList'

PScreen_PokedexMain:265:in `pbStartScene'

PScreen_PokedexMain:1198:in `pbStartScreen'

Pause Menu:112

Pause Menu:109:in `pbFadeOutIn'

Pause Menu:109

Pause Menu:84:in `call'
 

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
That seems to be an issue with the Pokedex. When exactly does this error occur? How did you try to open the Pokedex? Do you already have the Pokedex?
 

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
That seems to be an issue with the Pokedex. When exactly does this error occur? How did you try to open the Pokedex? Do you already have the Pokedex?
Actually, nevermind, the problem was the Pokedex, not the menu lol
 

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
Good to know :)
 

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
Just one last thing, i'm trying a lot to make the exit option prompt the save screen then close the game like the vanilla pause menu, but i'm having no success...
That is easy.
Add the following Proc after @@exitMenu = Proc.new{true}
Ruby:
Expand Collapse Copy
 @@closeGame = Proc.new { |sgm|
    sgm.pbHideMenu2
        if Kernel.pbConfirmMessage(_INTL("Are you sure you want to quit the game?"))
          scene = PokemonSave_Scene.new
          screen = PokemonSaveScreen.new(scene)
          screen.pbSaveScreen
          $scene = nil
          true
        else
          sgm.pbShowMenu2
          false
        end
  }
Then add it to @@menuItems like so:
Ruby:
Expand Collapse Copy
:closegame        => [6,"Close Game",@@closeGame]
You can also replace it with :exit if you don't need that
 

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
That is easy.
Add the following Proc after @@exitMenu = Proc.new{true}
Ruby:
Expand Collapse Copy
 @@closeGame = Proc.new { |sgm|
    sgm.pbHideMenu2
        if Kernel.pbConfirmMessage(_INTL("Are you sure you want to quit the game?"))
          scene = PokemonSave_Scene.new
          screen = PokemonSaveScreen.new(scene)
          screen.pbSaveScreen
          $scene = nil
          true
        else
          sgm.pbShowMenu2
          false
        end
  }
Then add it to @@menuItems like so:
Ruby:
Expand Collapse Copy
:closegame        => [6,"Close Game",@@closeGame]
You can also replace it with :exit if you don't need that
Yo, hello again, i want to know how can i make the names of the options appear under the icons
 

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
Yo, hello again, i want to know how can i make the names of the options appear under the icons
Yooo,
you can adjust the icons y position
instead of
Ruby:
Expand Collapse Copy
@@iconY           = @@viewportHeight/2
you do something like
Ruby:
Expand Collapse Copy
@@iconY           = (@@viewportHeight/2)+36

You probably need to fiddle around a bit to get it right. I believe the icon height was 32px so giving a little extra margin we get 36. That should do the trick.
 

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
Yooo,
you can adjust the icons y position
instead of
Ruby:
Expand Collapse Copy
@@iconY           = @@viewportHeight/2
you do something like
Ruby:
Expand Collapse Copy
@@iconY           = (@@viewportHeight/2)+36

You probably need to fiddle around a bit to get it right. I believe the icon height was 32px so giving a little extra margin we get 36. That should do the trick.
Um... This isn't exactly what i meant.
I meant something like this mockup:
capture072.png
 
Last edited:

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
Um... This isn't exactly what i meant.
I meant something like this mockup:
View attachment 4733
Sorry about that, For some reason I thought I had already added the texts. So yeah anyway. Checkout the update :)
I think that will get you what you need. Thanks for the idea.
 

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
Sorry about that, For some reason I thought I had already added the texts. So yeah anyway. Checkout the update :)
I think that will get you what you need. Thanks for the idea.
Lol, no problem, i'm glad i could help
 

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
Sorry about that, For some reason I thought I had already added the texts. So yeah anyway. Checkout the update :)
I think that will get you what you need. Thanks for the idea.
So, after i've updated it, i get this error after using every option, trying to come back to the menu:

Ruby:
Expand Collapse Copy
---------------------------
Pokemon Immortal X/Oblivion Y
---------------------------
[Pokémon Essentials version 17.2]

Exception: NameError

Message: uninitialized constant GUIMenu::PBDebugAll

Pause Menu:484:in `mainLoop'

Pause Menu:413:in `loop'

Pause Menu:509:in `mainLoop'

Pause Menu:607:in `startMenu'

Scene_Map:138:in `call_menu'

Scene_Map:229:in `old_update_ab'

Acro/Mach Bike:229:in `update'

Scene_Map:250:in `main'

Scene_Map:247:in `loop'

Scene_Map:252:in `main'
 

Hollow_Ego

Cooltrainer
Member
Joined
May 19, 2018
Posts
115
So, after i've updated it, i get this error after using every option, trying to come back to the menu:

Ruby:
Expand Collapse Copy
---------------------------
Pokemon Immortal X/Oblivion Y
---------------------------
[Pokémon Essentials version 17.2]

Exception: NameError

Message: uninitialized constant GUIMenu::PBDebugAll

Pause Menu:484:in `mainLoop'

Pause Menu:413:in `loop'

Pause Menu:509:in `mainLoop'

Pause Menu:607:in `startMenu'

Scene_Map:138:in `call_menu'

Scene_Map:229:in `old_update_ab'

Acro/Mach Bike:229:in `update'

Scene_Map:250:in `main'

Scene_Map:247:in `loop'

Scene_Map:252:in `main'
Could you show me your whole script, please?
I can't reproduce your error
 

BiggusWeeabus

"What's so funny about Biggus Dickus?"
Member
Joined
Sep 1, 2020
Posts
105
Could you show me your whole script, please?
I can't reproduce your error
Ruby:
Expand Collapse Copy
#===============================================================================
#                 Hollows Simple GUI Menu v2.1
#===============================================================================

class GUIMenu

#===============================================================================
#                           Methods for menu items
#===============================================================================
 
  # Bag
  @@openBag = Proc.new{
    item=0
    scene=PokemonBag_Scene.new
    screen=PokemonBagScreen.new(scene,$PokemonBag)
    pbFadeOutIn(99999) {
      item=screen.pbStartScreen
    }
    if item>0
      Kernel.pbUseKeyItemInField(item)
    end
  }

 
  # Trainer Card
  @@showTrainerCard= Proc.new{
    pbFadeOutIn(99999) {
      scene = PokemonTrainerCard_Scene.new
      screen = PokemonTrainerCardScreen.new(scene)
      screen.pbStartScreen
    }
  }
 
 
  # Save
  @@saveGame = Proc.new{ |sgm|
    if !$game_system || !$game_system.save_disabled
      #sgm.pbHideMenu2
      scene = PokemonSave_Scene.new
      screen = PokemonSaveScreen.new(scene)
      if screen.pbSaveScreen
        
      else
        sgm.pbShowMenu2
      end
    else
      Kernel.pbMessage("You can't save right now")
    end
  }
 
 
  # Settings
  @@openSettings = Proc.new{
    pbFadeOutIn(99999){
      scene = PokemonOption_Scene.new
      screen = PokemonOptionScreen.new(scene)
      screen.pbStartScreen
      pbUpdateSceneMap
    }
  }
 
 
 
  # Pokemon
  @@showParty = Proc.new{
    if $Trainer.party.length>0
      hiddenmove = nil
      pbFadeOutIn(99999){
        sscene = PokemonParty_Scene.new
        sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
        hiddenmove = sscreen.pbPokemonScreen
      }
      if hiddenmove
        disposeMenu
        Kernel.pbUseHiddenMove(hiddenmove[0],hiddenmove[1])
      end
    else
      Kernel.pbMessage("You don't have Pokemon yet.")
    end
  }
 
 
  # Pokedex
  @@openPokedex = Proc.new{
    if DEXDEPENDSONLOCATION
      pbFadeOutIn(99999){
        scene = PokemonPokedex_Scene.new
        screen = PokemonPokedexScreen.new(scene)
        screen.pbStartScreen
      }
    else
      if $PokemonGlobal.pokedexViable.length==1
        $PokemonGlobal.pokedexDex = $PokemonGlobal.pokedexViable[0]
        $PokemonGlobal.pokedexDex = -1 if $PokemonGlobal.pokedexDex==$PokemonGlobal.pokedexUnlocked.length-1
        pbFadeOutIn(99999){
          scene = PokemonPokedex_Scene.new
          screen = PokemonPokedexScreen.new(scene)
          screen.pbStartScreen
        }
      else
        pbFadeOutIn(99999){
          scene = PokemonPokedexMenu_Scene.new
          screen = PokemonPokedexMenuScreen.new(scene)
          screen.pbStartScreen
        }
      end
    end
  }
      
  # Phone
 
  @@openPhone = Proc.new{
 
  pbPlayDecisionSE
        pbFadeOutIn(99999){
          PokemonPhoneScene.new.start
        }
 
  }
 
  # Pokémon Amie
 
  @@openAmie = Proc.new{
        pbPlayDecisionSE()
        setAmiePokemon(pbGet(AMIEPOKEMON))
        pbFadeOutIn(99999) {
          scene = PokeAmie_Essentials_Scene.new
          screen = PokeAmie_EssentialsScreen.new(scene)
          screen.pbStartAmie(pbGet(AMIEPOKEMON),pbGet(AMIEINDEX))
            }
  }
      
 
  # Exit
#
  @@exitMenu = Proc.new{ |sgm|
    sgm.pbHideMenu2
        if Kernel.pbConfirmMessage(_INTL("Are you sure you want to quit the game?"))
          scene = PokemonSave_Scene.new
          screen = PokemonSaveScreen.new(scene)
          screen.pbSaveScreen
          $scene = nil
          true
        else
          sgm.pbShowMenu2
          false
        end}
 
    # Map
    
  @@showMap = Proc.new{
          pbPlayDecisionSE
        pbShowMap(-1,false)
        
  }

 
  # Your option
  # @@variableName = Proc.new{
    # your code goes here
  # }
 
  # Fame Checker
  @@openFameChecker = Proc.new{
     FameChecker.show
   }
 
 
#===============================================================================
#                         Settings (change accordingly)
#===============================================================================

  # Menu Items
  # Format: :key => [position,"name",proc to call action, proc for coditions (optional)
  # Name must be the file name and is also used as a display name
  # The variables holding the code need to be defined above this part
 
  @@menuItems={ 
    :pokemon     => [0,"Pokémon",@@showParty,Proc.new{$Trainer.party.length<=0}],
    :bag         => [1,"Bag",@@openBag],
    :amie        => [2,"Amie",@@openAmie],
    :map         => [3,"Map",@@showMap],
    :pokedex     => [4,"Pokédex",@@openPokedex,Proc.new{!$Trainer.pokedex || $PokemonGlobal.pokedexViable.length<=0}],
    :famechecker => [5,"Fame Checker",@@openFameChecker],
    :trainercard => [6,"Trainer",@@showTrainerCard],
    :phone       => [7,"Phone",@@openPhone],
    :save        => [8,"Save",@@saveGame],
    :settings    => [9,"Settings",@@openSettings],
    :exit        => [10,"Exit",@@exitMenu]
  }
 
  # Settings for the viewport of the icons
  @@viewportX       = 119 # Starting point x-axis of the viewport for the icons
  @@viewportY       = 108 # Starting point y-axis of the viewport for the icons
  @@viewportWidth   = 274
  @@viewportHeight  = 206

 
  # Icon and Icon Text Settings
  # Spacing between icons (from middle point to middle point)
  @@space           = 144 
  # where the icons should be placed relative to the viewport
  # the -36 are an offset to have it all centered includeing the text
  # remove or modify that part to reposition the icons and text on the y-axis
  @@iconY           = @@viewportHeight/2 - 20
  # Uses the name specified in @@menuItems (2nd position/index 1)
  @@showText        = true
  # Offset of the menu text. Set to a negative number if you want to move it further up
  # Don't forget to adjust the @@iconY if the centering is off
  @@textOffset      = 30
 
  @@textColor    = Color.new(240,240,240)
  @@textShadow   = Color.new(70,70,70)
 
  # Animation Settings
  @@animSpeed       = 8
  @@style           = 3
  @@jumpAmt         = 3
  @@zoomIcons       = true
  @@zoomFactor      = 1.5
 
  # Audio Settings
  @@moveSound       = true
  @@startSound      = true

 
  # Clock Settings
  @@clock           = true  # Whether or not to use a clock
  @@clockGraphic    = false # Wheter or not to use a clock graphics
  @@clockX          = 196   # Position of glock graphic on x-Axis
  @@clockY          = 290   # Position of glock graphic on y-Axis
 
  # Color of the time and menu text
  # Recommended colors: watch graphic=240,240,240 // clock graphic=18,22,36
  # Recommended shadow colors: watch graphic=160,160,160 // clock graphic=nil
  @@clockColor    = Color.new(240,240,240)
  @@clockShadow   = Color.new(70,70,70)

 
  # Where the time should appear relative to the bitmap
  # Recommend x values: watch graphic=330 // clock graphic=13
  # Recommend y values: watch graphic=77  // clock graphic=18
  @@timeX       = 330 
  @@timeY       = 77 
 
  # Enter a Font name here if you want to use a different font (e.g. "Power Clear" )
  # If you want to use the default put in nil
  # Recommended fonts: watch graphic=nil // clock graphic="QuiverItal"
  @@clockFont     = nil
  # Font size will only be relevant if a different font is used
  # Recommended size clock graphic=56
  @@clockFontSize = 56
 
#===============================================================================
#                                 Methods
#===============================================================================
  def initialize
    
    # Internatl - Organisation
    # Reset all variables
    @moving                   = false
    @options           = []
    @optionsIdx        = []
    @selectedIdx       = 0
    @debugSelected     = false
 
    pbSEPlay("menu") if @@startSound
    
    
    # Set the icon path
    folder              = @@style==1 ? "Single/" : "Dual/"
    @iconPath           = "Graphics/Pictures/Menu/"+ folder
    
    # Getting the icon sizes
    tempBitmap          = Bitmap.new(@iconPath+@@menuItems.values[0][1])
    @width              = tempBitmap.width
    @height             = tempBitmap.height
    @height            /= 2 if @@style==2 || @@style==3
    tempBitmap.dispose
 
    # setting the source rectangles for style 2+3
    @inactiveRect = Rect.new(0,0,@width,@height)        if @@style>1
    @activeRect   = Rect.new(0,@height,@width,@height)  if @@style>1
    
    # calculating the starting point
    @startingPointX     = (@@viewportWidth/2).floor
    
    # Viewport for menu background image
    @viewportBackground   = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewportBackground.z = 99998
    
    # Viewport for all icons
    @viewportIcons      = Viewport.new(@@viewportX,@@viewportY,@@viewportWidth,@@viewportHeight)
    @viewportIcons.z    = 99998

    
    @background         = Sprite.new(@viewportBackground)
    @background.bitmap  = Bitmap.new("Graphics/Pictures/Menu/background")
    @background.x       = 0
    @background.y       = 0
    
    counter     = 0
    @menuIcons  = {}
    @menuText   = {}

    # Make sure everything is in the right order
    @orderedMenu = Array.new(@@menuItems.length)
    @@menuItems.each{|key,value|
      @orderedMenu[value[0]] = key
    }
    
    # now use the ordered Array to iterate over it and create the icons
    for i in @orderedMenu
      value = @@menuItems[i]
      next if value[3] && value[3].call
      @menuIcons[value[1]]        = Sprite.new(@viewportIcons)
      @menuIcons[value[1]].bitmap = Bitmap.new(@iconPath+value[1])
    
      # Set the transformation point to the center of the icon
      @menuIcons[value[1]].ox = @menuIcons[value[1]].bitmap.width/2
      @menuIcons[value[1]].oy = @height/2
      @menuIcons[value[1]].x  = @startingPointX + @@space*counter
      @menuIcons[value[1]].y  = @@iconY
      
      # If style 2 or 3 make only top half visible
      @menuIcons[value[1]].src_rect = @inactiveRect
      
      @options.push(@menuIcons[value[1]])
      
      # Holds the keys to the selected index
      @optionsIdx.push(i)
      
      # Draw the icon names
      # Do so by creating new sprites with drawn text on it
      textBmpWidth              = @menuIcons[value[1]].bitmap.width*2
      textBmpHeight             = @menuIcons[value[1]].bitmap.height/4
      
      @menuText[value[1]+"Text"]        = Sprite.new(@viewportIcons)
      @menuText[value[1]+"Text"].bitmap = Bitmap.new(textBmpWidth,textBmpHeight)
      
      @menuText[value[1]+"Text"].ox = @menuText[value[1]+"Text"].bitmap.width/2
      @menuText[value[1]+"Text"].oy = textBmpHeight/2
      @menuText[value[1]+"Text"].x = @menuIcons[value[1]].x
      @menuText[value[1]+"Text"].y = @@iconY + @menuIcons[value[1]].y/2 + @@textOffset
    
      bitmap = @menuText[value[1]+"Text"].bitmap
    
      pbSetSystemFont(bitmap)
      tx = textBmpWidth/2
      ty = 0
      textPositions = [[_INTL("#{value[1]}"),tx,ty,2,@@textColor,@@textShadow]]
      pbDrawTextPositions(bitmap,textPositions) if @@showText
      
      counter+=1
    end
    
    
    # If style 2 or 3 is selected, color the active icon
    selectedIcon = @menuIcons[getValueFromHash(@optionsIdx[@selectedIdx])] if @@style>1
    selectedIcon.src_rect = @activeRect if @@style>1
    
    # Zoom in if zoom is activated
    selectedIcon.zoom_x = @@zoomFactor if @@zoomIcons
    selectedIcon.zoom_y = @@zoomFactor if @@zoomIcons
    
    # Show Debug Icon in Debug Mode only
    if $DEBUG
      # Store the bitmaps for easy swapping
      @debugIconActive=Bitmap.new("Graphics/Pictures/Menu/debug2")
      @debugIconInactive=Bitmap.new("Graphics/Pictures/Menu/debug")
      

      @debugIcon=Sprite.new(@viewportBackground)
      @debugIcon.bitmap=@debugIconInactive
      @debugIcon.x=460
      @debugIcon.y=330
    end

    
    if @@clock
      if @@clockGraphic
        @clock        = Sprite.new(@viewportBackground)
        @clock.bitmap = Bitmap.new("Graphics/Pictures/Menu/clock")
        @clock.x      = @@clockX
        @clock.y      = @@clockY
      end
      
      bitmap = @@clockGraphic ? @clock.bitmap : @background.bitmap
      if @@clockFont
        bitmap.font.size  = @@clockFontSize
        bitmap.font.name  = @@clockFont
      else
        pbSetSystemFont(bitmap)
      end
      
      # Draw the time
      # For bigger clocks it's better to use font bitmaps
      textPositions = [[_INTL("#{getTimeString}"),@@timeX,@@timeY,0,@@clockColor,@@clockShadow]]
      pbDrawTextPositions(bitmap,textPositions)
    end
    
end



#===============================================================================
#                                 Main Loop
#                               handles input
#===============================================================================

  def mainLoop
    frameSkip = 0
    loop do # Begin of the loop
      Graphics.update
      Input.update
      # Clock
      if @@clock && hasTimePassed?
        layer = @@clockGraphic ? @clock : @background
        layer.bitmap.clear
        btmp = @@clockGraphic ? Bitmap.new("Graphics/Pictures/Menu/clock") : Bitmap.new("Graphics/Pictures/Menu/background")
        layer.bitmap = btmp
        
        if @@clockFont
          layer.bitmap.font.size  = @@clockFontSize
          layer.bitmap.font.name  = @@clockFont
        else
          pbSetSystemFont(layer.bitmap)
        end

        textPositions=[[_INTL("#{getTimeString}"),@@timeX,@@timeY,0,@@clockColor,@@clockShadow]]
        pbDrawTextPositions(layer.bitmap,textPositions)
      end
    

#===============================================================================
#                                  Animation
#===============================================================================
      if (@@style==1 || @@style==3) && frameSkip==@@animSpeed
        
        currentSelection=@menuIcons[getValueFromHash(@optionsIdx[@selectedIdx])]
        direction= currentSelection.y==@@iconY + @@jumpAmt*-1 ? @@jumpAmt : @@jumpAmt*-1
        for i in @menuIcons
          
          i[1].y+=direction if i[1]==currentSelection
          i[1].y = @@iconY if i[1]!=currentSelection && !i[0].include?("Text")
        end
        frameSkip = 0
      end
#===============================================================================
#                                  Controls
#===============================================================================

# ----------------- Right Input ----------------------
      if Input.trigger?(Input::RIGHT) && !@debugSelected && !@moving
        oldIdx        = @selectedIdx
        @selectedIdx += 1
        @selectedIdx  = @selectedIdx>@menuIcons.length-1 ? 0 : @selectedIdx
        direction     = oldIdx>@selectedIdx ? "right" : "left"
      
        @@graphicsUpdateRate = oldIdx>@selectedIdx ?  @@space/(@@animSpeed/2) : @@space/@@animSpeed
        moveIcons(direction,oldIdx)
      end

# ----------------- Left Input ----------------------
      if Input.trigger?(Input::LEFT) && !@debugSelected && !@moving
        oldIdx        = @selectedIdx
        @selectedIdx -=1
        @selectedIdx  = @selectedIdx<0 ? @menuIcons.length-1 : @selectedIdx
        direction     = oldIdx>@selectedIdx ? "right" : "left"
      
        @@graphicsUpdateRate = oldIdx>@selectedIdx ?  @@space/@@animSpeed : @@space/(@@animSpeed/2)
        moveIcons(direction,oldIdx)
      end

# ----------------- C Input ----------------------
      if Input.trigger?(Input::C) && !@moving
        # Debug
        if @debugSelected && $DEBUG
          pbFadeOutIn(99999) { pbDebugMenu }
        else
          # Get what to do as a proc (defined above)
          proc = getValueFromHash(@optionsIdx[@selectedIdx],2)
          result = proc.call(self)
          PBDebugAll.log("Result: #{result}")
          break if result
        end
      end
    
# ----------------- Other Input ----------------------

      # Select/Deselect Debug Icon
      if Input.trigger?(Input::DOWN) && $DEBUG
        pbSEPlay("choose") if @@moveSound
        @debugSelected=true
        @debugIcon.bitmap=@debugIconActive
      end

      if Input.trigger?(Input::UP) && $DEBUG
        pbSEPlay("choose") if @@moveSound
        @debugSelected=false
        @debugIcon.bitmap=@debugIconInactive
      end

      # Cancel with X
      if Input.trigger?(Input::B)
        break
      end
    frameSkip += 1
    end # end of loop
    pbSEPlay("exit") if @@startSound
    disposeMenu 
  end # end of def main



#===============================================================================
#                              Class Helpers
#===============================================================================

  # Get the value from a hash by key
  # Only for @@menuItems
  # valueIdx = index of the value to retrieve
  def getValueFromHash(key,valueIdx=1)
    return @@menuItems[key][valueIdx]
  end


  # Moves the icons accordingly
  def moveIcons(direction,oldIdx)
    pbSEPlay("choose") if @@moveSound
    oldSelectedIcon     = @menuIcons[getValueFromHash(@optionsIdx[oldIdx])]
    newSelectedIcon     = @menuIcons[getValueFromHash(@optionsIdx[@selectedIdx])]
    dir                 = direction=="left" ? -1 : 1
    @moving             = true
    counter             = 0
    
    # Make nlock transfer to decolor old selction
    # Only if the style is set to 2 or 3
    oldSelectedIcon.src_rect = @inactiveRect if @@style>1
    
    # Resets zoom to 0
    oldSelectedIcon.zoom_x = 1
    oldSelectedIcon.zoom_y = 1
    
    # Every icon gets only moved by 1 pixel each frame
    # Graphics are updated when the counter is equal to the calculated update rate
    # This makes it so that the player doesn't see the movement in 1px steps
    # The loop stops when the selected icon is in the starting point (=@startingPointX)
    loop do
      for i in @menuIcons
        i[1].x += dir
        @menuText[i[0]+"Text"].x +=dir
      end
      counter += 1
      Graphics.update if counter == @@graphicsUpdateRate
      counter = counter == @@graphicsUpdateRate ? 0 : counter # reset counter
      break if newSelectedIcon.x == @startingPointX
    end
    
    # make block transfer to color the new selection
    newSelectedIcon.src_rect = @activeRect if @@style>1
    
    # Zooms in on selected icon
    newSelectedIcon.zoom_x = @@zoomFactor if @@zoomIcons
    newSelectedIcon.zoom_y = @@zoomFactor if @@zoomIcons
    
    Graphics.update
    @moving=false
  end


  # Gets rid of all viewports and graphics
  def disposeMenu
    pbDisposeSpriteHash(@menuIcons)
    pbDisposeSpriteHash(@menuText)
    @background.dispose
    @clock.dispose if @clock
    @viewportBackground.dispose
    @viewportIcons.dispose
    $game_temp.in_menu = false
  end

  def pbHideMenu2
    @viewportBackground.visible=false
    @viewportIcons.visible=false
  end


  def pbShowMenu2
    @viewportBackground.visible=true
    @viewportIcons.visible=true
  end

end # End of class




#===============================================================================
#                            General Purpose Helpers
#===============================================================================

# Use this line to open the menu
def startMenu
  $game_temp.in_menu  = true
  sgm                 = GUIMenu.new
  sgm.mainLoop
end



def startBenchMarkTest
  mark = Benchmark.measure {
    2.times do
      GUIMenu.new
    end
}

PBDebug.log("Opening the menu: #{mark}") 
end


 
# Time related methods
$lastHour    = 0
$lastMinute  = 0
def getTimeString
  $lastHour    = getHour
  $lastMinute  = getMinute
  return "#{$lastHour}:#{$lastMinute}"
end

def hasTimePassed?
  return $lastHour!=getHour || $lastMinute!=getMinute
end

def getHour
  time=pbGetTimeNow
  return time.hour
end

def getMinute
  time=pbGetTimeNow
  if time.min<10
    return "0#{time.min}"
    else return time.min
  end
end
 
Back
Top