03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

There are no surprises in the command-handling framework. Cmd-ZoomInL() and<br />

CmdZoomOutL() are handled by passing them straight to the controller:<br />

void CGameAppUi::CmdZoomInL()<br />

{<br />

iController->ZoomInL();<br />

}<br />

void CGameAppUi::CmdZoomOutL()<br />

{<br />

iController->ZoomOutL();<br />

}<br />

CmdStartL() checks to see if a game is already in progress, and queries the player if so:<br />

void CGameAppUi::CmdStartL()<br />

{<br />

// User-friendly check<br />

if(iController->IsMyTurn())<br />

{<br />

if(!iEikonEnv->QueryWinL(R_GAME_QUERY_ABANDON))<br />

}<br />

return;<br />

iController->Reset();<br />

iAppView->DrawTilesNow();<br />

}<br />

If the game had finished anyway, or if the user confirmed that they really did want to start a<br />

new game, then the app UI asks the controller to reset, and gets the app view to redraw.<br />

Back in <strong>Chapter</strong> 4, I introduced the resource file as being something quite heavily associated<br />

with the app UI. However, Solo Ships doesn't have a toolbar or any dialogs, so its resource<br />

file is not enormous. Here it is (minus #includes and suchlike):<br />

NAME SHIP<br />

...<br />

RESOURCE RSS_SIGNATURE { }<br />

RESOURCE TBUF { buf="Battleships"; }<br />

RESOURCE EIK_APP_INFO<br />

{<br />

menubar=r_game_menubar;<br />

hotkeys=r_game_hotkeys;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!