|
  |
3 Man CMS, Thought i'd post this was my fist cms |
|
|
|
|
Apr 11 2008, 04:33 AM
|

Level 6

Group: Member
Posts: 79
Type: Event Designer
RM Skill: Skilled

|
3 man CMS
Version: 1
Type: CMS IntroductionAnimated 3 man Custom Menu script, it was specially designed for 'Reaching for the Sky Beyond' and Spoofus allowed me to release it to the public Features- Face Sets
- Location Window
- Compact
- Animated CMS
Screenshots Demohttp://www.megaupload.com/?d=9BFNSDSKhttp://www.sendspace.com/file/teixgbScriptYou'll need to download the demo though if you want the correct icons. CODE #============================================================================== # ** Nortos # Nortos Beyond CMS Version # Version 1.0b #============================================================================== BG_item = 'item' BG_skill = 'skill' BG_equip = 'equip' BG_status = 'status' BG_save = 'save' BG_load = 'load' BG_exit = 'exit' BG_location = 'location' BG_playtime = 'time' BG_gold = 'gold'
#============================================================================== # ** Window_Selectable #------------------------------------------------------------------------------ # This window class contains cursor movement and scroll functions. #==============================================================================
class Window_Selectable1 < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :index # cursor position attr_reader :help_window # help window #-------------------------------------------------------------------------- # * Object Initialization # x : window x-coordinate # y : window y-coordinate # width : window width # height : window height #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @column_max = 1 @index = -1 end #-------------------------------------------------------------------------- # * Set Cursor Position # index : new cursor position #-------------------------------------------------------------------------- def index=(index) @index = index # Update Help Text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end # Update cursor rectangle update_cursor_rect end #-------------------------------------------------------------------------- # * Get Row Count #-------------------------------------------------------------------------- def row_max # Compute rows from number of items and columns return (@item_max + @column_max - 1) / @column_max end #-------------------------------------------------------------------------- # * Get Top Row #-------------------------------------------------------------------------- def top_row # Divide y-coordinate of window contents transfer origin by 1 row # height of 32 return self.oy / 32 end #-------------------------------------------------------------------------- # * Set Top Row # row : row shown on top #-------------------------------------------------------------------------- def top_row=(row) # If row is less than 0, change it to 0 if row < 0 row = 0 end # If row exceeds row_max - 1, change it to row_max - 1 if row > row_max - 1 row = row_max - 1 end # Multiply 1 row height by 32 for y-coordinate of window contents # transfer origin self.oy = row * 32 end #-------------------------------------------------------------------------- # * Get Number of Rows Displayable on 1 Page #-------------------------------------------------------------------------- def page_row_max # Subtract a frame height of 32 from the window height, and divide it by # 1 row height of 32 return (self.height - 32) / 32 end #-------------------------------------------------------------------------- # * Get Number of Items Displayable on 1 Page #-------------------------------------------------------------------------- def page_item_max # Multiply row count (page_row_max) times column count (@column_max) return page_row_max * @column_max end #-------------------------------------------------------------------------- # * Set Help Window # help_window : new help window #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window # Update help text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end end #-------------------------------------------------------------------------- # * Update Cursor Rectangle #-------------------------------------------------------------------------- def update_cursor_rect # If cursor position is less than 0 if @index < 0 self.cursor_rect.empty return end # Get current row row = @index / @column_max # If current row is before top row if row < self.top_row # Scroll so that current row becomes top row self.top_row = row end # If current row is more to back than back row if row > self.top_row + (self.page_row_max - 1) # Scroll so that current row becomes back row self.top_row = row - (self.page_row_max - 1) end # Calculate cursor width cursor_width = self.width / @column_max - 32 # Calculate cursor coordinates x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * 32 - self.oy # Update cursor rectangle self.cursor_rect.set(x, y, cursor_width, 32) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # If cursor is movable if self.active and @item_max > 0 and @index >= 0 # If the right directional button was pressed if Input.repeat?(Input::LEFT) # If column count is 2 or more, and cursor position is closer to front # than (item count -1) if (@column_max == 1 and Input.trigger?(Input::RIGHT)) or @index >= @column_max # Move cursor up $game_system.se_play($data_system.cursor_se) @index = (@index - @column_max + @item_max) % @item_max end end # If the left directional button was pressed if Input.repeat?(Input::RIGHT) # If column count is 2 or more, and cursor position is more back than 0 if (@column_max == 1 and Input.trigger?(Input::LEFT)) or @index < @item_max - @column_max # Move cursor down $game_system.se_play($data_system.cursor_se) @index = (@index + @column_max) % @item_max end end end # Update help text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end # Update cursor rectangle update_cursor_rect end end
class Window_Base < Window def fc face = RPG::Cache.picture("") end def draw_fc(actor,x,y) face = RPG::Cache.picture(actor.name + "_fc") rescue fc fw = face.width fh = face.height src_rect = Rect.new(0, 0, fw, fh) self.contents.blt(x , y - fh, face, src_rect) end end
class Window_PlayTime < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.name = "Tahoma" self.contents.font.size = 12 self.contents.font.color = system_color self.contents.draw_text(4, 0, 120, 32, "Play Time:") @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 = normal_color self.contents.draw_text(4, 0, 122, 32, text, 2) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if Graphics.frame_count / Graphics.frame_rate != @total_sec refresh end end end #-------------------------------------------------------------------------- # * Window Location #--------------------------------------------------------------------------
class Window_Location < Window_Base def initialize super(0, 0, 300, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = "Tahoma" self.contents.font.size = 14 refresh end def refresh self.contents.clear data = load_data("Data/MapInfos.rxdata") self.contents.font.color = system_color self.contents.draw_text(0, 0, 248, 32, "Location:") self.contents.font.color = normal_color self.contents.draw_text(50, 0, 100, 32, data[$game_map.map_id].name, 2) end end
#-------------------------------------------------------------------------- # * Window Gold #--------------------------------------------------------------------------
class Window_Gold < Window_Base def initialize super(0, 0, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh self.contents.clear self.contents.font.name = "Tahoma" cx = contents.text_size($data_system.words.gold).width self.contents.font.color = normal_color self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2) end end
#-------------------------------------------------------------------------- # * Menu_Status #--------------------------------------------------------------------------
class Window_MenuStatus < Window_Selectable1 def initialize super(0, 0, 700, 100) self.contents = Bitmap.new(width - 32, height - 32) refresh self.active = false self.index = -1 end
def refresh self.contents.font.name = "Tahoma" self.contents.font.size = 12 self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size x = i * 220 y = 0 actor = $game_party.actors[i] draw_fc(actor,x + 14,y + 53) draw_actor_name(actor, x+15, y) draw_actor_level(actor, x, y + 16) draw_actor_state(actor, x+15, y + 40) draw_actor_exp(actor, x + 50, y + 30) draw_actor_hp(actor, x + 65, y-10) draw_actor_sp(actor, x + 65, y+10) end end def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(@index * 220, 0, self.width - 480, 64) end end end
#-------------------------------------------------------------------------- # * Menu Scene #-------------------------------------------------------------------------- class Scene_Menu
def initialize(menu_index = 0) @menu_index = menu_index end def main @sprite = Spriteset_Map.new viewport = Viewport.new(0, 0, 640, 480) s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Status" s5 = "Save" s6 = "Load" s7 = "Exit" @command_window = Window_Command1.new(110, [s1, s2, s3, s4, s5, s6, s7]) @command_window.x = 495 + 160 @command_window.y = 40 @command_window.height = 257 @command_window.back_opacity = 170 @command_window.index = @menu_index # If number of party members is 0 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 if $game_system.save_disabled # Disable save @command_window.disable_item(4) end @window_PlayTime = Window_PlayTime.new @window_PlayTime.x = -160 @window_PlayTime.y = 300 @window_PlayTime.back_opacity = 170 @window_Gold = Window_Gold.new @window_Gold.x = -160 @window_Gold.y = 230 @window_Gold.back_opacity = 170 @window_Location = Window_Location.new @window_Location.y = 300 @window_Location.x = 344 + 290 @window_Location.back_opacity = 170 @status_window = Window_MenuStatus.new @status_window.x = -30 @status_window.y = 370 + 110 @status_window.back_opacity = 170 @item = Sprite.new @item.bitmap = RPG::Cache.icon(BG_item) @item.x = 600 + 160 @item.y = 60 @item.z = @item.z + 255 @skill = Sprite.new @skill.bitmap = RPG::Cache.icon(BG_skill) @skill.x = 600 + 160 @skill.y = 92 @skill.z = @skill.z + 255 @equip = Sprite.new @equip.bitmap = RPG::Cache.icon(BG_equip) @equip.x = 600 + 160 @equip.y = 124 @equip.z = @equip.z + 255 @status = Sprite.new @status.bitmap = RPG::Cache.icon(BG_status) @status.x = 600 + 160 @status.y = 156 @status.z = @status.z + 255 @save = Sprite.new @save.bitmap = RPG::Cache.icon(BG_save) @save.x = 600 + 160 @save.y = 188 @save.z = @save.z + 255 @load = Sprite.new @load.bitmap = RPG::Cache.icon(BG_load) @load.x = 600 + 160 @load.y = 220 @load.z = @load.z + 255 @quit = Sprite.new @quit.bitmap = RPG::Cache.icon(BG_exit) @quit.x = 600 + 160 @quit.y = 252 @quit.z = @quit.z + 255 @location = Sprite.new @location.bitmap = RPG::Cache.icon(BG_location) @location.x = 600 + 160 @location.y = 320 @location.z = @location.z + 255 @playtime = Sprite.new @playtime.bitmap = RPG::Cache.icon(BG_playtime) @playtime.x = -160 @playtime.y = 320 @playtime.z = @playtime.z + 255 @gold = Sprite.new @gold.bitmap = RPG::Cache.icon(BG_gold) @gold.x = -120 @gold.y = 250 @gold.z = @gold.z + 255 Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows viewport.dispose @command_window.dispose @window_PlayTime.dispose @window_Gold.dispose @window_Location.dispose @status_window.dispose @item.dispose @skill.dispose @equip.dispose @status.dispose @save.dispose @load.dispose @quit.dispose @gold.dispose @playtime.dispose @location.dispose @sprite.dispose end def entrance @command_window.x -= 10 if @command_window.x > 530 @window_PlayTime.x += 10 if @window_PlayTime.x < 0 @window_Location.x -= 15 if @window_Location.x > 344 @window_Gold.x += 10 if @window_Gold.x < 0 @status_window.y -= 10 if @status_window.y > 370 @item.x -= 10 if @item.x > 547 @skill.x -= 10 if @skill.x > 547 @equip.x -= 10 if @equip.x > 547 @status.x -= 10 if @status.x > 547 @save.x -= 10 if @save.x > 547 @load.x -= 10 if @load.x > 547 @quit.x -= 10 if @quit.x > 547 @playtime.x += 10 if @playtime.x < 70 @gold.x += 10 if @gold.x < 80 @location.x -= 10 if @location.x > 600 end
def exit @command_window.x += 10 if @command_window.x < 655 @window_PlayTime.x -= 10 if @window_PlayTime.x > -160 @window_Location.x += 15 if @window_Location.x < 640 @window_Gold.x -= 10 if @window_Gold.x > -160 @status_window.y += 10 if @status_window.y < 480 @item.x += 10 if @item.x < 760 @skill.x += 10 if @skill.x < 760 @quit.x += 10 if @quit.x < 760 @equip.x += 10 if @equip.x < 760 @status.x += 10 if @status.x < 760 @save.x += 10 if @save.x < 760 @load.x += 10 if @load.x < 760 @playtime.x -= 10 if @playtime.x > -160 @gold.x -= 10 if @gold.x > -160 @location.x += 10 if @location.x < 760 if @status_window.y >= 480 $scene = Scene_Map.new $game_map.autoplay return end end
def update if @intro == nil entrance end if @exit == true exit @intro = false end @status_window.update @window_Gold.update @window_PlayTime.update @window_Location.update @command_window.update
# If command window is active: call update_command if @command_window.active update_command return end # If status window is active: call update_status if @status_window.active update_status return end end def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) @exit = true return end # If C button was pressed if Input.trigger?(Input::C) # If command other than save or end game, and party members = 0 if $game_party.actors.size == 0 and @command_window.index < 4 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Branch by command window cursor position 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) @command_window.active = false @status_window.active = true @status_window.index = 0 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_Load_New.new when 6 $game_system.se_play($data_system.decision_se) $scene = Scene_End.new end return end end #-------------------------------------------------------------------------- # * Frame Update (when status window is active) #-------------------------------------------------------------------------- def update_status # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Make command window active @command_window.active = true @status_window.active = false @status_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 1 # skill # If this actor's action limit is 2 or more if $game_party.actors[@status_window.index].restriction >= 2 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to skill screen $scene = Scene_Skill.new(@status_window.index) when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to equipment screen $scene = Scene_Equip.new(@status_window.index) when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to status screen $scene = Scene_Status.new(@status_window.index) end return end end end
#============================================================================== # ** Scene_Load_New #------------------------------------------------------------------------------ # New Load Screen #==============================================================================
class Scene_Load_New < Scene_File #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize # Remake temporary object $game_temp = Game_Temp.new # Timestamp selects new file $game_temp.last_file_index = 0 latest_time = Time.at(0) for i in 0..3 filename = make_filename(i) if FileTest.exist?(filename) file = File.open(filename, "r") if file.mtime > latest_time latest_time = file.mtime $game_temp.last_file_index = i end file.close end end super("Which file would you like to load?") end #-------------------------------------------------------------------------- # * Decision Processing #-------------------------------------------------------------------------- def on_decision(filename) # If file doesn't exist unless FileTest.exist?(filename) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play load SE $game_system.se_play($data_system.load_se) # Read save data file = File.open(filename, "rb") read_save_data(file) file.close # Restore BGM and BGS $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) # Update map (run parallel process event) $game_map.update # Switch to map screen $scene = Scene_Map.new end #-------------------------------------------------------------------------- # * Cancel Processing #-------------------------------------------------------------------------- def on_cancel # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to menu screen $scene = Scene_Menu.new(0) end #-------------------------------------------------------------------------- # * Read Save Data # file : file object for reading (opened) #-------------------------------------------------------------------------- def read_save_data(file) # Read character data for drawing save file characters = Marshal.load(file) # Read frame count for measuring play time Graphics.frame_count = Marshal.load(file) # Read each type of game object $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) # If magic number is different from when saving # (if editing was added with editor) if $game_system.magic_number != $data_system.magic_number # Load map $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end # Refresh party members $game_party.refresh end end
#============================================================================== # ** Window_Command #------------------------------------------------------------------------------ # This window deals with general command choices. #==============================================================================
class Window_Command1 < 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 * 40 + 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(26, 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]) end #-------------------------------------------------------------------------- # * Disable Item # index : item number #-------------------------------------------------------------------------- def disable_item(index) draw_item(index, disabled_color) end end InstructionsTo change one of the icons save over them with the same names as the ones at the top of the script. For facesets you must insert the face or sprite into the pictures folder with _Fc at the end say Basil is you're charecter you must name it as Basil_Fc CompatibilityDoes not work for more than 3 man parties Credits and Thanks- Spoofus for the layout
- Using Sephs bars
- Silentwalker as i learnt how to animated windows of him
This post has been edited by Nortos: Apr 11 2008, 04:34 AM
__________________________
 
|
|
|
|
|
|
|
|
|
Apr 7 2012, 05:17 PM
|

Group: Member
Posts: 2
Type: None
RM Skill: Beginner

|
How do I add Menu options with this? I only know how to do it with the default T_T
|
|
|
|
|
|
|
|
|
Apr 7 2012, 08:40 PM
|

Level 50

Group: +Gold Member
Posts: 1,519
Type: Scripter
RM Skill: Undisclosed

|
CODE #============================================================================== # ** Nortos # Nortos Beyond CMS Version # Version 1.0b # Edited by: Night_Runner # @> http://www.rpgrevolution.com/forums/index.php?showtopic=12084 #==============================================================================
module Notros_CMS $data_system = load_data("Data/System.rxdata") # Do not touch this line Commands = [ # Items { :text => $data_system.words.item, :icon => '032-Item01', :disable => Proc.new { $game_party.actors.size == 0 }, :script => Proc.new do $game_system.se_play($data_system.decision_se) $scene = Scene_Item.new end }, # Skills { :text => $data_system.words.skill, :icon => '044-Skill01', :disable => Proc.new { $game_party.actors.size == 0 }, :script => Proc.new do $game_system.se_play($data_system.decision_se) $scene.after_statusMenu = Proc.new { |index| $scene = Scene_Skill.new(index) } cmd_win = $scene.instance_eval { @command_window } sts_win = $scene.instance_eval { @status_window } cmd_win.active = false sts_win.active = true sts_win.index = 0 end }, # Equip { :text => $data_system.words.equip, :icon => '013-Body01', :disable => Proc.new { $game_party.actors.size == 0 }, :script => Proc.new do $game_system.se_play($data_system.decision_se) $scene.after_statusMenu = Proc.new { |index| $scene = Scene_Equip.new(index) } cmd_win = $scene.instance_eval { @command_window } sts_win = $scene.instance_eval { @status_window } cmd_win.active = false sts_win.active = true sts_win.index = 0 end }, # Status { :text => 'Status', :icon => '036-Item05', :disable => Proc.new { $game_party.actors.size == 0 }, :script => Proc.new do $game_system.se_play($data_system.decision_se) @after_menuStatus = Proc.new { |index| $scene = Scene_Status.new(index) } cmd_win = $scene.instance_eval {@command_window } sts_win = $scene.instance_eval { @status_window } cmd_win.active = false sts_win.active = true sts_win.index = 0 end }, # Save { :text => 'Save', :icon => '039-Item08', :disable => Proc.new { $game_system.save_disabled }, :script => Proc.new do $game_system.se_play($data_system.decision_se) $scene = Scene_Save.new end }, # Load { :text => 'Load', :icon => '034-Item03', :disable => Proc.new { false }, :script => Proc.new do $game_system.se_play($data_system.decision_se) $scene = Scene_Load_New.new end }, # Exit { :text => 'Exit', :icon => '050-Skill07', :disable => Proc.new { false }, :script => Proc.new do $game_system.se_play($data_system.decision_se) $scene = Scene_End.new end } ] BG_location = '038-Item07' BG_playtime = '033-Item02' BG_gold = '032-Item01' Append_Charactername_for_face = '_fc' end
#============================================================================== # ** Window_Selectable #------------------------------------------------------------------------------ # This window class contains cursor movement and scroll functions. #==============================================================================
class Window_Selectable1 < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :index # cursor position attr_reader :help_window # help window #-------------------------------------------------------------------------- # * Object Initialization # x : window x-coordinate # y : window y-coordinate # width : window width # height : window height #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @column_max = 1 @index = -1 end #-------------------------------------------------------------------------- # * Set Cursor Position # index : new cursor position #-------------------------------------------------------------------------- def index=(index) @index = index # Update Help Text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end # Update cursor rectangle update_cursor_rect end #-------------------------------------------------------------------------- # * Get Row Count #-------------------------------------------------------------------------- def row_max # Compute rows from number of items and columns return (@item_max + @column_max - 1) / @column_max end #-------------------------------------------------------------------------- # * Get Top Row #-------------------------------------------------------------------------- def top_row # Divide y-coordinate of window contents transfer origin by 1 row # height of 32 return self.oy / 32 end #-------------------------------------------------------------------------- # * Set Top Row # row : row shown on top #-------------------------------------------------------------------------- def top_row=(row) # If row is less than 0, change it to 0 if row < 0 row = 0 end # If row exceeds row_max - 1, change it to row_max - 1 if row > row_max - 1 row = row_max - 1 end # Multiply 1 row height by 32 for y-coordinate of window contents # transfer origin self.oy = row * 32 end #-------------------------------------------------------------------------- # * Get Number of Rows Displayable on 1 Page #-------------------------------------------------------------------------- def page_row_max # Subtract a frame height of 32 from the window height, and divide it by # 1 row height of 32 return (self.height - 32) / 32 end #-------------------------------------------------------------------------- # * Get Number of Items Displayable on 1 Page #-------------------------------------------------------------------------- def page_item_max # Multiply row count (page_row_max) times column count (@column_max) return page_row_max * @column_max end #-------------------------------------------------------------------------- # * Set Help Window # help_window : new help window #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window # Update help text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end end #-------------------------------------------------------------------------- # * Update Cursor Rectangle #-------------------------------------------------------------------------- def update_cursor_rect # If cursor position is less than 0 if @index < 0 self.cursor_rect.empty return end # Get current row row = @index / @column_max # If current row is before top row if row < self.top_row # Scroll so that current row becomes top row self.top_row = row end # If current row is more to back than back row if row > self.top_row + (self.page_row_max - 1) # Scroll so that current row becomes back row self.top_row = row - (self.page_row_max - 1) end # Calculate cursor width cursor_width = self.width / @column_max - 32 # Calculate cursor coordinates x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * 32 - self.oy # Update cursor rectangle self.cursor_rect.set(x, y, cursor_width, 32) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # If cursor is movable if self.active and @item_max > 0 and @index >= 0 # If the right directional button was pressed if Input.repeat?(Input::LEFT) # If column count is 2 or more, and cursor position is closer to front # than (item count -1) if (@column_max == 1 and Input.trigger?(Input::RIGHT)) or @index >= @column_max # Move cursor up $game_system.se_play($data_system.cursor_se) @index = (@index - @column_max + @item_max) % @item_max end end # If the left directional button was pressed if Input.repeat?(Input::RIGHT) # If column count is 2 or more, and cursor position is more back than 0 if (@column_max == 1 and Input.trigger?(Input::LEFT)) or @index < @item_max - @column_max # Move cursor down $game_system.se_play($data_system.cursor_se) @index = (@index + @column_max) % @item_max end end end # Update help text (update_help is defined by the subclasses) if self.active and @help_window != nil update_help end # Update cursor rectangle update_cursor_rect end end
class Window_Base < Window def fc face = RPG::Cache.picture("") end def draw_fc(actor,x,y) suffix = Notros_CMS::Append_Charactername_for_face face = RPG::Cache.picture(actor.name + suffix) rescue return fw = face.width fh = face.height src_rect = Rect.new(0, 0, fw, fh) self.contents.blt(x , y - fh, face, src_rect) end end
class Window_PlayTime < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.name = "Tahoma" self.contents.font.size = 12 self.contents.font.color = system_color self.contents.draw_text(4, 0, 120, 32, "Play Time:") @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 = normal_color self.contents.draw_text(4, 0, 122, 32, text, 2) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if Graphics.frame_count / Graphics.frame_rate != @total_sec refresh end end end #-------------------------------------------------------------------------- # * Window Location #--------------------------------------------------------------------------
class Window_Location < Window_Base def initialize super(0, 0, 300, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = "Tahoma" self.contents.font.size = 14 refresh end
def refresh self.contents.clear data = load_data("Data/MapInfos.rxdata") self.contents.font.color = system_color self.contents.draw_text(0, 0, 248, 32, "Location:") self.contents.font.color = normal_color self.contents.draw_text(50, 0, 100, 32, data[$game_map.map_id].name, 2) end end
#-------------------------------------------------------------------------- # * Window Gold #--------------------------------------------------------------------------
class Window_Gold < Window_Base def initialize super(0, 0, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh self.contents.clear self.contents.font.name = "Tahoma" cx = contents.text_size($data_system.words.gold).width self.contents.font.color = normal_color self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2) end end
#-------------------------------------------------------------------------- # * Menu_Status #--------------------------------------------------------------------------
class Window_MenuStatus < Window_Selectable1 def initialize super(0, 0, 700, 100) self.contents = Bitmap.new(width - 32, height - 32) refresh self.active = false self.index = -1 end
def refresh self.contents.font.name = "Tahoma" self.contents.font.size = 12 self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size x = i * 220 y = 0 actor = $game_party.actors[i] draw_fc(actor,x + 14,y + 53) draw_actor_name(actor, x+15, y) draw_actor_level(actor, x, y + 16) draw_actor_state(actor, x+15, y + 40) draw_actor_exp(actor, x + 50, y + 30) draw_actor_hp(actor, x + 65, y-10) draw_actor_sp(actor, x + 65, y+10) end end def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(@index * 220, 0, self.width - 480, 64) end end end
#-------------------------------------------------------------------------- # * Menu Scene #-------------------------------------------------------------------------- class Scene_Menu include Notros_CMS attr_accessor :after_statusMenu @@last_menu_index = 0
def initialize(menu_index = 0) @menu_index = $scene.is_a?(Scene_Map) ? 0 : @@last_menu_index @after_statusMenu = Proc.new {} end
def main @sprite = Spriteset_Map.new viewport = Viewport.new(0, 0, 640, 480) s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = 'New Option' s5 = "Status" s6 = "Save" s7 = "Load" s8 = "Exit" @command_window = Window_Command1.new(110, Commands) @command_window.x = 495 + 160 @command_window.y = 40 @command_window.height = 257 @command_window.back_opacity = 170 @command_window.index = @menu_index # If number of party members is 0 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 if $game_system.save_disabled # Disable save @command_window.disable_item(4) end @window_PlayTime = Window_PlayTime.new @window_PlayTime.x = -160 @window_PlayTime.y = 300 @window_PlayTime.back_opacity = 170 @window_Gold = Window_Gold.new @window_Gold.x = -160 @window_Gold.y = 230 @window_Gold.back_opacity = 170 @window_Location = Window_Location.new @window_Location.y = 300 @window_Location.x = 344 + 290 @window_Location.back_opacity = 170 @status_window = Window_MenuStatus.new @status_window.x = -30 @status_window.y = 370 + 110 @status_window.back_opacity = 170 @location = Sprite.new @location.bitmap = RPG::Cache.icon(BG_location) @location.x = 600 + 160 @location.y = 320 @location.z = @location.z + 255 @playtime = Sprite.new @playtime.bitmap = RPG::Cache.icon(BG_playtime) @playtime.x = -160 @playtime.y = 320 @playtime.z = @playtime.z + 255 @gold = Sprite.new @gold.bitmap = RPG::Cache.icon(BG_gold) @gold.x = -120 @gold.y = 250 @gold.z = @gold.z + 255 Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Backup the index @@last_menu_index = @command_window.index # Dispose of windows viewport.dispose @command_window.dispose @window_PlayTime.dispose @window_Gold.dispose @window_Location.dispose @status_window.dispose @gold.dispose @playtime.dispose @location.dispose @sprite.dispose end def entrance @command_window.x -= 10 if @command_window.x > 530 @window_PlayTime.x += 10 if @window_PlayTime.x < 0 @window_Location.x -= 15 if @window_Location.x > 344 @window_Gold.x += 10 if @window_Gold.x < 0 @status_window.y -= 10 if @status_window.y > 370 @playtime.x += 10 if @playtime.x < 70 gld_str = $game_party.gold.to_s + ' ' + $data_system.words.gold gld_str_width = @window_Gold.contents.text_size(gld_str).width gld_fnl_x = @window_Gold.x + @window_Gold.contents.width - gld_str_width + 8 gld_fnl_x -= @gold.bitmap.width @gold.x = [@gold.x + 10, gld_fnl_x].min @location.x -= 10 if @location.x > 600 end
def exit
@command_window.x += 10 if @command_window.x < 655 @window_PlayTime.x -= 10 if @window_PlayTime.x > -160 @window_Location.x += 15 if @window_Location.x < 640 @window_Gold.x -= 10 if @window_Gold.x > -160 @status_window.y += 10 if @status_window.y < 480 @playtime.x -= 10 if @playtime.x > -160 @gold.x -= 10 if @gold.x > -160 @location.x += 10 if @location.x < 760 if @status_window.y >= 480 $scene = Scene_Map.new $game_map.autoplay return end end
def update if @intro == nil entrance end if @exit == true exit @intro = false end @status_window.update @window_Gold.update @window_PlayTime.update @window_Location.update @command_window.update
# If command window is active: call update_command if @command_window.active update_command return end # If status window is active: call update_status if @status_window.active update_status return end end def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) @exit = true return end # If C button was pressed if Input.trigger?(Input::C) # Run the code fo the item selected command = @command_window.selected if command[:disable].call == true $game_system.se_play($data_system.buzzer_se) else command[:script].call end end end #-------------------------------------------------------------------------- # * Frame Update (when status window is active) #-------------------------------------------------------------------------- def update_status # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Make command window active @command_window.active = true @status_window.active = false @status_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) @after_statusMenu.call(@status_window.index) end end end
#============================================================================== # ** Scene_Load_New #------------------------------------------------------------------------------ # New Load Screen #==============================================================================
class Scene_Load_New < Scene_File #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize # Remake temporary object $game_temp = Game_Temp.new # Timestamp selects new file $game_temp.last_file_index = 0 latest_time = Time.at(0) for i in 0..3 filename = make_filename(i) if FileTest.exist?(filename) file = File.open(filename, "r") if file.mtime > latest_time latest_time = file.mtime $game_temp.last_file_index = i end file.close end end super("Which file would you like to load?") end #-------------------------------------------------------------------------- # * Decision Processing #-------------------------------------------------------------------------- def on_decision(filename) # If file doesn't exist unless FileTest.exist?(filename) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play load SE $game_system.se_play($data_system.load_se) # Read save data file = File.open(filename, "rb") read_save_data(file) file.close # Restore BGM and BGS $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) # Update map (run parallel process event) $game_map.update # Switch to map screen $scene = Scene_Map.new end #-------------------------------------------------------------------------- # * Cancel Processing #-------------------------------------------------------------------------- def on_cancel # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to menu screen $scene = Scene_Menu.new(0) end #-------------------------------------------------------------------------- # * Read Save Data # file : file object for reading (opened) #-------------------------------------------------------------------------- def read_save_data(file) # Read character data for drawing save file characters = Marshal.load(file) # Read frame count for measuring play time Graphics.frame_count = Marshal.load(file) # Read each type of game object $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) # If magic number is different from when saving # (if editing was added with editor) if $game_system.magic_number != $data_system.magic_number # Load map $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end # Refresh party members $game_party.refresh end end
#============================================================================== # ** Window_Command #------------------------------------------------------------------------------ # This window deals with general command choices. #==============================================================================
class Window_Command1 < 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 * 40 + 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 command = @commands[i] if command[:disable].call == true disable_item(index) else draw_item(i, normal_color) end end end #-------------------------------------------------------------------------- # * Draw Item # index : item number # color : text color #-------------------------------------------------------------------------- def draw_item(index, color) # Setup & clean area self.contents.font.color = color width = self.contents.width rect = Rect.new(0, 32 * index, width, 32) command = @commands[index] self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) icon_width = 26 # Draw the icon bitmap = RPG::Cache.icon(command[:icon]) dy = (32 - bitmap.height) >> 1 dx = (icon_width - bitmap.width) >> 1 self.contents.blt(dx, 32 * index + dy, bitmap, bitmap.rect) # Draw the text text = command[:text] self.contents.draw_text(icon_width, 32 * index, width - icon_width,32, text) end #-------------------------------------------------------------------------- # * Disable Item # index : item number #-------------------------------------------------------------------------- def disable_item(index) draw_item(index, disabled_color) end #-------------------------------------------------------------------------- # * Selected #-------------------------------------------------------------------------- def selected return @commands[@index] end end I've updated the code, to add a new command all you have to do is copy one of the pre-existing commands (Items, Skills, etc) in the customisation at the top, and fill in the text to display, the icon to use, the condition to disable the option, and the script to run it its selected. I've added a few other fixes as well, such as the issue with the gold icon being in a static position, overlapping the gold text once you earn enough.
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question. Most important guide ever: Newbie's Guide to Switches
|
|
|
|
|
|
|
|
  |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|