Advertisement
Guest User

Shopaholic Page 8

a guest
Jul 29th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.74 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # page 8 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_Number < Window_Base
  10.  
  11. attr_reader :number
  12. #-----------------------------------------------------------------------------
  13. # Creates the window for bank number proccessing
  14. # x: The x-coordinate of the window
  15. # y: The y-coordinate of the window
  16. #-----------------------------------------------------------------------------
  17. def initialize(x, y)
  18. super(x, y, 544, 304)
  19. @account = nil
  20. @xferAccount = nil
  21. @max = 1
  22. @number = 0
  23. @digit = 0
  24. @maxDigit = 6
  25. @refreshNeeded = false
  26. end
  27. #-----------------------------------------------------------------------------
  28. # Sets the basic information for the number window
  29. # max: The maximum number that can be proccessed
  30. # action: The type of transaction being conducted
  31. # 0: Account Deposit
  32. # 1: Account Withdrawal
  33. # 2: Account Transfer
  34. # 3: Create Loan Account
  35. # 4: Buy Storage Slots
  36. # 5: Item Storage Proccessing
  37. # account: The primary account to be acted upon
  38. # xferAccount: The recieving account for balance transfers
  39. # item: The item being stored for Action 5
  40. # slotCost: The cost of a new storage slot for action 4
  41. #-----------------------------------------------------------------------------
  42. def set(max, action, account, xferAccount, item, slotCost)
  43. @account = account
  44. @xferAccount = xferAccount
  45. @max = max
  46. @action = action
  47. @item = item
  48. @slotCost = slotCost
  49. @min = (@action == 4 or @action == 5) ? 1 : 0
  50. @number = @min
  51. @digit = 0
  52. @maxDigit = @max.to_s.length - 1
  53. refresh
  54. end
  55. #-----------------------------------------------------------------------------
  56. # Refreshes the window's contents
  57. #-----------------------------------------------------------------------------
  58. def refresh
  59. x = 148
  60. y = 96
  61. self.contents.clear
  62. self.contents.font.color = normal_color
  63. case @action
  64. when 0 #deposit
  65. text = "How much will you deposit into your"
  66. opperator = @account.type == 2 ? "-" : "+"
  67. self.contents.draw_text(0 , 24 , 400, WLH, text)
  68. self.contents.draw_text(444, 24 , 10 , WLH, "?")
  69. self.contents.draw_text(24 , y - 24, 196, WLH, "Current Balance")
  70. self.contents.draw_text(24 , y , 196, WLH, "Deposit")
  71. self.contents.draw_text(172, y , 10 , WLH, opperator)
  72. self.contents.draw_text(148, y + 6 , 120, WLH, "________", 2)
  73. self.contents.draw_text(24 , y + 32, 196, WLH, "New Balance")
  74. self.contents.draw_text(172, y + 32, 10 , WLH, "=")
  75.  
  76. self.contents.font.color = system_color
  77. self.contents.draw_text(352, 24 , 100, WLH, @account.name, 1)
  78.  
  79. newBalance = @account.type == 2 ? @account.balance - @number :
  80. @account.balance + @number
  81. when 1 #withdraw
  82. text = "How much will you withdraw from your"
  83. self.contents.draw_text(0 , 24 , 400, WLH, text)
  84. self.contents.draw_text(444, 24 , 10 , WLH, "?")
  85. self.contents.draw_text(24 , y - 24, 196, WLH, "Current Balance")
  86. self.contents.draw_text(24 , y , 196, WLH, "Withdrawal")
  87. self.contents.draw_text(172, y , 10 , WLH, "-")
  88. self.contents.draw_text(148, y + 6 , 120, WLH, "________", 2)
  89. self.contents.draw_text(24 , y + 32, 196, WLH, "New Balance")
  90. self.contents.draw_text(172, y + 32, 10 , WLH, "=")
  91.  
  92. self.contents.font.color = system_color
  93. self.contents.draw_text(352, 24 , 100, WLH, @account.name, 1)
  94.  
  95. newBalance = @account.balance - @number
  96. when 2 #Transfer
  97. x = 256
  98. text = "How much will you transfer?"
  99. opperator = @xferAccount.type == 2 ? "-" : "+"
  100. self.contents.draw_text(12 , 12 , 512, WLH, text, 1)
  101.  
  102. #account
  103. self.contents.draw_text(12 , y - 24, 196, WLH, "Current Balance")
  104. self.contents.draw_text(12 , y , 196, WLH, "Transfer")
  105. self.contents.draw_text(160, y , 10 , WLH, "-")
  106. self.contents.draw_text(136, y + 6 , 120, WLH, "________", 2)
  107. self.contents.draw_text(12 , y + 32, 196, WLH, "New Balance")
  108. self.contents.draw_text(160, y + 32, 10 , WLH, "=")
  109.  
  110. #xfer account
  111. self.contents.draw_text(x + 12 , y - 24, 196, WLH, "Current Balance")
  112. self.contents.draw_text(x + 12 , y , 196, WLH, "Transfer")
  113. self.contents.draw_text(x + 160, y , 10 , WLH, opperator)
  114. self.contents.draw_text(x + 136, y + 6 , 120, WLH, "________", 2)
  115. self.contents.draw_text(x + 12 , y + 32, 196, WLH, "New Balance")
  116. self.contents.draw_text(x + 160, y + 32, 10 , WLH, "=")
  117.  
  118. xferBalance = @xferAccount.type == 2 ? @xferAccount.balance - @number :
  119. @xferAccount.balance + @number
  120. draw_currency_value(@xferAccount.balance, x + 136, y - 24, 120)
  121. draw_currency_value(@number, x + 136, y, 120)
  122. draw_currency_value(xferBalance, x + 136, y + 32, 120)
  123.  
  124. self.contents.font.color = system_color
  125. self.contents.draw_text(12 , 44, 256, WLH, @account.name , 1)
  126. self.contents.draw_text(x + 12, 44, 256, WLH, @xferAccount.name, 1)
  127.  
  128. x = 130
  129. newBalance = @account.balance - @number
  130. when 3 #create loan
  131. text = "How much would you like to borrow?"
  132. self.contents.draw_text(0, 48, 400, WLH, text)
  133. self.contents.font.color = system_color
  134. self.contents.draw_text(24, y, 196, WLH, "Loan Amount:")
  135. when 4 #buy slots
  136. text = "How many Safety Deposit Boxes"
  137. text2 = "would you like to buy?"
  138. self.contents.draw_text(0, 24, contents.width, WLH, text)
  139. self.contents.draw_text(0, 48, contents.width, WLH, text2)
  140. self.contents.font.color = system_color
  141. self.contents.draw_text(24, y , 196, WLH, "Safety Deposit Boxes")
  142. self.contents.draw_text(24, y + 32, 196, WLH, "Total")
  143. newBalance = @number * @slotCost
  144. when 5 #store item
  145. text = "How many would you like to deposit?"
  146. self.contents.draw_text(0, 24, contents.width, WLH, text)
  147. self.contents.font.color = system_color
  148. self.contents.draw_text(24, y , 196, WLH, @item.name)
  149. end
  150. self.contents.font.color = normal_color
  151. draw_currency_value(@account.balance, x, y - 24, 120) unless @action == 3 or
  152. @action == 4 or
  153. @action == 5
  154. draw_currency_value (@number, x, y, 120) unless @action == 4 or
  155. @action == 5
  156. self.contents.draw_text(236, y, 20, WLH, @number, 2) if @action == 4 or
  157. @action == 5
  158. draw_currency_value (newBalance, x, y + 32, 120) unless @action == 3 or
  159. @action == 5
  160. self.cursor_rect.set (x + 98 - @digit * 10, y, 10, WLH)
  161. @refreshNeeded = false
  162. end
  163. #-----------------------------------------------------------------------------
  164. # Updates the window with new input information
  165. #-----------------------------------------------------------------------------
  166. def update
  167. super
  168. if self.active
  169. last_number = @number
  170. if Input.repeat?(Input::RIGHT)
  171. if @digit == 0
  172. @number = @min
  173. else
  174. @digit -= 1
  175. @refreshNeeded = true
  176. end
  177. end
  178. if Input.repeat?(Input::LEFT)
  179. if @digit == @maxDigit
  180. @number = @max
  181. else
  182. @digit += 1
  183. @refreshNeeded = true
  184. end
  185. end
  186. if Input.repeat?(Input::UP) and @number < @max
  187. @number = [@number + 10**@digit, @max].min
  188. end
  189. if Input.repeat?(Input::DOWN) and @number > @min
  190. @number = [@number - 10**@digit, 1].max
  191. end
  192. if @number != last_number or @refreshNeeded
  193. Sound.play_cursor
  194. refresh
  195. end
  196. end
  197. end
  198. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement