Genetic Parameter Optimisation

Extended IRaceEngine to be asked what buttons to display
Skip unneeded buttons in Menus


git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5157 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 90e743971f6e9b4d47d4d0baf2573743b04ec089
Former-commit-id: 3a97b1a7121c327658b2733ebe6a31715a7a838b
This commit is contained in:
wdbee 2013-02-17 12:14:41 +00:00
parent f1078b174a
commit 0f93a35b2b
11 changed files with 54 additions and 14 deletions

View file

@ -60,6 +60,9 @@ public:
virtual void start() = 0;
virtual void stop() = 0;
virtual bool allowPlayerConfig() = 0;
#ifdef SD_DEBUG
virtual void step(double dt) = 0;
#endif

View file

@ -165,6 +165,8 @@ main(int argc, char *argv[])
if (piUserItf && piRaceEngine)
{
bool AllowPlayerConfig = piRaceEngine->allowPlayerConfig();
// Enter the user interface.
if (piUserItf->activate())
{

View file

@ -244,6 +244,11 @@ void GenParOptV1::stop(void)
::ReStop();
}
bool GenParOptV1::allowPlayerConfig()
{
return false;
}
#ifdef SD_DEBUG
void GenParOptV1::step(double dt)
{

View file

@ -81,6 +81,9 @@ public:
virtual void accelerateTime(double fMultFactor);
virtual void start();
virtual void stop();
virtual bool allowPlayerConfig();
#ifdef SD_DEBUG
virtual void step(double dt);
#endif

View file

@ -243,6 +243,11 @@ void StandardGame::stop(void)
::ReStop();
}
bool StandardGame::allowPlayerConfig()
{
return true;
}
#ifdef SD_DEBUG
void StandardGame::step(double dt)
{

View file

@ -80,6 +80,9 @@ public:
virtual void accelerateTime(double fMultFactor);
virtual void start();
virtual void stop();
virtual bool allowPlayerConfig();
#ifdef SD_DEBUG
virtual void step(double dt);
#endif

View file

@ -86,9 +86,11 @@ bool LegacyMenu::backLoad()
{
GfLogTrace("Pre-loading menu and game data ...\n");
// Pre-load the main and race select menus
bool AllowPlayerConfig = LmRaceEngine().allowPlayerConfig();
// Pre-load the main and race select menus
// (to be able to get back to them, even when directly starting a given race).
if (!RmRaceSelectInit(MainMenuInit()))
if (!RmRaceSelectInit(MainMenuInit(AllowPlayerConfig)))
return false;
// Pre-load race managers, drivers, tracks, cars stuff.

View file

@ -94,7 +94,7 @@ onMainMenuActivate(void * /* dummy */)
*/
void *
MainMenuInit(void)
MainMenuInit(bool AllowPlayerConfig)
{
// Initialize only once.
if (MenuHandle)
@ -112,7 +112,8 @@ MainMenuInit(void)
//Add buttons and create based on xml
GfuiMenuCreateButtonControl(MenuHandle, menuDescHdle, "race", NULL, onRaceSelectMenuActivate);
//GfuiMenuCreateButtonControl(MenuHandle, menuDescHdle, "weekend", NULL, onRaceWESelectMenuActivate);
GfuiMenuCreateButtonControl(MenuHandle, menuDescHdle, "configure", NULL, onPlayerConfigMenuActivate);
if (AllowPlayerConfig)
GfuiMenuCreateButtonControl(MenuHandle, menuDescHdle, "configure", NULL, onPlayerConfigMenuActivate);
GfuiMenuCreateButtonControl(MenuHandle, menuDescHdle, "options", NULL, onOptionsMenuActivate);
GfuiMenuCreateButtonControl(MenuHandle, menuDescHdle, "credits", NULL, onCreditsMenuActivate);
GfuiMenuCreateButtonControl(MenuHandle, menuDescHdle, "quit", NULL, onExitMenuActivate);

View file

@ -21,7 +21,7 @@
#ifndef _MAINMENU_H_
#define _MAINMENU_H_
extern void* MainMenuInit(void);
extern void* MainMenuInit(bool);
extern int MainMenuRun(void);
#endif /* _MAINMENU_H_ */

View file

@ -406,6 +406,9 @@ RmRacemanMenu()
GfuiScreenRelease(ScrHandle);
const GfRaceManager* pRaceMan = LmRaceEngine().race()->getManager();
// Ask the RaceEngine what types of races should be allowed here
bool AllowPlayerConfig = LmRaceEngine().allowPlayerConfig();
// Create screen, load menu XML descriptor and create static controls.
ScrHandle = GfuiScreenCreate(NULL, NULL, rmOnActivate,
@ -425,22 +428,26 @@ RmRacemanMenu()
// Create Configure race, Configure players and Back buttons.
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "ConfigureRaceButton",
NULL, RmConfigureRace);
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "ConfigurePlayersButton",
if (AllowPlayerConfig)
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "ConfigurePlayersButton",
NULL, rmOnPlayerConfig);
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "BackButton",
RmRaceSelectMenuHandle, GfuiScreenActivate);
// Create "Load / Resume / Save race" buttons.
SaveRaceConfigButtonId =
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "SaveRaceConfigButton",
if (AllowPlayerConfig)
{
// Create "Load / Resume / Save race" buttons.
SaveRaceConfigButtonId =
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "SaveRaceConfigButton",
ScrHandle, rmOnSaveRaceToConfigFile);
LoadRaceConfigButtonId =
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "LoadRaceConfigButton",
LoadRaceConfigButtonId =
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "LoadRaceConfigButton",
ScrHandle, rmOnLoadRaceFromConfigFile);
LoadRaceResultsButtonId =
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "LoadRaceResultsButton",
LoadRaceResultsButtonId =
GfuiMenuCreateButtonControl(ScrHandle, menuXMLDescHdle, "LoadRaceResultsButton",
ScrHandle, rmOnLoadRaceFromResultsFile);
}
// Create "Resume / Start race" buttons.
ResumeRaceButtonId =

View file

@ -123,7 +123,10 @@ RmRaceSelectInit(void *prevMenu)
{
if (RmRaceSelectMenuHandle)
return RmRaceSelectMenuHandle;
// Ask the RaceEngine what types of races should be allowed here
bool AllowPlayerConfig = LmRaceEngine().allowPlayerConfig();
// Create screen, load menu XML descriptor and create static controls.
RmRaceSelectMenuHandle = GfuiScreenCreate((float*)NULL,
NULL, rmOnActivate,
@ -145,6 +148,12 @@ RmRaceSelectInit(void *prevMenu)
// Create the race manager type button.
std::string strButtonCtrlName(*itRaceManType);
if (!AllowPlayerConfig)
{
if (strButtonCtrlName != "Practice")
continue;
}
strButtonCtrlName.erase(std::remove(strButtonCtrlName.begin(), strButtonCtrlName.end(), ' '), strButtonCtrlName.end()); // Such a pain to remove spaces !
strButtonCtrlName += "Button";
GfuiMenuCreateButtonControl(RmRaceSelectMenuHandle, hMenuXMLDesc, strButtonCtrlName.c_str(),