Advertisement
Kakakadafi

Kadafi - Multi Currency

Jun 22nd, 2014
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.92 KB | None | 0 0
  1. # =============================================================================
  2. # Kadafi - Multi Currency
  3. # Version : 1.1
  4. # Contact : http://kakakadafi.blogspot.com or umarqadafi1@hotmail.com
  5. # =============================================================================
  6. ($imported ||= {})[:Kadafi_MultiCurrency] = true
  7. # =============================================================================
  8. # CHANGE LOGS:
  9. # -----------------------------------------------------------------------------
  10. # 2014.06.22 - Started and Finished script
  11. # 2014.06.22 - Bugfix: Items still buyable even if the money is not enough to buy the items.
  12. # =============================================================================
  13. =begin
  14.  
  15.   Introduction :
  16.   This script allows you to have an auto Money Changer in shop.
  17.   You can call this "Multi Currency" System. :v
  18.  
  19.   How to Use :
  20. [*] Script call :
  21.     Kadafi::MultiCurrency  = true         >>> To activate this script.
  22.     Kadafi::CurrencySymbol = "Up to you"  >>> To set the currency symbol.
  23.     Kadafi::ExchangeRates  = amount       >>> To set the currency exchange rates.
  24.    
  25.     Example : <<< Call this on every map if you want to have different Exchange Rates.
  26.     Kadafi::MultiCurrency  = true
  27.     Kadafi::CurrencySymbol = "$"
  28.     Kadafi::ExchangeRates  = 10000
  29.  
  30.   TERMS OF USE :
  31.   Free for use on any non-Commercial or Commercial Game Projects.
  32.   If you use this for commercial uses,
  33.   give me a free copy of your game would be nice :)
  34.   Credit: Kadafi
  35.  
  36. =end
  37. # =============================================================================
  38. # Configuration - Don't edit this configuration.
  39. # =============================================================================
  40. module Kadafi
  41.   MultiCurrency  = false
  42.   CurrencySymbol = ""
  43.   ExchangeRates  = 1
  44. end
  45. # =============================================================================
  46. # End of Configuration
  47. # =============================================================================
  48. class Window_ShopBuy < Window_Selectable
  49.   #--------------------------------------------------------------------------
  50.   # * New Method : Get New Price of Item
  51.   #--------------------------------------------------------------------------
  52.   def new_price(item)
  53.     if Kadafi::MultiCurrency
  54.       @price[item] * Kadafi::ExchangeRates
  55.     else
  56.       @price[item]
  57.     end
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # * Overwritten Method : Display in Enabled State?
  61.   #--------------------------------------------------------------------------
  62.   def enable?(item)
  63.     if Kadafi::MultiCurrency
  64.       item && new_price(item) <= @money && !$game_party.item_max?(item)
  65.     else
  66.       item && price(item) <= @money && !$game_party.item_max?(item)
  67.     end
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Overwritten Method : Draw Item
  71.   #--------------------------------------------------------------------------
  72.   def draw_item(index)
  73.     item = @data[index]
  74.     rect = item_rect(index)
  75.     draw_item_name(item, rect.x, rect.y, enable?(item))
  76.     if Kadafi::MultiCurrency
  77.       draw_currency_value(price(item), Kadafi::CurrencySymbol, 4, 0, contents.width - 8)
  78.     else
  79.       draw_currency_value(price(item), Vocab::currency_unit, 4, 0, contents.width - 8)
  80.     end
  81.   end
  82. end
  83.  
  84. class Window_ShopStatus < Window_Base
  85.   #--------------------------------------------------------------------------
  86.   # * Alias Method : Refresh
  87.   #--------------------------------------------------------------------------
  88.   alias new_refresh refresh
  89.   def refresh
  90.     new_refresh
  91.     draw_exchange_rates(4, line_height * 1)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * New Method : Draw Exchange Rates
  95.   #--------------------------------------------------------------------------
  96.   def draw_exchange_rates(x, y)
  97.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  98.     change_color(system_color)
  99.     draw_text(rect, "Exchange Rates")
  100.     if Kadafi::MultiCurrency
  101.       draw_currency_value(Kadafi::ExchangeRates, Vocab::currency_unit, 4, line_height * 1, contents.width - 8)
  102.     else  
  103.       draw_currency_value("1", Vocab::currency_unit, 4, line_height * 1, contents.width - 8)
  104.     end  
  105.   end
  106. end
  107.  
  108. class Scene_Shop < Scene_MenuBase
  109.   #--------------------------------------------------------------------------
  110.   # * Overwritten Method : Get Purchase Price
  111.   #--------------------------------------------------------------------------
  112.   def buying_price
  113.     @buy_window.new_price(@item)
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # * Overwritten Methd : Get Sale Price
  117.   #--------------------------------------------------------------------------
  118.   def selling_price
  119.     if Kadafi::MultiCurrency
  120.       @buy_window.new_price(@item) / 2
  121.     else
  122.       @item.price / 2
  123.     end
  124.   end
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement