Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # TheoAllen - Profile Slot
- # Version : 1.0
- # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
- # (This script documentation is written in informal indonesian language)
- # =============================================================================
- ($imported ||= {})[:Theo_ProfileSlot] = true
- # =============================================================================
- # Change Logs:
- # -----------------------------------------------------------------------------
- # 2013.11.14 - Finished script
- # =============================================================================
- =begin
- -----------------------------------------------------------------------------
- Perkenalan :
- Script ini menambahkan fitur profile slot. Apa itu profile slot? Yaitu
- sebuah slot untuk tempat kamu menyimpan data di dalam game kamu.
- Gampangannya, kamu memilih slot yang akan di gunakan buat save game nantinya
- di game. Nah, player tidak bisa mengganti slot / save index di tengah
- permainan. Cara new gamenya pun harus dengan memilih index kosong.
- -----------------------------------------------------------------------------
- Cara penggunaan :
- Pasang script ini dibawah main namun diatas material
- Edit konfigurasinya untuk mengatur preferensi kamu
- Untuk menyimpan game dalam peta (Misalnya checkpoint) cukup dengan
- menggunakan script call seperti ini :
- DataManager.save
- -----------------------------------------------------------------------------
- Catatan :
- Script ini menghapus command continue pada titlescreen
- Script ini mengalihfungsikan save dalam menu command untuk save game
- Script ini mengalihfungsikan new game untuk masuk ke select profile
- -----------------------------------------------------------------------------
- Terms of use :
- Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
- keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
- dipake buat komersil, jangan lupa, gw dibagi gratisannya.
- =end
- # =============================================================================
- # Konfigurasi :
- # =============================================================================
- module Theo
- module ProfSlot
- # --------------------------------------------------------------------
- # Bantuan dan Konfirmasi :
- # --------------------------------------------------------------------
- HelpText = "Chọn File Lưu Hoặc Nhấn Nút SHIFT Để Xoá"
- DeleteConfirm = "Bạn Chắc Chắn Sẽ Xoá File Này Chứ ?"
- YesConfirm = "Vâng"
- CancelConfirm = "Không"
- DeleteButton = :SHIFT # Công Tắt Xoá
- # --------------------------------------------------------------------
- # --------------------------------------------------------------------
- # Vokab untuk isi slot :
- # --------------------------------------------------------------------
- VocabFilename = "File %d" # Nama file
- VocabLocation = "Vị Trí : " # Lokasi peta
- VocabPlaytime = "Thơi Gian : " # Lama bermain
- VocabNewGame = "Trò Mới :" # Untuk slot kosong
- # --------------------------------------------------------------------
- # --------------------------------------------------------------------
- # Lain-lain :
- # --------------------------------------------------------------------
- Disable_Save = false # Nếu bạn để true thì mục save ko hiện trong menu
- Use_Transition = true # Transisi saat load / new game?
- Background = "Wallpaper"
- # -------------------------------------------------------------------
- # ^
- # Wallpaper untuk select profile. Isi dengan "nil" (tanpa kutip) atau
- # kosongkan text diantara "" jika kamu tidak menggunakannya
- # --------------------------------------------------------------------
- end
- end
- # =============================================================================
- # Akhir dari konfigurasi
- # =============================================================================
- class << DataManager
- attr_accessor :profile_id
- alias theo_profile_slot_init init
- def init
- theo_profile_slot_init
- @profile_id = 0
- end
- def save
- save_game(profile_id)
- end
- alias theo_profslot_save_header make_save_header
- def make_save_header
- header = theo_profslot_save_header
- header[:gold] = $game_party.gold
- header[:location] = $game_map.display_name
- header
- end
- def delete_save(index)
- File.delete(make_filename(index))
- end
- end
- class Window_ProfileSlot < Window_Base
- attr_reader :index
- include Theo::ProfSlot
- def initialize(x,y,width,height,index)
- super(x,y,width,height)
- @index = index
- self.active = true
- refresh
- unselect
- end
- def item_rect
- xpos = 0
- ypos = 0
- width = 70
- height = line_height
- Rect.new(xpos,ypos,width,height)
- end
- def select
- cursor_rect.set(item_rect)
- end
- def unselect
- cursor_rect.empty
- end
- def refresh
- contents.clear
- change_color(normal_color)
- @header = DataManager.load_header(@index)
- rect = item_rect
- rect.x += 4
- draw_text(rect, sprintf(VocabFilename,@index+1))
- return draw_filled_slot unless slot_empty?
- return draw_empty_slot
- end
- def draw_filled_slot
- draw_party
- draw_info
- draw_gold
- end
- def draw_party
- x = 24
- y = item_rect.height + line_height * 2 + 12
- @header[:characters].each_with_index do |data, i|
- draw_character(data[0], data[1], x + i * 48, y)
- end
- end
- def draw_info
- y = contents.height - line_height*2
- s1 = VocabLocation
- s2 = VocabPlaytime
- width1 = text_size(s1).width
- width2 = text_size(s2).width
- change_color(system_color)
- draw_text(4,y,contents.width,line_height,s1)
- draw_text(4,y + line_height,contents.width,line_height,s2)
- change_color(normal_color)
- draw_text(4+width1,y,contents.width,line_height,@header[:location])
- playtime = @header[:playtime_s]
- draw_text(4+width2,y + line_height,contents.width,line_height,playtime)
- end
- def draw_gold
- draw_currency_value(@header[:gold],Vocab.currency_unit,
- 4,0,contents.width - 8)
- end
- def draw_empty_slot
- rect = contents.rect
- draw_text(rect, VocabNewGame, 1)
- end
- def slot_empty?
- @header.nil?
- end
- end
- class Window_ProfConfirm < Window_Command
- def initialize
- super(0,0)
- self.openness = 0
- deactivate
- end
- def make_command_list
- add_command(Theo::ProfSlot::YesConfirm, :yes)
- add_command(Theo::ProfSlot::CancelConfirm, :cancel)
- end
- def alignment
- return 1
- end
- end
- class Window_ProfConfirmText < Window_Base
- def initialize
- super(0,0,1,fitting_height(1))
- resize_window
- self.openness = 0
- end
- def resize_window
- @text = Theo::ProfSlot::DeleteConfirm
- size = text_size(@text).width + standard_padding*2 + 4
- self.width = size
- create_contents
- to_center
- refresh
- end
- def to_center
- self.x = (Graphics.width - width) / 2
- self.y = ((Graphics.height - height) / 2) - 24
- end
- def refresh
- contents.clear
- draw_text(0,0,contents.width,line_height,@text,1)
- end
- end
- class Window_MenuCommand < Window_Command
- alias theo_profslot_make_command make_command_list
- def make_command_list
- theo_profslot_make_command
- @list.delete_if do |list|
- list[:symbol] == :save
- end if Theo::ProfSlot::Disable_Save
- end
- end
- class Window_TitleCommand < Window_Command
- alias theo_profslot_make_command make_command_list
- def make_command_list
- theo_profslot_make_command
- @list.delete_if do |list|
- list[:symbol] == :continue
- end
- end
- end
- class Scene_Title < Scene_Base
- # --------------------------------------------------------------------------
- # Overwrite Command New Game
- # --------------------------------------------------------------------------
- def command_new_game
- close_command_window
- fadeout_all
- SceneManager.goto(Scene_ProfileSlot)
- end
- end
- class Scene_Menu < Scene_MenuBase
- # --------------------------------------------------------------------------
- # Overwrite Command Save
- # --------------------------------------------------------------------------
- def command_save
- DataManager.save
- @command_window.activate
- end
- end
- class Scene_ProfileSlot < Scene_MenuBase
- attr_reader :index
- def start
- super
- @index = 0
- @viewport2 = Viewport.new
- @viewport2.z = 300
- @active = true
- create_help
- create_slots
- create_confirmation
- end
- def create_background
- super
- bgname = Theo::ProfSlot::Background
- @background_sprite.bitmap = Cache.system(bgname) if bgname && !bgname.empty?
- end
- def create_help
- @help_window = Window_Help.new(1)
- @help_window.set_text(Theo::ProfSlot::HelpText)
- end
- def create_slots
- width = Graphics.width / 2
- height = (Graphics.height - @help_window.height) / 2
- @slots = Array.new(4) do |index|
- xpos = (index % 2) * width
- ypos = (index / 2) * height + @help_window.height
- Window_ProfileSlot.new(xpos,ypos,width,height,index)
- end
- refresh_cursor
- end
- def create_confirmation
- @confirm_text = Window_ProfConfirmText.new
- @confirm_command = Window_ProfConfirm.new
- @confirm_command.x = (Graphics.width - @confirm_command.width)/2
- @confirm_command.y = @confirm_text.y + @confirm_text.height
- @confirm_command.set_handler(:yes, method(:on_delete_ok))
- @confirm_command.set_handler(:cancel, method(:on_delete_cancel))
- end
- def update
- super
- update_slot
- if @active
- update_cursor
- on_confirm if Input.trigger?(:C)
- on_cancel if Input.trigger?(:B)
- on_delete if Input.trigger?(Theo::ProfSlot::DeleteButton)
- end
- end
- def update_slot
- @slots.each {|slot| slot.update}
- end
- def update_cursor
- change_index(-2)if Input.trigger?(:UP)
- change_index(2)if Input.trigger?(:DOWN)
- change_index(-1)if Input.trigger?(:LEFT)
- change_index(1)if Input.trigger?(:RIGHT)
- end
- def change_index(new_index)
- return unless change_possible?(new_index)
- @index += new_index
- Sound.play_cursor
- refresh_cursor
- end
- def change_possible?(new_index)
- n = @index + new_index
- return n >= 0 && n <= 3
- end
- def refresh_cursor
- @slots.each do |slot|
- if slot.index == @index
- slot.select
- else
- slot.unselect
- end
- end
- end
- def on_confirm
- Sound.play_ok
- start_darken
- end
- def start_darken
- @viewport.color = Color.new(0,0,0,0)
- first_transition
- execute_slot
- end
- def execute_slot
- @slots[index].slot_empty? ? on_new_game : on_load_game
- end
- def on_cancel
- Sound.play_cancel
- return_scene
- end
- def on_delete
- if @slots[index].slot_empty?
- Sound.play_buzzer
- return
- end
- Sound.play_ok
- @active = false
- @confirm_text.open
- @confirm_command.open
- @confirm_command.activate
- end
- def on_delete_ok
- @active = true
- DataManager.delete_save(index)
- Sound.play_equip
- @slots[index].refresh
- close_confirmation
- end
- def on_delete_cancel
- @active = true
- close_confirmation
- end
- def close_confirmation
- @confirm_text.close
- @confirm_command.close
- @confirm_command.deactivate
- end
- def on_new_game
- second_transition
- DataManager.profile_id = @index
- DataManager.setup_new_game
- $game_map.autoplay
- SceneManager.goto(Scene_Map)
- end
- def on_load_game
- second_transition
- DataManager.profile_id = @index
- DataManager.load_game(@index)
- $game_system.on_after_load
- SceneManager.goto(Scene_Map)
- end
- def first_transition
- return unless Theo::ProfSlot::Use_Transition
- if $imported[:Theo_Movement]
- x = (Graphics.width - @slots[index].width) / 2
- y = (Graphics.height - @slots[index].height) / 2
- @slots[index].goto(x,y)
- end
- @help_window.viewport = @viewport
- @slots.each do |slot|
- if slot.index == index
- slot.viewport = @viewport2
- else
- slot.viewport = @viewport
- end
- end
- until @viewport.color.alpha == 255
- update_basic
- @slots[index].update
- @viewport.color.alpha += 5
- end
- end
- def second_transition
- return unless Theo::ProfSlot::Use_Transition
- 60.times { update_basic }
- @viewport2.color = Color.new(0,0,0,0)
- until @viewport2.color.alpha == 255
- update_basic
- @viewport2.color.alpha += 5
- end
- @slots[index].visible = false
- @viewport2.color.alpha = 0
- end
- def terminate
- super
- @slots.each {|slot| slot.dispose}
- end
- end
Add Comment
Please, Sign In to add comment