Advertisement
Kakakadafi

Save Notification

Oct 3rd, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.80 KB | None | 0 0
  1. #==============================================================================
  2. # Kadafi - Save Notification
  3. # Version : 1.0
  4. # Contact : http://forums.rpgmakerweb.com/index.php?/user/33654-kadafi/
  5. #==============================================================================
  6. ($imported ||= {})[:Kadafi_SaveNotif] = true
  7. #==============================================================================
  8. # CHANGE LOGS:
  9. # -----------------------------------------------------------------------------
  10. # 2016.10.04 - Finished script
  11. #==============================================================================
  12. =begin
  13.  
  14.   Introduction :
  15.   This script create a save notification.
  16.  
  17.   How to Use :
  18.   Edit the configuration below.
  19.  
  20.   Terms of Use :
  21.   1. Credit me as Kadafi (Optional)
  22.  
  23. =end
  24. #==============================================================================
  25. # Configuration
  26. #==============================================================================
  27. module Kadafi
  28.   #--------------------------------------------------------------------------
  29.   # * Notification Window Width in Scene_Map
  30.   #--------------------------------------------------------------------------
  31.   SaveNotifWindow_Width = 256
  32.   #--------------------------------------------------------------------------
  33.   # * Notification Vocab
  34.   #--------------------------------------------------------------------------
  35.   SaveNotif_Vocab = "Game Saved"
  36.   #--------------------------------------------------------------------------
  37.   # * Notification Window Show Count
  38.   #--------------------------------------------------------------------------
  39.   SaveNotif_ShowCount = 30 # Frames / 60s
  40. end
  41. #==============================================================================
  42. # Don't edit below this line unless you know what to do.
  43. #==============================================================================
  44.  
  45. #==============================================================================
  46. # ** Game_Map
  47. #==============================================================================
  48.  
  49. class Game_Map
  50.   attr_reader :save_notif
  51.   attr_accessor :save_notif
  52.   #--------------------------------------------------------------------------
  53.   # * Object Initialization
  54.   #--------------------------------------------------------------------------
  55.   alias old_initialize_1 initialize
  56.   def initialize
  57.     old_initialize_1
  58.     @save_notif = false
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Show Item Use Notification
  62.   #--------------------------------------------------------------------------
  63.   def save_notification
  64.     @save_notif = true
  65.   end
  66. end
  67.  
  68. #==============================================================================
  69. # ** Window_SaveNotification
  70. #==============================================================================
  71.  
  72. class Window_SaveNotification < Window_Base
  73.   #--------------------------------------------------------------------------
  74.   # * Object Initialization
  75.   #--------------------------------------------------------------------------
  76.   def initialize
  77.     super(0, 0, window_width, fitting_height(1))
  78.     update_placement
  79.     @notif = ""
  80.     @fade = false
  81.     @show_count = 0
  82.     refresh
  83.     hide
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # * Update Window Position
  87.   #--------------------------------------------------------------------------
  88.   def update_placement
  89.     self.x = (Graphics.width - width) / 2
  90.     self.y = Graphics.height - height
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # * Get Window Width
  94.   #--------------------------------------------------------------------------
  95.   def window_width
  96.     return Kadafi::EquipSkillNotifWindow_Width
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # * Refresh
  100.   #--------------------------------------------------------------------------
  101.   def refresh
  102.     contents.clear
  103.     text = Kadafi::SaveNotif_Vocab
  104.     draw_text(0 - line_height / 2, 0, width, line_height, text, 1)
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Frame Update
  108.   #--------------------------------------------------------------------------
  109.   def update
  110.     super
  111.     if open? && @show_count > 0
  112.       @show_count -= 1
  113.       if @show_count == 0
  114.         @fade = true
  115.       end
  116.     end
  117.     if @fade
  118.       self.opacity -= 1
  119.       self.contents_opacity -= 1
  120.       if self.opacity == 0
  121.         @fade = false
  122.       end
  123.     end
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # * Show Notification
  127.   #--------------------------------------------------------------------------
  128.   def show_notification
  129.     self.opacity = 255
  130.     self.contents_opacity = 255
  131.     @show_count = Kadafi::SaveNotif_ShowCount
  132.     refresh
  133.     show
  134.   end
  135. end
  136.  
  137. #==============================================================================
  138. # ** Scene_Map
  139. #==============================================================================
  140.  
  141. class Scene_Map < Scene_Base
  142.   #--------------------------------------------------------------------------
  143.   # * Start Processing
  144.   #--------------------------------------------------------------------------
  145.   alias old_start start
  146.   def start
  147.     old_start
  148.     create_savenotif_window
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Create Notification Window
  152.   #--------------------------------------------------------------------------
  153.   def create_savenotif_window
  154.     @savenotif_window = Window_SaveNotification.new
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # * Show Item Use Notification
  158.   #--------------------------------------------------------------------------
  159.   def show_savenotif
  160.     @savenotif_window.show_notification
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # * Frame Update
  164.   #--------------------------------------------------------------------------
  165.   alias old_update_1 update
  166.   def update
  167.     old_update_1
  168.     if $game_map.save_notif
  169.       show_savenotif
  170.       $game_map.save_notif = false
  171.     end
  172.   end
  173. end
  174.  
  175. #==============================================================================
  176. # ** Scene_Save
  177. #==============================================================================
  178.  
  179. class Scene_Save < Scene_File
  180.   #--------------------------------------------------------------------------
  181.   # * Processing When Save Is Successful
  182.   #--------------------------------------------------------------------------
  183.   alias old_on_save_success_1 on_save_success
  184.   def on_save_success
  185.     old_on_save_success_1
  186.     $game_map.save_notification
  187.   end
  188. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement