add script command for menu items with alternate fonts
Also: add '\a' to the list of escaped characters and remove storage of
unneeded "filename".
mitemaltfont <altfont> <text> <action> <hoveraction> <desc>
Displays a menu line with a text which may contain chars from an
alternate font.
altfont
Name of the alternate font.
text
Content of menu line. Chars from the alternate font have to be marked
with "\a". Alternate font chars have no width and are just rendered
above the following text. Use spaces to counter that.
action, hoveraction, desc
Same function as with other menu lines.
DOCREF menuitemaltfont
This commit is contained in:
@@ -1464,6 +1464,7 @@ const char *escapestring(const char *s, bool force, bool noquotes)
|
||||
case '\n': buf.put("\\n", 2); break;
|
||||
case '\r': buf.put("\\n", 2); break;
|
||||
case '\t': buf.put("\\t", 2); break;
|
||||
case '\a': buf.put("\\a", 2); break;
|
||||
case '\f': buf.put("\\f", 2); break;
|
||||
case '"': buf.put("\\\"", 2); break;
|
||||
case '\\': buf.put("\\\\", 2); break;
|
||||
|
||||
+10
-5
@@ -291,11 +291,10 @@ VARP(hidebigmenuimages, 0, 0, 1);
|
||||
|
||||
struct mitemimagemanual : mitemmanual
|
||||
{
|
||||
const char *filename;
|
||||
Texture *image;
|
||||
font *altfont;
|
||||
|
||||
mitemimagemanual(gmenu *parent, const char *filename, const char *altfontname, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc = NULL) : mitemmanual(parent, text, action, hoveraction, bgcolor, desc), filename(filename)
|
||||
mitemimagemanual(gmenu *parent, const char *filename, const char *altfontname, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc = NULL) : mitemmanual(parent, text, action, hoveraction, bgcolor, desc)
|
||||
{
|
||||
image = filename ? textureload(filename, 3) : NULL;
|
||||
altfont = altfontname ? getfont(altfontname) : NULL;
|
||||
@@ -365,10 +364,9 @@ struct mitemimagemanual : mitemmanual
|
||||
|
||||
struct mitemimage : mitemimagemanual
|
||||
{
|
||||
mitemimage(gmenu *parent, const char *filename, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc = NULL) : mitemimagemanual(parent, filename, NULL, text, action, hoveraction, bgcolor, desc) {}
|
||||
mitemimage(gmenu *parent, const char *filename, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc = NULL, const char *altfont = NULL) : mitemimagemanual(parent, filename, altfont, text, action, hoveraction, bgcolor, desc) {}
|
||||
virtual ~mitemimage()
|
||||
{
|
||||
DELETEA(filename);
|
||||
DELETEA(text);
|
||||
DELETEA(action);
|
||||
DELETEA(hoveraction);
|
||||
@@ -955,12 +953,19 @@ void menuitemimage(char *name, char *text, char *action, char *hoveraction)
|
||||
{
|
||||
if(!lastmenu) return;
|
||||
if(fileexists(name, "r") || findfile(name, "r") != name)
|
||||
lastmenu->items.add(new mitemimage(lastmenu, newstring(name), newstring(text), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL));
|
||||
lastmenu->items.add(new mitemimage(lastmenu, name, newstring(text), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL));
|
||||
else
|
||||
lastmenu->items.add(new mitemtext(lastmenu, newstring(text), newstring(action[0] ? action : text), hoveraction[0] ? newstring(hoveraction) : NULL, NULL));
|
||||
}
|
||||
COMMAND(menuitemimage, "ssss");
|
||||
|
||||
void menuitemaltfont(char *altfont, char *text, char *action, char *hoveraction, char *desc)
|
||||
{
|
||||
if(!lastmenu) return;
|
||||
lastmenu->items.add(new mitemimage(lastmenu, NULL, newstring(text), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL, desc[0] ? newstring(desc) : NULL, altfont));
|
||||
}
|
||||
COMMAND(menuitemaltfont, "sssss");
|
||||
|
||||
void menuitemmapload(char *name, char *text)
|
||||
{
|
||||
if(!lastmenu) return;
|
||||
|
||||
@@ -246,6 +246,7 @@ void filterrichtext(char *dst, const char *src, int len)
|
||||
{
|
||||
case '\0': --src; continue;
|
||||
case 'f': c = '\f'; break;
|
||||
case 'a': c = '\a'; break;
|
||||
case 'n': c = '\n'; break;
|
||||
case 'x':
|
||||
b = 16;
|
||||
|
||||
Reference in New Issue
Block a user