Ogłoszenie 

Uwaga! To forum jest w trybie offline.
Wszelką pomoc uzyskasz pod adresem
forum.ultimateam.pl


Administracja Forum


Poprzedni temat «» Następny temat
Enhanced DMS
Autor Wiadomość
Loki 




Preferowany:
RPG Maker VX

Pomógł: 12 razy
Dołączył: 25 Kwi 2012
Posty: 162
Wysłany: Sob 19 Maj, 2012 22:47
Enhanced DMS
~ Enhanced DMS ~


Autor:
Longfellow

Kompatybilność:
RPG Maker XP

Skrypt:
Spoiler:

Kod:
#============================================================================
# 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


Screeny:
Spoiler:


 
 
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Nie możesz załączać plików na tym forum
Możesz ściągać załączniki na tym forum
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group | Template Klam by Ayene