Hey all, question for VX scripting.
I'm making some changes to the Battle Processing scene to show a row of thin facebars for the party with their current states. I'm wanting to use an image to replace the windowskin so that I'm not limited to the hard 16px margin around content, but the images are conflicting with the others' (x, y) draw.
what I want to do:
So that the background window is the image and it draws the faces appropriately (the face draw works perfectly fine over a standard window or without the image being drawn behind them)
What is happening:
Here's my current script noodling about:
Thanks in advance!
I'm making some changes to the Battle Processing scene to show a row of thin facebars for the party with their current states. I'm wanting to use an image to replace the windowskin so that I'm not limited to the hard 16px margin around content, but the images are conflicting with the others' (x, y) draw.
what I want to do:
So that the background window is the image and it draws the faces appropriately (the face draw works perfectly fine over a standard window or without the image being drawn behind them)
What is happening:
Here's my current script noodling about:
Code:
class Window_BattleFace < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-16, 272, 672, 100) #416
self.windowskin = Cache.system("")
refresh
self.active = false
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.members.size
for i in 0...@item_max
draw_item_face(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : Item number
#--------------------------------------------------------------------------
def draw_item_face(index)
rect = item_rect(index)
rect.x += 0
rect.y += 0
rect.width -= 0
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
actor = $game_party.members[index]
draw_face_back
draw_actor_bface(actor.id, 4 + index % 4 * 152, 0) # 152
draw_actor_state(actor, 116 + index % 4 * 152, 0, 48) #112
end
def draw_actor_bface(id, x, y)
bitmap = Cache.bface(id)
#contents.blt(0, 0, bitmap, rect, 255)
self.contents.blt(x, y, bitmap, bitmap.rect)
end
def draw_face_back
#Sprite.new
#rect = Rect.new(0, 0, 0, 0)
bitmap = Cache.bfaceback
self.z = +0
self.contents.blt(0, 0, bitmap, bitmap.rect)
bitmap.dispose
end
end
module Cache
def self.id_to_name(id)
if id < 10
filename = "00" + id.to_s
elsif id < 100
filename = "0" + id.to_s
end
return filename
end
def self.bface(id)
filename = id_to_name(id)
# The directory in which the face graphics are stored
load_bitmap("Graphics/Battle Faces/", filename)
end
def self.bfaceback
filenamebar = "facebar"
load_bitmap("Graphics/Battle Faces/", filenamebar)
end
end
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Selectable
attr_accessor :message_x
attr_accessor :message_y
attr_accessor :message_width
attr_accessor :message_height
@message_width = 640
@message_height = 86
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
attr_accessor :message_x
attr_accessor :message_y
attr_accessor :message_width
attr_accessor :message_height
@message_width = 640
@message_height = 86
def start
super
$game_temp.in_battle = true
@spriteset = Spriteset_Battle.new
@message_window = Window_BattleMessage.new
@face_bar_window = Window_BattleFace.new
@action_battlers = []
create_info_viewport
$game_message.clear
end
#--------------------------------------------------------------------------
# * Create Information Display Viewport
#--------------------------------------------------------------------------
def create_face_viewport
@info_viewport = Viewport.new(0, 288, 544, 128)
@info_viewport.z = 100
@status_window = Window_BattleStatus.new
@party_command_window = Window_PartyCommand.new
@actor_command_window = Window_ActorCommand.new
@status_window.viewport = @info_viewport
@party_command_window.viewport = @info_viewport
@actor_command_window.viewport = @info_viewport
@status_window.x = 128
@actor_command_window.x = 544
@info_viewport.visible = false
end
#--------------------------------------------------------------------------
# * Dispose of Information Display Viewport
#--------------------------------------------------------------------------
def dispose_face_viewport
@status_window.dispose
@party_command_window.dispose
@actor_command_window.dispose
@info_viewport.dispose
end
#--------------------------------------------------------------------------
# * Update Information Display Viewport
#--------------------------------------------------------------------------
def update_face_viewport
@party_command_window.update
@actor_command_window.update
@status_window.update
if @party_command_window.active and @info_viewport.ox > 0
@info_viewport.ox -= 16
elsif @actor_command_window.active and @info_viewport.ox < 128
@info_viewport.ox += 16
end
end
end
Thanks in advance!