TheoAllen

Theo - Save Confirmation

Sep 2nd, 2013
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.80 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Save Confirmation
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_SaveConfirm] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.09.03 - Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Script ini ngebikin saat kamu save game akan menampilkan window konfirmasi
  17.   jika slot save sudah terpakai
  18.  
  19.   Cara penggunaan :
  20.   Pasang dibawah material namun diatas main
  21.   Edit konfigurasinya jika dirasa perlu
  22.  
  23.   Terms of use :
  24.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  25.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  26.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.    
  27.  
  28. =end
  29. # =============================================================================
  30. # konfigurasi
  31. # =============================================================================
  32. module THEO
  33.   module Save
  34.    
  35.   # ------------------------------------------------------------------------  
  36.     ConfirmText = "Overwrite existing file?"
  37.   # Text yang ditampilin di help window
  38.   # ------------------------------------------------------------------------
  39.  
  40.   # ------------------------------------------------------------------------  
  41.     YesConfirm  = "Yes" # Vocab untuk iya
  42.     NoConfirm   = "No"  # Vocab untuk tidak
  43.   # ------------------------------------------------------------------------
  44.  
  45.   end
  46. end
  47. # =============================================================================
  48. # Akhir dari konfig
  49. # =============================================================================
  50. class Window_SaveConfirm < Window_Command  
  51.  
  52.   def initialize
  53.     super(0,0)
  54.     to_center
  55.     self.openness = 0
  56.     deactivate
  57.   end
  58.  
  59.   def to_center
  60.     self.x = (Graphics.width - width)/2
  61.     self.y = (Graphics.height - height)/2
  62.   end
  63.  
  64.   def alignment
  65.     return 1
  66.   end
  67.  
  68.   def make_command_list
  69.     add_command(THEO::Save::YesConfirm, :yes)
  70.     add_command(THEO::Save::NoConfirm, :cancel)
  71.   end
  72.  
  73.   def window_width
  74.     return 120
  75.   end  
  76.  
  77. end
  78.  
  79. class Scene_Save < Scene_File
  80.  
  81.   alias theo_saveconfirm_start start
  82.   def start
  83.     theo_saveconfirm_start
  84.     create_saveconfirm
  85.   end
  86.  
  87.   def create_saveconfirm
  88.     @confirm = Window_SaveConfirm.new
  89.     @confirm.viewport = @viewport
  90.     @confirm.set_handler(:yes, method(:theo_saveconfirm_ok))
  91.     @confirm.set_handler(:cancel, method(:confirm_cancel))
  92.   end
  93.  
  94.   alias theo_saveconfirm_ok on_savefile_ok
  95.   def on_savefile_ok
  96.     if file_exist?
  97.       activate_confirm
  98.     else
  99.       theo_saveconfirm_ok
  100.     end
  101.   end
  102.  
  103.   def activate_confirm
  104.     @confirm.open
  105.     @confirm.activate
  106.     @help_window.set_text(confirm_text)
  107.   end
  108.  
  109.   def confirm_text
  110.     THEO::Save::ConfirmText
  111.   end
  112.  
  113.   def confirm_cancel
  114.     @confirm.close
  115.     @help_window.set_text(help_window_text)
  116.   end
  117.  
  118.   def file_exist?
  119.     filename = DataManager.make_filename(@index)
  120.     FileTest.exist?(filename)
  121.   end
  122.  
  123.   alias theo_saveconfirm_update_cursor update_cursor
  124.   def update_cursor
  125.     return if @confirm.active
  126.     theo_saveconfirm_update_cursor
  127.   end
  128.  
  129.   alias theo_saveconfirm_update update
  130.   def update
  131.     theo_saveconfirm_update
  132.     update_active
  133.   end
  134.  
  135.   def update_active
  136.     @savefile_windows.each {|window| window.active = !@confirm.active}
  137.   end
  138.  
  139. end
Advertisement
Add Comment
Please, Sign In to add comment