00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <coemain.h>
00032 #include "common.hrh"
00033 #include "rpsGameScreens.h"
00034 #include "rpsgameengine.h"
00035 #include "bluetoothmanager.h"
00036
00037
00038
00039
00040
00041
00042
00043 CGameScreen* CControlScreen::NewL(CGameScreenManager& aScreenMgr)
00044 {
00045 CControlScreen* me = new (ELeave) CControlScreen(aScreenMgr);
00046 CleanupStack::PushL(me);
00047 me->ConstructL();
00048 CleanupStack::Pop(me);
00049 return (static_cast<CGameScreen*>(me));
00050 }
00051
00052 CControlScreen::CControlScreen(CGameScreenManager& aScreenMgr)
00053 : CMenuScreen(aScreenMgr)
00054 {}
00055
00056 void CControlScreen::ConstructL()
00057 {
00058 _LIT(KMaster, "Control Game");
00059 _LIT(KSlave, "Wait Connection");
00060
00061 TGameScreenItem* item = new (ELeave) TGameScreenItem(RPS::EMaster, KMaster);
00062 item->iX = KRPSScreensHAlignment;
00063 item->iY = gScreenHeight/3;
00064 item->iHighlighted = ETrue;
00065 iItems.AddFirst(*item);
00066 iIterator.SetToFirst();
00067
00068 item = new (ELeave) TGameScreenItem(RPS::ESlave, KSlave);
00069 item->iX = KRPSScreensHAlignment;
00070 item->iY = 2*gScreenHeight/3;
00071 TGameScreenItem* current = iIterator;
00072 ASSERT(current);
00073 item->iDlink.Enque(¤t->iDlink);
00074 }
00075
00076
00077
00078 void CControlScreen::DoProcessInput(RPS::TMenuOption aSelected)
00079 {
00080 switch (aSelected)
00081 {
00082 case(RPS::EMaster):
00083 iGameScreenMgr.BluetoothManager().StartBtMaster();
00084 break;
00085 case(RPS::ESlave):
00086 iGameScreenMgr.BluetoothManager().StartBtSlave();
00087 break;
00088 default:
00089 ASSERT(EFalse);
00090 }
00091 }
00092
00093
00094
00095
00096
00097
00098
00099 CGameScreen* CStartScreen::NewL(CGameScreenManager& aScreenMgr)
00100 {
00101 CStartScreen* me = new (ELeave) CStartScreen(aScreenMgr);
00102 CleanupStack::PushL(me);
00103 me->ConstructL();
00104 CleanupStack::Pop(me);
00105 return (static_cast<CGameScreen*>(me));
00106 }
00107
00108 CStartScreen::CStartScreen(CGameScreenManager& aScreenMgr)
00109 : CMenuScreen(aScreenMgr)
00110 {}
00111
00112 void CStartScreen::ConstructL()
00113 {
00114 _LIT(KStartMsg, "Start Game");
00115
00116 TGameScreenItem* item = new (ELeave) TGameScreenItem(RPS::EStart, KStartMsg);
00117 item->iX = KRPSScreensHAlignment;
00118 item->iY = gScreenHeight/2;
00119 item->iHighlighted = ETrue;
00120 iItems.AddFirst(*item);
00121 iIterator.SetToFirst();
00122 }
00123
00124
00125
00126 void CStartScreen::DoProcessInput(RPS::TMenuOption aSelected)
00127 {
00128 switch (aSelected)
00129 {
00130 case(RPS::EStart):
00131 iGameScreenMgr.BluetoothManager().StartGame();
00132 break;
00133 default:
00134 ASSERT(EFalse);
00135 }
00136 }
00137
00138
00139
00140
00141
00142
00143
00144 CWaitStartScreen* CWaitStartScreen::NewL(CGameScreenManager& aScreenMgr)
00145 {
00146 CWaitStartScreen* me = new (ELeave) CWaitStartScreen(aScreenMgr);
00147 return (me);
00148 }
00149
00150 void CWaitStartScreen::DrawGameScreen()
00151 {
00152 CWindowGc& gc = CCoeEnv::Static()->SystemGc();
00153 gc.SetPenStyle(CGraphicsContext::ENullPen);
00154 gc.UseFont(CCoeEnv::Static()->NormalFont());
00155 gc.SetPenColor(KRgbGray);
00156
00157 _LIT(KWaitingText, "Waiting to start...");
00158
00159 gc.DrawText(KWaitingText, TPoint(KRPSScreensHAlignment, gScreenHeight/2));
00160 }
00161
00162
00163 CWaitStartScreen::CWaitStartScreen(CGameScreenManager& aScreenMgr)
00164 : CGameScreen(aScreenMgr)
00165 {}
00166
00167
00168
00169
00170
00171
00172 CWaitConnScreen* CWaitConnScreen::NewL(CGameScreenManager& aScreenMgr)
00173 {
00174 CWaitConnScreen* me = new (ELeave) CWaitConnScreen(aScreenMgr);
00175 return (me);
00176 }
00177
00178 void CWaitConnScreen::DrawGameScreen()
00179 {
00180 CWindowGc& gc = CCoeEnv::Static()->SystemGc();
00181 gc.SetPenStyle(CGraphicsContext::ENullPen);
00182 gc.UseFont(CCoeEnv::Static()->NormalFont());
00183 gc.SetPenColor(KRgbGray);
00184
00185 _LIT(KWaitingText, "Waiting to connect...");
00186
00187 gc.DrawText(KWaitingText, TPoint(KRPSScreensHAlignment, gScreenHeight/2));
00188 }
00189
00190 CWaitConnScreen::CWaitConnScreen(CGameScreenManager& aScreenMgr)
00191 : CGameScreen(aScreenMgr)
00192 {}
00193
00194
00195
00196
00197
00198
00199
00200
00201 CErrorScreen* CErrorScreen::NewL(CGameScreenManager& aScreenMgr)
00202 {
00203 CErrorScreen* me = new (ELeave) CErrorScreen(aScreenMgr);
00204 return (me);
00205 }
00206
00207 void CErrorScreen::DrawGameScreen()
00208 {
00209 CWindowGc& gc = CCoeEnv::Static()->SystemGc();
00210 gc.SetPenStyle(CGraphicsContext::ENullPen);
00211 gc.UseFont(CCoeEnv::Static()->NormalFont());
00212 gc.SetPenColor(KRgbGray);
00213
00214 if(iGameScreenMgr.GameData().iRpsError == KErrDisconnected)
00215 {
00216 _LIT(KDisconnectedText, "Lost Connection");
00217 gc.DrawText(KDisconnectedText, TPoint(KRPSScreensHAlignment, gScreenHeight/3));
00218 }
00219 else if(iGameScreenMgr.GameData().iRpsError == KErrTimedOut)
00220 {
00221 _LIT(KTimedOutText, "Timed out");
00222 gc.DrawText(KTimedOutText, TPoint(KRPSScreensHAlignment, gScreenHeight/3));
00223 }
00224 else
00225 {
00226 _LIT(KGeneralErrText, "An error occurred");
00227 gc.DrawText(KGeneralErrText, TPoint(KRPSScreensHAlignment, gScreenHeight/3));
00228 }
00229 _LIT(KPressQuit, "Press 5 continue");
00230 gc.DrawText(KPressQuit, TPoint(KRPSScreensHAlignment, 2*gScreenHeight/3));
00231 }
00232
00233 void CErrorScreen::ProcessInput(TUint& aKeyState)
00234 {
00235 if (aKeyState & KKey5)
00236 {
00237 iGameScreenMgr.SetGameState(CGameScreenManager::EMainScreen);
00238 aKeyState &= ~KKey5;
00239 }
00240 }
00241
00242 void CErrorScreen::DeActivate()
00243 {
00244 if (iGameScreenMgr.PlayMode()==CGameScreenManager::ETwoPlayerShortlink)
00245 iGameScreenMgr.BluetoothManager().QuitMultiplayerGame();
00246 }
00247
00248 CErrorScreen::CErrorScreen(CGameScreenManager& aScreenMgr)
00249 : CGameScreen(aScreenMgr)
00250 {}
00251
00252
00253
00254
00255
00256 CConnectingScreen* CConnectingScreen::NewL(CGameScreenManager& aScreenMgr)
00257 {
00258 CConnectingScreen* me = new (ELeave) CConnectingScreen(aScreenMgr);
00259 return (me);
00260 }
00261
00262 void CConnectingScreen::DrawGameScreen()
00263 {
00264 CWindowGc& gc = CCoeEnv::Static()->SystemGc();
00265 gc.SetPenStyle(CGraphicsContext::ENullPen);
00266 gc.UseFont(CCoeEnv::Static()->NormalFont());
00267 gc.SetPenColor(KRgbGray);
00268
00269 _LIT(KDisconnectedText, "Connecting...");
00270 gc.DrawText(KDisconnectedText, TPoint(KRPSScreensHAlignment, gScreenHeight/3));
00271 _LIT(KPressQuit, "Press 5 to cancel");
00272 gc.DrawText(KPressQuit, TPoint(KRPSScreensHAlignment, 2*gScreenHeight/3));
00273 }
00274
00275 void CConnectingScreen::ProcessInput(TUint& aKeyState)
00276 {
00277 if (aKeyState & KKey5)
00278 {
00279 iGameScreenMgr.SetGameState(CGameScreenManager::EMainScreen);
00280 iGameScreenMgr.BluetoothManager().QuitMultiplayerGame();
00281 aKeyState &= ~KKey5;
00282 }
00283 }
00284
00285 CConnectingScreen::CConnectingScreen(CGameScreenManager& aScreenMgr)
00286 : CGameScreen(aScreenMgr)
00287 {}
00288
00289
00290
00291
00292
00293
00294 CWaitOpponentScreen* CWaitOpponentScreen::NewL(CGameScreenManager& aScreenMgr)
00295 {
00296 CWaitOpponentScreen* me = new (ELeave) CWaitOpponentScreen(aScreenMgr);
00297 return (me);
00298 }
00299
00300 void CWaitOpponentScreen::DrawGameScreen()
00301 {
00302 CWindowGc& gc = CCoeEnv::Static()->SystemGc();
00303 gc.SetPenStyle(CGraphicsContext::ENullPen);
00304 gc.UseFont(CCoeEnv::Static()->NormalFont());
00305 gc.SetPenColor(KRgbGray);
00306
00307 _LIT(KWaitingText, "Waiting for opponent...");
00308
00309 gc.DrawText(KWaitingText, TPoint(KRPSScreensHAlignment, gScreenHeight/2));
00310 }
00311
00312
00313
00314 CWaitOpponentScreen::CWaitOpponentScreen(CGameScreenManager& aScreenMgr)
00315 : CGameScreen(aScreenMgr)
00316 {}