Advertisement
Guest User

Shopaholic Page 6

a guest
Jul 29th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # page 6 of 12
  3. # Shopoholic v 2.0
  4. # code by cmpsr2000
  5. # available exclusively @ rpgrevolution.com/forums
  6. # Released June 25, 2008
  7. #
  8. #-------------------------------------------------------------------------------
  9. class Window_Bank_Account < Window_Selectable
  10.  
  11. attr_accessor :accountCmd_window
  12. #-----------------------------------------------------------------------------
  13. # Creates the bank accounts window
  14. # x: The x-coordinate of the printing
  15. # y: The y-coordinate of the printing
  16. # bankID: The
  17. #-----------------------------------------------------------------------------
  18. def initialize(x, y, bankID)
  19. super(x, y, 544, 304)
  20. @bankID = bankID
  21.  
  22. #---------------------------------------------------------------------------
  23. # Change these if you want to label the list differently.
  24. #---------------------------------------------------------------------------
  25. @headings = ["Account", "Interest Rate", "Balance"]
  26.  
  27. self.index = 0
  28. end
  29. #-----------------------------------------------------------------------------
  30. # Refreshes the contents of the window
  31. #-----------------------------------------------------------------------------
  32. def refresh
  33. @data = []
  34. @data.push(nil) #for headings
  35. for account in $game_banking.bankAccounts[@bankID]
  36. @data.push(account)
  37. end
  38. @data.push(nil) #for get loan
  39. @item_max = @data.length
  40. create_contents
  41. for i in 0...@item_max
  42. if @data[i] != nil
  43. draw_item(i)
  44. else
  45. draw_label(i)
  46. end
  47. end
  48. if self.index > @item_max - 1
  49. self.index = @item_max - 1
  50. end
  51. end
  52. #-----------------------------------------------------------------------------
  53. # Draws the label for the specified object index
  54. # index: The index of the label
  55. #-----------------------------------------------------------------------------
  56. def draw_label(index)
  57. rect = item_rect(index)
  58. self.contents.clear_rect(rect)
  59. self.contents.font.color = system_color
  60. self.contents.font.color.alpha = 255
  61. if index == 0
  62. self.contents.draw_text(rect.x , rect.y, 172, WLH, @headings[0])
  63. self.contents.draw_text(rect.x + 172, rect.y, 172, WLH, @headings[1])
  64. self.contents.draw_text(rect.x + 344, rect.y, 172, WLH, @headings[2], 1)
  65. else
  66. self.contents.font.color = system_color
  67. self.contents.draw_text(rect.x, rect.y, 520, WLH, "Secure a new loan", 1)
  68. end
  69. end
  70. #-----------------------------------------------------------------------------
  71. # Draws the item for the specified object index
  72. # index: The index of the item
  73. #-----------------------------------------------------------------------------
  74. def draw_item(index)
  75. account = @data[index]
  76. enabled = !(@accountCmd_window.index == 2 and @index == index)
  77. rect = item_rect(index)
  78. self.contents.clear_rect(rect)
  79. draw_account_info(account, rect.x + 24, rect.y, enabled)
  80. end
  81. #-----------------------------------------------------------------------------
  82. # Draws the info for the specified account
  83. # account: The account to draw
  84. # x: The x-coordinate of the printing
  85. # y: The y-coordinate of the printing
  86. # enabled: Whether to draw the account opaque or transparent
  87. #-----------------------------------------------------------------------------
  88. def draw_account_info(account, x, y, enabled = true)
  89. draw_icon(account.icon_index, x, y, enabled)
  90. x += 24
  91. self.contents.font.color = normal_color
  92. self.contents.font.color.alpha = enabled ? 255 : 128
  93. interestRate = (account.interestRate * 100).to_i.to_s + "%"
  94. self.contents.draw_text(x , y, 120, WLH, account.name ,0)
  95. self.contents.draw_text(x + 120, y, 132, WLH, interestRate ,2)
  96. self.contents.draw_text(x + 252, y, 164, WLH, account.balance.to_s,2)
  97. end
  98. #-----------------------------------------------------------------------------
  99. # Returns the currently highlighted account object
  100. # RETURNS: Account
  101. #-----------------------------------------------------------------------------
  102. def account
  103. return @data[@index]
  104. end
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement