class Game_System
attr_accessor :gtbs_a_id
attr_accessor :gtbs_e_id
alias gtbs_ums_system_init initialize
def initialize
@gtbs_a_id = -1
@gtbs_e_id = -1
gtbs_ums_system_init
end
end
class Scene_Battle_TBS
alias gtbs_sb_ums_update update
def update
$game_system.slave_windows.each_value { |window| window.update }
$game_system.indy_windows.each_value { |window| window.update }
gtbs_sb_ums_update
end
end
class Window_Message < Window_Selectable
alias gtbs_ums_gm_refresh refresh
def refresh
if $game_temp.message_text != nil
text = $game_temp.message_text
text.gsub!(/\\[Gg][Tt][Bb][Ss][Aa]\[([0-999]+)\]/) do
$game_system.gtbs_a_id = $1.to_i
""
end
# GTBS Enemy Battle Event
text.gsub!(/\\[Gg][Tt][Bb][Ss][Ee]\[([0-999]+)\]/) do
$game_system.gtbs_e_id = $1.to_i
""
end
$game_temp.message_text = text
end
gtbs_ums_gm_refresh
end
#--------------------------------------------------------------------------
# * Set Window Position and Opacity Level
#--------------------------------------------------------------------------
def reset_window (change_opacity = true)
# x-coordinate depends on justification
if $game_system.message_event == -1 and $game_system.train_actor == -1
if $game_system.window_justification == RIGHT
self.x = 640 - $game_system.window_width
elsif $game_system.window_justification == LEFT
self.x = 0
else # center
self.x = (640 - self.width) / 2
end
elsif $game_system.train_actor >= 0
if $game_system.train_actor == 0 or $game_system.train_actor > $game_party.actors.size - 1
# center on player
event_x = $game_player.screen_x
else
# center on train actor
event_x = $game_train.actors[$game_system.train_actor - 1].screen_x
end
self.x = event_x - self.width / 2
@comic.x = self.x + (self.width / 2) + 4
else
if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
# center on player
event_x = $game_player.screen_x
else
# center on the event specified
event_x = $game_map.events[$game_system.message_event].screen_x
end
self.x = event_x - self.width / 2
@comic.x = self.x + (self.width / 2) + 4
end
if $game_temp.in_battle
self.y = 16
else
if $game_system.message_event == -1 and $game_system.train_actor == -1
case $game_system.message_position
when 0 # up
self.y = 16
when 1 # middle
self.y = (480 - $game_system.window_height) / 2
when 2 # down
self.y = 480 - $game_system.window_height - 24
end
elsif $game_system.train_actor >= 0
if $game_system.train_actor == 0 or $game_system.train_actor > $game_party.actors.size - 1
# center on player
self.y = $game_player.screen_y - self.height - 48
else
# center on train actor
self.y = $game_train.actors[$game_system.train_actor - 1].screen_y - self.height - 48
end
@comic.y = self.y + self.height - 2
@comic.angle = 0
else
if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
# above player
self.y = $game_player.screen_y - self.height - 48
else
# above event specified
self.y = $game_map.events[$game_system.message_event].screen_y - self.height - 48
end
@comic.y = self.y + self.height - 2
@comic.angle = 0
end
end
if self.y < 0 + ($game_system.name == "" ? 0 : 16)
if $game_system.comic_enabled
if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
self.y = $game_player.screen_y - 16
else
self.y = $game_map.events[$game_system.message_event].screen_y - 16
end
@comic.angle = 180
@comic.y = self.y + 2
@comic.x = self.x + (self.width / 2) - 4
else
self.y = 0 + ($game_system.name == "" ? 0 : 16)
end
elsif self.y > 480 - self.height
self.y = 480 - self.height
end
if self.x < 0
self.x = 0
elsif self.x > 680 - self.width - 48
self.x = 640 - self.width
end
if $game_temp.in_battle and $scene.is_a?(Scene_Battle_TBS)
if $game_system.gtbs_a_id >= 0 and $game_system.gtbs_e_id == -1
actor = nil
for act in $game_system.tactics_actors + $game_system.tactics_neutral + $game_system.tactics_dead
if act.id == $game_system.gtbs_a_id and act.is_a?(Game_Actor)
actor = act
end
end
if actor != nil
event_x = actor.screen_x
self.y = actor.screen_y-self.height-16
self.x = event_x - self.width / 2
@comic.angle = 180
@comic.y = @comic.y = self.y + 2
@comic.x = self.x + (self.width / 2) + 4
@comic.visible = true
end
elsif $game_system.gtbs_a_id == -1 and $game_system.gtbs_e_id >= 0
actor = nil
for act in $game_system.tactics_enemies + $game_system.tactics_dead
if act.id == $game_system.gtbs_e_id and act.is_a?(Game_Enemy)
actor = act
end
end
if actor != nil
event_x = actor.screen_x
self.y = actor.screen_y-self.height-16
self.x = event_x - self.width / 2
@comic.angle = 180
@comic.y = @comic.y = self.y + 2
@comic.x = self.x + (self.width / 2) + 4
@comic.visible = true
end
elsif $game_system.gtbs_a_id == -1 && $game_system.gtbs_e_id == -1
self.x = 320 - self.width/2
self.y = 480-self.height-16
end
if (self.x+self.width) > 640
self.x -= (self.x+self.width)-640
elsif self.x < 0
self.x = 0
end
if self.y + self.height > 480
self.y -= (self.y+self.height)-480
elsif self.y < 0
self.y = 0
end
$game_system.comic_style = TALK1
@comic.bitmap = RPG::Cache.windowskin("talk1.png")
end
if change_opacity
if $game_system.message_frame == 0 and $game_temp.message_text != ""
self.opacity = $game_system.opacity
else
self.opacity = 0
end
self.back_opacity = $game_system.back_opacity
end
# window back stuff
if $game_system.window_image != nil
@window_back.bitmap = RPG::Cache.windowskin($game_system.window_image)
@window_back.x = self.x
@window_back.y = self.y
end
# face stuff
if $game_system.face_graphic != ""
# the player has chosen to show a face graphic
if @done and $game_system.resting_face != ""
@face.bitmap = RPG::Cache.picture($game_system.face_graphic + $game_system.resting_face)
if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
@face_frame = 0
end
else
@face.bitmap = RPG::Cache.picture($game_system.face_graphic)
end
# picture y-coordinate
if $game_system.face_graphic_position == ABOVE
@face.y = self.y - @face.bitmap.height
@face_offset = 0
elsif $game_system.face_graphic_position == CENTER
delta = (@face.bitmap.height - self.height) / 2
@face.y = self.y - delta
if $game_system.animated_faces
@face_offset = $game_system.face_frame_width + 16
else
@face_offset = @face.bitmap.width + 16
end
elsif $game_system.face_graphic_position == BOTTOM
@face.y = self.y + self.height - @face.bitmap.height
if $game_system.animated_faces
@face_offset = $game_system.face_frame_width + 16
else
@face_offset = @face.bitmap.width + 16
end
else # side
delta = (@face.bitmap.height - self.height) / 2
@face.y = self.y - delta
@face_offset = 0
end
# picture x-coordinate
if $game_system.face_graphic_justification == LEFT
if $game_system.face_graphic_position == SIDE
@face.x = self.x - @face.bitmap.width
else
@face.x = self.x + 10
end
else # right side
if $game_system.animated_faces
offset = @face.bitmap.width - $game_system.face_frame_width
else
offset = 0
end
if $game_system.face_graphic_position == SIDE
@face.x = self.x + self.width + offset
else
@face.x = self.x + self.width - @face.bitmap.width - 10 + offset
@face_offset = 0
end
end
if $game_system.animated_faces
@face.src_rect = Rect.new(@face_frame * $game_system.face_frame_width, 0, $game_system.face_frame_width, @face.bitmap.height)
if @done and $game_system.resting_face != ""
pause = $game_system.resting_animation_pause
else
pause = $game_system.animation_pause
end
if Graphics.frame_count % pause == 0
@animate_face = true
end
if @animate_face
if Graphics.frame_count % 3 == 0
@face_frame += 1
if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
@face_frame = 0
@animate_face = false
end
end
end
end
end
# name window
if $game_system.name != ""
@name_window.x = self.x
@name_window.y = self.y - 36
@name_window.set_name($game_system.name)
end
# If choice
if $game_temp.choice_max > 0
@choice_window.set_choices($game_temp.choices)
# determine x and y coords for choice window
if $game_system.choice_justification == LEFT
@choice_window.x = self.x
else
@choice_window.x = self.x + self.width - @choice_window.width
end
if $game_system.choice_position == ABOVE
# check to make sure there is enough room above the textbox
if self.y < @choice_window.height
# not enough room above, place below
@choice_window.y = self.y + self.height
else
# draw above
@choice_window.y = self.y - @choice_window.height
end
elsif $game_system.choice_position == BOTTOM
# check to make sure there is enough room below the textbox
if (480 - self.y - self.height) < @choice_window.height
# not enough room below, place above
@choice_window.y = self.y - @choice_window.height
else
# draw below
@choice_window.y = self.y + self.height
end
else # side
if $game_system.choice_justification == LEFT
# check to make sure there's room on the left side
if self.y < @choice_window.width
# not enough room on the side, check to make sure there's room below
if (480 - self.y - self.height) < @choice_window.height
# not enough room below, place above
@choice_window.y = self.y - @choice_window.height
else
# draw below
@choice_window.y = self.y + self.height
end
else
# place on the left side
@choice_window.y = self.y
@choice_window.x = self.x - @choice_window.width
end
else # right
# check to make sure there's room on the right side
if (680 - (self.y + self.width)) < @choice_window.width
# not enough room on the side, check to make sure there's room below
if (480 - self.y - self.height) < @choice_window.height
# not enough room below, place above
@choice_window.y = self.y - @choice_window.height
else
# draw below
@choice_window.y = self.y + self.height
end
else
# place on the left side
@choice_window.y = self.y
@choice_window.x = self.x + self.width
end
end
end
end
# If number input
if $game_temp.num_input_variable_id > 0
if @input_number_window == nil
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
end
# determine x and y coords for number input window
if $game_system.choice_justification == LEFT
@input_number_window.x = self.x
else
@input_number_window.x = self.x + self.width - @input_number_window.width
end
if $game_system.choice_position == ABOVE
# check to make sure there is enough room above the textbox
if self.y < @input_number_window.height
# not enough room above, place below
@input_number_window.y = self.y + self.height
else
# draw above
@input_number_window.y = self.y - @choice_window.height
end
elsif $game_system.choice_position == BOTTOM
# check to make sure there is enough room below the textbox
if (480 - self.y - self.height) < @input_number_window.height
# not enough room below, place above
@input_number_window.y = self.y - @input_number_window.height
else
# draw below
@input_number_window.y = self.y + self.height
end
else # side
if $game_system.choice_justification == LEFT
# check to make sure there's room on the left side
if self.y < @input_number_window.width
# not enough room on the side, check to make sure there's room below
if (480 - self.y - self.height) < @input_number_window.height
# not enough room below, place above
@input_number_window.y = self.y - @input_number_window.height
else
# draw below
@input_number_window.y = self.y + self.height
end
else
# place on the left side
@input_number_window.y = self.y
@input_number_window.x = self.x - @choice_window.width
end
else # right
# check to make sure there's room on the right side
if (680 - (self.y + self.width)) < @input_number_window.width
# not enough room on the side, check to make sure there's room below
if (480 - self.y - self.height) < @input_number_window.height
# not enough room below, place above
@input_number_window.y = self.y - @input_number_window.height
else
# draw below
@input_number_window.y = self.y + self.height
end
else
# place on the left side
@input_number_window.y = self.y
@input_number_window.x = self.x + self.width
end
end
end
end
end
alias gtbs_ums_terminate_message terminate_message
def terminate_message
gtbs_ums_terminate_message
$game_system.gtbs_a_id = -1
$game_system.gtbs_e_id = -1
@comic.visible = false
end
alias gtbs_ums_update update
def update
gtbs_ums_update
if @fadein
if $scene.is_a?(Scene_Battle_TBS)
if $game_system.comic_enabled
@comic.opacity = self.opacity
@comic.visible = self.visible
end
end
end
end
end