alternate font size for battle command? [XP]

Started by shintashi, October 16, 2011, 05:03:47 pm

Previous topic - Next topic

shintashi

I've tried messing with the font size for the command window in and out of battle and it's given me nothing but bad mojo. Stuff like

    self.contents.font.size = 24



    self.bitmap.font.size = 24


crashes or gets ignored, and trying to implement
    
if $game_temp.in_battle
#any command whatsoever, even blank space...
end


inside Window_Command was met with a quick and unpleasant "wtf do you think you are doing?" crash.

I can add new commands in battle, but I don't seem to be able to shrink the font size and arrangement. I'd like to keep the window size the same.

KK20

You should try clarifying a bit more by what you want fixed. I did this in Window_Command:
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.font.size = 18
    self.contents.draw_text(rect, @commands[index])
  end
And that reduced the size of the "Attack, Skills, Items, Defend" commands in battle. It also changes the font size of the title screen window.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

ForeverZer0

October 16, 2011, 05:53:49 pm #2 Last Edit: October 16, 2011, 05:55:45 pm by ForeverZer0
class Window_Command
 
 alias battle_font_refresh refresh
 def refresh
   if $game_temp.in_battle
     self.contents.font.name = 'Calibri'
     self.contents.font.size = 12
   end
   battle_font_refresh
 end
end


The KK20's will try to change the font every time a item is drawn, this way it happens only when the window is refreshed, which is the only way to alias it correctly without the need to over-write a method.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

KK20

Actually, yeah, the whole '$game_temp.in_battle' throws errors. It's because $game_temp isn't initialized BEFORE the title screen's window pops up. So, to combat this, I added $game_temp = Game_Temp.new in 'Main', right below 'begin'. F0's edit then worked.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

ForeverZer0

Oops, forgot about window command being used on the title as well.
You can simply check to see if it is defined instead of initializing the class, or simple check the scene instead...

if $scene.is_a?(Scene_Battle)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

shintashi

I'm glad I'm not the only one running into this game temp/opening error, but where does this:

if $scene.is_a?(Scene_Battle)


go? is it a rewrite of


class Window_Command
 
  alias battle_font_refresh refresh
  def refresh
    if $game_temp.in_battle
      self.contents.font.name = 'Calibri'
      self.contents.font.size = 12
    end
    battle_font_refresh
  end
end


and can I stick it the normal command window, or does it belong above main?

Fantasist

October 17, 2011, 09:52:52 pm #6 Last Edit: October 17, 2011, 10:30:50 pm by Fantasist
Kind of. Instead of checking for $game_temo, which might or might not be created already, you check for $scene.is_a?, which will work as long as Ruby works. So:

class Window_Command
 
  alias battle_font_refresh refresh
  def refresh
    if $scene.is_a?(Scene_Battle)
      self.contents.font.name = 'Calibri'
      self.contents.font.size = 12
    end
    battle_font_refresh
  end
end


Now that I think about it, changing the font size alone wont give you any extra room. The cursor rect will still be big. Try this instead:


#==============================================================================
# ** Window_BattleCommand
#==============================================================================

class Window_BattleCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # * Start Config
  #--------------------------------------------------------------------------
  FONTNAME = 'Calibri'
  FONTSIZE = 18
  #--------------------------------------------------------------------------
  # * End Config
  #--------------------------------------------------------------------------
  LINEHEIGHT = FONTSIZE + 4
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(width, commands)
    super(0, 0, width, commands.size * LINEHEIGHT + 32)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * LINEHEIGHT)
    self.contents.font.name = FONTNAME
    self.contents.font.size = FONTSIZE
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, LINEHEIGHT * index, self.contents.width - 8, LINEHEIGHT)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------
  def top_row
    return self.oy / LINEHEIGHT
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #--------------------------------------------------------------------------
  def top_row=(row)
    row = 0 if row < 0
    (row = row_max - 1) if (row > row_max - 1)
    self.oy = row * LINEHEIGHT
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_row_max
    return (self.height - 32) / LINEHEIGHT
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    super
    battle_font_cursor_rect
    y = @index / @column_max * LINEHEIGHT - self.oy
    self.cursor_rect.y = y
    self.cursor_rect.height = LINEHEIGHT
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end

class Scene_Battle
 
  alias battle_font_prep start_phase1
  def start_phase1
    unless @actor_command_window.is_a?(Window_BattleCommand)
      # Make actor command window
      s1 = $data_system.words.attack
      s2 = $data_system.words.skill
      s3 = $data_system.words.guard
      s4 = $data_system.words.item
      @actor_command_window = Window_BattleCommand.new(160, [s1, s2, s3, s4])
      @actor_command_window.y = 160
      @actor_command_window.back_opacity = 160
      @actor_command_window.active = false
      @actor_command_window.visible = false
    end
    battle_font_prep
  end
 
end


Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




shintashi

I was looking at the test in the shintashi.exe and it sort of hovers - that's easy enough to fix, but I think I'll try playing around with the right fonts for a bit before messing with it further, since I'm only partially done with editing my actor commands (the most complicated is already done but not interfaced with battle equations yet).

 

Fantasist

Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews