mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 19:39:24 +01:00
Make gui views a stack
This commit is contained in:
parent
2b77141e20
commit
688a18721b
@ -74,6 +74,7 @@ public:
|
|||||||
virtual void escapeCallback(int which)
|
virtual void escapeCallback(int which)
|
||||||
{
|
{
|
||||||
printf("entry %d escaped: %s\n", which, this->pp_msgs[which]);
|
printf("entry %d escaped: %s\n", which, this->pp_msgs[which]);
|
||||||
|
this->parent->parent->resetViewStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -166,7 +167,7 @@ Gui::Gui()
|
|||||||
|
|
||||||
/* Create the views */
|
/* Create the views */
|
||||||
MainView *mv = new MainView(this);
|
MainView *mv = new MainView(this);
|
||||||
this->registerView(mv);
|
this->pushView(mv);
|
||||||
this->cur_view = mv;
|
this->cur_view = mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +228,8 @@ void Gui::runLogic(void)
|
|||||||
this->cur_view->runLogic();
|
this->cur_view->runLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::registerView(GuiView *view)
|
|
||||||
|
void Gui::pushView(GuiView *view)
|
||||||
{
|
{
|
||||||
int cur = this->n_views;
|
int cur = this->n_views;
|
||||||
|
|
||||||
@ -237,6 +239,27 @@ void Gui::registerView(GuiView *view)
|
|||||||
this->views[cur] = view;
|
this->views[cur] = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuiView *Gui::popView()
|
||||||
|
{
|
||||||
|
this->n_views--;
|
||||||
|
if (this->n_views <= 0)
|
||||||
|
{
|
||||||
|
this->n_views = 0;
|
||||||
|
free(this->views);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->views = (GuiView**)xrealloc(this->views,
|
||||||
|
sizeof(GuiView*) * this->n_views);
|
||||||
|
return this->views[this->n_views - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gui::resetViewStack()
|
||||||
|
{
|
||||||
|
free(this->views);
|
||||||
|
this->views = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void Gui::pushEvent(SDL_Event *ev)
|
void Gui::pushEvent(SDL_Event *ev)
|
||||||
{
|
{
|
||||||
if (this->is_active)
|
if (this->is_active)
|
||||||
|
@ -24,7 +24,6 @@ public:
|
|||||||
|
|
||||||
virtual void draw(SDL_Surface *where) = 0;
|
virtual void draw(SDL_Surface *where) = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
Gui *parent;
|
Gui *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -47,7 +46,11 @@ public:
|
|||||||
|
|
||||||
void draw(SDL_Surface *where);
|
void draw(SDL_Surface *where);
|
||||||
|
|
||||||
void registerView(GuiView *view);
|
void pushView(GuiView *view);
|
||||||
|
|
||||||
|
GuiView *popView();
|
||||||
|
|
||||||
|
void resetViewStack();
|
||||||
|
|
||||||
/* These are private, keep off! */
|
/* These are private, keep off! */
|
||||||
const char *getThemePath(const char *dir, const char *what);
|
const char *getThemePath(const char *dir, const char *what);
|
||||||
|
Loading…
Reference in New Issue
Block a user