Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # page 8 of 12
- # Shopoholic v 2.0
- # code by cmpsr2000
- # available exclusively @ rpgrevolution.com/forums
- # Released June 25, 2008
- #
- #-------------------------------------------------------------------------------
- class Window_Bank_Number < Window_Base
- attr_reader :number
- #-----------------------------------------------------------------------------
- # Creates the window for bank number proccessing
- # x: The x-coordinate of the window
- # y: The y-coordinate of the window
- #-----------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 544, 304)
- @account = nil
- @xferAccount = nil
- @max = 1
- @number = 0
- @digit = 0
- @maxDigit = 6
- @refreshNeeded = false
- end
- #-----------------------------------------------------------------------------
- # Sets the basic information for the number window
- # max: The maximum number that can be proccessed
- # action: The type of transaction being conducted
- # 0: Account Deposit
- # 1: Account Withdrawal
- # 2: Account Transfer
- # 3: Create Loan Account
- # 4: Buy Storage Slots
- # 5: Item Storage Proccessing
- # account: The primary account to be acted upon
- # xferAccount: The recieving account for balance transfers
- # item: The item being stored for Action 5
- # slotCost: The cost of a new storage slot for action 4
- #-----------------------------------------------------------------------------
- def set(max, action, account, xferAccount, item, slotCost)
- @account = account
- @xferAccount = xferAccount
- @max = max
- @action = action
- @item = item
- @slotCost = slotCost
- @min = (@action == 4 or @action == 5) ? 1 : 0
- @number = @min
- @digit = 0
- @maxDigit = @max.to_s.length - 1
- refresh
- end
- #-----------------------------------------------------------------------------
- # Refreshes the window's contents
- #-----------------------------------------------------------------------------
- def refresh
- x = 148
- y = 96
- self.contents.clear
- self.contents.font.color = normal_color
- case @action
- when 0 #deposit
- text = "How much will you deposit into your"
- opperator = @account.type == 2 ? "-" : "+"
- self.contents.draw_text(0 , 24 , 400, WLH, text)
- self.contents.draw_text(444, 24 , 10 , WLH, "?")
- self.contents.draw_text(24 , y - 24, 196, WLH, "Current Balance")
- self.contents.draw_text(24 , y , 196, WLH, "Deposit")
- self.contents.draw_text(172, y , 10 , WLH, opperator)
- self.contents.draw_text(148, y + 6 , 120, WLH, "________", 2)
- self.contents.draw_text(24 , y + 32, 196, WLH, "New Balance")
- self.contents.draw_text(172, y + 32, 10 , WLH, "=")
- self.contents.font.color = system_color
- self.contents.draw_text(352, 24 , 100, WLH, @account.name, 1)
- newBalance = @account.type == 2 ? @account.balance - @number :
- @account.balance + @number
- when 1 #withdraw
- text = "How much will you withdraw from your"
- self.contents.draw_text(0 , 24 , 400, WLH, text)
- self.contents.draw_text(444, 24 , 10 , WLH, "?")
- self.contents.draw_text(24 , y - 24, 196, WLH, "Current Balance")
- self.contents.draw_text(24 , y , 196, WLH, "Withdrawal")
- self.contents.draw_text(172, y , 10 , WLH, "-")
- self.contents.draw_text(148, y + 6 , 120, WLH, "________", 2)
- self.contents.draw_text(24 , y + 32, 196, WLH, "New Balance")
- self.contents.draw_text(172, y + 32, 10 , WLH, "=")
- self.contents.font.color = system_color
- self.contents.draw_text(352, 24 , 100, WLH, @account.name, 1)
- newBalance = @account.balance - @number
- when 2 #Transfer
- x = 256
- text = "How much will you transfer?"
- opperator = @xferAccount.type == 2 ? "-" : "+"
- self.contents.draw_text(12 , 12 , 512, WLH, text, 1)
- #account
- self.contents.draw_text(12 , y - 24, 196, WLH, "Current Balance")
- self.contents.draw_text(12 , y , 196, WLH, "Transfer")
- self.contents.draw_text(160, y , 10 , WLH, "-")
- self.contents.draw_text(136, y + 6 , 120, WLH, "________", 2)
- self.contents.draw_text(12 , y + 32, 196, WLH, "New Balance")
- self.contents.draw_text(160, y + 32, 10 , WLH, "=")
- #xfer account
- self.contents.draw_text(x + 12 , y - 24, 196, WLH, "Current Balance")
- self.contents.draw_text(x + 12 , y , 196, WLH, "Transfer")
- self.contents.draw_text(x + 160, y , 10 , WLH, opperator)
- self.contents.draw_text(x + 136, y + 6 , 120, WLH, "________", 2)
- self.contents.draw_text(x + 12 , y + 32, 196, WLH, "New Balance")
- self.contents.draw_text(x + 160, y + 32, 10 , WLH, "=")
- xferBalance = @xferAccount.type == 2 ? @xferAccount.balance - @number :
- @xferAccount.balance + @number
- draw_currency_value(@xferAccount.balance, x + 136, y - 24, 120)
- draw_currency_value(@number, x + 136, y, 120)
- draw_currency_value(xferBalance, x + 136, y + 32, 120)
- self.contents.font.color = system_color
- self.contents.draw_text(12 , 44, 256, WLH, @account.name , 1)
- self.contents.draw_text(x + 12, 44, 256, WLH, @xferAccount.name, 1)
- x = 130
- newBalance = @account.balance - @number
- when 3 #create loan
- text = "How much would you like to borrow?"
- self.contents.draw_text(0, 48, 400, WLH, text)
- self.contents.font.color = system_color
- self.contents.draw_text(24, y, 196, WLH, "Loan Amount:")
- when 4 #buy slots
- text = "How many Safety Deposit Boxes"
- text2 = "would you like to buy?"
- self.contents.draw_text(0, 24, contents.width, WLH, text)
- self.contents.draw_text(0, 48, contents.width, WLH, text2)
- self.contents.font.color = system_color
- self.contents.draw_text(24, y , 196, WLH, "Safety Deposit Boxes")
- self.contents.draw_text(24, y + 32, 196, WLH, "Total")
- newBalance = @number * @slotCost
- when 5 #store item
- text = "How many would you like to deposit?"
- self.contents.draw_text(0, 24, contents.width, WLH, text)
- self.contents.font.color = system_color
- self.contents.draw_text(24, y , 196, WLH, @item.name)
- end
- self.contents.font.color = normal_color
- draw_currency_value(@account.balance, x, y - 24, 120) unless @action == 3 or
- @action == 4 or
- @action == 5
- draw_currency_value (@number, x, y, 120) unless @action == 4 or
- @action == 5
- self.contents.draw_text(236, y, 20, WLH, @number, 2) if @action == 4 or
- @action == 5
- draw_currency_value (newBalance, x, y + 32, 120) unless @action == 3 or
- @action == 5
- self.cursor_rect.set (x + 98 - @digit * 10, y, 10, WLH)
- @refreshNeeded = false
- end
- #-----------------------------------------------------------------------------
- # Updates the window with new input information
- #-----------------------------------------------------------------------------
- def update
- super
- if self.active
- last_number = @number
- if Input.repeat?(Input::RIGHT)
- if @digit == 0
- @number = @min
- else
- @digit -= 1
- @refreshNeeded = true
- end
- end
- if Input.repeat?(Input::LEFT)
- if @digit == @maxDigit
- @number = @max
- else
- @digit += 1
- @refreshNeeded = true
- end
- end
- if Input.repeat?(Input::UP) and @number < @max
- @number = [@number + 10**@digit, @max].min
- end
- if Input.repeat?(Input::DOWN) and @number > @min
- @number = [@number - 10**@digit, 1].max
- end
- if @number != last_number or @refreshNeeded
- Sound.play_cursor
- refresh
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement