apply dialog fixes + new menuinit command
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2019 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -265,6 +265,8 @@ void setupscreen(int &usedcolorbits, int &useddepthbits, int &usedfsaa)
|
||||
|
||||
void resetgl()
|
||||
{
|
||||
clearchanges(CHANGE_GFX);
|
||||
|
||||
loadingscreen();
|
||||
|
||||
extern void cleanupparticles();
|
||||
|
||||
+50
-7
@@ -15,7 +15,7 @@ void menuset(void *m)
|
||||
if((curmenu = (gmenu *)m)) curmenu->open();
|
||||
}
|
||||
|
||||
void showmenu(const char *name)
|
||||
void showmenu_(const char *name, bool top)
|
||||
{
|
||||
if(!name)
|
||||
{
|
||||
@@ -24,9 +24,36 @@ void showmenu(const char *name)
|
||||
}
|
||||
gmenu *m = menus.access(name);
|
||||
if(!m) return;
|
||||
if(!top && curmenu)
|
||||
{
|
||||
if(curmenu==m) return;
|
||||
loopv(menustack) if(menustack[i]==m) return;
|
||||
menustack.insert(0, m);
|
||||
return;
|
||||
}
|
||||
menuset(m);
|
||||
}
|
||||
|
||||
void closemenu(const char *name)
|
||||
{
|
||||
gmenu *m = menus.access(name);
|
||||
if(!m) return;
|
||||
if(curmenu==m) menuset(NULL);
|
||||
else loopv(menustack)
|
||||
{
|
||||
if(menustack[i]==m)
|
||||
{
|
||||
menustack.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showmenu(const char *name)
|
||||
{
|
||||
showmenu_(name, true);
|
||||
}
|
||||
|
||||
void menuselect(void *menu, int sel)
|
||||
{
|
||||
gmenu &m = *(gmenu *)menu;
|
||||
@@ -432,6 +459,7 @@ void *addmenu(const char *name, const char *title, bool allowinput, void (__cdec
|
||||
menu.inited = false;
|
||||
menu.hotkeys = hotkeys;
|
||||
menu.refreshfunc = refreshfunc;
|
||||
menu.initaction = NULL;
|
||||
menu.dirlist = NULL;
|
||||
menu.forwardkeys = forwardkeys;
|
||||
lastmenu = &menu;
|
||||
@@ -457,6 +485,12 @@ void menuheader(void *menu, char *header, char *footer)
|
||||
m.footer = footer && footer[0] ? footer : NULL;
|
||||
}
|
||||
|
||||
void menuinit(char *initaction)
|
||||
{
|
||||
if(!lastmenu) return;
|
||||
lastmenu->initaction = newstring(initaction);
|
||||
}
|
||||
|
||||
void menuitem(char *text, char *action, char *hoveraction)
|
||||
{
|
||||
if(!lastmenu) return;
|
||||
@@ -526,6 +560,7 @@ COMMAND(menumdl, ARG_5STR);
|
||||
COMMAND(menudirlist, ARG_3STR);
|
||||
COMMAND(chmenumdl, ARG_6STR);
|
||||
COMMAND(showmenu, ARG_1STR);
|
||||
COMMAND(menuinit, ARG_1STR);
|
||||
COMMAND(menuitem, ARG_3STR);
|
||||
COMMAND(menuitemtextinput, ARG_4STR);
|
||||
COMMAND(menuitemslider, ARG_7STR);
|
||||
@@ -661,6 +696,7 @@ void gmenu::open()
|
||||
if(!forwardkeys) player1->stopmoving();
|
||||
if(items.inrange(menusel)) items[menusel]->focus(true);
|
||||
init();
|
||||
if(initaction) execute(initaction);
|
||||
}
|
||||
|
||||
void gmenu::close()
|
||||
@@ -753,21 +789,28 @@ VARP(applydialog, 0, 1, 1);
|
||||
void addchange(const char *desc, int type)
|
||||
{
|
||||
if(!applydialog || type!=CHANGE_GFX) return;
|
||||
loopv(needsapply) if(!strcmp(needsapply[i], desc)) return;
|
||||
needsapply.add(desc);
|
||||
showmenu("apply");
|
||||
bool changed = false;
|
||||
loopv(needsapply) if(!strcmp(needsapply[i], desc)) { changed = true; break; }
|
||||
if(!changed) needsapply.add(desc);
|
||||
showmenu_("apply", false);
|
||||
}
|
||||
|
||||
void clearchanges(int type)
|
||||
{
|
||||
if(type!=CHANGE_GFX) return;
|
||||
needsapply.setsize(0);
|
||||
closemenu("apply");
|
||||
}
|
||||
|
||||
void refreshapplymenu(void *menu, bool init)
|
||||
{
|
||||
if(!init) return;
|
||||
gmenu *m = (gmenu *) menu;
|
||||
if(!m) return;
|
||||
if(!m || (!init && needsapply.length() != m->items.length()-3)) return;
|
||||
m->items.setsize(0);
|
||||
loopv(needsapply) m->items.add(new mitemtext(m, newstring(needsapply[i]), NULL, NULL, NULL));
|
||||
m->items.add(new mitemtext(m, newstring(""), NULL, NULL, NULL));
|
||||
m->items.add(new mitemtext(m, newstring("Yes"), newstring("resetgl"), NULL, NULL));
|
||||
m->items.add(new mitemtext(m, newstring("No"), newstring("echo [..restart AssaultCube to apply the new settings]"), NULL, NULL));
|
||||
m->menusel = m->items.length()-2; // select OK
|
||||
if(init) m->menusel = m->items.length()-2; // select OK
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -86,6 +86,7 @@ extern void menuset(void *m);
|
||||
extern void menuselect(void *menu, int sel);
|
||||
extern void showmenu(const char *name);
|
||||
extern void addchange(const char *desc, int type);
|
||||
extern void clearchanges(int type);
|
||||
extern void refreshapplymenu(void *menu, bool init);
|
||||
|
||||
struct mitem
|
||||
@@ -126,12 +127,13 @@ struct gmenu
|
||||
int menusel;
|
||||
bool allowinput, inited, hotkeys, forwardkeys;
|
||||
void (__cdecl *refreshfunc)(void *, bool);
|
||||
char *initaction;
|
||||
|
||||
const char *mdl;
|
||||
int anim, rotspeed, scale;
|
||||
mdirlist *dirlist;
|
||||
|
||||
gmenu(){};
|
||||
gmenu(){}
|
||||
virtual ~gmenu()
|
||||
{
|
||||
DELETEA(name);
|
||||
@@ -140,6 +142,7 @@ struct gmenu
|
||||
DELETEA(footer);
|
||||
DELETEA(mdl);
|
||||
DELETEP(dirlist);
|
||||
DELETEA(initaction);
|
||||
items.deletecontentsp();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user