[Scummvm-cvs-logs] SF.net SVN: scummvm:[48922] tools/trunk/gui

criezy at users.sourceforge.net criezy at users.sourceforge.net
Mon May 3 20:51:06 CEST 2010


Revision: 48922
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48922&view=rev
Author:   criezy
Date:     2010-05-03 18:51:06 +0000 (Mon, 03 May 2010)

Log Message:
-----------
Improve the way we go back to the first page (instead of creating a new first page it now goes back to the one stored in the old pages - it also now destroys all the other old pages).

Modified Paths:
--------------
    tools/trunk/gui/main.cpp
    tools/trunk/gui/main.h
    tools/trunk/gui/pages.cpp

Modified: tools/trunk/gui/main.cpp
===================================================================
--- tools/trunk/gui/main.cpp	2010-05-03 18:32:26 UTC (rev 48921)
+++ tools/trunk/gui/main.cpp	2010-05-03 18:51:06 UTC (rev 48922)
@@ -258,7 +258,7 @@
 	SetMenuBar(menubar);
 }
 
-void ScummToolsFrame::switchPage(WizardPage *next, bool moveback) {
+void ScummToolsFrame::switchPage(WizardPage *next, SwitchToPage page) {
 	// Associate us with the new page
 	if (next)
 		next->SetScummFrame(this);
@@ -269,12 +269,23 @@
 	if (oldPanel)
 		_pages.back()->save(oldPanel);
 
-	if (moveback) {
-		// Don't save the old page (which is ontop of the stack already)
-		delete _pages.back();
-		_pages.pop_back();
-	} else {
+	switch (page) {
+	case FirstPage:
+		while (_pages.size() > 1) {
+			delete _pages.back();
+			_pages.pop_back();
+			
+		}
+		break;
+	case PreviousPage:
+		if (_pages.size() > 1) {
+			delete _pages.back();
+			_pages.pop_back();
+		}
+		break;
+	case NextPage:
 		_pages.push_back(next);
+		break;
 	}
 
 	if (oldPanel)

Modified: tools/trunk/gui/main.h
===================================================================
--- tools/trunk/gui/main.h	2010-05-03 18:32:26 UTC (rev 48921)
+++ tools/trunk/gui/main.h	2010-05-03 18:51:06 UTC (rev 48922)
@@ -77,16 +77,23 @@
 	 *                 and this page displayed in it's stead.
 	 */
 	void switchPage(WizardPage *nextPage) {
-		switchPage(nextPage, false);}
+		switchPage(nextPage, NextPage);}
 
 	/**
 	 * Switches back page to the previous page
 	 * The current page is destroyed.
 	 */
 	void switchToPreviousPage() {
-		switchPage(NULL, true);}
+		switchPage(NULL, PreviousPage);}
 
 	/**
+	 * Switches to the first page, the stack of old pages is emptied
+	 * and the current pag is destroyed.
+	 */
+	void switchToFirstPage() {
+		switchPage(NULL, FirstPage);}
+
+	/**
 	 * Get help text of this window
 	 */
 	virtual wxString GetHelpText();
@@ -116,7 +123,8 @@
 	/** The button pane */
 	WizardButtons *_buttons;
 private:
-	void switchPage(WizardPage *nextPage, bool moveback);
+	enum SwitchToPage { NextPage, PreviousPage, FirstPage };
+	void switchPage(WizardPage *nextPage, SwitchToPage page);
 
 	wxPanel *_wizardpane;
 

Modified: tools/trunk/gui/pages.cpp
===================================================================
--- tools/trunk/gui/pages.cpp	2010-05-03 18:32:26 UTC (rev 48921)
+++ tools/trunk/gui/pages.cpp	2010-05-03 18:51:06 UTC (rev 48922)
@@ -1552,7 +1552,7 @@
 
 	wxCheckBox *restart = static_cast<wxCheckBox *>(panel->FindWindowByName(wxT("ProcessOther")));
 	if (restart->GetValue())
-		switchPage(new IntroPage(_configuration));
+		_topframe->switchToFirstPage();
 	else
 		_topframe->Close(true);
 }
@@ -1601,7 +1601,7 @@
 void FailurePage::onNext(wxWindow *panel) {
 	wxCheckBox *restart = static_cast<wxCheckBox *>(panel->FindWindowByName(wxT("ProcessOther")));
 	if (restart->GetValue())
-		switchPage(new IntroPage(_configuration));
+		_topframe->switchToFirstPage();
 	else
 		_topframe->Close(true);
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list