Advertisement
QuasiXi

[GTBS] Place Window v2

Jan 24th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.97 KB | None | 0 0
  1. #===============================================================================
  2. # GTBS Placement Window v2
  3. #
  4. # This Script was made for GTBS 2.4. It is a plug-n-play
  5. # Paste this anywhere below [GTBS] Window_Base
  6. # Feel free to use/edit, no credit needed
  7. #
  8. # Edit the values in module Quasi to your liking.
  9. # Don't edit anything else unless you know what you are doing.
  10. #
  11. # To use a picture instead of windowskin for the Place Window
  12. # Make a file in Graphics/Pictures/GTBS/ named "TBS_Place"
  13. #
  14. # Animated Character by Galv
  15. #
  16. # By Quasi (http://quasixi.wordpress.com/)
  17. # New version: http://pastebin.com/hZiYa0Mb
  18. # New version fixed some issues and added remove character during placement
  19. #===============================================================================
  20.  
  21. module Quasi
  22. PLACEOFFSET_Y = 80
  23. PLACEWIN_X = 0
  24. PLACEWIN_Y = Graphics.height - 170
  25. PLACEWIN_Z = 2
  26. PLACEWIN_HEIGHT = 100
  27. PLACEWIN_WIDTH = Graphics.width
  28. PLACEWIN_COL = 5 #Max Number of actors to display
  29. WINPLACE_SPACING = 40 #Spacing Between Actors
  30. end
  31.  
  32.  
  33. #===============================================================================
  34. # Changes to [GTBS] Scene_Battle
  35. # Adds window + hides
  36. #===============================================================================
  37. class Scene_Battle_TBS
  38. Win_Place = 'place'
  39. alias quasi_create_windows create_windows
  40. alias quasi_win_confirm_update win_confirm_update
  41. alias quasi_finish_prep finish_prep
  42.  
  43. def create_windows
  44. quasi_create_windows
  45. @windows[Win_Place] = Windows_Place_GTBS.new
  46. end
  47.  
  48. def finish_prep
  49. @windows[Win_Place].hide
  50. quasi_finish_prep
  51. end
  52.  
  53. def win_confirm_update
  54. @windows[Win_Place].visible = false
  55. quasi_win_confirm_update
  56. end
  57.  
  58. #===============================================================================
  59. # Changes to [GTBS] Place_Actors
  60. # Updates Place Window
  61. # Flipped R and L
  62. #===============================================================================
  63.  
  64. alias quasi_start_actor_place start_actor_place
  65. alias quasi_place_update place_update
  66. alias quasi_place_init place_init
  67.  
  68. def set_place_finish?
  69. @windows[Win_Confirm].ask(Command_Confirm::Place)
  70. @windows[Win_Place].visible = false
  71. end
  72.  
  73. def start_actor_place
  74. quasi_start_actor_place
  75. @windows[Win_Place].visible = true
  76. @windows[Win_Place].update($game_party.all_members[@index], @index)
  77. end
  78.  
  79. def place_init
  80. quasi_place_init
  81. if Input.trigger?(Input::R)
  82. Sound.play_cursor
  83. # Doubled to over right old input
  84. next_actor_to_place
  85. next_actor_to_place
  86. #previous actor
  87. elsif Input.trigger?(Input::L)
  88. Sound.play_cursor
  89. # Doubled to over right old input
  90. previous_actor_to_place
  91. previous_actor_to_place
  92. end
  93. end
  94.  
  95. def place_update
  96. quasi_place_update
  97. @windows[Win_Help].visible = true if @windows[Win_Help].visible != true
  98. @windows[Win_Place].visible = true if @windows[Win_Confirm].visible == false
  99. @windows[Win_Place].update($game_party.all_members[@index], @index)
  100. end
  101. end
  102.  
  103. #===============================================================================
  104. # Allow Place Window to have a picture for a background.
  105. #===============================================================================
  106. module GTBS_Win_Base
  107. def create_gtbs_back
  108. case self
  109. when Windows_Status_GTBS
  110. back_name = 'TBS_Status.png'
  111. when Window_EXP_Earn
  112. back_name = 'TBS_Exp_Gain.png'
  113. when Commands_All
  114. back_name = 'Commands_All.png'
  115. when Battle_Option
  116. back_name = 'TBS_Battle_Option.png'
  117. when Command_Confirm
  118. back_name = 'Command_Confirm.png'
  119. when Window_Actor_Display
  120. back_name = 'Actor_Display.png'
  121. when Window_Config
  122. back_name = 'TBS_Config.png'
  123. when Window_Select_Color
  124. back_name = 'TBS_Select_Color.png'
  125. when TBS_Item, TBS_Skill
  126. back_name = 'TBS_Item_Skill.png'
  127. when Window_Full_Status
  128. back_name = 'TBS_Full_Status.png'
  129.  
  130. # Added Place Window to possible picture backgrounds
  131. when Windows_Place_GTBS
  132. back_name = 'TBS_Place.png'
  133. end
  134. if back_name and FileTest.exist?('Graphics/Pictures/GTBS/' + back_name)
  135. @back = Sprite.new
  136. self.opacity = 0
  137. @back.bitmap = Cache.picture('GTBS/' + back_name)
  138. @back.visible = false
  139. @back.opacity = GTBS::CONTROL_OPACITY
  140. else
  141. self.opacity = GTBS::CONTROL_OPACITY
  142. end
  143. end
  144. end
  145.  
  146. #===============================================================================
  147. # Windows_Place_GTBS
  148. # By Quasi
  149. #===============================================================================
  150. class Windows_Place_GTBS < TBS_Window_Base
  151. #----------------------------------------------------------------------------
  152. # * Object Intialization
  153. # actor = Game_Actor/Game_Enemy/nil
  154. #----------------------------------------------------------------------------
  155. def initialize(actor = nil)
  156. super(Quasi::PLACEWIN_X, Quasi::PLACEWIN_Y, Quasi::PLACEWIN_WIDTH, Quasi::PLACEWIN_HEIGHT)
  157. @actor = nil
  158. @index = 0
  159. @animtime = 0
  160. @walk = 0
  161. @step = 0
  162. @afix = 1
  163. @key = ""
  164. @col = Quasi::PLACEWIN_COL
  165. @y = Quasi::PLACEOFFSET_Y
  166. self.z = Quasi::PLACEWIN_Z
  167. create_contents
  168. refresh
  169. end
  170. #----------------------------------------------------------------------------
  171. # Update Method
  172. #----------------------------------------------------------------------------
  173. def update(actor = nil, index = nil)
  174. super()
  175. if @actor != actor
  176. @actor = actor
  177. refresh
  178. end
  179. if @index != index
  180. @index = index
  181. refresh
  182. end
  183.  
  184. return unless self.visible
  185. @animtime += 1
  186. if @animtime == 10
  187. case @walk
  188. when 1; @walk -= 1
  189. when -1; @walk += 1
  190. when 0
  191. if @step == 1
  192. @walk = -1; @step = 0
  193. else
  194. @walk = 1; @step = 1
  195. end
  196. end
  197. @animtime = 0
  198. refresh
  199. end
  200. end
  201.  
  202. #----------------------------------------------------------------------------
  203. # Refresh Method
  204. #----------------------------------------------------------------------------
  205. def refresh
  206. if @actor == nil
  207. hide
  208. return
  209. end
  210. draw_actor_info
  211. self.visible = true
  212. #self.opacity = GTBS::CONTROL_OPACITY
  213. end
  214.  
  215. def draw_character(character_name, character_index, x, y, enabled = true)
  216. return unless character_name
  217. bitmap = Cache.character(character_name)
  218. sign = character_name[/^[\!\$]./]
  219. if sign && sign.include?('$')
  220. cw = bitmap.width / 3
  221. ch = bitmap.height / 4
  222. else
  223. cw = bitmap.width / 12
  224. ch = bitmap.height / 8
  225. end
  226. n = character_index
  227. step = 0
  228. step = @walk if enabled
  229. src_rect = Rect.new((n%4*3+1+step)*cw, (n/4*4)*ch, cw, ch)
  230. ret_rect = Rect.new(x - cw, y - ch, cw, ch)
  231. contents.stretch_blt(ret_rect, bitmap, src_rect)
  232. end
  233.  
  234. def draw_actor_info
  235. clear_info
  236. draw_text(0, 50, 180, line_height, " < Prev")
  237. draw_text(Graphics.width - 100, 50, 180, line_height, "Next > ")
  238.  
  239. party_members = $game_party.all_members
  240. if @col > party_members.size
  241. @col = party_members.size
  242. end
  243.  
  244. @odd = (@col + 1) % 2
  245. @ofix = (@col / 2) - @odd
  246. @afix = party_members.size - (@col - @ofix)
  247.  
  248. @fix = @col
  249. @fix %= 2
  250.  
  251. @pindex = @index + @afix
  252. for i in 0...@col
  253. @pindex += 1
  254. @pindex %= party_members.size
  255.  
  256. @a = party_members[@pindex]
  257.  
  258. spacing = i * Quasi::WINPLACE_SPACING
  259. x = ( Graphics.width / 2 ) - (((@col - @fix) * 40) / 2 )
  260. if @index != @pindex
  261. @ani = false
  262. else
  263. @ani = true
  264. end
  265. if @a != nil
  266. draw_character(@a.character_name, @a.character_index, x + spacing + 2, @y, @ani)
  267. end
  268. end
  269. end
  270.  
  271. def clear_info
  272. self.contents.clear
  273. contents.clear
  274. end
  275. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement