[XP] Enhanced DMS v 1.00

Started by fugibo, March 11, 2008, 12:57:59 pm

Previous topic - Next topic

fugibo

March 11, 2008, 12:57:59 pm Last Edit: September 30, 2009, 01:48:35 pm by Longfellow
Enhanced DMS (Default Menu System) (EDMS)
Authors: Longfellow
Version: 1.00
Type: Custom Menu System
Key Term: Custom Menu System



Introduction

This script is a graphically enhanced version of the default menu system, with an added Load option. I decided to make it so that I could get back used to RGSS


Features


  • Has all the options of the DMS, plus load
  • Uses Icons and gradients
  • Has map as background
  • Has a real-world time window that replaces the steps window
  • Under 350 lines of actual code



Screenshots

Screenshot: ShowHide






Script

Spoiler: ShowHide

#============================================================================
# Enhanced Defualt Menu System (EDMS) v 1.0.0
# by WcW
#
# Introduction:
#   I made this script just so I could actually make a useful script and get
# back used to RGSS. It has all the features of the defualt menu system, but
# also features icons, HP, SP, and EXP bars, the map as a background, and
# a slightly altered layout.
#
# Features:
# - Has all of the options of the defualt menu system, plus load
# - Has icons in the command window
# - Uses gradient bars
# - Features map as the background
# - Has Playtime, Real Time, and Gold displayed
# - Low chance of incompatibility
#
# Instructions:
#   Just paste this below the defualt scripts and above Blizz's script and Main
# in your script editor.
#   Also, you will need to have a file called "x-icon.png" in your
# Graphics/Icons folder. If you do not have this, you will get an error. This
# is the icon used for the "Exit" option in the menu.
#
# Compatiblity:
#   Is probably incompatible with other CMS's. Tested with RTAB and Tons of
# Add-On's. If you find any compatibility problems, please post them at
# http://forums.chaos-project.com/.
#============================================================================

#----------------------------------------------------------------------------
# * Window Command (WcW)
#     Displays options w/ icons. Feel free to use this in your own script.
#----------------------------------------------------------------------------
class Window_Command_WcW < Window_Selectable
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(x, y, width, commands)
    # Calls original initialize method
    super(x, y, width, commands.size * 32 + 32)
    # Sets maximum items and commands variables
    @item_max = commands.size
    @commands = commands
    # Initializes the @disabled array, which is used for drawing disabled items
    @disabled = []; @commands.size.times { @disabled.push false }
    # Creates a new bitmap for the contents
    self.contents = Bitmap.new(width-32, commands.size * 32)
    # Sets the index to 0
    self.index = 0
    # Draws contents
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refreshes Contents
  #--------------------------------------------------------------------------
  def refresh
    # Clears bitmap
    self.contents.clear
    # For each command in the @commands array....
    @commands.size.times {|i|
      # Get the icon from RPG::Cache
      self.contents.blt(4, 32 * i + 4, RPG::Cache.icon(@commands[i][0]),
          Rect.new(0, 0, 24, 24))
      # If the disabled array has this down for this disabled, draw it as
      # disabled, if not, draw it normal
      self.contents.font.color = @disabled[i] ? disabled_color : normal_color
      # Draw the command
      self.contents.draw_text(34, 32 * i, self.contents.width - 34, 32,
          @commands[i][1], 0)
    }
  end
  #--------------------------------------------------------------------------
  # * Disable Items
  #--------------------------------------------------------------------------
  def disable_items(*indexes)
    # For each index in the given argument array,
    indexes.each {|index|
      # Set that index to disabled in the @disabled array
      @disabled[index] = true
    }
    # Re-draw contents
    refresh 
  end
  #--------------------------------------------------------------------------
  # * Enable Items
  #--------------------------------------------------------------------------
  def enable_items(*indexes)
    # For each index in the given argument array,
    indexes.each {|index|
      # Set that index to enabled in the @disabled array
      @disable[index] = false
    }
    # Red-draw contents
    refresh
  end
end

#----------------------------------------------------------------------------
# * Status Window (Menu)
#     Displays actor sprtie, name, level, HP (w/ graident), SP (w/ gradient),
#   XP (w/ gradient), and state. This is specifically designed for this CMS
#   and probably will not fit in anywhere else.
#----------------------------------------------------------------------------
class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(160, 16, 464, $game_party.actors.size*80+32)
    self.contents = Bitmap.new(432, $game_party.actors.size*80)
    @item_max = $game_party.actors.size
    self.index = -1
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Gradient Bar
  #     Draws a white slant, then a slant on top of that made with a black-to-
  #   gray gradient, then tops it off with another gradient made of the two
  #   given colors that's width is multiplied times fill.
  #--------------------------------------------------------------------------
  def draw_gradient_bar(x, y, width, height, c1, c2, fill)
    # Sets white, black, and gray colors
    white = Color.new(255, 255, 255, 255)
    black = Color.new(0, 0, 0, 255)
    gray = Color.new(100, 100, 100, 255)
    # For every row of pixels...
    height.times {|i|
      # Draw white slant
      self.contents.fill_rect(x+(height-i-1), y+i, width-height, 1, white)
      # Unless it is the last row
      unless i == height - 1
        # Draws black-gray gradient slant
        red = black.red + ((gray.red - black.red) / height * i)
        green = black.green + ((gray.green - black.green) / height * i)
        blue = black.blue + ((gray.blue - black.blue) / height * i)
        self.contents.fill_rect(x+(height-i), y+i, width-height-1, 1,
            Color.new(red, green, blue, 255))
        # Draws main slant
        red = c1.red + ((c2.red - c1.red) / height * i)
        green = c1.green + ((c2.green - c1.green) / height * i)
        blue = c1.blue + ((c2.blue - c1.blue) / height * i)
        self.contents.fill_rect(x+(height-i), y+i, (width-height-1).to_f*fill,
            1, Color.new(red, green, blue, 255))
           
      end
    }
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Bar
  #     Draws the specified text, then draws a gradient bar based on the given
  #   stat with the specified colors. If "status" is true, then it will also
  #   change the font color if, say, HP or SP critical or knocked out, if not
  #   it will only use the normal font color, which is used for XP.
  #--------------------------------------------------------------------------
  def draw_actor_bar(x, y, text, stat1, stat2, c1, c2, status=true)
    # Sets font color to the system color and makes it bold
    self.contents.font.color = system_color
    self.contents.font.bold = true
    # Draws the specified text
    self.contents.draw_text(x, y, 28, 32, text, 0)
    # Changes font color to critical or knockout if "status" is true
    self.contents.font.color = ! status ? normal_color :
        stat1 == 0 && stat1 != stat2 ? knockout_color :
        stat1 <= stat2 / 4 ? crisis_color : normal_color
    # Un-bolds the text
    self.contents.font.bold = false
    # Sets array of the words to be drawn
    words = [stat1.to_s, "/", stat2.to_s]
    # Draws everything within the "words" array
    3.times {|i| self.contents.draw_text(x+40, y, 106, 16, words[i], i) }
    # Sets fill
    fill = stat1 == 0 ? 0.0 : stat1.to_f / stat2.to_f
    # Draws gradient bar
    draw_gradient_bar(x+40, y+18, 106, 8, c1, c2, fill)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # clears contents
    self.contents.clear
    # for each actor in the party
    $game_party.actors.size.times {|i|
      # Draws actor sprite
      character = RPG::Cache.character($game_party.actors[i].character_name,
          $game_party.actors[i].character_hue)
      self.contents.blt(0, i*80+8, character, Rect.new(0, 0,
          character.width / 4, character.height / 4))
      # Draws actor name
      self.contents.font.size = 20
      self.contents.font.bold = true
      self.contents.font.color = normal_color
      self.contents.draw_text(36, i*80, 92, 32, $game_party.actors[i].name, 0)
      # Draws actor level
      self.contents.draw_text(36, i*80+32, 92, 32,
          "Lvl #{$game_party.actors[i].level.to_s}", 0)
      # Draws actor HP
      draw_actor_bar(132, i*80, "HP", $game_party.actors[i].hp,
          $game_party.actors[i].maxhp, Color.new(80, 0, 0, 255),
          Color.new(255, 0, 0, 255))
      # Draws actor SP
      draw_actor_bar(286, i*80, "SP", $game_party.actors[i].sp,
          $game_party.actors[i].maxsp, Color.new(0, 0, 80, 255),
          Color.new(0, 0, 255, 255))
      # Draws actor XP
      draw_actor_bar(132, i*80+32, "XP", $game_party.actors[i].exp,
          $game_party.actors[i].next_exp_s.to_i, Color.new(0, 80, 0, 255),
          Color.new(0, 255, 0, 255), false)
      # Draws actor state
      state = ''
      last_rating = 0
      $game_party.actors[i].states.each {|s|
        if $data_states[s].rating > 0 && $data_states[s].rating >= last_rating
          state = $data_states[s].name
          last_rating = $data_states[s].rating
        end
      }
      state = state == '' ? 'Normal' : state
      self.contents.font.color = $game_party.actors[i].hp == 0 ?
          knockout_color : normal_color
      self.contents.draw_text(286, i*80+32, 146, 32, state, 0)
    }
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rect
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If inactive...
    if @index < 0
      # Get rid of that nasty cursor rect
      self.cursor_rect.empty
    else
      # Set the cursor rect to the index
      self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
    end
  end
end

#----------------------------------------------------------------------------
# * Gold Window (Menu)
#     Resized and set to position.
#----------------------------------------------------------------------------
class Window_MenuGold < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    # Call original method
    super(16, 392, 192, 64)
    # Create a new bitmap 160 x 32
    self.contents = Bitmap.new(160, 32)
    # Draw Contents
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # clears bitmap
    self.contents.clear
    # Set font color to system color
    self.contents.font.color = system_color
    # Get the width it would take to draw the gold word set in the database
    width = self.contents.text_size($data_system.words.gold).width
    # Draw the above-mentioned gold word
    self.contents.draw_text(160-width, 0, width, 32, $data_system.words.gold,
        2)
    # Set font color to normal
    self.contents.font.color = normal_color
    # Draw current amount of gold
    self.contents.draw_text(0, 0, 160-width, 32, $game_party.gold.to_s, 2)
  end
end

#----------------------------------------------------------------------------
# * Time Window (Menu)
#     Draws the real world time. Of my own design, with a small amount of code
#   borrowed from the defualt Window_PlayTime.
#----------------------------------------------------------------------------
class Window_MenuTime < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    # Call original Method
    super(224, 392, 192, 64)
    # Create new 160 x 32 bitmap
    self.contents = Bitmap.new(160, 32)
    # Draws contents
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Clears bitmap
    self.contents.clear
    # Sets font color to system color
    self.contents.font.color = system_color
    # Draws the word "Time:"
    self.contents.draw_text(0, 0, 160, 32, "Time:", 0)
    # Sets the font color to the normal color
    self.contents.font.color = normal_color
    # Gets the current time
    time = Time.now
    # Draws current time
    self.contents.draw_text(0, 0, 160, 32, sprintf("%02d:%02d:%02d", time.hour,
        time.min, time.sec), 2)
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # call original
    super()
    # redraw contents
    refresh
  end
end

#----------------------------------------------------------------------------
# * Playtime Window
#     A resized and positioned version of the original
#----------------------------------------------------------------------------
class Window_PlayTime < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    # Calls original method
    super(432, 392, 192, 64)
    # Creates new 160 x 32 bitmap
    self.contents = Bitmap.new(160, 32)
    # Get the current number of seconds
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    # Draw contents
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Clears bitmap
    self.contents.clear
    # *sigh* You should know this by now.
    self.contents.font.color = system_color
    # writes "Playtime:"
    self.contents.draw_text(0, 0, 160, 32, 'Playtime:', 0)
    # If you don't know this after reading it commented half a dozen times,
    # you fail as a scripter.
    self.contents.font.color = normal_color
    # Gets the current number of seconds AGAIN
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    # Turns it into numbers
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    # Draws the numbers
    self.contents.draw_text(0, 0, 160, 32,
        sprintf("%02d:%02d:%02d", hour, min, sec), 2)
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # Calls original method
    super()
    # Redraws contents if the playtime has changed
    refresh if Graphics.frame_count / Graphics.frame_rate != @total_sec
  end
end

#----------------------------------------------------------------------------
# * Load Scene (Menu)
#     Modified so that it goes back to the menu, instead of the title screen.
#----------------------------------------------------------------------------
class Scene_LoadMenu < Scene_Load
  #--------------------------------------------------------------------------
  # * On Cancel
  #     Called when you exit the scene.
  #--------------------------------------------------------------------------
  def on_cancel
    # Plays buzzer SE
    $game_system.se_play($data_system.buzzer_se)
    # Goes back to the menu, with the cursor set to Load
    $scene = Scene_Menu.new(5)
  end
end

#----------------------------------------------------------------------------
# * Menu Scene
#     The scene that launches the menu.
#----------------------------------------------------------------------------
class Scene_Menu
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(index = 0)
    # Sets the @index variable to the given index
    @index = index
  end
  #--------------------------------------------------------------------------
  # * Main
  #--------------------------------------------------------------------------
  def main
    # Create map background
    @map = Spriteset_Map.new
    # Create command window
    @command = Window_Command_WcW.new(16, 16, 128, [["032-Item01",
        $data_system.words.item], ["044-Skill01", $data_system.words.skill],
        ["001-Weapon01", $data_system.words.equip], ["050-Skill07", "Status"],
        ["047-Skill04", "Save"], ["048-Skill05", "Load"], ["x-icon","Exit"]
        ])
    # Set command window opacity
    @command.back_opacity = 200
    # Set command index
    @command.index = @index
    # Disable options if party size is zero
    if $game_party.actors.size <= 0
      @command.disable_items(0, 1, 2, 3)
    end
    # Disable save if forbidden
    if $game_system.save_disabled
      @command.disable_items(4)
    end
    # Create status window
    @status = Window_MenuStatus.new
    # Set status window opacity
    @status.back_opacity = 200
    # Creates gold window
    @gold = Window_MenuGold.new
    # Set gold window opacity
    @gold.back_opacity = 200
    # Creates menu time window
    @time = Window_MenuTime.new
    # Set time window opacity
    @time.back_opacity = 200
    # *sigh* creates playtime window and set opacity...
    @playtime = Window_PlayTime.new
    @playtime.back_opacity = 200
    # Transitions screen
    Graphics.transition
    # Main loop
    loop do
      # Frame update
      Graphics.update
      Input.update
      # Updates map & windows
      @map.update
      @command.update
      @status.update
      @gold.update
      @time.update
      @playtime.update
      # Update command or status
      update
      # Ends loop if scene no longer is self
      if $scene != self
        break
      end
    end
    # Freezes graphics
    Graphics.freeze
    # Disposes map and windows
    @map.dispose
    @command.dispose
    @status.dispose
    @gold.dispose
    @time.dispose
    @playtime.dispose
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # Updates @command or @status processing depending on which is active
    if @command.active
      update_command
      return
    end
    if @status.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Update Command
  #--------------------------------------------------------------------------
  def update_command
    # If you pressed B, it plays the cancel SE and exits the menu, then goes
    # back to the map.
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    end
    # Check to see if you pressed C or not
    if Input.trigger?(Input::C)
      # Does stuff based on the index of @command when you pressed C
      case @command.index
      when 0
        # Plays decision SE if there are Actors in the party, then opens item
        # menu.
        if $game_party.actors.size >= 1
          $game_system.se_play($data_system.decision_se)
          $scene = Scene_Item.new
        # Plays buzzer if the party has no actors
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      when 1
        # Same as above, but goes into picking actor
        if $game_party.actors.size >= 1
          $game_system.se_play($data_system.decision_se)
          @command.active = false
          @status.active = true
          @status.index = 0
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      when 2
        # Same as above, but goes into picking actor
        if $game_party.actors.size >= 1
          $game_system.se_play($data_system.decision_se)
          @command.active = false
          @status.active = true
          @status.index = 0
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      when 3
        # Same as above, but goes into picking actor
        if $game_party.actors.size >= 1
          $game_system.se_play($data_system.decision_se)
          @command.active = false
          @status.active = true
          @status.index = 0
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      when 4
        # Plays buzzer SE if save is disabled, opens save if it isn't
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
        else
          $game_system.se_play($data_system.decision_se)
          $scene = Scene_Save.new
        end
      when 5
        # Goes to the slightly modded load menu and plays decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_LoadMenu.new
      when 6
        # ENDS THE GAME
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Status
  #--------------------------------------------------------------------------
  def update_status
    # Goes back to command window if B is pressed.
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command.active = true
      @status.active = false
      @status.index = -1
    end
    # Does stuff based on index
    if Input.trigger?(Input::C)
      case @command.index
      when 1
        # Opens skill menu
        if $game_party.actors[@status.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
        else
          $game_system.se_play($data_system.decision_se)
          $scene = Scene_Skill.new(@status.index)
        end
      when 2
        # opens equip menu
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status.index)
      when 3
        # opens status menu
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status.index)
      end
    end
  end
end



Instructions

Inside the script.


Compatibility

None known. Tested with ToAO's v 6.13b, RTAB, and Blood Mage v 1.58.


Credits and Thanks


  • WcW
  • Blizz, for helping me learn to script and teaching me a lot



Author's Notes

To quote the Blizzard, "N-Joy!"

Juan

March 11, 2008, 03:57:35 pm #1 Last Edit: March 12, 2008, 04:25:14 pm by Juan
This is pretty good. I may want to show you to scrool with left and right  when in for example the skill screen.
Edit Heres the code     
# If Right button was pressed
    if Input.trigger?(Input::RIGHT)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Skill.new(@actor_index)     
    # If Left button was pressed
    elsif Input.trigger?(Input::LEFT)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Skill.new(@actor_index)   
end
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Blizzard

*powers up* <3
It has everything the default menu is missing, but isn't as heavyweight as other CMS-es. The perfect combination. :)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

fugibo

Yeah, I know how to do that, this is just a very basic CMS. It's not meant to be complex at all, only the main menu and the load screen are modified. Maybe I'll add all that later.

Sally


fugibo

yay *turns the emo button off*

Nortos

gj on this it's nice and classy looking maybe you could put an option for location window above gold and underneath commands I know it would be harder cos not so wide area but something like this
Location:

"John's Bathrooom"

and than have it so people can set it to true or false at the top

fugibo

0_o Hmm... maybe in the next update I'll make it switch between displaying those three windows and a location window every few seconds...

Nortos

that would also be cool lol, looking forward to seeing the code

fugibo

Next update will prolly include that and the Exit menu added to the main part of the menu.

Flermza


fugibo

Thanks!! Anyone found any bugs in it yet?

Fantasist

Not so far, but I love it. Why didn't I see it earlier? *powers up*
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Tazero

Lolz i love it Propz man Propz :D   :rockit:


If you were a fish...

adrian_587

September 27, 2010, 11:09:50 pm #14 Last Edit: September 28, 2010, 12:02:14 am by adrian_587
Okay, first off, LOVE the script! I'm making a small game for someone real young and don't want to confuse them with some of the complicated menu system scripts out there. Like was said above, it gives you what you need without being extraneous. Props to ya!  :haha:

You asked about bugs? Well, I wanted to add in a secret character who is at level 99 when he joins. The thing is, when I try to start a game with the character in the party the game starts as usual. But when you hit MENU, this error is displayed. Note, it is a level bug as if the level is 98, the error does NOT occur. It seems this experience bar thing that so many people like to use is glitched to the max.

And a suggestion, I think it will be better if on the main menu screen you do not show the actual number with regards to experience. The bar might be enough to tell just as a quick indicator. If players want to know the exact amount, let them check the status screen or something. The reason is that the experience number display overlaps and looks really bad and ruins what is otherwise a GREAT script. Just those two nitpicks.



And this is the cluttered experience bar thingamabob. Not pretty :p.



Oh and I didn't ask but, is it okay to modify the script. The game I'm making will not be commercial or anything. I just ask because some people are REALLY touchy about modifying their work (and rightly so if someone is going to take false credit for their blood, sweat and tears). Just asking to be sure. I felt that having a real time clock wasn't all that useful for my game, especially as I am using the CCTS script from here.