Advertisement
Holy87

Generic Map Bar - ENG

Aug 3rd, 2015
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 28.03 KB | None | 0 0
  1. $imported = {} if $imported == nil
  2. $imported["h87_Genericbar"] = true
  3. #===============================================================================
  4. # GENERIC BARS ON MAPS
  5. #===============================================================================
  6. # Author: Holy87
  7. # Version: 1.2
  8. # User difficulty: ★★
  9. #-------------------------------------------------------------------------------
  10. # With this script you can show a bar on the map that indicates anything you
  11. # want. It's possible, through script commands, set position, description and
  12. # bar color, and, obviously, the value.
  13. # It's not completely customizable to be easy to use.
  14. #-------------------------------------------------------------------------------
  15. # Instructions:
  16. # Paste this script under Materials and before the Main. You can set the bar's
  17. # description with a SCRIPT CALL:
  18. # ★ set_genbar("Text"), for the bar title (like Life, Mana etc...)
  19. # when setted, you can use the command to show the bar like this:
  20. # ★ show_bar
  21. # You can set the bar value with a number between 0 and 100, calling the script
  22. # ★ set_bar_value(x), where x is the value.
  23. # to close the windows when you don't need it anymore:
  24. # ★ hide_bar
  25. #
  26. # ADVANCED CONTROLS:
  27. # ★ set_bar("Text",color,x,y)
  28. # wher color is a Color class: Color.new(R,G,B) (R, G and B) are the tonalities
  29. # between 0 and 255, and rapresents the bar color
  30. # x & y are respectively the x and y coordinates of the square
  31. # ★ resize_bar(width, height)
  32. # resizes the aspect of the bar's square
  33. # ★ get_bar_value or get_bar_value(bar_name) returns the bar's value
  34. #
  35. # FOR MORE BARS:
  36. # The previous methods use a default bar, but you can add multiple bars using
  37. # a symbol or a string that identify them.
  38. # ★ add_bar(:bar_name) adds a new generic bar
  39. # ★ remove_bar(:bar_name:) deletes a bar from the map
  40. # ★ set_bar(:bar_name,["Text",color,x,y])
  41. #    adds and sets a new bar on the screen. the bar_name variable identify it
  42. #    (for example, "hungry") identifies a bar that we use for hungry. The values
  43. #    inside the square parenthesys are optional.
  44. # ★ resize_bar(:bar_name, width, eight)
  45. #    resizes the square of bar_name
  46. # ★ show_bar(:bar_name) show a bar on the screen
  47. # ★ set_bar_value(:bar_name, x) sets the value x of a specific bar
  48. # ★ hide_bar(:bar_name) hides a bar
  49. #
  50. # USING SPECIAL EFFECTS
  51. # ★ snooze_bar o snooze_bar(:bar_name) make the bar shaking (in example, to
  52. #    symulate an hit received)
  53. #    more options: snooze_bar(:bar_name, timing, strenght)
  54. #    timing: how much time it will shake (15 by default)
  55. #    strenght: the shake strenght (5 by default)
  56. # ★ flash_bar or flash_bar(:bar_name) emits a flash on the bar
  57. #    more options: flash_bar(:bar_name, timing, color)
  58. #    timing: the flash duration (30 by default, ½ of second)
  59. #    color: (white by default) is a Color.new(R, G, B)
  60. # * You can omit :bar_name if it's the default bar.
  61. #-------------------------------------------------------------------------------
  62. # Compatibility:
  63. # classe Spriteset_Map -> alias update, initialize, terminate
  64. #-------------------------------------------------------------------------------
  65.  
  66. #===============================================================================
  67. # ** Settings
  68. #===============================================================================
  69. module H87_GBSettings
  70.                   #R, G,  B
  71.   Default_Color = [0,120,250]           #Default color
  72.   DefaultX = 10                         #Default X position
  73.   DefaultY = 10                         #Default Y position
  74.   DefaultWidth = 200                    #Default width
  75.   DefaultHeight = 40                    #Default height
  76.  
  77.   BarHeight = 10                        #Bar height
  78.  
  79. end
  80.   #============================================================================
  81.   # ** END OF CONFIGURATION **
  82.   # Edit below this point is risky to anyone can't make scripts.
  83.   #============================================================================
  84.  
  85.  
  86.  
  87.  
  88. #===============================================================================
  89. # ** Classe Game_System
  90. #===============================================================================
  91. class Game_System
  92.   include H87_GBSettings          #Including the module
  93.   #-----------------------------------------------------------------------------
  94.   # * Returns the bar's status
  95.   #-----------------------------------------------------------------------------
  96.   def generic_bar_settings(bar = :default)
  97.     @barsettings = {} if @barsettings.nil?
  98.     reset_bar_h(bar) if @barsettings[bar] == nil
  99.     return @barsettings[bar]
  100.   end
  101.   #-----------------------------------------------------------------------------
  102.   # * Resets the bar settings
  103.   #-----------------------------------------------------------------------------
  104.   def reset_bar_h(bar = :default)
  105.     @barsettings[bar] = [
  106.                     bar_defaultx, #PosX
  107.                     bar_defaulty, #PosY
  108.                     bar_defaultw, #Width
  109.                     bar_defaulth, #Heihgt
  110.                     "",           #Name
  111.                     bar_def_colr, #Bar color
  112.                     false,        #Visible?
  113.                     0,            #Percentage
  114.                     false,        #Changed?
  115.                     false         #Width changed
  116.     ]
  117.   end
  118.   #-----------------------------------------------------------------------------
  119.   # * Returns the current scene (VX or VX Ace)
  120.   #-----------------------------------------------------------------------------
  121.   def current_scene
  122.     begin
  123.       return SceneManager.scene
  124.     rescue
  125.       return $scene
  126.     end
  127.   end
  128.   #-----------------------------------------------------------------------------
  129.   # * Returns the bar's default color
  130.   #-----------------------------------------------------------------------------
  131.   def bar_def_colr
  132.     c = Default_Color
  133.     return Color.new(c[0],c[1],c[2])
  134.   end
  135.   #-----------------------------------------------------------------------------
  136.   # * Restituisce la coordinata predefinita
  137.   #-----------------------------------------------------------------------------
  138.   def bar_defaultx
  139.     return DefaultX
  140.   end
  141.   #-----------------------------------------------------------------------------
  142.   # * Restituisce la coordinata predefinita
  143.   #-----------------------------------------------------------------------------
  144.   def bar_defaulty
  145.     return DefaultY
  146.   end
  147.   #-----------------------------------------------------------------------------
  148.   # * Restituisce la larghezza predefinita
  149.   #-----------------------------------------------------------------------------
  150.   def bar_defaultw
  151.     return DefaultWidth
  152.   end
  153.   #-----------------------------------------------------------------------------
  154.   # * Restituisce l'altezza predefinita
  155.   #-----------------------------------------------------------------------------
  156.   def bar_defaulth
  157.     return DefaultHeight
  158.   end
  159.   #-----------------------------------------------------------------------------
  160.   # * Reimposta le proprietà della finestra della barra. Aggiunge una nuova se
  161.   #   il nome non è compreso
  162.   #-----------------------------------------------------------------------------
  163.   def generic_bar_set(letter, colore = bar_def_colr, x = nil, y = nil, bar = :default)
  164.     @barsettings = {} if @barsettings.nil?
  165.     if @barsettings[bar] == nil
  166.       reset_bar_h
  167.       add_active_bar(bar)
  168.     end
  169.     @barsettings[bar][0] = x if x != nil
  170.     @barsettings[bar][1] = y if y != nil
  171.     @barsettings[bar][4] = letter
  172.     @barsettings[bar][5] = colore
  173.     @barsettings[bar][8] = true #flag di modifica per refresh
  174.   end
  175.   #-----------------------------------------------------------------------------
  176.   # * Metodo alternativo per impostare la barra
  177.   #-----------------------------------------------------------------------------
  178.   def set_bar(bar, text, colore = bar_def_colr, x = nil, y = nil)
  179.     generic_bar_set(text, colore, x, y, bar)
  180.   end
  181.   #-----------------------------------------------------------------------------
  182.   # * Restituisce il colore predefinito della barra
  183.   #-----------------------------------------------------------------------------
  184.   def active_bars
  185.     @barsettings = {} if @barsettings.nil?
  186.     return @barsettings
  187.   end
  188.   #-----------------------------------------------------------------------------
  189.   # * Aggiunge una nuova barra
  190.   #-----------------------------------------------------------------------------
  191.   def add_active_bar(bar_name)
  192.     return if bar_name == :default
  193.     @barsettings = {} if @barsettings.nil?
  194.     return if self.active_bars.include?(bar_name)
  195.     @barsettings[bar_name] = reset_bar_h(bar_name)
  196.     current_scene.add_genbar(bar_name)
  197.   end
  198.   #-----------------------------------------------------------------------------
  199.   # * Rimuove una barra
  200.   #-----------------------------------------------------------------------------
  201.   def remove_active_bar(bar_name)
  202.     return if bar_name == :default
  203.     self.active_bars.delete(bar_name)
  204.     current_scene.remove_genbar(bar_name)
  205.   end
  206.   #-----------------------------------------------------------------------------
  207.   # * Mostra la finestra della barra
  208.   #-----------------------------------------------------------------------------
  209.   def show_generic_bar(bar = :default)
  210.     @barsettings = {} if @barsettings.nil?
  211.     reset_bar_h(bar) if @barsettings[bar] == nil
  212.     return if @barsettings[bar][6] == true
  213.     @barsettings[bar][6] = true
  214.     @barsettings[bar][8] = true
  215.   end
  216.   #-----------------------------------------------------------------------------
  217.   # * Nasconde la finestra della barra
  218.   #-----------------------------------------------------------------------------
  219.   def hide_generic_bar(bar = :default)
  220.     @barsettings = {} if @barsettings.nil?
  221.     reset_bar_h(bar) if @barsettings[bar] == nil
  222.     return if @barsettings[bar][6] == false
  223.     @barsettings[bar][6] = false
  224.     @barsettings[bar][8] = true
  225.   end
  226.   #-----------------------------------------------------------------------------
  227.   # * Assegna un valore da 0 a 100 per la percentuale della barra
  228.   #-----------------------------------------------------------------------------
  229.   def bar_percentage(value, bar = :default)
  230.     @barsettings = {} if @barsettings.nil?
  231.     reset_bar_h(bar) if @barsettings[bar].nil?
  232.     value = 0 if value < 0
  233.     value = 100 if value > 100
  234.     @barsettings[bar][7] = value
  235.     @barsettings[bar][9] = false
  236.   end
  237.   #-----------------------------------------------------------------------------
  238.   # * restituisce il valore della barra
  239.   #-----------------------------------------------------------------------------
  240.   def get_bar_percentage(bar = :default)
  241.     @barsettings = {} if @barsettings.nil?
  242.     @barsettings[bar][7] = 0 if @barsettings[bar][7] == nil
  243.     return @barsettings[bar][7]
  244.   end
  245.   #-----------------------------------------------------------------------------
  246.   # * Ridimensiona la finestra della barra
  247.   #-----------------------------------------------------------------------------
  248.   def bar_resize(w,h, bar = :default)
  249.     @barsettings[bar][2] = w
  250.     @barsettings[bar][3] = h
  251.     @barsettings[bar][8] = true
  252.   end
  253. end #game_system
  254.  
  255. #===============================================================================
  256. # ** Classe Barra_Generica
  257. #===============================================================================
  258. class Barra_Generica
  259.   attr_reader   :visible
  260.   attr_reader   :x
  261.   attr_reader   :y
  262.   attr_reader   :width
  263.   attr_reader   :height
  264.   #-----------------------------------------------------------------------------
  265.   # * Inizializzazione
  266.   #-----------------------------------------------------------------------------
  267.   def initialize(viewport, bar_name = :default)
  268.     @bar_name = bar_name
  269.     @lb = H87_GBSettings::BarHeight #altezza barra
  270.     @sp = 5                         #spaziatura
  271.     @viewport = viewport
  272.     @snooze_time = 0
  273.     reset_settings
  274.   end
  275.   #-----------------------------------------------------------------------------
  276.   # * Assegna (o reimposta) le proprietà
  277.   #-----------------------------------------------------------------------------
  278.   def reset_settings(update = false)
  279.     set = $game_system.generic_bar_settings(@bar_name)
  280.     @x = set[0]
  281.     @y = set[1]
  282.     @width = set[2]
  283.     @height = set[3]
  284.     @letter = set[4]
  285.     @color = set[5]
  286.     @visible = set[6]
  287.     start(update)
  288.   end
  289.   #-----------------------------------------------------------------------------
  290.   # * Comincia a creare la grafica
  291.   #   update: true se è già stata creata
  292.   #-----------------------------------------------------------------------------
  293.   def start(update=false)
  294.     create_main_graphic(update)
  295.     create_bar(update)
  296.   end
  297.   #-----------------------------------------------------------------------------
  298.   # * Crea la grafica di sfondo
  299.   #-----------------------------------------------------------------------------
  300.   def create_main_graphic(update)
  301.     @Spriterect.bitmap.clear if update
  302.     barback_color = Color.new(@color.red/2,@color.green/2,@color.blue/2)
  303.     bitmap = Bitmap.new(@width+4, @height+4)
  304.     bitmap.fill_rect(2,2,@width,@height,Color.new(0,0,0,150))
  305.     bitmap.blur
  306.     bitmap.fill_rect(@sp,@height-(@sp+@lb),@width-(@sp*2),@lb,barback_color)
  307.     bitmap.draw_text(@sp,@sp,@width-@sp,24,@letter)
  308.     @Spriterect = Sprite.new(@viewport)
  309.     @Spriterect.bitmap = bitmap
  310.     @Spriterect.x = @x-2
  311.     @Spriterect.y = @y-2
  312.     @visible ? @Spriterect.opacity = 255 : @Spriterect.opacity = 0
  313.   end
  314.   #-----------------------------------------------------------------------------
  315.   # * Crea la grafica della barra
  316.   #-----------------------------------------------------------------------------
  317.   def create_bar(update)
  318.     @bar.bitmap.clear if update                       #pulisci se si deve agg.
  319.     bitmap = Bitmap.new(1,@lb)
  320.     @color = $game_system.generic_bar_settings(@bar_name)[5]
  321.     bitmap.fill_rect(0,0,1,@lb,@color)
  322.     @bar = Sprite.new(@viewport)
  323.     @bar.x = @Spriterect.x + @sp
  324.     @bar.y = @Spriterect.y + @Spriterect.height - @sp-@lb -4
  325.     @bar.bitmap = bitmap
  326.     @bar.zoom_x = 1
  327.     @visible ? @bar.opacity = 255 : @bar.opacity = 0
  328.     $game_system.generic_bar_settings(@bar_name)[9] = false
  329.   end
  330.   #-----------------------------------------------------------------------------
  331.   # * Imposta se mostrare o nascondere la finestra della barra
  332.   #-----------------------------------------------------------------------------
  333.   def visible=(vis)
  334.     @visible = vis
  335.     @visible ? @Spriterect.opacity = 255 : @Spriterect.opacity = 0
  336.     @visible ? @bar.opacity = 255 : @bar.opacity = 0
  337.   end
  338.   #-----------------------------------------------------------------------------
  339.   # * Effetto del flash
  340.   #-----------------------------------------------------------------------------
  341.   def flash(time = 30, color = Color.new(255,255,255))
  342.     @bar.flash(color, time)
  343.     @Spriterect.flash(color, time)
  344.   end
  345.   #-----------------------------------------------------------------------------
  346.   # * Effetto tremolio
  347.   #-----------------------------------------------------------------------------
  348.   def snooze(time = 20, str = 5)
  349.     str = 0 if str < 0
  350.     time = 0 if time < 0
  351.     str = 20 if str > 20
  352.     @snooze_str = str
  353.     @snooze_time = time
  354.   end
  355.   #-----------------------------------------------------------------------------
  356.   # * Aggiornamento
  357.   #-----------------------------------------------------------------------------
  358.   def update
  359.     if $game_system.generic_bar_settings(@bar_name)[8] #controllo refresh
  360.       reset_settings(true)
  361.       $game_system.generic_bar_settings(@bar_name)[8] = false
  362.       return
  363.     end
  364.     if @visible #aggiorna se la finestra è visibile
  365.       bar_update
  366.       snooze_update
  367.       effects_update
  368.     end
  369.   end
  370.   #-----------------------------------------------------------------------------
  371.   # * Aggiornamento del tremolio
  372.   #-----------------------------------------------------------------------------
  373.   def snooze_update
  374.     return if @snooze_time <= 0
  375.     if @snooze_time % 2 == 0
  376.       randx = rand(@snooze_str)-(@snooze_str/2)
  377.       randy = rand(@snooze_str)-(@snooze_str/2)
  378.       @bar.ox = randx
  379.       @bar.oy = randy
  380.       @Spriterect.ox = randx
  381.       @Spriterect.oy = randy
  382.     else
  383.       @bar.ox = 0
  384.       @bar.oy = 0
  385.       @Spriterect.ox = 0
  386.       @Spriterect.oy = 0
  387.     end
  388.     @snooze_time -= 1
  389.     if @snooze_time == 0
  390.       @bar.ox = 0
  391.       @bar.oy = 0
  392.       @Spriterect.ox = 0
  393.       @Spriterect.oy = 0
  394.     end
  395.   end
  396.   #-----------------------------------------------------------------------------
  397.   # * Aggiornamento del flash
  398.   #-----------------------------------------------------------------------------
  399.   def effects_update
  400.     @bar.update
  401.     @Spriterect.update
  402.   end
  403.   #-----------------------------------------------------------------------------
  404.   # * Aggiornamento dell'animazione della barra
  405.   #-----------------------------------------------------------------------------
  406.   def bar_update
  407.     return if $game_system.generic_bar_settings(@bar_name)[9]
  408.     percent = $game_system.generic_bar_settings(@bar_name)[7]
  409.     width = @width-(@sp*2)
  410.     larg = (width.to_f/100.0) * percent
  411.     distanza = larg - @bar.zoom_x
  412.     @bar.zoom_x += distanza/2
  413.     $game_system.generic_bar_settings(@bar_name)[9] = true if distanza <1 and distanza > -1
  414.   end
  415.   #-----------------------------------------------------------------------------
  416.   # * Eliminazione
  417.   #-----------------------------------------------------------------------------
  418.   def dispose
  419.     @bar.bitmap.dispose
  420.     @bar.dispose
  421.     @Spriterect.bitmap.dispose
  422.     @Spriterect.dispose
  423.   end
  424. end #barra
  425.  
  426. #===============================================================================
  427. # ** Classe Spriteset_Map
  428. #===============================================================================
  429. class Spriteset_Map
  430.   #-----------------------------------------------------------------------------
  431.   # * Alias Inizializzazione
  432.   #-----------------------------------------------------------------------------
  433.   alias bgen_initialize initialize unless $@
  434.   def initialize
  435.     create_generic_bars
  436.     bgen_initialize
  437.   end
  438.   #-----------------------------------------------------------------------------
  439.   # * Alias Uscita
  440.   #-----------------------------------------------------------------------------
  441.   alias bgen_dispose dispose unless $@
  442.   def dispose
  443.     bgen_dispose
  444.     dispose_generic_bars
  445.   end
  446.   #-----------------------------------------------------------------------------
  447.   # * Alias Aggiornamento
  448.   #-----------------------------------------------------------------------------
  449.   alias bgen_update update unless $@
  450.   def update
  451.     bgen_update
  452.     update_generic_bars
  453.   end
  454.   #-----------------------------------------------------------------------------
  455.   # * Creazione finestra con barra
  456.   #-----------------------------------------------------------------------------
  457.   def create_generic_bars
  458.     @generic_bars = {}
  459.     @generic_bars[:default] = Barra_Generica.new(@viewport2)
  460.     $game_system.active_bars.each_key do |name|
  461.       next if name == :default or name.nil?
  462.       @generic_bars[name]=Barra_Generica.new(@viewport2, name)
  463.     end
  464.   end
  465.   #-----------------------------------------------------------------------------
  466.   # * Eliminazione
  467.   #-----------------------------------------------------------------------------
  468.   def dispose_generic_bars
  469.     @generic_bars.each do |bar|
  470.       bar[1].dispose
  471.     end
  472.   end
  473.   #-----------------------------------------------------------------------------
  474.   # * Aggiornamento
  475.   #-----------------------------------------------------------------------------
  476.   def update_generic_bars
  477.     @generic_bars.each do |gbar|
  478.        gbar[1].update
  479.      end
  480.   end
  481.   #-----------------------------------------------------------------------------
  482.   # * Aggiunge una barra
  483.   #-----------------------------------------------------------------------------
  484.   def add_gen_bar(bar_name)
  485.     @generic_bars[bar_name] = Barra_Generica.new(@viewport2, bar_name)
  486.     print @generic_bars.size
  487.   end
  488.   #-----------------------------------------------------------------------------
  489.   # * Rimuove una barra
  490.   #-----------------------------------------------------------------------------
  491.   def remove_gen_bar(bar_name)
  492.     bar = @generic_bars[bar_name]
  493.     bar.visible = false
  494.     bar.dispose
  495.     @generic_bars.delete(bar_name)
  496.   end
  497.   #-----------------------------------------------------------------------------
  498.   # * Flash alla barra
  499.   #-----------------------------------------------------------------------------
  500.   def bar_flash(time, color, bar)
  501.     return if @generic_bars[bar].nil?
  502.     @generic_bars[bar].flash(time, color)
  503.   end
  504.   #-----------------------------------------------------------------------------
  505.   # * Tremolio della barra
  506.   #-----------------------------------------------------------------------------
  507.   def bar_snooze(time, str, bar)
  508.     return if @generic_bars[bar].nil?
  509.     @generic_bars[bar].snooze(time, str)
  510.   end
  511. end #spriteset_map
  512.  
  513. #===============================================================================
  514. # ** Classe Game_Interpreter
  515. #===============================================================================
  516. class Game_Interpreter
  517.   #-----------------------------------------------------------------------------
  518.   # * Sets a bar
  519.   #-----------------------------------------------------------------------------
  520.   def set_bar(*args)
  521.     if args.size > 1 && !args[1].is_a?(Color)
  522.       set_custom_bar(*args)
  523.     else
  524.       set_genbar(*args)
  525.     end
  526.   end
  527.   #-----------------------------------------------------------------------------
  528.   # * Reimposta le proprietà della barra
  529.   #-----------------------------------------------------------------------------
  530.   def set_genbar(text, color = bar_def_colr, x = nil, y = nil)
  531.     $game_system.generic_bar_set(text, color, x, y)
  532.   end
  533.   #-----------------------------------------------------------------------------
  534.   # * Reimposta una barra generica
  535.   #-----------------------------------------------------------------------------
  536.   def set_custom_bar(bar_name, letter, color = bar_def_colr, x = nil, y = nil)
  537.     $game_system.generic_bar_set(letter, color, x, y, bar_name)
  538.   end
  539.   #-----------------------------------------------------------------------------
  540.   # * Nascondi barra
  541.   #-----------------------------------------------------------------------------
  542.   def hide_bar(bar_name = :default)
  543.     $game_system.hide_generic_bar(bar_name)
  544.   end
  545.   #-----------------------------------------------------------------------------
  546.   # * Mostra barra
  547.   #-----------------------------------------------------------------------------
  548.   def show_bar(bar_name = :default)
  549.     $game_system.show_generic_bar(bar_name)
  550.   end
  551.   #-----------------------------------------------------------------------------
  552.   # * Set a bar value
  553.   #-----------------------------------------------------------------------------
  554.   def set_bar_value(*args)
  555.     args.size > 1 ? bar_value(args[1], args[0]) : bar_value(*args)
  556.   end
  557.   #-----------------------------------------------------------------------------
  558.   # * Assegna valore barra
  559.   #-----------------------------------------------------------------------------
  560.   def bar_value(value, bar_name = :default)
  561.     $game_system.bar_percentage(value, bar_name)
  562.   end
  563.   #-----------------------------------------------------------------------------
  564.   # * Right method for resizing bars
  565.   #-----------------------------------------------------------------------------
  566.   def resize_bar(*args)
  567.     args.size > 2 ? bar_resize(args[1], args[2], args[0]) : bar_resize(*args)
  568.   end
  569.   #-----------------------------------------------------------------------------
  570.   # * Ridimensiona finestra
  571.   #-----------------------------------------------------------------------------
  572.   def bar_resize(width, height, bar_name = :default)
  573.     $game_system.bar_resize(width,height,bar_name)
  574.   end
  575.   #-----------------------------------------------------------------------------
  576.   # * Aggiunge una barra personalizzata
  577.   #-----------------------------------------------------------------------------
  578.   def add_bar(bar_name)
  579.     $game_system.add_active_bar(bar_name)
  580.   end
  581.   #-----------------------------------------------------------------------------
  582.   # * Rimuove una barra personalizzata
  583.   #-----------------------------------------------------------------------------
  584.   def remove_bar(bar_name)
  585.     $game_system.remove_active_bar(bar_name)
  586.   end
  587.   #-----------------------------------------------------------------------------
  588.   # * Flash
  589.   #-----------------------------------------------------------------------------
  590.   def flash_bar(*args)
  591.     if args.size == 0 || !args[0].is_a?(Integer)
  592.       flash_bar_old(*args)
  593.     else
  594.       flash_bar_old(:default, *args)
  595.     end
  596.   end
  597.   #-----------------------------------------------------------------------------
  598.   # * Old Flash method
  599.   #-----------------------------------------------------------------------------
  600.   def flash_bar_old(bar = :default, time = 30, color = Color.new(255,255,255))
  601.     $game_system.current_scene.bar_flash(time, color, bar)
  602.   end
  603.   #-----------------------------------------------------------------------------
  604.   # * Shake
  605.   #-----------------------------------------------------------------------------
  606.   def snooze_bar(*args)
  607.     if args.size == 0 || !args[0].is_a?(Integer)
  608.       snooze_bar_old(*args)
  609.     else
  610.       snooze_bar_old(:default, *args)
  611.     end
  612.   end
  613.   #-----------------------------------------------------------------------------
  614.   # * Shake (old method)
  615.   #-----------------------------------------------------------------------------
  616.   def snooze_bar_old(bar = :default, time = 15, str = 5)
  617.     $game_system.current_scene.bar_snooze(time, str, bar)
  618.   end
  619.   #-----------------------------------------------------------------------------
  620.   # * Assign color
  621.   #-----------------------------------------------------------------------------
  622.   def bar_def_colr
  623.     c = H87_GBSettings::Default_Color
  624.     return Color.new(c[0],c[1],c[2])
  625.   end
  626. end #game_interpreter
  627.  
  628. #===============================================================================
  629. # ** Classe Scene_Base
  630. #===============================================================================
  631. class Scene_Base
  632.   #-----------------------------------------------------------------------------
  633.   # * Metodi vuoti, servono per non generare errori se non si è sulla mappa.
  634.   #-----------------------------------------------------------------------------
  635.   def add_genbar(bar_name);end
  636.   def remove_genbar(bar_name);end
  637.   def bar_flash(time, color, bar);end
  638.   def bar_snooze(time, str, bar);end
  639. end #scene_base
  640.  
  641. #===============================================================================
  642. # ** Classe Scene_Map
  643. #===============================================================================
  644. class Scene_Map < Scene_Base
  645.   #-----------------------------------------------------------------------------
  646.   # * Aggiunge una barra allo spriteset
  647.   #-----------------------------------------------------------------------------
  648.   def add_genbar(bar_name)
  649.     @spriteset.add_gen_bar(bar_name)
  650.   end
  651.   #-----------------------------------------------------------------------------
  652.   # * Rimuove una barra dallo spriteset
  653.   #-----------------------------------------------------------------------------
  654.   def remove_genbar(bar_name)
  655.     @spriteset.remove_gen_bar(bar_name)
  656.   end
  657.   #-----------------------------------------------------------------------------
  658.   # * Flash barra dello spriteset
  659.   #-----------------------------------------------------------------------------
  660.   def bar_flash(time, color, bar)
  661.     @spriteset.bar_flash(time, color, bar)
  662.   end
  663.   #-----------------------------------------------------------------------------
  664.   # * Tremolio alla barra dello spriteset
  665.   #-----------------------------------------------------------------------------
  666.   def bar_snooze(time, str, bar)
  667.     @spriteset.bar_snooze(time,str,bar)
  668.   end
  669. end #scene_map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement