allow text to be used with gem menu item
This commit is contained in:
parent
915851dc87
commit
6c9741df61
4 changed files with 23 additions and 2 deletions
src
|
@ -188,6 +188,7 @@ typedef struct _menuitem_input_ {
|
|||
int maxch;
|
||||
} MenuitemInput;
|
||||
typedef struct _menuitem_gem_ {
|
||||
unsigned char *text;
|
||||
unsigned int state;
|
||||
int xsize;
|
||||
int ysize;
|
||||
|
|
|
@ -745,6 +745,8 @@ local void DrawGem(Menuitem *mi, int mx, int my)
|
|||
MenuButtonId rb;
|
||||
int x;
|
||||
int y;
|
||||
int nc;
|
||||
int rc;
|
||||
|
||||
flags = mi->flags;
|
||||
rb = mi->d.gem.button;
|
||||
|
@ -765,6 +767,18 @@ local void DrawGem(Menuitem *mi, int mx, int my)
|
|||
}
|
||||
}
|
||||
VideoDraw(MenuButtonGfx.Sprite, rb, x, y);
|
||||
|
||||
GetDefaultTextColors(&nc, &rc);
|
||||
if (mi->d.gem.text) {
|
||||
// FIXME: find correct x, y for other gem types , add options for other fonts
|
||||
VideoDrawText(x+24, y+3, GameFont, mi->d.gem.text);
|
||||
if (mi->flags&MenuButtonActive) {
|
||||
SetDefaultTextColors(rc,rc);
|
||||
VideoDrawRectangleClip(ColorGray,mx+mi->xofs-4,my+mi->yofs-4,
|
||||
VideoTextLength(GameFont, mi->d.gem.text)+30,VideoTextHeight(GameFont)+12);
|
||||
SetDefaultTextColors(nc,rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1497,7 +1511,10 @@ local void MenuHandleMouseMove(int x,int y)
|
|||
case MI_TYPE_GEM:
|
||||
xs = menu->x + mi->xofs;
|
||||
ys = menu->y + mi->yofs;
|
||||
if (x < xs || x > xs + mi->d.gem.xsize || y < ys || y > ys + mi->d.gem.ysize) {
|
||||
if ((!mi->d.gem.text || x < xs - 4 || x > xs +
|
||||
VideoTextLength(GameFont, mi->d.gem.text)+32 || y < ys - 4 ||
|
||||
y > ys + VideoTextHeight(GameFont)+10) && (x < xs ||
|
||||
x > xs + mi->d.gem.xsize || y < ys || y > ys + mi->d.gem.ysize)) {
|
||||
if (!(mi->flags&MenuButtonClicked)) {
|
||||
if (mi->flags&MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
|
|
|
@ -2428,7 +2428,7 @@ local void TipsFreeTips(void)
|
|||
Menu *menu;
|
||||
|
||||
menu = FindMenu("menu-tips");
|
||||
for (i = 5; i < 13; i++) {
|
||||
for (i = 4; i < 12; i++) {
|
||||
if (menu->items[i].d.text.text) {
|
||||
free(menu->items[i].d.text.text);
|
||||
menu->items[i].d.text.text = NULL;
|
||||
|
|
|
@ -2932,6 +2932,9 @@ local SCM CclDefineMenuItem(SCM list)
|
|||
} else if ( gh_eq_p(value, gh_symbol2scm("style")) ) {
|
||||
value=gh_car(sublist);
|
||||
item->d.gem.button=scm2buttonid(value);
|
||||
} else if ( gh_eq_p(value, gh_symbol2scm("text")) ) {
|
||||
value=gh_car(sublist);
|
||||
item->d.gem.text=gh_scm2newstr(value, NULL);
|
||||
} else {
|
||||
//s1=gh_scm2newstr(value, NULL);
|
||||
//fprintf(stderr, "Unsupported property %s\n", s1);
|
||||
|
|
Loading…
Add table
Reference in a new issue