Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # page 6 of 12
- # Shopoholic v 2.0
- # code by cmpsr2000
- # available exclusively @ rpgrevolution.com/forums
- # Released June 25, 2008
- #
- #-------------------------------------------------------------------------------
- class Window_Bank_Account < Window_Selectable
- attr_accessor :accountCmd_window
- #-----------------------------------------------------------------------------
- # Creates the bank accounts window
- # x: The x-coordinate of the printing
- # y: The y-coordinate of the printing
- # bankID: The
- #-----------------------------------------------------------------------------
- def initialize(x, y, bankID)
- super(x, y, 544, 304)
- @bankID = bankID
- #---------------------------------------------------------------------------
- # Change these if you want to label the list differently.
- #---------------------------------------------------------------------------
- @headings = ["Account", "Interest Rate", "Balance"]
- self.index = 0
- end
- #-----------------------------------------------------------------------------
- # Refreshes the contents of the window
- #-----------------------------------------------------------------------------
- def refresh
- @data = []
- @data.push(nil) #for headings
- for account in $game_banking.bankAccounts[@bankID]
- @data.push(account)
- end
- @data.push(nil) #for get loan
- @item_max = @data.length
- create_contents
- for i in 0...@item_max
- if @data[i] != nil
- draw_item(i)
- else
- draw_label(i)
- end
- end
- if self.index > @item_max - 1
- self.index = @item_max - 1
- end
- end
- #-----------------------------------------------------------------------------
- # Draws the label for the specified object index
- # index: The index of the label
- #-----------------------------------------------------------------------------
- def draw_label(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- self.contents.font.color = system_color
- self.contents.font.color.alpha = 255
- if index == 0
- self.contents.draw_text(rect.x , rect.y, 172, WLH, @headings[0])
- self.contents.draw_text(rect.x + 172, rect.y, 172, WLH, @headings[1])
- self.contents.draw_text(rect.x + 344, rect.y, 172, WLH, @headings[2], 1)
- else
- self.contents.font.color = system_color
- self.contents.draw_text(rect.x, rect.y, 520, WLH, "Secure a new loan", 1)
- end
- end
- #-----------------------------------------------------------------------------
- # Draws the item for the specified object index
- # index: The index of the item
- #-----------------------------------------------------------------------------
- def draw_item(index)
- account = @data[index]
- enabled = !(@accountCmd_window.index == 2 and @index == index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- draw_account_info(account, rect.x + 24, rect.y, enabled)
- end
- #-----------------------------------------------------------------------------
- # Draws the info for the specified account
- # account: The account to draw
- # x: The x-coordinate of the printing
- # y: The y-coordinate of the printing
- # enabled: Whether to draw the account opaque or transparent
- #-----------------------------------------------------------------------------
- def draw_account_info(account, x, y, enabled = true)
- draw_icon(account.icon_index, x, y, enabled)
- x += 24
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- interestRate = (account.interestRate * 100).to_i.to_s + "%"
- self.contents.draw_text(x , y, 120, WLH, account.name ,0)
- self.contents.draw_text(x + 120, y, 132, WLH, interestRate ,2)
- self.contents.draw_text(x + 252, y, 164, WLH, account.balance.to_s,2)
- end
- #-----------------------------------------------------------------------------
- # Returns the currently highlighted account object
- # RETURNS: Account
- #-----------------------------------------------------------------------------
- def account
- return @data[@index]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement