ALERROR CWaitSession::OnInit (CString *retsError) // OnInit // // Initialize { const CVisualPalette &VI = m_HI.GetVisuals(); RECT rcRect; VI.GetWidescreenRect(m_HI.GetScreen(), &rcRect); // Create the title CUIHelper Helper(m_HI); IAnimatron *pTitle; Helper.CreateSessionTitle(this, m_Service, m_sTitle, CUIHelper::OPTION_SESSION_NO_CANCEL_BUTTON, &pTitle); StartPerformance(pTitle, ID_CTRL_TITLE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Create a wait animation IAnimatron *pAni; VI.CreateWaitAnimation(NULL, ID_CTRL_WAIT, rcRect, &pAni); StartPerformance(pAni, ID_CTRL_WAIT, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Done return NOERROR; }
ALERROR CLoginSession::OnCommand (const CString &sCmd, void *pData) // OnCommand // // Handle a command { if (strEquals(sCmd, CMD_ALL_TASKS_DONE)) { StopPerformance(ID_CTRL_WAIT); ShowInitialDlg(); } else if (strEquals(sCmd, CMD_CANCEL)) CmdCancel(); else if (strEquals(sCmd, CMD_REGISTER)) CmdRegister(); else if (strEquals(sCmd, CMD_REGISTER_COMPLETE)) CmdRegisterComplete((CRegisterUserTask *)pData); else if (strEquals(sCmd, CMD_SIGN_IN)) CmdSignIn(); else if (strEquals(sCmd, CMD_SIGN_IN_COMPLETE)) CmdSignInComplete((CSignInUserTask *)pData); else if (strEquals(sCmd, CMD_SWITCH_TO_LOGIN)) { StopPerformance(ID_DLG_REGISTER); const CVisualPalette &VI = m_HI.GetVisuals(); IAnimatron *pDlg; CreateDlgSignIn(VI, &pDlg); m_iCurrent = dlgSignIn; StartPerformance(pDlg, ID_DLG_SIGN_IN, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); } else if (strEquals(sCmd, CMD_SWITCH_TO_REGISTER)) { StopPerformance(ID_DLG_SIGN_IN); const CVisualPalette &VI = m_HI.GetVisuals(); IAnimatron *pDlg; CreateDlgRegister(VI, &pDlg); m_iCurrent = dlgRegister; StartPerformance(pDlg, ID_DLG_REGISTER, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); } else if (strEquals(sCmd, CMD_PASSWORD_RESET)) CmdPasswordReset(); else if (strEquals(sCmd, CMD_TOS)) sysOpenURL(CONSTLIT("http://www.kronosaur.com/legal/TermsofService.html")); return NOERROR; }
void CProfileSession::CmdReadComplete (CReadProfileTask *pTask) // CmdReadComplete // // Done reading the profile { const CVisualPalette &VI = m_HI.GetVisuals(); // Done with wait animation StopPerformance(ID_CTRL_WAIT); // Check for error CString sError; if (pTask->GetResult(&sError) != NOERROR) { IAnimatron *pMsg; VI.CreateMessagePane(NULL, ID_MESSAGE, ERR_TITLE, strPatternSubst(ERR_DESC, sError), m_rcRecords, 0, &pMsg); StartPerformance(pMsg, ID_MESSAGE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return; } // Show the profile IAnimatron *pList = pTask->GetListHandoff(); pList->SetPropertyVector(PROP_POSITION, CVector(m_rcRecords.left, m_rcRecords.top)); pList->SetPropertyMetric(PROP_VIEWPORT_HEIGHT, (Metric)RectHeight(m_rcRecords)); StartPerformance(pList, ID_PROFILE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); }
void CLoadGameSession::CmdReadComplete (CListSaveFilesTask *pTask) // CmdReadComplete // // We've finished loading the list of games { const CVisualPalette &VI = m_HI.GetVisuals(); RECT rcRect; VI.GetWidescreenRect(m_HI.GetScreen(), &rcRect); // Done with wait animation StopPerformance(ID_CTRL_WAIT); // Check for error CString sError; if (pTask->GetResult(&sError) != NOERROR) { IAnimatron *pMsg; VI.CreateMessagePane(NULL, ID_MESSAGE, ERR_TITLE, strPatternSubst(ERR_DESC, sError), rcRect, 0, &pMsg); StartPerformance(pMsg, ID_MESSAGE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return; } // If we have no entries, then show a message IAnimatron *pList = pTask->GetListHandoff(); if (pList->GetPropertyInteger(PROP_COUNT) == 0) { delete pList; IAnimatron *pMsg; VI.CreateMessagePane(NULL, ID_MESSAGE, ERR_NO_ENTRIES, ERR_NO_ENTRIES_DESC, rcRect, 0, &pMsg); StartPerformance(pMsg, ID_MESSAGE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return; } // Show the profile RECT rcList; pList->GetSpacingRect(&rcList); pList->SetPropertyVector(PROP_POSITION, CVector(rcRect.left + (RectWidth(rcRect) - RectWidth(rcList)) / 2, rcRect.top)); pList->SetPropertyVector(PROP_SCALE, CVector(SAVE_ENTRY_WIDTH, RectHeight(rcRect))); pList->SetPropertyMetric(PROP_VIEWPORT_HEIGHT, (Metric)RectHeight(rcRect)); RegisterPerformanceEvent(pList, EVENT_ON_DOUBLE_CLICK, CMD_OK_SESSION); StartPerformance(pList, ID_LIST, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); }
ALERROR CTextCrawlSession::OnInit (CString *retsError) // OnInit // // Initialize { RECT rcCenter; const CVisualPalette &VI = m_HI.GetVisuals(); VI.GetWidescreenRect(&rcCenter); // Compute the RECT where the text will go RECT rcRect; rcRect.top = rcCenter.top + (RectHeight(rcCenter) - TEXT_CRAWL_HEIGHT) / 2; rcRect.left = rcCenter.left + (RectWidth(rcCenter) / 2); rcRect.bottom = rcRect.top + TEXT_CRAWL_HEIGHT; rcRect.right = rcRect.left + TEXT_CRAWL_WIDTH; // Create the text animation IAnimatron *pAni; CreateCrawlAnimation(m_sText, rcRect, &pAni); StartPerformance(pAni, ID_TEXT_CRAWL_PERFORMANCE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return NOERROR; }
void CStatsSession::OnKeyDown (int iVirtKey, DWORD dwKeyData) // OnKeyDown { switch (iVirtKey) { case 'C': if (uiIsControlDown()) { ::CopyGameStatsToClipboard(m_HI.GetHWND(), m_Stats); IAnimatron *pAni; CreateCopyAnimation(m_rcStats, 2, &pAni); StartPerformance(pAni, ID_GAME_STAT_COPY_FLASH, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); } break; case VK_CONTROL: break; case VK_F1: m_HI.HICommand(CMD_UI_SHOW_HELP); break; case VK_DOWN: case VK_RIGHT: SetSelection(GAME_STAT_POSITION_NEXT); break; case VK_END: SetSelection(GAME_STAT_POSITION_END); break; case VK_HOME: SetSelection(GAME_STAT_POSITION_HOME); break; case VK_LEFT: case VK_UP: SetSelection(GAME_STAT_POSITION_PREV); break; case VK_NEXT: SetSelection(GAME_STAT_POSITION_NEXT_PAGE); break; case VK_PRIOR: SetSelection(GAME_STAT_POSITION_PREV_PAGE); break; default: m_HI.HICommand(CMD_SESSION_STATS_DONE); break; } }
ALERROR CTextCrawlSession::OnCommand (const CString &sCmd, void *pData) // OnCommand // // Handle a command { if (strEquals(sCmd, CMD_OK_SESSION)) { OnCommand(CMD_SHOW_WAIT_ANIMATION); m_HI.HICommand(m_sCmdDone); } else if (strEquals(sCmd, CMD_SHOW_OK_BUTTON)) { CUIHelper Helper(m_HI); IAnimatron *pTitle; Helper.CreateSessionTitle(this, m_Service, NULL_STR, NULL, CUIHelper::OPTION_SESSION_NO_HEADER | CUIHelper::OPTION_SESSION_NO_CANCEL_BUTTON | CUIHelper::OPTION_SESSION_OK_BUTTON, &pTitle); StartPerformance(pTitle, ID_CTRL_TITLE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); } else if (strEquals(sCmd, CMD_SHOW_WAIT_ANIMATION)) { if (!m_bWaitAnimation) { CUIHelper Helper(m_HI); IAnimatron *pAni; Helper.CreateSessionWaitAnimation(ID_CTRL_WAIT, CONSTLIT("Creating Game"), &pAni); StartPerformance(pAni, ID_CTRL_WAIT, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); m_bWaitAnimation = true; } } return NOERROR; }
void CLoginSession::ShowInitialDlg (void) // ShowInitialDlg // // Shows the first dialog box { const CVisualPalette &VI = m_HI.GetVisuals(); IAnimatron *pDlg; // If we're already signed in then we're done. if (m_Service.HasCapability(ICIService::canGetUserProfile)) CmdCancel(); // Otherwise, if we have a username else if (m_Service.HasCapability(ICIService::cachedUser)) { CreateDlgSignIn(VI, &pDlg); m_iCurrent = dlgSignIn; StartPerformance(pDlg, ID_DLG_SIGN_IN, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); if (!m_Service.GetDefaultUsername().IsBlank()) SetInputFocus(ID_CTRL_PASSWORD); } // Otherwise, register else if (m_Service.HasCapability(ICIService::registerUser)) { CreateDlgRegister(VI, &pDlg); m_iCurrent = dlgRegister; StartPerformance(pDlg, ID_DLG_REGISTER, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); } // Otherwise, cannot sign in else CmdCancel(); }
ALERROR CProfileSession::OnInit (CString *retsError) // OnInit // // Initialize { const CVisualPalette &VI = m_HI.GetVisuals(); GetPaneRect(&m_rcPane); int cxWidth = Min(RectWidth(m_rcPane), MAX_RECORD_WIDTH); m_rcRecords.left = m_rcPane.left + (RectWidth(m_rcPane) - cxWidth) / 2; m_rcRecords.right = m_rcRecords.left + cxWidth; m_rcRecords.top = m_rcPane.top; m_rcRecords.bottom = m_rcPane.bottom; // Create a task to read the profile information and wait until it // finishes. m_HI.AddBackgroundTask(new CReadProfileTask(m_HI, m_Service, RectWidth(m_rcRecords)), 0, this, CMD_READ_COMPLETE); // Create the title CUIHelper Helper(m_HI); IAnimatron *pTitle; Helper.CreateSessionTitle(this, m_Service, CONSTLIT("Scores & Records"), NULL, 0, &pTitle); StartPerformance(pTitle, ID_CTRL_TITLE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Create a wait animation IAnimatron *pAni; VI.CreateWaitAnimation(NULL, ID_CTRL_WAIT, m_rcPane, &pAni); StartPerformance(pAni, ID_CTRL_WAIT, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Done return NOERROR; }
ALERROR CLoadGameSession::OnInit (CString *retsError) // OnInit // // Initialize { const CVisualPalette &VI = m_HI.GetVisuals(); RECT rcRect; VI.GetWidescreenRect(m_HI.GetScreen(), &rcRect); // Get the folder where save files are stored. // (For now all the save files are kept with the executable). CString sFolder; // Create a task to read the list of save files from disk m_HI.AddBackgroundTask(new CListSaveFilesTask(m_HI, sFolder, m_Service.GetUsername(), SAVE_ENTRY_WIDTH), this, CMD_READ_COMPLETE); // Create the title CUIHelper Helper(m_HI); IAnimatron *pTitle; Helper.CreateSessionTitle(this, m_Service, CONSTLIT("Load Game"), CUIHelper::OPTION_SESSION_OK_BUTTON, &pTitle); StartPerformance(pTitle, ID_CTRL_TITLE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Create a wait animation IAnimatron *pAni; VI.CreateWaitAnimation(NULL, ID_CTRL_WAIT, rcRect, &pAni); StartPerformance(pAni, ID_CTRL_WAIT, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Done return NOERROR; }
void CStatsSession::SetSelection (int iPos) // SetSelection // // Sets the selection position { IAnimatron *pAni = GetPerformance(ID_GAME_STAT_PERFORMANCE); if (pAni == NULL) return; // Set SelectGameStat(pAni, iPos, RectWidth(m_rcStats)); // Restart animation StartPerformance(ID_GAME_STAT_PERFORMANCE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); }
ALERROR CMessageSession::OnInit (CString *retsError) // OnInit // // Initialize { // We're showing dialog boxes, so the previous session shows through. SetTransparent(); // Create the dialog box IAnimatron *pDlg; CreateDlgMessage(&pDlg); StartPerformance(pDlg, ID_DLG_MESSAGE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Done return NOERROR; }
void CGalacticMapSession::Select (CTopologyNode *pNode) // Select // // Selects the given node { // If this node is already selected, skip if (pNode == m_pPainter->GetSelection()) return; // Select g_pUniverse->PlaySound(NULL, g_pUniverse->FindSound(UNID_DEFAULT_SELECT)); m_pPainter->SetSelection(pNode); // We always stop the performance, if there is one StopPerformance(ID_DETAILS); // If we have a valid node, then show data for it. if (pNode) { RECT rcPane = m_rcView; rcPane.right = m_rcView.right - SCREEN_BORDER_X; rcPane.left = rcPane.right - DETAIL_PANE_WIDTH; rcPane.top = m_rcView.top + (RectHeight(m_rcView) - DETAIL_PANE_HEIGHT) / 2; rcPane.bottom = rcPane.top + DETAIL_PANE_HEIGHT; CGalacticMapSystemDetails Details(m_HI.GetVisuals(), GetReanimator(), rcPane); IAnimatron *pAni; Details.CreateDetailsPane(pNode, &pAni); StartPerformance(pAni, ID_DETAILS, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); } }
ALERROR CLoginSession::OnInit (CString *retsError) // OnInit // // Initialize { // We're showing dialog boxes, so the previous session shows through. SetTransparent(); // See if any background tasks are running. If so, then we show the status // dialog box and wait for tasks to complete. if (m_HI.RegisterOnAllBackgroundTasksComplete(this)) { const CVisualPalette &VI = m_HI.GetVisuals(); RECT rcRect; VI.GetWidescreenRect(m_HI.GetScreen(), &rcRect); // Create a wait animation IAnimatron *pAni; VI.CreateWaitAnimation(NULL, ID_CTRL_WAIT, rcRect, &pAni); StartPerformance(pAni, ID_CTRL_WAIT, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return NOERROR; } // Otherwise, we show the sign in dialog box ShowInitialDlg(); // Done return NOERROR; }
ALERROR CStatsSession::OnInit (CString *retsError) // OnInit { ALERROR error; const CVisualPalette &VI = m_HI.GetVisuals(); // Load a JPEG of the background image HBITMAP hDIB; if (error = JPEGLoadFromResource(g_hInst, MAKEINTRESOURCE(IDR_GAME_STATS_SCREEN), JPEG_LFR_DIB, NULL, &hDIB)) return error; error = m_BackgroundImage.CreateFromBitmap(hDIB); ::DeleteObject(hDIB); if (error) return error; // Figure out where the stats will go RECT rcCenter; RECT rcFull; VI.GetWidescreenRect(m_HI.GetScreen(), &rcCenter, &rcFull); const CG16bitFont &MediumFont = VI.GetFont(fontMedium); const CG16bitFont &HeaderFont = VI.GetFont(fontHeader); m_rcStats = rcCenter; m_rcStats.left = rcCenter.left + RectWidth(rcCenter) / 2; m_rcStats.right = rcFull.right - 4 * VI.GetFont(fontHeader).GetHeight(); // Create stats animation IAnimatron *pAni; CreateGameStatsAnimation(m_Stats, m_rcStats, rcCenter.left + 3 * RectWidth(rcCenter) / 4, &pAni); SelectGameStat(pAni, 1, RectWidth(m_rcStats)); StartPerformance(pAni, ID_GAME_STAT_PERFORMANCE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Figure out where task status will go m_rcTaskProgress.right = rcCenter.right; m_rcTaskProgress.left = m_rcTaskProgress.right - 80 * HeaderFont.GetAverageWidth(); m_rcTaskProgress.top = rcCenter.bottom + MediumFont.GetHeight(); m_rcTaskProgress.bottom = m_rcTaskProgress.top + HeaderFont.GetHeight(); // OK button CUIHelper Helper(m_HI); IAnimatron *pTitle; Helper.CreateSessionTitle(this, m_Service, NULL_STR, NULL, CUIHelper::OPTION_SESSION_NO_HEADER | CUIHelper::OPTION_SESSION_NO_CANCEL_BUTTON | CUIHelper::OPTION_SESSION_OK_BUTTON, &pTitle); StartPerformance(pTitle, ID_CTRL_TITLE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return NOERROR; }
ALERROR CNewGameSession::OnInit (CString *retsError) // OnInit // // Initialize { ALERROR error; int i; const CVisualPalette &VI = m_HI.GetVisuals(); // The main pane is divided into three columns. Compute the size and // position here. RECT rcCenter; VI.GetWidescreenRect(m_HI.GetScreen(), &rcCenter); m_cxLeftCol = RectWidth(rcCenter) / 3; m_cxRightCol = m_cxLeftCol; m_cxCenterCol = RectWidth(rcCenter) - (m_cxLeftCol + m_cxRightCol); m_xLeftCol = 0; m_xCenterCol = m_cxLeftCol; m_xRightCol = m_cxLeftCol + m_cxCenterCol; // Compute the location of various elements (relative to the upper-left of // the root vscroller). m_xPlayerName = m_xLeftCol; m_yPlayerName = MAJOR_PADDING_TOP; m_cxPlayerName = m_cxLeftCol; m_xPlayerGenome = m_xRightCol; m_yPlayerGenome = MAJOR_PADDING_TOP; m_cxPlayerGenome = m_cxRightCol; m_xShipClass = m_xLeftCol; m_yShipClass = MAJOR_PADDING_TOP; m_cxShipClass = RectWidth(rcCenter); // Generate a list of ship classes CAdventureDesc *pAdventure = g_pUniverse->GetCurrentAdventureDesc(); if (pAdventure == NULL) { *retsError = ERR_NO_ADVENTURE; return ERR_FAIL; } if (error = pAdventure->GetStartingShipClasses(&m_ShipClasses, retsError)) return error; if (m_ShipClasses.GetCount() == 0) { *retsError = ERR_NO_SHIP_CLASSES; return ERR_FAIL; } // Find the default ship class in the list m_iCurShipClass = 0; for (i = 0; i < m_ShipClasses.GetCount(); i++) if (m_ShipClasses[i]->GetUNID() == m_Settings.dwPlayerShip) { m_iCurShipClass = i; break; } // Create the title CUIHelper Helper(m_HI); IAnimatron *pTitle; Helper.CreateSessionTitle(this, m_Service, pAdventure->GetName(), CUIHelper::OPTION_SESSION_OK_BUTTON, &pTitle); StartPerformance(pTitle, ID_CTRL_TITLE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Create a scroller to hold all the settings m_pRoot = new CAniVScroller; m_pRoot->SetPropertyVector(PROP_POSITION, CVector(rcCenter.left, rcCenter.top)); m_pRoot->SetPropertyMetric(PROP_VIEWPORT_HEIGHT, (Metric)RectHeight(rcCenter)); m_pRoot->SetPropertyMetric(PROP_FADE_EDGE_HEIGHT, 0.0); m_pRoot->SetPropertyMetric(PROP_PADDING_BOTTOM, (Metric)MAJOR_PADDING_BOTTOM); // Create the player name CreatePlayerName(m_Settings.sPlayerName, m_xPlayerName, m_yPlayerName, m_cxPlayerName); m_bEditingName = false; // Create the player genome CreatePlayerGenome(m_Settings.iPlayerGenome, m_xPlayerGenome, m_yPlayerGenome, m_cxPlayerGenome); // Create the ship class CreateShipClass(m_ShipClasses[m_iCurShipClass], m_xShipClass, m_yShipClass, m_cxShipClass); // Start the settings pane StartPerformance(m_pRoot, ID_SETTINGS, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); // Done return NOERROR; }