Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # http://thiagodd.blogspot.com.br/
- # [TSDA] Custom Menu
- # --> Versions 1.0
- # by thiago_d_d
- #
- # -----------------------------------------------------------------------------
- # * Features
- # -----------------------------------------------------------------------------
- # + Just another menu, with an different design.
- #
- # -----------------------------------------------------------------------------
- # * Install
- # -----------------------------------------------------------------------------
- # Put this script in the aditional scripts section.
- #
- # -----------------------------------------------------------------------------
- # * Configuration
- # -----------------------------------------------------------------------------
- # Change the below lines.
- #===============================================================================
- #===============================================================================
- # TSDA
- #===============================================================================
- module TSDA
- #Vocabulary
- REAL_TIME_ST = "Tempo"
- NREAL_TIME_ST = "Tempo de Jogo"
- MENU_WORDS = ["Itens",
- "Habil.",
- "Equip.",
- "Estado",
- "Salvar",
- "Sair"]
- SaveSlot = "Arquivo"
- ClearSlot = "Arquivo Vazio"
- NoMenuInfo = "Não há informação disponível"
- NoMenuItem = "Não há itens no seu bolso de itens"
- HaveSTItems = "Mostrando os %d item(s) de seu bolso de itens"
- HaveMoreSTItems = "Mostrando os primeiros 16 itens de seu bolso de itens"
- Nda = "Nada"
- #It will use real life time?
- REAL_TIME = false
- #Icons indexes
- MENU_ICONS = [32,35,3,149,150,117]
- #Background image
- # "Black" for none
- # "Map" if you want the map as BG
- # "MapFocus" if you want focused map as BG
- # or any image name if you want custom BG
- BACK_MENU_IMG = "MapFocus"
- #Windows opacity
- MENU_WINDOW_OPACITY = 255
- end
- #===============================================================================
- # Window_Base
- #===============================================================================
- class Window_Base
- attr_reader :opening
- attr_reader :closing
- end
- #===============================================================================
- # Game_Map
- #===============================================================================
- class Game_Map
- alias menu_bat_init initialize
- #---
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize
- menu_bat_init
- @map_info = load_data("Data/MapInfos.rvdata")
- end
- #--------------------------------------------------------------------------
- # map_name
- #--------------------------------------------------------------------------
- def map_name
- return @map_info[@map_id].name
- end
- end
- #===============================================================================
- # Scene_Menu
- #===============================================================================
- class Scene_Menu < Scene_Base
- include TSDA
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(menu_index = 0)
- @menu_index = menu_index
- end
- #--------------------------------------------------------------------------
- # start
- #--------------------------------------------------------------------------
- def start
- @playtime_window = Window_PlayTime.new
- @gold_window = Window_GoldMap.new
- @status_window = Window_SEH.new(@menu_index)
- @command_window = Window_MenuCommand.new(@status_window)
- @command_window.index = @menu_index
- if BACK_MENU_IMG == "Map"
- create_menu_background
- elsif BACK_MENU_IMG == "MapFocus"
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = $game_temp.background_bitmap
- elsif !(BACK_MENU_IMG == "Black")
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = Cache.picture(BACK_MENU_IMG)
- end
- end
- #--------------------------------------------------------------------------
- # terminate
- #--------------------------------------------------------------------------
- def terminate
- if @menuback_sprite != nil
- @menuback_sprite.dispose
- end
- @playtime_window.dispose
- @gold_window.dispose
- @command_window.dispose
- @status_window.dispose
- end
- #--------------------------------------------------------------------------
- # update
- #--------------------------------------------------------------------------
- def update
- if @menuback_sprite != nil
- @menuback_sprite.update
- end
- if @status_window.open_flag
- if !@status_window.opening
- @status_window.open_flag = false
- @status_window.refresh
- end
- end
- @playtime_window.update
- @gold_window.update
- @command_window.update
- @status_window.update
- if @command_window.active
- update_command_selection
- elsif @status_window.active
- update_actor_selection
- end
- end
- #--------------------------------------------------------------------------
- # update_command_selection
- #--------------------------------------------------------------------------
- def update_command_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- $scene = Scene_Map.new
- elsif Input.trigger?(Input::C)
- if $game_party.members.size == 0 and @command_window.index < 4
- Sound.play_buzzer
- return
- elsif $game_system.save_disabled and @command_window.index == 4
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- case @command_window.index
- when 0
- $scene = Scene_Item.new
- when 1,2,3
- start_actor_selection
- when 4
- $scene = Scene_File.new(true, false, false)
- when 5
- $scene = Scene_End.new
- end
- end
- end
- end
- #===============================================================================
- # Window_GoldMap
- #===============================================================================
- class Window_GoldMap < Window_Base
- include TSDA
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize
- super(0,0, 544,WLH + 32)
- self.back_opacity = MENU_WINDOW_OPACITY
- refresh
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- if $game_party.members.size > 0
- draw_actor_name($game_party.members[0],0,0)
- end
- self.contents.font.color = system_color
- self.contents.draw_text(0, 0, 512, WLH, $game_map.map_name, 1)
- draw_currency_value($game_party.gold, 388, 0, 120)
- end
- end
- #===============================================================================
- # Window_MenuCommand
- #===============================================================================
- class Window_MenuCommand < Window_Selectable
- include TSDA
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(status_window)
- super(0,WLH + 32,384,WLH * 2 + 32)
- self.back_opacity = MENU_WINDOW_OPACITY
- @column_max = 6
- @row_max = 1
- @item_max = 6
- self.index = 0
- @status_window = status_window
- refresh
- end
- #--------------------------------------------------------------------------
- # update
- #--------------------------------------------------------------------------
- def update
- if @status_window.opening or @status_window.closing
- if cursor_movable?
- last_index = @index
- if Input.repeat?(Input::RIGHT)
- cursor_right(Input.trigger?(Input::RIGHT))
- end
- if Input.repeat?(Input::LEFT)
- cursor_left(Input.trigger?(Input::LEFT))
- end
- if @index != last_index
- Sound.play_cursor
- @status_window.openness = 255
- end
- end
- return
- end
- last_index = @index
- super
- if @index != last_index
- @status_window.openness = 0
- @status_window.menu_index = @index
- @status_window.open
- @status_window.contents.clear
- end
- end
- #--------------------------------------------------------------------------
- # cursor_right
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- if (@index < @item_max - 1 or wrap)
- @index = (@index + 1) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # cursor_left
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- if (@index > 0 or wrap)
- @index = (@index - 1 + @item_max) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # item_rect
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- r = contents.width / @column_max
- rect.width = r
- rect.height = contents.height
- rect.x = index * r
- rect.y = 0
- return rect
- end
- #--------------------------------------------------------------------------
- # update_cursor
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0
- self.cursor_rect.empty
- else
- self.cursor_rect = item_rect(@index)
- end
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- enable = [true, true, true, true, true, true]
- if $game_party.members.size == 0
- enable[0] = false
- enable[1] = false
- enable[2] = false
- enable[3] = false
- end
- if $game_system.save_disabled
- enable[4] = false
- end
- for i in 0...6
- draw_icon(MENU_ICONS[i], 5 + 58 * i, 5, enable[i])
- self.contents.draw_text(5 + 58 * i,24,58,WLH,MENU_WORDS[i])
- end
- end
- end
- #===============================================================================
- # Window_SEH
- #===============================================================================
- class Window_SEH < Window_Selectable
- attr_reader :menu_index
- attr_accessor :open_flag
- #---
- include TSDA
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(index)
- super(0,WLH * 3 + 64,544,280)
- self.back_opacity = MENU_WINDOW_OPACITY
- @column_max = $game_party.members.size
- @row_max = 1
- @item_max = $game_party.members.size
- self.index = -1
- @menu_index = index
- @open_flag = false
- refresh
- end
- #--------------------------------------------------------------------------
- # item_rect
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- r = contents.width / 4
- rect.width = r
- rect.height = contents.height
- rect.x = index * r
- rect.y = 0
- return rect
- end
- #--------------------------------------------------------------------------
- # update_cursor
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0
- self.cursor_rect.empty
- else
- self.cursor_rect = item_rect(@index)
- end
- end
- #--------------------------------------------------------------------------
- # menu_index=
- #--------------------------------------------------------------------------
- def menu_index=(index)
- @menu_index = index
- @open_flag = true
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- case @menu_index
- when 0
- refresh_item
- when 1
- refresh_skill
- when 2
- refresh_equip
- when 3
- refresh_status
- when 4
- refresh_save
- when 5
- self.contents.font.color = normal_color
- self.contents.draw_text(0,124 - WLH / 2,512, WLH,
- NoMenuInfo, 1)
- end
- end
- #--------------------------------------------------------------------------
- # refresh_status
- #--------------------------------------------------------------------------
- def refresh_status
- for actor in $game_party.members
- x = actor.index * 128 + 4
- draw_actor_face(actor, x, 4, 92)
- draw_actor_name(actor, x, 94)
- draw_actor_class(actor, x, 94 + WLH)
- draw_actor_level(actor, x, 94 + WLH * 2)
- draw_actor_state(actor, x, 94 + WLH * 3)
- draw_actor_hp(actor, x, 94 + WLH * 4)
- draw_actor_mp(actor, x, 94 + WLH * 5)
- end
- end
- #--------------------------------------------------------------------------
- # refresh_item
- #--------------------------------------------------------------------------
- def refresh_item
- if $game_party.items.size > 0
- self.contents.font.color = system_color
- if $game_party.items.size <= 16
- self.contents.draw_text(0,0,512, WLH,
- sprintf(HaveSTItems, $game_party.items.size), 1)
- data = []
- for i in 0...$game_party.items.size
- data.push($game_party.items[i])
- end
- for i in 0...data.size
- draw_item(i, data[i])
- end
- else
- self.contents.draw_text(0,0,512, WLH,
- HaveMoreSTItems, 1)
- data = []
- counter = 0
- for i in 0...16
- data.push($game_party.items[i])
- end
- for i in 0...data.size
- draw_item(i, data[i])
- end
- end
- else
- self.contents.font.color = normal_color
- self.contents.draw_text(0,124 - WLH / 2,512, WLH,
- NoMenuItem, 1)
- end
- end
- #--------------------------------------------------------------------------
- # draw_item
- #--------------------------------------------------------------------------
- def draw_item(index, item)
- rect = Rect.new((index % 2) * 256 + 4, (index / 2) * WLH + WLH * 2,
- 248,WLH)
- if item != nil
- number = $game_party.item_number(item)
- draw_item_name(item, rect.x, rect.y, true)
- self.contents.draw_text(rect, sprintf(":%2d", number), 2)
- end
- end
- #--------------------------------------------------------------------------
- # refresh_skill
- #--------------------------------------------------------------------------
- def refresh_skill
- for actor in $game_party.members
- x = actor.index * 128 + 4
- draw_actor_name(actor, x, 0)
- draw_actor_hp(actor, x, WLH)
- draw_actor_mp(actor, x, WLH * 2)
- draw_actor_level(actor, x, WLH * 3)
- counter = 0
- for skill in actor.skills
- if skill != nil
- draw_width_item_name(skill, x, WLH * counter + WLH * 5)
- counter += 1
- end
- if counter >= 5
- break
- end
- end
- if counter == 0
- self.contents.draw_text(x, WLH * 5, 128, WLH, TSDA::Nda)
- end
- end
- end
- #--------------------------------------------------------------------------
- # refresh_equip
- #--------------------------------------------------------------------------
- def refresh_equip
- for actor in $game_party.members
- x = actor.index * 128 + 4
- draw_actor_name(actor, x, 0)
- draw_actor_class(actor, x, WLH)
- draw_actor_level(actor, x, WLH * 2)
- counter = 0
- for item in actor.equips
- draw_width_item_name(item, x, WLH * counter + WLH * 4)
- if item != nil
- counter += 1
- end
- end
- if counter == 0
- self.contents.draw_text(x, WLH * 4, 128, WLH, TSDA::Nda)
- end
- end
- end
- #--------------------------------------------------------------------------
- # draw_only_item_name
- #--------------------------------------------------------------------------
- def draw_width_item_name(item, x, y, width = 120)
- if item != nil
- draw_icon(item.icon_index, x, y, true)
- self.contents.font.color = normal_color
- self.contents.draw_text(x + 24, y, width - 24, WLH, item.name)
- end
- end
- #--------------------------------------------------------------------------
- # refresh_save
- #--------------------------------------------------------------------------
- def refresh_save
- for i in 0..3
- filename = "Save#{i + 1}.rvdata"
- file_exist = FileTest.exist?(filename)
- self.contents.font.color = system_color
- name = SaveSlot + " #{i + 1}"
- self.contents.draw_text(i * 124 + 4, 4, 200, WLH, name)
- if file_exist
- file = File.open(filename, "r")
- error = false
- begin
- characters = Marshal.load(file)
- frame_count = Marshal.load(file)
- last_bgm = Marshal.load(file)
- last_bgs = Marshal.load(file)
- game_system = Marshal.load(file)
- game_message = Marshal.load(file)
- game_switches = Marshal.load(file)
- game_variables = Marshal.load(file)
- game_self_switches = Marshal.load(file)
- game_actors = Marshal.load(file)
- game_party = Marshal.load(file)
- game_troop = Marshal.load(file)
- game_map = Marshal.load(file)
- map_name = game_map.map_name
- total_sec = frame_count / Graphics.frame_rate
- rescue
- error = true
- ensure
- file.close
- end
- self.contents.font.color = normal_color
- if error
- self.contents.draw_text(i * 124 + 4, 4 + WLH * 2, 100, WLH,
- ClearSlot, 0)
- else
- self.contents.draw_text(i * 124 + 4, 4 + WLH, 100, WLH,
- map_name, 1)
- draw_playtime(i * 124 + 4, 4 + WLH * 2, 100, 1,total_sec)
- draw_party_characters(i * 124 + 4, 4 + WLH * 3,characters)
- end
- else
- self.contents.font.color = normal_color
- self.contents.draw_text(i * 124 + 4, 4 + WLH * 2, 120, WLH,
- ClearSlot, 0)
- end
- end
- end
- #--------------------------------------------------------------------------
- # draw_party_characters
- #--------------------------------------------------------------------------
- def draw_party_characters(x, y, characters)
- for i in 0...characters.size
- name = characters[i][0]
- index = characters[i][1]
- draw_character(name, index, x + (i % 2) * 32 + 32, y + (i / 2) * 64 + 64)
- end
- end
- #--------------------------------------------------------------------------
- # draw_playtime
- #--------------------------------------------------------------------------
- def draw_playtime(x, y, width, align, total_sec)
- hour = total_sec / 60 / 60
- min = total_sec / 60 % 60
- sec = total_sec % 60
- time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width, WLH, time_string, align)
- end
- end
- #===============================================================================
- # Window_PlayTime
- #===============================================================================
- class Window_PlayTime < Window_Base
- include TSDA
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize
- super(384,WLH + 32,160,WLH * 2 + 32)
- self.back_opacity = MENU_WINDOW_OPACITY
- refresh
- end
- #--------------------------------------------------------------------------
- # update
- #--------------------------------------------------------------------------
- def update
- super
- if REAL_TIME
- time = Time.now
- hour = time.hour
- min = time.min
- sec = time.sec
- total_sec = hour * 60 * 60 + min * 60 + sec
- if total_sec != @total_sec
- refresh(total_sec)
- end
- else
- if Graphics.frame_count / Graphics.frame_rate != @total_sec
- refresh
- end
- end
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh(total_sec = nil)
- self.contents.clear
- self.contents.font.color = system_color
- if REAL_TIME
- self.contents.draw_text(4, 0, 120, WLH, REAL_TIME_ST)
- if total_sec == nil
- time = Time.now
- hour = time.hour
- min = time.min
- sec = time.sec
- @total_sec = hour * 60 * 60 + min * 60 + sec
- else
- @total_sec = total_sec
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- end
- text = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(4, WLH, 120, WLH, text, 2)
- else
- self.contents.draw_text(4, 0, 120, WLH, NREAL_TIME_ST)
- @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, WLH, 120, WLH, text, 2)
- end
- end
- end
- #===============================================================================
- # FIM DO SCRIPT
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement