jewelappui.cpp

来自「symbian下的泡泡龙游戏源码,手机游戏开放新手学习的好资料」· C++ 代码 · 共 122 行

CPP
122
字号
/*
* ============================================================================
*  Name     : CJewelAppUi from JewelAppui.cpp
*  Part of  : Jewel
*  Created  : 02.10.2005 by Thosing
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  : 0.1
*  Copyright: Another
* ============================================================================
*/

// INCLUDE FILES
#include "JewelAppui.h"
#include "JewelView.h"
#include "JewelEngine.h"
#include "JewelStartScreen.h"
#include <Jewel.rsg>
#include "Jewel.hrh"

#include <avkon.hrh>

// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CJewelAppUi::ConstructL()
// 
// ----------------------------------------------------------
//
void CJewelAppUi::ConstructL() {
  BaseConstructL();

  iStartScreen = new (ELeave) CJewelStartScreen;
  iStartScreen->SetMopParent( this );
  iStartScreen->ConstructL( ApplicationRect() );
  AddToStackL( iStartScreen );
  iStartScreen->ActivateL();

  iAppContainer = new (ELeave) CJewelView;
  iAppContainer->SetMopParent( this );
  iAppContainer->ConstructL( ApplicationRect() );
  AddToStackL( iAppContainer );

  iGameStart=EFalse;

}

// ----------------------------------------------------
// CJewelAppUi::~CJewelAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CJewelAppUi::~CJewelAppUi() {
  if (iAppContainer) {
    RemoveFromStack( iAppContainer );
    delete iAppContainer;
  }
  if(iStartScreen) {
    RemoveFromStack(iStartScreen);
    delete iStartScreen;
  }
}

// ------------------------------------------------------------------------------
// CJewelAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
//  This function is called by the EIKON framework just before it displays
//  a menu pane. Its default implementation is empty, and by overriding it,
//  the application can set the state of menu items dynamically according
//  to the state of application data.
// ------------------------------------------------------------------------------
//
void CJewelAppUi::DynInitMenuPaneL(TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/){}

// ----------------------------------------------------
// CJewelAppUi::HandleKeyEventL(
//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CJewelAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode aType){
  if(!iGameStart && aType==EEventKeyDown) {
    iAppContainer->ActivateL();
    iGameStart=ETrue;
    iStartScreen->MakeVisible(EFalse);
    iAppContainer->MakeVisible(ETrue);
    iAppContainer->FullLife();
  }
  return EKeyWasNotConsumed;
}

// ----------------------------------------------------
// CJewelAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CJewelAppUi::HandleCommandL(TInt aCommand) {
  switch ( aCommand ) {
    case EAknSoftkeyBack:
    case EEikCmdExit:
      {
        Exit();
        break;
      }
    case EJewelCmdAppTest:
      {
        _LIT(KHIGHSCORE, "High Score:");
        TBuf<21> msg(KHIGHSCORE);
        msg.AppendNum(CJewelEngine::LoadHighScore());
        iEikonEnv->InfoMsg(msg);
        break;
      }

    default:
      break;      
  }
}



// End of File  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?