00001 // Copyright 2002 Kenneth Guy, 00002 // 00003 // You are free to take the source and do as you wish with it. 00004 // However it would be nice if you let me know if the code was useful 00005 // to you and give me an acknowledgement if you use a significant portion 00006 // of the code in an application. 00007 // 00008 // CGameState.cpp 00009 00014 #include "CGameState.h" 00015 #include "CHighScores.h" 00016 #include "Game.hrh" 00017 00018 #include <eikappui.h> 00019 #include <eikapp.h> 00020 #include <eikdoc.h> 00021 #include <eikenv.h> 00022 #include <uikon.hrh> 00023 #include <eikmfne.h> 00024 #include <eikdialg.h> 00025 #include <eikon.hrh> 00026 #include <eikbtgpc.h> 00027 00028 00034 CGameState* CGameState::NewL(const TDesC& aFileName) { 00035 CGameState* self= new (ELeave) CGameState; 00036 CleanupStack::PushL(self); 00037 self->ConstructL(aFileName); 00038 CleanupStack::Pop(self); 00039 return(self); 00040 } 00041 00049 void CGameState::ConstructL(const TDesC& aFileName) { 00050 iHighScores=CHighScores::NewL(aFileName); 00051 } 00052 00054 CGameState::CGameState() : iState(ENoGame) { 00055 00056 } 00057 00059 CHighScores& CGameState::HighScores() { 00060 return *iHighScores; 00061 } 00062 00063 00066 CGameState::TState CGameState::State() { 00067 return iState; 00068 } 00069 00074 void CGameState::SetState(CGameState::TState aState) { 00075 iState=aState; 00076 CEikButtonGroupContainer* cba=CEikonEnv::Static()->AppUiFactory()->ToolBar(); 00077 switch(iState) { 00078 case ENoGame: 00079 cba->DimCommand(ECmdCancelGame,ETrue); 00080 cba->DimCommand(ECmdContinueGame,ETrue); 00081 cba->DimCommand(ECmdStartGame,EFalse); 00082 break; 00083 case EPaused: 00084 case ENextLevel: 00085 cba->DimCommand(ECmdCancelGame,EFalse); 00086 cba->DimCommand(ECmdContinueGame,EFalse); 00087 cba->DimCommand(ECmdStartGame,ETrue); 00088 break; 00089 } 00090 cba->DrawNow(); 00091 } 00092 00095 CGameState::~CGameState() { 00096 delete iHighScores; 00097 } 00098