[XP] Zydragon's Simple CMS

Started by Trainer Zydragon, February 16, 2010, 08:10:43 pm

Previous topic - Next topic

Trainer Zydragon

February 16, 2010, 08:10:43 pm Last Edit: February 16, 2010, 08:35:44 pm by Zydragon
Zydragon's Simple CMS
Authors: Zydragon
Version: v1.1
Type: Simple custom menu system
Key Term: Custom Menu System



Introduction

This script is a simple menu system, omitting the SAVE option for those games that don't have saveable areas. This was to make way for an OPTIONS function, which I am currently scripting and will release in v2.0. If you would like a SAVE option, send me a private message and I'll send an edited script with the SAVE option included.

Put simply: This is an edit on the normal menu, giving it a more interesting look, and will be edited in terms of style and code in the near future.


Features


  • Simple CMS showing important features like Playtime and Gold
  • Added Location window, uses map names
  • plug&play script
  • Customizable features



Screenshots

Spoiler: ShowHide



Demo

Demo v1.1


Script

Spoiler: ShowHide

#===============================================================================
#                 Zydragon's Simple Custom Menu System
#                                 v1.1
#===============================================================================
#____Copyright_©____
#This Custom Menu System has been created by Zydragon™ and as such can not be
#used or distributed without formal acknowledgement and the acceptance of the
#creator. If this CMS is edited you must still acknowledge the original creator.
#
#____Version History____
#
#   v1.0      9/2/2010      Created
#   v1.1      14/2/2010     Optional section created + Location window
#
#
#
#===============================================================================
#-------------------------------------------------------------------------------
#This is a simple CMS showing the amount of money held, the playtime, and the
#party's stats, while looking more aesthetic and sleek (It looks different
#ok :D), as well as showing the map name.
#-------------------------------------------------------------------------------
#===============================================================================
#START Script settings section
#-------------------------------------------------------------------------------

GENERAL_TEXT = 6 #Change the number for a different color
SECONDARY_TEXT = 0 #Changes gold and playtime color
NAME_TEXT = 0 #Changes color of NAME text
LEVEL_TEXT = 3 #Changes color of LEVEL text
HP_TEXT = 2 #Changes color of HP text
SP_TEXT = 1 #Changes color of SP text

MENU_LOCATION = "center" #change to "left", "right" or "center" to change menu position

#========================================
#Opacity settings
#----------------------------------------

GOLDW_OPAC=150 #Gold window opacity
LOCW_OPAC=150 #Location window opacity
PLAYW_OPAC=150 #Playtime window opacity
MENUW_OPAC=200 #Menu opacity
CHARW_OPAC=175 #Character window opacity
 
#-------------------------------------------------------------------------------
#END Options section
#===============================================================================

def initialize (menu_index = 0)
 @menu_index = menu_index
end

#===============================================================================
#Gold Window
#Displays current amount of gold held
#-------------------------------------------------------------------------------

class Gold_Win_Hi < Window_Base
 
 def initialize
   super(0, 0, 200, 60)
   self.contents = Bitmap.new(width-32, height-32)
   self.contents.font.name = "Arial"
   self.contents.font.size = 24
   
   cx = contents.text_size($data_system.words.gold).width
   self.contents.font.color = text_color(GENERAL_TEXT)
   self.contents.draw_text(160-cx, 0, cx, 32, $data_system.words.gold, 2)
   self.contents.font.color = text_color(SECONDARY_TEXT)
   self.contents.draw_text(4, 0, 150-cx-2, 32, $game_party.gold.to_s, 2)
 end
end

#===============================================================================
#Playtime Window
#Displays & refreshes PlayTime
#-------------------------------------------------------------------------------

class PlayTime_Win < Window_Base
 
 def initialize
   super(0, 0, 200, 60)
   self.contents = Bitmap.new(width-32, height-32)
   self.contents.font.name = "Arial"
   self.contents.font.size = 24
   refresh
 end
 
 def refresh
   self.contents.clear
   self.contents.font.color = text_color(GENERAL_TEXT)
   self.contents.draw_text(0, 0, 80, 32, "Time: ")
   
   @total_sec = Graphics.frame_count / Graphics.frame_rate
   hour = @total_sec / 60 / 60
   minute = @total_sec / 60 % 60
   second = @total_sec % 60
   time = sprintf("%02d:%02d:%02d", hour, minute, second)
   self.contents.font.color = text_color(SECONDARY_TEXT)
   self.contents.draw_text(60, 0, 140, 32, time)
 end
 
 def update
   if Graphics.frame_count / Graphics.frame_rate != @total_sec
     refresh
   end
 end
end


#===============================================================================
#Initialize class Scene_Menu
#-------------------------------------------------------------------------------

class Scene_Menu

 def main
   
#========================================
#Create Menu Window
#----------------------------------------
   s1="Items"
   s2="Skills"
   s3="Equip"
   s4="Status"
   s5="Quit"
   s6="Cancel"
   @menu_win=Window_Command2.new(120, [s1, s2, s3, s4, s5, s6])
   if MENU_LOCATION=="left"
     @menu_win.x=0
   end
   if MENU_LOCATION=="center"
     @menu_win.x=260
   end
   if MENU_LOCATION=="right"
     @menu_win.x=520
   end
   @menu_win.y=60
   @menu_win.height=260
   @menu_win.opacity=MENUW_OPAC
   @menu_win.back_opacity=MENUW_OPAC
   @menu_win.index=@menu_index
   
   if $game_party.actors.size == 0
     # Disable items, skills, equipment, and status
     @command_window.disable_item(0)
     @command_window.disable_item(1)
     @command_window.disable_item(2)
     @command_window.disable_item(3)
   end
#========================================

   @gold_win_hi=Gold_Win_Hi.new
   @gold_win_hi.opacity=GOLDW_OPAC
   @gold_win_hi.back_opacity=GOLDW_OPAC
   
   @playtime_win=PlayTime_Win.new
   @playtime_win.x=440
   @playtime_win.opacity=PLAYW_OPAC
   @playtime_win.back_opacity=PLAYW_OPAC
   
   @char_win_sel=Char_Window_Select.new
   @char_win_sel.y=320
   @char_win_sel.opacity=CHARW_OPAC
   @char_win_sel.back_opacity=CHARW_OPAC
   
   @window_location=Window_Location.new
   @window_location.x=200
   @window_location.opacity=LOCW_OPAC
   @window_location.back_opacity=LOCW_OPAC
   
   @spriteset = Spriteset_Map.new
   
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   
   @gold_win_hi.dispose
   @playtime_win.dispose
   @spriteset.dispose
   @menu_win.dispose
   @char_win_sel.dispose
   @window_location.dispose
 end
 
#========================================
#Frame Update
#----------------------------------------
 def update
   
   @playtime_win.update
   @gold_win_hi.update
   @spriteset.update
   @menu_win.update
   @char_win_sel.update
   @window_location.update
   
   if @menu_win.active
     update_menu
     return
   end
   
   if @char_win_sel.active
     update_char
     return
   end
 end

#========================================
#Frame Update (When menu_win is active)
#----------------------------------------

 def update_menu
   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 @menu_win.index < 4
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     case @menu_win.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)
       @menu_win.active = false
       @char_win_sel.active = true
       @char_win_sel.index = 0
     when 2
       $game_system.se_play($data_system.decision_se)
       @menu_win.active = false
       @char_win_sel.active = true
       @char_win_sel.index = 0
     when 3
       $game_system.se_play($data_system.decision_se)
       @menu_win.active = false
       @char_win_sel.active = true
       @char_win_sel.index = 0
     when 4
       $game_system.se_play($data_system.decision_se)
       $scene = Scene_End.new
     when 5  #Define CANCEL option
       $game_system.se_play($data_system.cancel_se)
       $scene = Scene_Map.new
       $game_map.autoplay
     end
     return
   end
 end
 
#========================================
#Frame Update (When char_win_sel is active)
#----------------------------------------
 
 def update_char
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.decision_se)
     @menu_win.active = true
     @char_win_sel.active = false
     @char_win_sel.index = -1
     return
   end
   
   if Input.trigger?(Input::C)
     case @menu_win.index
     when 1  # skill
       if $game_party.actors[@char_win_sel.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(@char_win_sel.index)
     when 2  # equipment
       $game_system.se_play($data_system.decision_se)
       $scene = Scene_Equip.new(@char_win_sel.index)
     when 3  # status
       $game_system.se_play($data_system.decision_se)
       $scene = Scene_Status.new(@char_win_sel.index)
     end
     return
   end
 end
end


#-------------------------------------------------------------------------------
#END Main
#===============================================================================
#===============================================================================
#START Window_Command2 (Thanks nathmatt)
#-------------------------------------------------------------------------------

class Window_Command2 < Window_Selectable
 #-----------------------------------------------------
 # * Object Initialization
 #     width    : window width
 #     commands : command text string array
 #-----------------------------------------------------
 def initialize(width, commands)
   # Compute window height from command quantity
   super(0, 0, width, commands.size * 32 + 32)
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 32)
   refresh
   self.index = 0
 end
 #-----------------------------------------------------
 # * Refresh
 #-----------------------------------------------------
 def refresh
   self.contents.clear
   for i in 0...@item_max
     draw_item(i, normal_color)
   end
 end
 #-----------------------------------------------------
 # * Draw Item
 #     index : item number
 #     color : text color
 #-----------------------------------------------------
 def draw_item(index, color)
   self.contents.font.color = color
   rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index],1)
 end
 #-----------------------------------------------------
 # * Disable Item
 #     index : item number
 #-----------------------------------------------------
 def disable_item(index)
   draw_item(index, disabled_color)
 end
end

#-------------------------------------------------------------------------------
#END Window_Command2
#===============================================================================
#===============================================================================
#START Character window SELECTABLE
#-------------------------------------------------------------------------------

class Char_Window_Select < Window_Selectable
 
 def initialize
   super(0, 0, 640, 160)
   self.contents = Bitmap.new(width-32, height-32)
   refresh
   self.active = false
   self.index = -1
   @column_max = 4
 end
 
 def refresh
   self.contents.clear
   @item_max = $game_party.actors.size
   for i in 0...$game_party.actors.size
     x = i * 158 - 8
     y = 0
     char = $game_party.actors[i]
     char_hp_string = char.hp.to_s + "/" + char.maxhp.to_s
     char_sp_string = char.sp.to_s + "/" + char.maxsp.to_s
     self.contents.font.color = text_color(NAME_TEXT)  #Text colour
     self.contents.draw_text(x, y, 158, 32, char.name, 1) #Write name
     self.contents.font.color = text_color(LEVEL_TEXT)
     self.contents.draw_text(x, y+32, 158, 32, "Level " + char.level.to_s, 1)
     self.contents.font.color = text_color(HP_TEXT)
     self.contents.draw_text(x, y+64, 158, 32, char_hp_string, 1)
     self.contents.font.color = text_color(SP_TEXT)
     self.contents.draw_text(x, y+96, 158, 32, char_sp_string, 1)
   end
 end
 
 def update_cursor_rect
   if @index < 0
     self.cursor_rect.empty
   else
     self.cursor_rect.set(@index * 158, 0, 138, self.height - 32)
   end
 end
end

#-------------------------------------------------------------------------------
#END Character window SELECTABLE
#===============================================================================
#===============================================================================
#START Location Window (Thankyou dubealex)
#-------------------------------------------------------------------------------

class Game_Map
 def name
  $map_infos[@map_id]
 end
end

#---------------------------------------

class Scene_Title
  $map_infos = load_data("Data/MapInfos.rxdata")
  for key in $map_infos.keys
    $map_infos[key] = $map_infos[key].name
  end
end

#---------------------------------------

class Window_Location < Window_Base
 def initialize
   super(0, 0, 240, 60)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = "Tahoma"
   self.contents.font.size = 24
   refresh
 end

 def refresh
   self.contents.clear
   self.contents.font.color = text_color(SECONDARY_TEXT)
   self.contents.draw_text(0, 0, 208, 30, $game_map.name, 1)
 end
end

#-------------------------------------------------------------------------------
#END Location Window
#===============================================================================



Instructions

Pretty much copy&pasta, then press ESC to open the menu :)


Compatibility

This script bypasses any menu system put before it, and is therefore incompatible with other Custom Menu System scripts

This script is compatible with Zydragon's other scripts


Credits and Thanks


  • Nathmatt
  • Dubealex
  • And of course myself.