/*----------------------------------------------------------------------------- Name : spScenarioWindowInit Description : Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void spScenarioWindowInit(char *name, featom *atom) { fonthandle oldfont; sdword index; if (FEFIRSTCALL(atom)) { oldfont = fontMakeCurrent(spListFont); spScenarioListWindow = (listwindowhandle)atom->pData; uicListWindowInit(spScenarioListWindow, NULL, // title draw, no title NULL, // title click process, no title 0/*fontHeight(" ")*2*/, // title height, no title spScenarioItemDraw, // item draw function fontHeight(" ")+SCP_VertSpacing, // item height UICLW_CanSelect|UICLW_CanHaveFocus); //spScenarioListWindow->reg.flags |= for (index = 0; index < spNumberScenarios; index++) { if (index==spCurrentSelected) uicListAddItem(spScenarioListWindow, (ubyte *)&spScenarios[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail); else uicListAddItem(spScenarioListWindow, (ubyte *)&spScenarios[index], UICLI_CanSelect, UICLW_AddToTail); } fontMakeCurrent(oldfont); return; } else { switch (spScenarioListWindow->message) { case CM_AcceptText: spDonePicking(NULL,NULL); break; case CM_DoubleClick: spDonePicking(NULL,NULL); break; case CM_NewItemSelected: spNewItem(); } } }
/*----------------------------------------------------------------------------- Name : gpGameWindowInit Description : Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void gpGameWindowInit(char *name, featom *atom) { fonthandle oldfont; sdword index; if (FEFIRSTCALL(atom)) { if (strcmp(name,"FE_RecordedGameWindowInit") == 0) { SavedGamesPath = RecordedGamesPath; } else if (strcmp(name,"FE_TutorialGameWindowInit") == 0) { SavedGamesPath = TutorialSavedGamesPath; tutorial = TUTORIAL_ONLY; gpLoadTutorial = TRUE; gpLoadSinglePlayerGame = TRUE; } else { if (gameIsRunning) { if (singlePlayerGame) { gpLoadSinglePlayerGame = TRUE; } else { gpLoadSinglePlayerGame = FALSE; } gpLoadTutorial = (tutorial==TUTORIAL_ONLY) ? TRUE : FALSE; } else { if (mgRunning) { gpLoadSinglePlayerGame = FALSE; } else { gpLoadSinglePlayerGame = TRUE; } gpLoadTutorial = (tutorial==TUTORIAL_ONLY) ? TRUE : FALSE; } if (gpLoadSinglePlayerGame) { SavedGamesPath = gpLoadTutorial ? TutorialSavedGamesPath : SinglePlayerSavedGamesPath; } else { SavedGamesPath = MultiPlayerSavedGamesPath; } } gpTitleListLoad(); oldfont = fontMakeCurrent(gpListFont); gpGameListWindow = (listwindowhandle)atom->pData; uicListWindowInit(gpGameListWindow, NULL, // title draw, no title NULL, // title click process, no title 0, // title height, no title gpGameItemDraw, // item draw function fontHeight(" ")+GP_VertSpacing, // item height UICLW_CanSelect|UICLW_CanHaveFocus); for (index = 0; index < gpNumberGames; index++) { if (index == 0) { uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail); gpCurrentSelected = 0; } else { uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect, UICLW_AddToTail); } } fontMakeCurrent(oldfont); return; } else if (FELASTCALL(atom)) { gpGameListWindow = NULL; return; } else if (gpGameListWindow->message == CM_NewItemSelected) { if (gpNameEntryBox != NULL) { uicTextEntrySet(gpNameEntryBox, ((gpgame *)gpGameListWindow->CurLineSelected->data)->title,strlen(((gpgame *)gpGameListWindow->CurLineSelected->data)->title)); } } }
void gpDeleteGame(char *name, featom *atom) { char filename[PATH_MAX] = ""; sdword i; sdword index; fonthandle oldfont; if (!gpGetGameName(name,atom,filename)) { return; } // gpCurrentSelected will be set by gpGetGameName feScreenDisappear(NULL, NULL); char *tmpFilePath = filePathPrepend(filename, FF_UserSettingsPath); strcpy(filename, tmpFilePath); fileDelete(filename); if (SavedGamesPath == RecordedGamesPath) { char tmpfile[PATH_MAX] = ""; strcpy(tmpfile,filename); strcat(tmpfile,PKTS_EXTENSION); fileDelete(tmpfile); } for (i=gpCurrentSelected;i<gpNumberGames-1;i++) { gpGames[i] = gpGames[i+1]; } gpNumberGames--; if (gpNumberGames == 0) { gpCurrentSelected = 0; } else if (gpCurrentSelected >= gpNumberGames) { gpCurrentSelected--; dbgAssertOrIgnore(gpCurrentSelected >= 0); dbgAssertOrIgnore(gpCurrentSelected < gpNumberGames); } dbgAssertOrIgnore(gpNumberGames >= 0); oldfont = fontMakeCurrent(gpListFont); // fontHeight called later on in this function uicListCleanUp(gpGameListWindow); uicListWindowInit(gpGameListWindow, NULL, // title draw, no title NULL, // title click process, no title 0, // title height, no title gpGameItemDraw, // item draw function fontHeight(" ")+GP_VertSpacing, // item height UICLW_CanSelect); for (index = 0; index < gpNumberGames; index++) { if (index==gpCurrentSelected) uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail); else uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect, UICLW_AddToTail); } fontMakeCurrent(oldfont); }