(Force[force].Reset() should be placed before the loop)
Remove the behavior of changing of force index (since it doesn't work befor and it is strange)
Some clean up.
If the user types something like "foo~!bar" in a TextField widget,
then display the tilde as is; the "~!" there does not mean that the
next character is a hot key. The user is not supposed to know about
any such syntax.
Implemented by having a parallel plain-text CFont that Lua code then
assigns to each TextField it creates. The plain-text CFont shares
textures with the markup CFont, so the memory cost is minimal.
(Originally, I was instead going to implement this by adding a syntax
parameter to gcn::Font::drawString and all related functions. That
however was the wrong choice because e.g. gcn::ImageFont::drawString
then had to take the parameter but had no idea what to do with it.)
Plain-text fonts can be used in all other widgets too, such as list
boxes or labels. This commit does not make any such widgets use them
though, and the choice of font does not currently affect how the
engine checks whether the widget has a hot key defined.
This was doing x += getWidth(text) after drawing each glyph,
but getWidth returns the width of the whole string, thus being
wrong if the string contains more than one glyph.
drawGlyph has already been documented as returning the width
of the single glyph, so use that instead.
This fix is not particularly important, because gcn::DefaultFont
is only a fallback for when the correct font has not been set.
Do not assume the Boolean value is at the top of the Lua stack,
although it currently always is because CSerializeLua::AppendLuaFields
does not support Boolean values as keys in the table.
Also replaced RegisterAi and DefineAi with DefineAiType,
which now takes a table rather than a set of parameters.
This table is the object that DefineAiType adds to AiTypes.
The keys of the table are constant strings, not numbers.
The purpose is to make the engine more aware of AI initialization
functions, although this commit doesn't yet get that far.
After assignments such as
test = {};
test[42] = 61;
test[69] = 105;
SaveGlobal used to serialize the variable like this:
test={61
, 105
}
Which was wrong because the keys then became 1 and 2,
rather than 42 and 69. Fix SaveGlobal so that it outputs
numeric keys where necessary.
While at it, make some more changes:
- Wrap the related functions in a new class, CSerializeLua.
- Append the output into an std::vector, instead of duplicating
strings everywhere. This makes it easier to ensure that
no memory will leak.
- In the global environment, forbid keys that begin with a digit.
- In other tables, allow arbitrary strings as keys.
- Forbid tables that have metatables.
- Blacklist _G (previously a separate check) and AllowedUnits
(previously blocked by the dashes in its key strings).
- Nicely indent the output with tab characters.