Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # GTBS Placement Window v2
- #
- # This Script was made for GTBS 2.4. It is a plug-n-play
- # Paste this anywhere below [GTBS] Window_Base
- # Feel free to use/edit, no credit needed
- #
- # Edit the values in module Quasi to your liking.
- # Don't edit anything else unless you know what you are doing.
- #
- # To use a picture instead of windowskin for the Place Window
- # Make a file in Graphics/Pictures/GTBS/ named "TBS_Place"
- #
- # Animated Character by Galv
- #
- # By Quasi (http://quasixi.wordpress.com/)
- # New version: http://pastebin.com/hZiYa0Mb
- # New version fixed some issues and added remove character during placement
- #===============================================================================
- module Quasi
- PLACEOFFSET_Y = 80
- PLACEWIN_X = 0
- PLACEWIN_Y = Graphics.height - 170
- PLACEWIN_Z = 2
- PLACEWIN_HEIGHT = 100
- PLACEWIN_WIDTH = Graphics.width
- PLACEWIN_COL = 5 #Max Number of actors to display
- WINPLACE_SPACING = 40 #Spacing Between Actors
- end
- #===============================================================================
- # Changes to [GTBS] Scene_Battle
- # Adds window + hides
- #===============================================================================
- class Scene_Battle_TBS
- Win_Place = 'place'
- alias quasi_create_windows create_windows
- alias quasi_win_confirm_update win_confirm_update
- alias quasi_finish_prep finish_prep
- def create_windows
- quasi_create_windows
- @windows[Win_Place] = Windows_Place_GTBS.new
- end
- def finish_prep
- @windows[Win_Place].hide
- quasi_finish_prep
- end
- def win_confirm_update
- @windows[Win_Place].visible = false
- quasi_win_confirm_update
- end
- #===============================================================================
- # Changes to [GTBS] Place_Actors
- # Updates Place Window
- # Flipped R and L
- #===============================================================================
- alias quasi_start_actor_place start_actor_place
- alias quasi_place_update place_update
- alias quasi_place_init place_init
- def set_place_finish?
- @windows[Win_Confirm].ask(Command_Confirm::Place)
- @windows[Win_Place].visible = false
- end
- def start_actor_place
- quasi_start_actor_place
- @windows[Win_Place].visible = true
- @windows[Win_Place].update($game_party.all_members[@index], @index)
- end
- def place_init
- quasi_place_init
- if Input.trigger?(Input::R)
- Sound.play_cursor
- # Doubled to over right old input
- next_actor_to_place
- next_actor_to_place
- #previous actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- # Doubled to over right old input
- previous_actor_to_place
- previous_actor_to_place
- end
- end
- def place_update
- quasi_place_update
- @windows[Win_Help].visible = true if @windows[Win_Help].visible != true
- @windows[Win_Place].visible = true if @windows[Win_Confirm].visible == false
- @windows[Win_Place].update($game_party.all_members[@index], @index)
- end
- end
- #===============================================================================
- # Allow Place Window to have a picture for a background.
- #===============================================================================
- module GTBS_Win_Base
- def create_gtbs_back
- case self
- when Windows_Status_GTBS
- back_name = 'TBS_Status.png'
- when Window_EXP_Earn
- back_name = 'TBS_Exp_Gain.png'
- when Commands_All
- back_name = 'Commands_All.png'
- when Battle_Option
- back_name = 'TBS_Battle_Option.png'
- when Command_Confirm
- back_name = 'Command_Confirm.png'
- when Window_Actor_Display
- back_name = 'Actor_Display.png'
- when Window_Config
- back_name = 'TBS_Config.png'
- when Window_Select_Color
- back_name = 'TBS_Select_Color.png'
- when TBS_Item, TBS_Skill
- back_name = 'TBS_Item_Skill.png'
- when Window_Full_Status
- back_name = 'TBS_Full_Status.png'
- # Added Place Window to possible picture backgrounds
- when Windows_Place_GTBS
- back_name = 'TBS_Place.png'
- end
- if back_name and FileTest.exist?('Graphics/Pictures/GTBS/' + back_name)
- @back = Sprite.new
- self.opacity = 0
- @back.bitmap = Cache.picture('GTBS/' + back_name)
- @back.visible = false
- @back.opacity = GTBS::CONTROL_OPACITY
- else
- self.opacity = GTBS::CONTROL_OPACITY
- end
- end
- end
- #===============================================================================
- # Windows_Place_GTBS
- # By Quasi
- #===============================================================================
- class Windows_Place_GTBS < TBS_Window_Base
- #----------------------------------------------------------------------------
- # * Object Intialization
- # actor = Game_Actor/Game_Enemy/nil
- #----------------------------------------------------------------------------
- def initialize(actor = nil)
- super(Quasi::PLACEWIN_X, Quasi::PLACEWIN_Y, Quasi::PLACEWIN_WIDTH, Quasi::PLACEWIN_HEIGHT)
- @actor = nil
- @index = 0
- @animtime = 0
- @walk = 0
- @step = 0
- @afix = 1
- @key = ""
- @col = Quasi::PLACEWIN_COL
- @y = Quasi::PLACEOFFSET_Y
- self.z = Quasi::PLACEWIN_Z
- create_contents
- refresh
- end
- #----------------------------------------------------------------------------
- # Update Method
- #----------------------------------------------------------------------------
- def update(actor = nil, index = nil)
- super()
- if @actor != actor
- @actor = actor
- refresh
- end
- if @index != index
- @index = index
- refresh
- end
- return unless self.visible
- @animtime += 1
- if @animtime == 10
- case @walk
- when 1; @walk -= 1
- when -1; @walk += 1
- when 0
- if @step == 1
- @walk = -1; @step = 0
- else
- @walk = 1; @step = 1
- end
- end
- @animtime = 0
- refresh
- end
- end
- #----------------------------------------------------------------------------
- # Refresh Method
- #----------------------------------------------------------------------------
- def refresh
- if @actor == nil
- hide
- return
- end
- draw_actor_info
- self.visible = true
- #self.opacity = GTBS::CONTROL_OPACITY
- end
- def draw_character(character_name, character_index, x, y, enabled = true)
- return unless character_name
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- step = 0
- step = @walk if enabled
- src_rect = Rect.new((n%4*3+1+step)*cw, (n/4*4)*ch, cw, ch)
- ret_rect = Rect.new(x - cw, y - ch, cw, ch)
- contents.stretch_blt(ret_rect, bitmap, src_rect)
- end
- def draw_actor_info
- clear_info
- draw_text(0, 50, 180, line_height, " < Prev")
- draw_text(Graphics.width - 100, 50, 180, line_height, "Next > ")
- party_members = $game_party.all_members
- if @col > party_members.size
- @col = party_members.size
- end
- @odd = (@col + 1) % 2
- @ofix = (@col / 2) - @odd
- @afix = party_members.size - (@col - @ofix)
- @fix = @col
- @fix %= 2
- @pindex = @index + @afix
- for i in 0...@col
- @pindex += 1
- @pindex %= party_members.size
- @a = party_members[@pindex]
- spacing = i * Quasi::WINPLACE_SPACING
- x = ( Graphics.width / 2 ) - (((@col - @fix) * 40) / 2 )
- if @index != @pindex
- @ani = false
- else
- @ani = true
- end
- if @a != nil
- draw_character(@a.character_name, @a.character_index, x + spacing + 2, @y, @ani)
- end
- end
- end
- def clear_info
- self.contents.clear
- contents.clear
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement