=begin
** Battle Turn Count Window v1.1 **
by Mr. Bubble
A simple script that creates a small window which displays the current turn
in battle.
This script was made for keeping better track of the turn number for projects
in development. Not very flashy for final products.
Made compatible with the RPG Tankentai SBS and ATB. Place this script below
those battle system scripts if you're using them.
=end
module Bubs
module BattleTurnCount
#--------------------------------------------------------------------------
# Turn Count Window User Customization Module
#--------------------------------------------------------------------------
# Text before turn value.
TURN_WINDOW_TEXT = "总回合数: "
# Text font size. Default VX font size is 20. Very large sizes will not
# fit well.
TURN_WINDOW_TEXTSIZE = 20
# Text font name(s). Include an array of strings to specify multiple
# fonts to be used in a desired order. If the higher priority font does
# not exist within the system, the second choice will be used instead and
# so on.
TURN_WINDOW_FONT = ["方正少儿简体"]
# X-coordinate position of turn count window.
TURN_COUNT_WINDOW_X = 410
# Y-coordinate position of turn count window.
TURN_COUNT_WINDOW_Y = 0
# true: Show window skin
# false: Hide window skin
# Only affects the Turn Count Window. Text will still show.
USE_WINDOWSKIN = false
# true: Always use default skin for Turn Count Window
# false: Use windowskin as defined for WINDOWSKIN_FILENAME
# If you use a separate window skin changer script, you may want to
# keep this true.
USE_DEFAULT_WINDOWSKIN = true
# File name of window skin in the Graphics/System folder.
# Only affects the Turn Count Window
# USE_DEFAULT_WINDOWSKIN must be false for this to take effect
WINDOWSKIN_FILENAME = "1"
#--------------------------------------------------------------------------
# End of Turn Count Window User Customization Module
#--------------------------------------------------------------------------
end
end
class Window_BattleTurnCount < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 128, WLH + 32)
# Added to provide compatibility with windowskin changer scripts
if !Bubs::BattleTurnCount::USE_DEFAULT_WINDOWSKIN
self.windowskin = Cache.system(Bubs::BattleTurnCount::WINDOWSKIN_FILENAME)
end
# Set windowskin opacity to 0 (text still shows)
self.opacity = 0 if !Bubs::BattleTurnCount::USE_WINDOWSKIN
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
turn_num = $game_troop.turn_count + 1 # +1 because first turn value is 0.
self.contents.font.color = normal_color
# TCW Font Size
self.contents.font.size = Bubs::BattleTurnCount::TURN_WINDOW_TEXTSIZE
# TCW Font
self.contents.font.name = Bubs::BattleTurnCount::TURN_WINDOW_FONT
# unless Tankentai ATB is installed
self.contents.draw_text(4, 0, 128, WLH,
Bubs::BattleTurnCount::TURN_WINDOW_TEXT + turn_num.to_s) unless defined?(::N02)
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Create Information Display Viewport
#--------------------------------------------------------------------------
alias create_iv_bubs_tcw create_info_viewport
def create_info_viewport
# (x,y) coordinates of TCW
x = Bubs::BattleTurnCount::TURN_COUNT_WINDOW_X
y = Bubs::BattleTurnCount::TURN_COUNT_WINDOW_Y
@turn_count_window = Window_BattleTurnCount.new(x, y)
@turn_count_window.visible = true
create_iv_bubs_tcw
end
#--------------------------------------------------------------------------
# * Start party command selection
#--------------------------------------------------------------------------
alias spcs_bubs_tcw start_party_command_selection
def start_party_command_selection
if $game_temp.in_battle
@turn_count_window.refresh
@turn_count_window.visible = true
spcs_bubs_tcw
end
end
#--------------------------------------------------------------------------
# * Dispose of Information Display Viewport
#--------------------------------------------------------------------------
alias terminate_bubs_tcw terminate
def terminate
@turn_count_window.dispose
terminate_bubs_tcw
end
#--------------------------------------------------------------------------
# * Update Information Display Viewport
#--------------------------------------------------------------------------
alias update_iv_bubs_tcw update_info_viewport
def update_info_viewport
# if Tankentai ATB is installed
if defined?(::N02)
@turn_count_window.contents.clear
turn_num = $game_troop.turn_count + 1
@turn_count_window.contents.draw_text(4, 0, 128, 24,
Bubs::BattleTurnCount::TURN_WINDOW_TEXT + turn_num.to_s)
end
@turn_count_window.update
update_iv_bubs_tcw
end
#--------------------------------------------------------------------------
# * Victory Processing
#--------------------------------------------------------------------------
alias process_victory_bubs_tcw process_victory
def process_victory
# Hides TCW when winning a battle
@turn_count_window.visible = false
process_victory_bubs_tcw
end
#--------------------------------------------------------------------------
# * Escape Processing
#--------------------------------------------------------------------------
alias process_escape_bubs_tcw process_escape
def process_escape
# Hides TCW when escaping
@turn_count_window.visible = false
process_escape_bubs_tcw
end
#--------------------------------------------------------------------------
# * Start Execution of Battle Processing
#--------------------------------------------------------------------------
alias start_main_atb_bubs_tcw start_main
def start_main(*args)
# unless Tankentai ATB is installed
@turn_count_window.visible = false unless defined?(::N02)
start_main_atb_bubs_tcw(*args)
end
end