Advertisement
Holy87

CoinCurrency - Ace

Jul 16th, 2013
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.95 KB | None | 0 0
  1. $imported = {} if $imported == nil
  2. $imported["H87_Golds"] = true
  3. #===============================================================================
  4. # DENARO SUDDIVISO IN MONETE
  5. #===============================================================================
  6. # Autore: Holy87
  7. # Versione: 1.2
  8. # Difficoltà utente: ★
  9. #-------------------------------------------------------------------------------
  10. # In molti giochi di ruolo, come World of Warcraft e Dragon Age, il denaro
  11. # posseduto viene calcolato in monete di bronzo, monete d'argento e monete d'oro.
  12. # Questo script convertirà il denaro da semplice numero e valuta in monete con
  13. # relativa icona.
  14. # *fix valori negativi
  15. # *Novità versione 1.1: compatibilità YEA Save Engine
  16. #-------------------------------------------------------------------------------
  17. # Istruzioni:
  18. # Copiare lo script sotto Materials, prima del Main.
  19. # Puoi anche convertire un numero in monete nella finestra dei messaggi
  20. # scrivendo \M[valore].
  21. #-------------------------------------------------------------------------------
  22. # Compatibilità:
  23. # Window_Base
  24. #   draw_currency_value       -> riscrittura
  25. #   process_escape_character  -> alias
  26. # Window_ShopBuy
  27. #   draw_item                 -> riscrittura
  28. #-------------------------------------------------------------------------------
  29. module H87_GoldSetup
  30.  
  31. #===============================================================================
  32. # ** CONFIGURAZIONE **
  33. #===============================================================================
  34.   #Inserisci l'ID delle relative icone:
  35.   ICONBRONZE = 140  #icona della moneta di bronzo
  36.   ICONSILVER = 141  #icona della moneta d'argento
  37.   ICONGOLD   = 361  #icona della moneta d'oro
  38.  
  39.   #Se vuoi, puoi impostare valori differenti per ogni moneta:
  40.   VALUEBRONZE = 1
  41.   VALUESILVER = 100
  42.   VALUEGOLD   = 100
  43.  
  44.   #Imposta questa costante su True se vuoi che le cifre si sovrappongano a una
  45.   #parte dell'icona della moneta, risparmiando così lo spazio.
  46.   IconOverlay = true
  47. end
  48.  
  49. module Vocab
  50.   #Testo che viene mostrato alla fine della battaglia.
  51.   ObtainGold      = "Hai guadagnato \\M[%s]!"
  52. end
  53.  
  54.  
  55. #===============================================================================
  56. # ** FINE CONFIGURAZIONE **
  57. # Attenzione: Non modificare ciò che c'è oltre, a meno che tu non sappia ciò che
  58. # fai! C'è gente che si è suicidata per molto meno, fidati.
  59. #===============================================================================
  60.  
  61.  
  62.  
  63. #==============================================================================
  64. # ** Window_Base
  65. #------------------------------------------------------------------------------
  66. #  La maggior parte dei metodi necessari si trovano in questa classe
  67. #==============================================================================
  68. class Window_Base < Window
  69.   include H87_GoldSetup #inclusione del modulo
  70.  
  71.   #--------------------------------------------------------------------------
  72.   # * Riscrittura di draw_currency_value
  73.   #--------------------------------------------------------------------------
  74.   def draw_currency_value(value, unit, x, y, width)
  75.     if value < 0
  76.       @negative = true
  77.       value *= -1
  78.     end
  79.    
  80.     iconw = IconOverlay ? 12 : 24
  81.     bronzes = get_bronzes(value)
  82.     silvers = get_silvers(value)
  83.     golds   = get_golds(value)
  84.     w2 = width
  85.    
  86.     if bronzes > 0
  87.       draw_icon(ICONBRONZE,x+w2-24,y)
  88.       w2-=iconw
  89.       w1 = text_size(bronzes).width
  90.       draw_text(x,y,w2,line_height,bronzes,2)
  91.       w2-=w1
  92.     end
  93.    
  94.     if silvers > 0
  95.       draw_icon(ICONSILVER,x+w2-24,y)
  96.       w2-=iconw
  97.       w1 = text_size(silvers).width
  98.       draw_text(x,y,w2,line_height,silvers,2)
  99.       w2-=w1
  100.     end
  101.    
  102.     if golds > 0
  103.       draw_icon(ICONGOLD,x+w2-24,y)
  104.       w2-=iconw
  105.       w1 = text_size(golds).width
  106.       draw_text(x,y,w2,line_height,golds,2)
  107.       w2 -= w1
  108.     end
  109.    
  110.     if @negative #disegna un meno con i numeri negativi
  111.       draw_text(x,y,w2,line_height,"-",2)
  112.     end
  113.    
  114.   end
  115.  
  116.   #--------------------------------------------------------------------------
  117.   # * Restituisce le monete di bronzo da value
  118.   #--------------------------------------------------------------------------
  119.   def get_bronzes(value)
  120.     value%VALUESILVER
  121.   end
  122.  
  123.   #--------------------------------------------------------------------------
  124.   # * Restituisce le monete d'argento da value
  125.   #--------------------------------------------------------------------------
  126.   def get_silvers(value)
  127.     value/VALUESILVER%VALUEGOLD
  128.   end
  129.  
  130.   #--------------------------------------------------------------------------
  131.   # * Restituisce le monete d'oro da value
  132.   #--------------------------------------------------------------------------
  133.   def get_golds(value)
  134.     value/VALUESILVER/VALUEGOLD
  135.   end
  136.    
  137.   #--------------------------------------------------------------------------
  138.   # * alias process_escape_character
  139.   #--------------------------------------------------------------------------
  140.   alias goldp_e_c process_escape_character unless $@
  141.   def process_escape_character(code, text, pos)
  142.     goldp_e_c(code, text, pos)
  143.     case code.upcase
  144.     when 'M'
  145.       process_draw_coins(obtain_escape_param(text),pos)
  146.     end
  147.   end
  148.  
  149.   #--------------------------------------------------------------------------
  150.   # * disegna le monete nella finestra
  151.   #--------------------------------------------------------------------------
  152.   def process_draw_coins(value, pos)
  153.     width = calc_currency_width(value)
  154.     draw_currency_value(value, "", pos[:x], pos[:y], width)
  155.     pos[:x] += width
  156.   end
  157.  
  158.   #--------------------------------------------------------------------------
  159.   # * restituisce la larghezza giusta del testo
  160.   #--------------------------------------------------------------------------
  161.   def calc_currency_width(value)
  162.     iconw = IconOverlay ? 12 : 24
  163.     bronzes = get_bronzes(value)
  164.     silvers = get_silvers(value)
  165.     golds   = get_golds(value)
  166.     text = ""
  167.     width = 0
  168.     if bronzes > 0
  169.       text += bronzes.to_s
  170.       width += iconw
  171.     end
  172.     if silvers > 0
  173.       text += silvers.to_s
  174.       width += iconw
  175.     end
  176.     if golds > 0
  177.       text += golds.to_s
  178.       width += iconw
  179.     end
  180.     width += text_size(text).width
  181.     return width
  182.   end
  183.  
  184. end #window_base
  185.  
  186. #==============================================================================
  187. # ** Window_ShopBuy
  188. #------------------------------------------------------------------------------
  189. #  Modifica del metodo per mostrare le monete
  190. #==============================================================================
  191. class Window_ShopBuy < Window_Selectable
  192.  
  193.   #--------------------------------------------------------------------------
  194.   # * riscrittura del metodo draw_item
  195.   #--------------------------------------------------------------------------
  196.   def draw_item(index)
  197.     item = @data[index]
  198.     rect = item_rect(index)
  199.     draw_item_name(item, rect.x, rect.y, enable?(item))
  200.     rect.width -= 4
  201.     draw_currency_value(price(item),"",rect.x,rect.y,rect.width)
  202.   end
  203. end #window_shopbuy
  204.  
  205.  
  206. if $imported["YEA-SaveEngine"]
  207. #==============================================================================
  208. # ** Window_FileStatus
  209. #------------------------------------------------------------------------------
  210. #  Override per compatibilità Yanfly
  211. #==============================================================================
  212. class Window_FileStatus < Window_Base
  213.  
  214.   #--------------------------------------------------------------------------
  215.   # * draw_save_gold
  216.   #--------------------------------------------------------------------------
  217.   def draw_save_gold(dx, dy, dw)
  218.     return if @header[:party].nil?
  219.     reset_font_settings
  220.     change_color(system_color)
  221.     draw_text(dx, dy, dw, line_height, YEA::SAVE::TOTAL_GOLD)
  222.     change_color(normal_color)
  223.     draw_currency_value(@header[:party].gold.group.to_i, "", dx, dy, dw)
  224.   end
  225. end
  226. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement