Original Source
- Original title: HUD issues: removing cursor, altering update function
- Original author: johnnyqdoe
- Original date: August 9, 2013
- Source thread: https://forums.rpgmakerweb.com/threads/hud-issues-removing-cursor-altering-update-function.16676/
- Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSSx Script Support
Summary
So, I've been trying to create a special HUD for my game since at the end, there are 6 members in the party. This is my first coding in the game, and it's probably not the easiest to follow. I'm using VX ACE. Looking good at the beginning: My code works, so I'm not looking for issues in the code, but how to add the remaining functionality of: removing the portraits of all 6 characters being drawn in between every attack. Basically, I need one function for draw_all_items and another for...
Archived First Post
Looking good at the beginning:
My code works, so I'm not looking for issues in the code, but how to add the remaining functionality of:
- removing the portraits of all 6 characters being drawn in between every attack. Basically, I need one function for draw_all_items and another for draw_all_NameHP. I need to call the draw_all_items for setting it up, but want to call draw_all_NameHP between battle attacks so I don't rerender all the portraits over and over again. I'm unsure where in the code I can insert my functions in-between battle rounds.
- when the command list is drawn for each character, that character's portrait becomes fully-colored in the battle_status window. Currently it only draws it the moment you select a command from the command list, not prior to. This makes it look like you're choosing a command from the previous ally, and I can't see where in the code I can alter this.
Link
As you can see, it processes the command list, and when I select "Playlist" it will draw his colored portrait and open the target window. I want this done before you select the command as it looks...broken (well, because it is). NOTE: I know the names and HP aren't updating on the main window. It's the first fix I'm making today and I know where the issue is.
- removing cursor
Link
I can't find any support on disabling the cursor window.
Found this:
def update_cursor
self.cursor_rect.empty
end
Here is my code:
This is some nasty/inefficient code, but it's my first stab at Ruby and I'm still learning how everything works.
draw_item draws the player portrait
draw_itemNH draws the player's Name and HP
any duplicate function that ends with *gt is very similar except it draws it greyscale (having to change hue to a great value) and transparency. This is intensive and I want to remove this from in between every part of the attack phase. I can flip the draw_item and draw_itemNH so that the main call is of the name and HP, and then I tell it when to draw the portrait, but I have other issues as well
class Window_BattleStatus < Window_Selectable #--------------------------------------------------------------------------
# * Draw All Items
#--------------------------------------------------------------------------
def draw_all_items
item_max.times do |i|
draw_item(item_max - i - 1)
draw_item_gt(item_max - i - 1)
end
draw_item(0)
item_max.times do |j|
draw_itemNH(item_max-j-1)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# ONLY PORTRAITS
#--------------------------------------------------------------------------
def draw_item(index)
actor = $game_party.battle_members[index]
draw_basic_area(basic_area_rect(index), actor)
#drawNameHP(basic_area_rect(index), actor)
end
#--------------------------------------------------------------------------
# * Draw Item
# NAMES and HP
#--------------------------------------------------------------------------
def draw_itemNH(index)
actor = $game_party.battle_members[index]
#draw_basic_area(basic_area_rect(index), actor)
drawNameHP(basic_area_rect(index), actor)
end
#--------------------------------------------------------------------------
# * Redraw Item
#--------------------------------------------------------------------------
def redraw_item(index)
clear_item(index) if index >= 0
draw_item(index) if index >= 0
draw_itemNP(index) if index >= 0
end
#--------------------------------------------------------------------------
# * Get Basic Area Retangle
#--------------------------------------------------------------------------
def basic_area_rect(index)
rect = item_rect_for_text(index)
# rect.width -= gauge_area_width + 10
# above, original
rect.width = 64
rect
end
#--------------------------------------------------------------------------
# * Get Rectangle for Drawing Items (for Text)
#--------------------------------------------------------------------------
def item_rect_for_text(index)
rect = item_rect(index)
# rect.x += 4
# rect.width -= 8
# above, original
rect.x = index * 60
rect.width = 64
rect
end
#--------------------------------------------------------------------------
# * Get Rectangle for Drawing Items
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = item_height
#rect.x = index * 60
rect.x = index % col_max * (item_width + spacing)
# rect.y = 0
index / col_max * item_height
rect
end
#--------------------------------------------------------------------------
# * Get Item Width
#--------------------------------------------------------------------------
def item_width
(width - standard_padding * 2 + spacing) / col_max - spacing
#96
end
#--------------------------------------------------------------------------
# * Get Item Height
#--------------------------------------------------------------------------
def item_height
#line_height
96
end
#--------------------------------------------------------------------------
# * Draw HP
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 96)
# draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
change_color(system_color)
# draw_text(x, y, 30, line_height, Vocab::hp_a)
draw_current_value(x, y, width, actor.hp, hp_color(actor))
end
#--------------------------------------------------------------------------
# * Draw Current Value
# current : Current value
# color1 : Color of current value
#--------------------------------------------------------------------------
def draw_current_value(x, y, width, current, color1)
change_color(color1)
xr = x + width
if width < 96
draw_text(xr - 40, y, 42, line_height, current, 2)
else
draw_text(xr - 92, y, 42, line_height, current, 2)
end
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def row_max
#[(item_max + col_max - 1) / col_max, 1].max
1
end
#--------------------------------------------------------------------------
# * Get Digit Count
# USING AS COLUMN COUNT
#--------------------------------------------------------------------------
def col_max
return 6
end
#--------------------------------------------------------------------------
# * Draw Face Graphic
# enabled : Enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, x, y, enabled = true)
bitmap = Cache.face(face_name)
rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
#bitmap.hue_change(900)
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
bitmap.dispose
end
#--------------------------------------------------------------------------
# * Draw Face Graphic -
# GREY and transparent
# enabled : Enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_face_gt(face_name, face_index, x, y, enabled = false)
bitmap = Cache.face(face_name)
rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
bitmap.hue_change(900)
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
bitmap.dispose
end
#--------------------------------------------------------------------------
# * Draw Actor Face Graphic
#--------------------------------------------------------------------------
def draw_actor_face(actor, x, y, enabled = true)
draw_face(actor.face_name, actor.face_index, x, y, enabled)
end
#--------------------------------------------------------------------------
# * Draw Actor Face Graphic
# GREY & TRANSPARENT
#--------------------------------------------------------------------------
def draw_actor_face_gt(actor, x, y, enabled = true)
draw_face_gt(actor.face_name, actor.face_index, x, y, enabled)
end
#--------------------------------------------------------------------------
# * Draw Item
# GREY and transparent
#--------------------------------------------------------------------------
def draw_item_gt(index)
actor = $game_party.battle_members[index]
draw_basic_area_gt(basic_area_rect(index), actor)
end
#--------------------------------------------------------------------------
# * Draw Item
# GREY and transparent
# NO PORTRAIT
#--------------------------------------------------------------------------
def draw_item_gt(index)
actor = $game_party.battle_members[index]
draw_basic_area_gt(basic_area_rect(index), actor)
end
#--------------------------------------------------------------------------
# * Draw Basic Area
#--------------------------------------------------------------------------
def draw_basic_area(rect, actor)
draw_actor_face(actor, rect.x + 0, 0, true) #set to false for transparent
#draw_actor_name(actor, rect.x + 10, rect.y, 100)
#draw_actor_hp(actor, rect.x + 0, rect.y + 76, 100)
end
#--------------------------------------------------------------------------
# * Draw Basic Area
# GREY & TRANSPARENT
#--------------------------------------------------------------------------
def draw_basic_area_gt(rect, actor)
draw_actor_face_gt(actor, rect.x + 0, 0, false) #set to false for transparent
#draw_actor_name(actor, rect.x + 10, rect.y, 100)
#draw_actor_hp(actor, rect.x + 0, rect.y + 76, 100)
end
#--------------------------------------------------------------------------
# * Draw Basic Area
# GREY & TRANSPARENT
# NO PORTRAIT
#--------------------------------------------------------------------------
def draw_basic_area_gtnp(rect, actor)
#draw_actor_face_gt(actor, rect.x + 0, 0, false) #set to false for transparent
draw_actor_name(actor, rect.x + 10, rect.y, 100)
#draw_actor_hp(actor, rect.x + 0, rect.y + 76, 100)
end
#--------------------------------------------------------------------------
# * Move Cursor Right
#--------------------------------------------------------------------------
def cursor_right(wrap = false)
if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))
select((index + 1) % item_max)
#added to provide highlight
if index != 0
draw_item_gt(index-1)
else
draw_item_gt(item_max-1)
end
draw_item(index)
draw_itemNH(index)
if index != 0
draw_itemNH(index-1)
else
draw_itemNH(item_max-1)
end
if index != item_max-1
draw_itemNH(index+1)
else
draw_itemNH(0)
end
end
end
#--------------------------------------------------------------------------
# * Move Cursor Left
#--------------------------------------------------------------------------
def cursor_left(wrap = false)
if col_max >= 2 && (index > 0 || (wrap && horizontal?))
select((index - 1 + item_max) % item_max)
if index != item_max-1
draw_item_gt(index+1)
if (index != item_max-2)
draw_itemNH(index+2)
end
else
draw_item_gt(0)
draw_itemNH(1)
end
draw_item(index)
draw_itemNH(index)
if index != item_max-1
draw_itemNH(index+1)
else
draw_itemNH(0)
end
if index != 0
draw_itemNH(index-1)
else
draw_itemNH(item_max-1)
end
end
end
#----------------
# Draw Name & HP
#----------------
def drawNameHP(rect, actor)
draw_actor_name(actor, rect.x + 10, rect.y, 100)
draw_actor_hp(actor, rect.x + 0, rect.y + 76, 100)
end
end
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...