On page 3 of that first link, there is a version that works out how much room to leave for the text. In particular, instead of a constant:
It uses a variable, which is worked out by taking the maximum of the description widths:
-- work out how far in to start the gauge
gauge_left = WindowTextWidth (win, font_id, "HP: ")
gauge_left = math.max (gauge_left, WindowTextWidth (win, font_id, "Endurance: "))
gauge_left = math.max (gauge_left, WindowTextWidth (win, font_id, "Guile: "))
gauge_left = gauge_left + 5 -- allow gap from edge
Then elsewhere in the code, change GAUGE_LEFT to gauge_left.
The constant at the start:
... controls how wide the overall window is (and therefore the width of the bars, less the width of the description).
Quote:
2. If I want a combination of gauges and just showing a value, how do I add that to a line in the miniwindow?
Instead of calling DoGauge, call another function (which you write) which does a couple of WindowText calls, instead of all the stuff to draw the box.
For example:
function DoText (sPrompt, current, max, Colour)
if max <= 0 then
return
end -- no divide by zero
-- fraction in range 0 to 1
local Fraction = math.min (math.max (current / max, 0), 1)
local width = WindowTextWidth (win, font_id, sPrompt)
WindowText (win, font_id, sPrompt, gauge_left - width, vertical, 0, 0, FONT_COLOUR)
WindowText (win, font_id, string.format ("%i/%i (%0.2f%%)", current, max, Fraction * 100), gauge_left, vertical, 0, 0, Colour)
vertical = vertical + font_height + 3
end -- function DoText
Now you can show XP as text, for example:
DoGauge ("HP: ", hp , max_hp, ColourNameToRGB "darkgreen")
DoText ("XP: ", xp, max_xp, ColourNameToRGB "darkblue")
DoGauge ("Mana: ", mana, max_mana, ColourNameToRGB "mediumblue")
DoGauge ("Move: ", move, max_move, ColourNameToRGB "gold")
Quote:
3. How do I add/remove rows and have the box draw properly? I can't seem to figure that out... (I've been using the xml from ref a. as a basis)
I don't understand that. Remove rows? If you want to omit a row, omit one of the lines shown above. |