Advertisement
LiTTleDRAgo

[RGSS/2/3] Drago - Button Reminder

Nov 21st, 2013
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.02 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # [Xp/Vx-VxA] Button Reminder
  3. # Version 1.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6.  
  7. ($imported ||= {})[:drg_button_reminder] = 1.00
  8.  
  9. module LiTTleDRAgo
  10.  
  11.   BUTTON_REMINDER_FONT_NAME1 = ["Finger Paint","Georgia","Arial"]
  12.   BUTTON_REMINDER_FONT_NAME2 = ["Georgia","Arial"]
  13.  
  14.   BUTTON_REMINDER_FONT_SIZE1 = 20
  15.   BUTTON_REMINDER_FONT_SIZE2 = 20
  16.  
  17.   BUTTON_REMINDER_FONT_COLOR1 = Color.blue
  18.   BUTTON_REMINDER_FONT_COLOR2 = nil
  19.  
  20. end
  21.  
  22. text = "This Script needs Drago - Core Engine v1.39 or later"
  23. ($imported[:drg_core_engine] || 0) >= 1.39 || raise(text)
  24. #==============================================================================
  25. # ** Scene_Map
  26. #------------------------------------------------------------------------------
  27. #  This class performs the map screen processing.
  28. #==============================================================================
  29. class Scene_Map
  30.   #--------------------------------------------------------------------------
  31.   # * Disable Button Reminder Sprite
  32.   # Add your own condition to disable button reminder
  33.   #--------------------------------------------------------------------------
  34.   def disable_brsprite?
  35.     return true if $game_map.interpreter.running?
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # * Condition Button Reminder Sprite
  39.   #--------------------------------------------------------------------------
  40.   def condition_brsprite
  41.     cond = {
  42.     'E Hotkey Change' => $mog_rgss3_ultima_hud && (hud = @spriteset.
  43.                          instance_variable_get(:@ultima_hud)).
  44.                          is_a?(Ultima_Hud) && !hud.can_auto_hide?,
  45.     'B/ESC Main Menu' => true,                       # always active
  46.     'Shift Run'       => $game_switches[1] == true,  # if switch 1 is on
  47.     }
  48.     return cond
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # * Alias Listing
  52.   #--------------------------------------------------------------------------
  53.   alias_sec_method :button_reminder_main,   :main
  54.   alias_sec_method :button_reminder_update, :update
  55.   #--------------------------------------------------------------------------
  56.   # * Main
  57.   #--------------------------------------------------------------------------
  58.   def main
  59.     button_reminder_main
  60.     @brsprite.each {|s| s.disposed? || s.dispose }
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Update Frame
  64.   #--------------------------------------------------------------------------
  65.   def update
  66.     button_reminder_update
  67.     create_brsprite && update_brsprite && update_condition_brsprite
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Create Button Reminder Sprite
  71.   #--------------------------------------------------------------------------
  72.   def create_brsprite
  73.     @brsprite ||= []
  74.     $game_system.button_reminder.each_with_index do |string,i|
  75.       if @brsprite[i].not.is_a?(Sprite) || @brsprite[i].disposed?
  76.         @brsprite[i] = Sprite.new
  77.         @brsprite[i].instance_variable_set(:@words,string)
  78.         words = string.words
  79.         @brsprite[i].bitmap = Bitmap.new(a = Graphics.width, 32)
  80.         @brsprite[i].x = a
  81.         @brsprite[i].y = 42 + i * 24
  82.         font = @brsprite[i].bitmap.font.dup
  83.         text = words.shift
  84.         fna1 = LiTTleDRAgo::BUTTON_REMINDER_FONT_NAME1
  85.         fna2 = LiTTleDRAgo::BUTTON_REMINDER_FONT_NAME2
  86.         @brsprite[i].bitmap.font.name = [fna2, font.name].flatten
  87.         @brsprite[i].bitmap.font.size = LiTTleDRAgo::BUTTON_REMINDER_FONT_SIZE2
  88.         if (color = LiTTleDRAgo::BUTTON_REMINDER_FONT_COLOR2)
  89.           unless @brsprite[i].bitmap.font.respond_to?(:glow) &&
  90.             (@brsprite[i].bitmap.font.glow  = color)
  91.             (@brsprite[i].bitmap.font.color = color)
  92.           end
  93.         end
  94.         size = @brsprite[i].bitmap.text_size(w = " : #{words.join(' ')}").width
  95.         @brsprite[i].bitmap.draw_text(0,0, a - 20, 32, w, 2)
  96.         @brsprite[i].bitmap.font.name = [fna1, font.name].flatten
  97.         @brsprite[i].bitmap.font.size = LiTTleDRAgo::BUTTON_REMINDER_FONT_SIZE1
  98.         if (color = LiTTleDRAgo::BUTTON_REMINDER_FONT_COLOR1)
  99.           unless @brsprite[i].bitmap.font.respond_to?(:glow) &&
  100.             (@brsprite[i].bitmap.font.glow  = color)
  101.             (@brsprite[i].bitmap.font.color = color)
  102.           end
  103.         end
  104.         @brsprite[i].bitmap.draw_text(0,0, a - size - 20, 32,text,2)
  105.       end
  106.     end
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # * Update Button Reminder Sprite
  110.   #--------------------------------------------------------------------------
  111.   def update_brsprite
  112.     @brsprite.each_index do |i|
  113.       next if @brsprite[i].disposed?
  114.       @brsprite[i].opacity += disable_brsprite? ? -10 : 10
  115.       if @brsprite[i].instance_variable_get(:@words) ==
  116.         $game_system.button_reminder[i]
  117.         @brsprite[i].update
  118.         @brsprite[i].x = [@brsprite[i].x - 8,0].max
  119.       else
  120.         @brsprite[i].update
  121.         @brsprite[i].x = [@brsprite[i].x + 15,Graphics.width].min
  122.         @brsprite[i].dispose if @brsprite[i].x >= Graphics.width
  123.       end
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Update Condition Button Reminder Sprite
  128.   #--------------------------------------------------------------------------
  129.   def update_condition_brsprite
  130.     condition_brsprite.each do |key,value|
  131.       if value && !button_reminder.include?(key)
  132.         button_reminder << key
  133.       elsif !value && button_reminder.include?(key)
  134.         button_reminder.delete(key)
  135.       end
  136.     end
  137.   end
  138. end
  139.  
  140. #==============================================================================
  141. # ** Object
  142. #------------------------------------------------------------------------------
  143. #  This class is superclass from all classes.
  144. #==============================================================================
  145. class Object
  146.   #--------------------------------------------------------------------------
  147.   # * Button Reminder
  148.   #--------------------------------------------------------------------------
  149.   define_inexist_method(:button_reminder) { $game_system.button_reminder }
  150. end
  151.  
  152. #==============================================================================
  153. # ** Game_System
  154. #------------------------------------------------------------------------------
  155. #  This class handles system data. It saves the disable state of saving and
  156. # menus. Instances of this class are referenced by $game_system.
  157. #==============================================================================
  158. class Game_System
  159.   #--------------------------------------------------------------------------
  160.   # * Public Instance Variables
  161.   #--------------------------------------------------------------------------
  162.   attr_sec_reader :button_reminder, "[]"
  163. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement