sint32 spnewgamediffscreen_displayMyWindow(BOOL viewMode,BOOL reinit) { sint32 retval=0; if(!s_spNewGameDiffScreen) { retval = spnewgamediffscreen_Initialize(); } if(reinit) { s_spNewGameDiffScreen->Ok()->SetActionFuncAndCookie(spnewgamediffscreen_backPress,NULL); } AUI_ERRCODE auiErr; sint32 i; for(i = 0; i < s_diffListBox->NumItems(); i++) s_diffListBox->GetItemByIndex(i)->Enable(!viewMode); for(i = 0; i < s_riskListBox->NumItems(); i++) s_riskListBox->GetItemByIndex(i)->Enable(!viewMode); auiErr = g_c3ui->AddWindow(s_spNewGameDiffScreen); keypress_RegisterHandler(s_spNewGameDiffScreen); Assert( auiErr == AUI_ERRCODE_OK ); return retval; }
void loadsavescreen_PlayersScreenActionCallback(aui_Control *control, uint32 action, uint32 data, void *cookie) { if ( action != (uint32)AUI_BUTTON_ACTION_EXECUTE ) return; spnewgameplayersscreen_removeMyWindow(AUI_BUTTON_ACTION_EXECUTE); g_useScenarioCivs = g_theProfileDB->GetNPlayers()-1; if (s_tempSaveInfo->startInfoType != STARTINFOTYPE_NOLOCS) { if (g_useScenarioCivs > s_tempSaveInfo->numPositions) { g_useScenarioCivs = s_tempSaveInfo->numPositions; g_theProfileDB->SetNPlayers(g_useScenarioCivs+1); } } if (s_tempSaveInfo->startInfoType == STARTINFOTYPE_CIVSFIXED) { if (g_startEmailGame || g_startHotseatGame) { hotseatlist_ClearOptions(); for (sint32 i=0; i<g_theProfileDB->GetNPlayers(); i++) { sint32 civIndex = s_tempSaveInfo->playerCivIndexList[i]; hotseatlist_SetPlayerCiv(i, civIndex); } hotseatlist_LockCivs(); loadsavescreen_SetupHotseatOrEmail(); } else { spnewgamediffscreen_Initialize(loadsavescreen_DifficultyScreenActionCallback); spnewgamediffscreen_displayMyWindow(); } } else { if (g_startEmailGame || g_startHotseatGame) { if (s_tempSaveInfo->startInfoType == STARTINFOTYPE_POSITIONSFIXED) { hotseatlist_ClearOptions(); hotseatlist_EnableAllCivs(); loadsavescreen_SetupHotseatOrEmail(); } else { if (s_tempSaveInfo->startInfoType == STARTINFOTYPE_NOLOCS) { hotseatlist_ClearOptions(); hotseatlist_LockCivs(); for (sint32 i=0; i<k_MAX_PLAYERS; i++) { hotseatlist_EnableCiv(s_tempSaveInfo->playerCivIndexList[i]); } loadsavescreen_SetupHotseatOrEmail(); } else { hotseatlist_ClearOptions(); hotseatlist_DisableAllCivs(); for (sint32 i=0; i<s_tempSaveInfo->numPositions; i++) { hotseatlist_EnableCiv(s_tempSaveInfo->positions[i].civIndex); } loadsavescreen_SetupHotseatOrEmail(); } } } else { spnewgametribescreen_Cleanup(); spnewgametribescreen_Initialize( loadsavescreen_TribeScreenActionCallback ); if (s_tempSaveInfo->startInfoType == STARTINFOTYPE_POSITIONSFIXED) { spnewgametribescreen_setTribeIndex(1 + rand() % (g_theCivilisationDB->NumRecords() - 1)); } else { spnewgametribescreen_clearTribes(); if (s_tempSaveInfo->startInfoType == STARTINFOTYPE_NOLOCS) { if (g_saveFileVersion >= 50 && s_tempSaveInfo->startingPlayer != -1) { // Only one player is enabled spnewgametribescreen_addTribe(s_tempSaveInfo->playerCivIndexList[s_tempSaveInfo->startingPlayer]); } else { s_tempSaveInfo->startingPlayer = -1; s_tempSaveInfo->showLabels=FALSE; BOOL noCivsInList = TRUE; sint32 i; for (i=0; i<k_MAX_PLAYERS; i++) { if (s_tempSaveInfo->playerCivIndexList[i] > 0) { noCivsInList = FALSE; break; } } if (noCivsInList) { BOOL foundOne = FALSE; for (size_t i = 0; i < k_MAX_PLAYERS; ++i) { MBCHAR * civName = s_tempSaveInfo->civList[i]; if (strlen(civName) > 0) { for (sint32 j=0; j<g_theCivilisationDB->NumRecords(); j++) { MBCHAR const * dbString = g_theStringDB->GetNameStr(g_theCivilisationDB->Get(j)->GetPluralCivName()); if (!stricmp(dbString, civName)) { spnewgametribescreen_addTribeNoDuplicate(j); foundOne = TRUE; break; } } } } if (!foundOne) { spnewgametribescreen_Cleanup(); spnewgamediffscreen_Initialize(loadsavescreen_DifficultyScreenActionCallback); spnewgamediffscreen_displayMyWindow(); return; } } else { for (size_t i = 0; i < k_MAX_PLAYERS; ++i) { spnewgametribescreen_addTribeNoDuplicate(s_tempSaveInfo->playerCivIndexList[i]); } } } spnewgametribescreen_displayMyWindow(NULL, TRUE); return; } else { for ( sint32 i = 0; i < s_tempSaveInfo->numPositions; i++ ) { spnewgametribescreen_addTribeNoDuplicate(s_tempSaveInfo->positions[i].civIndex); } sint32 index = rand() % s_tempSaveInfo->numPositions; spnewgametribescreen_setTribeIndex(s_tempSaveInfo->positions[index].civIndex); } } spnewgametribescreen_displayMyWindow(NULL, TRUE); } } allocated::clear(s_tempSaveInfo); }
void loadsavescreen_TribeScreenActionCallback(aui_Control *control, uint32 action, uint32 data, void *cookie) { if ( action != (uint32)AUI_BUTTON_ACTION_EXECUTE ) return; MBCHAR tempNameStr[k_MAX_NAME_LEN]; spnewgametribescreen_removeMyWindow(action, tempNameStr ); sint32 tribeIndex = spnewgametribescreen_getTribeIndex(); if(tribeIndex < 0 || tribeIndex >= g_theCivilisationDB->NumRecords()) { tribeIndex = 1; } g_theProfileDB->SetCivIndex(tribeIndex); if(s_tempSaveInfo && s_tempSaveInfo->startInfoType == STARTINFOTYPE_NOLOCS ){ bool noCivsInList = true; for(sint32 i = 0; i < k_MAX_PLAYERS; i++) { if(s_tempSaveInfo->playerCivIndexList[i] > 0) { noCivsInList = false; break; } } if(noCivsInList) { bool foundOne = false; for(sint32 i = 0; i < k_MAX_PLAYERS; i++) { MBCHAR *civName; MBCHAR *dbString; civName = s_tempSaveInfo->civList[i]; dbString = (MBCHAR *)g_theStringDB->GetNameStr(g_theCivilisationDB->Get(tribeIndex)->GetPluralCivName()); if(strlen(civName) > 0) { if(!stricmp(dbString, civName)) { g_scenarioUsePlayerNumber = i; foundOne = true; break; } } } if (!foundOne) { g_scenarioUsePlayerNumber = 1; } } else { for (sint32 i=0; i<k_MAX_PLAYERS; i++) { if (s_tempSaveInfo->playerCivIndexList[i] == tribeIndex) { g_scenarioUsePlayerNumber = i; break; } } } allocated::clear(s_tempSaveInfo); } spnewgamediffscreen_Initialize(loadsavescreen_DifficultyScreenActionCallback); spnewgamediffscreen_displayMyWindow(); }