Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Zexion on April 05, 2012, 09:09:00 pm

Title: [XP] Kingdom Hearts Main Menu
Post by: Zexion on April 05, 2012, 09:09:00 pm
Kingdom Hearts Main Menu
Authors: Zexion
Version: 1.0
Type: CMS
Key Term: Custom Menu System



Introduction

I've been asked several times to release this, on my youtube and deviant art accounts. I always said NO. Seeing as how I no longer use this menu, started a new project, and designed my own custom menu, I decided it was time to release it.


Features




Screenshots
Spoiler: ShowHide
(http://img403.imageshack.us/img403/2029/menuff.png)



Demo

See script.


Script
Spoiler: ShowHide
#==============================================================================#
#                          Kingdom Hearts Main Menu                            #
#       This script is a modification of Mog's Sence Menu Itigo V1.5           #
#==============================================================================#

module Config
 
    # Main Menu Graphics Used
      MAIN_LAYOUT       = "Main Menu"       # Main Menu Graphics
      MAIN_BACKGROUND   = "Main Menu_bg"    # Animated background graphic
      MAIN_BACKGROUND2  = "Main Menu_bg2"   # Only used when main_fx = 3
                                            # It is mainly for a still transparent pic
    # Menu
      MAIN_FX           = 3                 # BG FX (0, Animated no bg)
                                            #       (1, Still picture)
                                            #       (2, Map as bg)
                                            #       (3, Animated with bg)
                                            # 3 is for picture with transperency
      MAIN_TRAN_TIME    = 20                # Transition Time.
      MAIN_TRAN_TYPE    = ""                # Transition Type (Name)
      MAIN_MAPNAME      = true              # If true, shows the map name
    # Font Used
      MAIN_FONT         = "Zeroes 1"        # Font used in Main Menu
      MAIN_CURSOR       = "Indicator"       # Cursor graphic
  #Background Box
      BGBox             = "Bg-Box"          # Box behind stats
     
  # MENU BUTTONS
      MENU_TYPE_1       = "MenuButtons1"   # Button layout
      MENU_TYPE_2       = "MenuButtons2"
      MENU_TYPE_3       = "MenuButtons3"
      MENU_TYPE_4       = "MenuButtons4"
      MENU_TYPE_5       = "MenuButtons5"
      MENU_TYPE_6       = "MenuButtons6"
    end
   
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :map_id                   # map id
  #--------------------------------------------------------------------------
  # * Map Name
  #-------------------------------------------------------------------------- 
  def mpname
    $mpname = load_data("Data/MapInfos.rxdata")
    $mpname[@map_id].name
  end
end



#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window

  #--------------------------------------------------------------------------
  # * Draw HP from Image
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #-------------------------------------------------------------------------- 
  def draw_kh_hp(actor, x, y)
    back = RPG::Cache.picture(Config::MAIN_BAR_HP_bg)
    cw = back.width 
    ch = back.height
    src_rect = Rect.new(0, 0, cw, ch)   
    self.contents.blt(x + 66, y - ch + 30, back, src_rect)
    meter = RPG::Cache.picture(Config::MAIN_BAR_HP)
    cw = meter.width  * actor.hp / actor.maxhp
    ch = meter.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x + 68, y - ch + 30, meter, src_rect)
  end 
  #--------------------------------------------------------------------------
  # * Draw SP from Image
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_kh_mp(actor, x, y)
    back = RPG::Cache.picture(Config::MAIN_BAR_SP_bg )
    cw = back.width 
    ch = back.height
    src_rect = Rect.new(0, 0, cw, ch)   
    self.contents.blt(x + 66, y - ch + 30, back, src_rect)
    meter = RPG::Cache.picture(Config::MAIN_BAR_SP)   
    cw = meter.width  * actor.sp / actor.maxsp
    ch = meter.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x + 68, y - ch + 30, meter, src_rect)
  end 
  #--------------------------------------------------------------------------
  # * Draw Box Behind Stats
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_bg_box(actor, x, y)
    back = RPG::Cache.picture(Config::BGBox )
    cw = back.width 
    ch = back.height
    src_rect = Rect.new(0, 0, cw, ch)   
    self.contents.blt(x + 66, y - ch + 30, back, src_rect)
  end 
  #--------------------------------------------------------------------------
  # * Draw State
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_state(actor, x, y, width = 80)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.name = "OCR A Extended"
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    self.contents.draw_text(x, y, width, 32, text, 2)
  end
 
 
  #------------------#
  #ACTOR BODY SPRITES#
  #------------------#
    def draw_actor_art(actor, x, y)
    face = RPG::Cache.character("MenuArt/" + actor.character_name,
    actor.character_hue)
    fw = face.width
    fh = face.height
    src_rect = Rect.new(0, 0, fw, fh)
    self.contents.blt(x - fw / 23, y - fh, face, src_rect)
  end

end




#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================

class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #-------------------------------------------------------------------------- 
  def initialize
    super(0, 0, 640, 280)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.windowskin = RPG::Cache.windowskin("")
    self.opacity = 0
    self.z = 15
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #-------------------------------------------------------------------------- 
  def refresh
    self.contents.clear
    self.contents.font.name = "OCR A Extended"
    self.contents.font.size = 14
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = i * 135
      y = 150
      actor = $game_party.actors[i]
      draw_actor_art(actor, x + 20, y)
      draw_bg_box(actor, x - 54, y)
      draw_actor_level(actor, x + 85, y - 60)
      draw_actor_hp(actor, x + 10, y - 40)
      draw_actor_sp(actor, x + 10, y - 20)
      draw_actor_exp(actor, x - 37, y + 5)
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(5, @index * 62, self.width - 32, 50)
    end
  end
end




#==============================================================================
# ** Window_munny
#------------------------------------------------------------------------------
#  This window displays amount of gold.
#==============================================================================

class Window_munny < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 300, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.windowskin = RPG::Cache.windowskin("")
    self.opacity = 0
    self.z = 15
    refresh
  end
end



#==============================================================================
# ** Window_PlayTime
#------------------------------------------------------------------------------
#  This window displays play time on the menu screen.
#==============================================================================

class Window_PlayTime < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 300, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.windowskin = RPG::Cache.windowskin("")
    self.opacity = 0
    self.z = 15
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    text = sprintf("%02d:%02d:%02d", hour, min, sec)
    self.contents.font.color = Color.new(0,255,255,255)
    self.contents.font.name = "Zeroes One"
    self.contents.draw_text(4, 32, 120, 32, text, 2)
  end
end






#==============================================================================
# ** Window_Map_Name
#------------------------------------------------------------------------------
#  This window displays the map name on the menu screen.
#==============================================================================

class Window_Map_Name < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 100, 480, 65)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.windowskin = RPG::Cache.windowskin("")
    self.opacity = 0
    self.z = 15
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.name = "Khmer UI"
    self.contents.font.size = 22
    self.contents.font.color = Color.new(239,231,0,255)
    self.contents.draw_text(-10, 0, 260, 40, $game_map.mpname.to_s, 1)
  end
end



#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    s1 = ""
    s2 = ""
    s3 = ""
    s4 = ""
    s5 = ""
    s6 = ""
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    if $game_party.actors.size == 0
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    @command_window.visible = false
    @command_window.x = -640
    @mnlay = Sprite.new
    @mnlay.bitmap = RPG::Cache.picture(Config::MAIN_LAYOUT)
    @mnlay.z = 10
    @mnlay.opacity = 0
    @mnlay.x = -100
    @mncom = Sprite.new
    @mncom.bitmap = RPG::Cache.picture(Config::MENU_TYPE_1)
    @mncom.z = 100
    if Config::MAIN_FX == 0
      @mnback = Plane.new
      @mnback.bitmap = RPG::Cache.picture(Config::MAIN_BACKGROUND)
      @mnback.blend_type = 0
      @mnback.z = 5
      @mnback2 = Plane.new
      @mnback2.bitmap = RPG::Cache.picture(Config::MAIN_BACKGROUND)
      @mnback2.blend_type = 0
      @mnback2.z = 5
      @mnback2.opacity = 60
    elsif Config::MAIN_FX == 1
      @mnback = Plane.new
      @mnback.bitmap = RPG::Cache.picture(Config::MAIN_BACKGROUND)
      @mnback.blend_type = 0
      @mnback.z = 5
    elsif Config::MAIN_FX == 3
      @spriteset = Spriteset_Map.new
      @mnback = Plane.new
      @mnback.bitmap = RPG::Cache.picture(Config::MAIN_BACKGROUND)
      @mnback.blend_type = 0
      @mnback.z = 5
      @mnback2 = Plane.new
      @mnback2.bitmap = RPG::Cache.picture(Config::MAIN_BACKGROUND)
      @mnback2.blend_type = 0
      @mnback2.z = 5
      @mnback2.opacity = 60
      @mnback3 = Plane.new
      @mnback3.bitmap = RPG::Cache.picture(Config::MAIN_BACKGROUND2)
      @mnback3.blend_type = 0
      @mnback3.z = 5
      @mnback3.opacity = 255
    else
      @spriteset = Spriteset_Map.new
    end
    @mnsel = Sprite.new
    @mnsel.bitmap = RPG::Cache.picture(Config::MAIN_CURSOR)
    @mnsel.z = 20
    @mnsel.x = 1000
    @mnsel.y = 1000
    @mnop = 100
    if $game_system.save_disabled
      @command_window.disable_item(4)
    end
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = -38
    @playtime_window.y = 402
    @playtime_window.contents_opacity = 0
    if Config::MAIN_MAPNAME == true
      @mapname_window = Window_Map_Name.new
      @mapname_window.x = 350
      @mapname_window.y = 0
      @mapname_window.contents_opacity = 0
    end
    @gold_window = Window_munny.new
    @gold_window.x = -44
    @gold_window.y = 383
    @gold_window.contents_opacity = 0
    @status_window = Window_MenuStatus.new
    @status_window.x = 295
    @status_window.y = 110
    @status_window.contents_opacity = 0
    if Config::MAIN_FX == 0
      Graphics.transition(Config::MAIN_TRAN_TIME, "Graphics/Transitions/" +
        Config::MAIN_TRAN_TYPE)
    elsif Config::MAIN_FX == 1
      Graphics.transition(Config::MAIN_TRAN_TIME, "Graphics/Transitions/" +
        Config::MAIN_TRAN_TYPE)
    else
      Graphics.transition 
    end
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    for i in 0..10 
      if Config::MAIN_FX == 0
        @mnback.oy += 1
        @mnback.ox += 1
        @mnback2.oy += 1
        @mnback2.ox -= 1
      elsif Config::MAIN_FX == 3
        @mnback.oy += 1
        @mnback.ox += 1
        @mnback2.oy += 1
        @mnback2.ox -= 1
      end
      @status_window.x += 20
      @status_window.contents_opacity -= 25
      @mnsel.opacity -= 15
      @mnsel.zoom_x += 0.03
      @mnlay.x -= 10
      @mnlay.opacity -= 25
      if Config::MAIN_MAPNAME == true
        @mapname_window.x += 5
        @mapname_window.contents_opacity -= 20
      end
      @gold_window.contents_opacity -= 25
      @playtime_window.contents_opacity -= 25
      Graphics.update   
    end
    Graphics.freeze
    @command_window.dispose
    @playtime_window.dispose
    @gold_window.dispose   
    @status_window.dispose
    @mnlay.dispose
    @mncom.dispose
    if Config::MAIN_FX == 0
      @mnback.dispose
      @mnback2.dispose
    elsif Config::MAIN_FX == 1
      @mnback.dispose
    elsif Config::MAIN_FX == 3
      @mnback.dispose
      @mnback2.dispose
      @mnback3.dispose
      @spriteset.dispose
    else
      @spriteset.dispose
    end
    @mnsel.dispose
    @mapname_window.dispose if Config::MAIN_MAPNAME == true
    Graphics.update
  end
 
 
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
     if @mnsel.zoom_x > 1.6
        @mnsel.zoom_x = 1.0
        @mnsel.opacity = 266
      end     
    if @mnlay.x < 0
      @mnlay.opacity += 25
      @mnlay.x += 10
    elsif @mnlay.x >= 0 
      @mnlay.opacity = 255
      @mnlay.x = 0
    end
    @command_window.update if @command_window.active
    @playtime_window.update
    @status_window.update if @status_window.active
    if Config::MAIN_FX == 0
      @mnback.oy += 1
      @mnback.ox += 1
      @mnback2.oy += 1
      @mnback2.ox -= 1
    elsif Config::MAIN_FX == 3
      @mnback.oy += 1
      @mnback.ox += 1
      @mnback2.oy += 1
      @mnback2.ox -= 1

    end
    @mapname_window.contents_opacity += 15 if Config::MAIN_MAPNAME == true
    @playtime_window.contents_opacity += 15
    @gold_window.contents_opacity += 15
    @playtime_window.contents_opacity += 15
    if @status_window.x > 195
      @status_window.x -= 10
      @status_window.contents_opacity += 10
    elsif @status_window.x <= 195
      @status_window.x = 195
      @status_window.contents_opacity = 255
    end
    if @command_window.active
      update_command
      return
    end
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    case @command_window.index
    when 0 
      @mncom.bitmap = RPG::Cache.picture(Config::MENU_TYPE_1)
    when 1
    @mncom.bitmap = RPG::Cache.picture(Config::MENU_TYPE_2)
    when 2
    @mncom.bitmap = RPG::Cache.picture(Config::MENU_TYPE_3)
    when 3
    @mncom.bitmap = RPG::Cache.picture(Config::MENU_TYPE_4)
    when 4
    @mncom.bitmap = RPG::Cache.picture(Config::MENU_TYPE_5)
    when 5
    @mncom.bitmap = RPG::Cache.picture(Config::MENU_TYPE_6)
    end   
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Hotkeys.new
      when 2
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
        return
      end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Journal.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status 
    case @status_window.index
    when 0 
      @mnsel.x = 190
      @mnsel.y = 195
    when 1
      @mnsel.x = 323
      @mnsel.y = 195
    when 2
      @mnsel.x = 455
      @mnsel.y = 195
    when 3
      @mnsel.x = 180
      @mnsel.y = 320
    end 
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
    @mnsel.z = 20
    @mnsel.x = 1000
    @mnsel.y = 1000
    @mnop = 100
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 1
        if $game_party.actors[@status_window.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@status_window.index)
      when 2 
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status_window.index)
      when 3 
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status_window.index)
        end
      return
    end
  end
end




Instructions

Place above main. Download the gfx below, and put them in pictures folder. Create a folder inside the character folder. Name it "MenuArt" every character MUST have a specific graphic in the menu art folder.


Compatibility

Not compatible with other Main Menu edits. Will work with other menus such as equipment/status mods. Not tested with SDK.


Credits and Thanks




Author's Notes

Don't forget the MenuArt folder MUST be in the CHARACTERS folder. THIS IS NOT PLUG AND PLAY. You must download the font Zeros1 Zeroes2 and Zeroes3 for it to be "plug-and-play". Otherwise, change all the custom font parts in the menu. (should only be in config section.)

Pictures:
Download. (http://khd.do.am/Kh_Main_GFX.zip)
Title: Re: [XP] Kingdom Hearts Main Menu
Post by: ForeverZer0 on April 05, 2012, 11:34:33 pm
Nice job. Level+ :)

* Moves to database *

When using the script template, do not include the < > for the parameters, those are just there to show what values you need to change. If they are left in, the script will not be displayed in the Script Index. Also, don't forget to add the [XP] and/or [VX] tag to the title. I fixed it up for you already, just letting you know for (hopefully) next time.
Title: Re: [XP] Kingdom Hearts Main Menu
Post by: Zexion on April 06, 2012, 12:37:42 am
Thnx I've done it right in the past, but for some reason I just confused my self when I made the post lol. Thanks for fixing it though :D

Edit: I fixed it. Had some useless code, and missed 2 graphics. :P Updated it already