Esempio n. 1
0
void CSMLoginScene::OnEvent_LoginOKNormal( int iAccountID )
{
	CCLog( "@@login03: OnEvent_LoginOKNormal()\r\n" );

	m_iAccountID = iAccountID;
#ifdef USE_MGSDK
    if(m_pLayerUpdate)
    {
        NDUIImage * pImage = (NDUIImage *)m_pLayerUpdate->GetChild( TAG_CTRL_PIC_BG);
        if ( pImage )
        {
            NDPicture * pPicture = new NDPicture;
            std::string str = SZ_UPDATE_BG_PNG_PATH;
            pPicture->Initialization( NDPath::GetUIImgPath( str.c_str() ).c_str() );
            pImage->SetPicture( pPicture, true );
        }
    }
#endif
	
#if UPDATE_ON == 0
		CloseWaitingAni();
		StartEntry();
#endif
#if UPDATE_ON == 1
	const char*	pszUpdateURL	= SZ_UPDATE_URL;//ScriptMgrObj.excuteLuaFuncRetS( "GetUpdateURL", "Update" );//此时Lua脚本未加载……
	if ( !pszUpdateURL )
	{
		CloseWaitingAni();
		StartEntry();
		return;
	}
		
	if (m_pLabelPromtp)
	{
		m_pLabelPromtp->SetText( NDCommonCString2(SZ_CONNECT_SERVER).c_str() );
		m_pLabelPromtp->SetVisible( true );
	}
	if ( !NDBeforeGameMgrObj.CheckClientVersion( pszUpdateURL ) )
	{
		CloseWaitingAni();
		StartEntry();
	}
#endif
}
Esempio n. 2
0
//===========================================================================
void CSMLoginScene::OnTimer( OBJID idTag )
{
	static bool bFirst = true;

	if (bFirst)
	{
		LOGD("Entry First OnTimer");
		//idTag = TAG_TIMER_UPDATE;
		bFirst = false;
	}

	if ( idTag == TAG_TIMER_UPDATE ) 
	{
		if ( !rename( m_strSavePath.c_str(), m_strSavePath.c_str() ) )
		{
			if ( remove( m_strSavePath.c_str() ) )
			{ 
				m_pTimer->KillTimer(this, TAG_TIMER_UPDATE);
				return;
			}
		}

		FromUrl(m_strUpdateURL.c_str());
		ToPath(m_strSavePath.c_str()); 
		Download();
		m_pTimer->KillTimer(this, TAG_TIMER_UPDATE);
	}
	else if ( idTag == TAG_TIMER_DOWNLOAD_SUCCESS )
	{
		m_pTimer->KillTimer(this, TAG_TIMER_DOWNLOAD_SUCCESS);
        
		LOGD("Entry TAG_TIMER_DOWNLOAD_SUCCESS process.");
		UnZipFile( m_strSavePath.c_str(), m_strCachePath.c_str());
	}
    else if ( idTag == TAG_TIMER_UNZIP_SUCCESS )
	{
		m_pTimer->KillTimer(this, TAG_TIMER_UNZIP_SUCCESS);
		if ( remove(m_strSavePath.c_str()) )
		{
		    NDLog("delete:%s failed",m_strSavePath.c_str());
		    //return;
		}
        std::string szListFile = NDPath::GetCashesPath() + SZ_DEL_FILE;
		DeleteFileFromFile( szListFile );
    
		if(kDeqUpdateUrl.size() > 0)
		{
		    kDeqUpdateUrl.pop_front();
		}

		PackageCount++;
		//查找下载队列
		if (kDeqUpdateUrl.size() > 0)
		{
		    //定义保存路径
		    m_strUpdateURL = *kDeqUpdateUrl.begin();
		    //m_savePath = [[NSString stringWithFormat:@"%s/update%d.zip", m_cachPath.c_str(), PackageCount] UTF8String];
		    m_pTimer->SetTimer( this, TAG_TIMER_UPDATE, 0.5f );
		    StartDownload();
		}
		else
		{
		    //跳转到启动界面
		    StartEntry();
		}
	}
	else if ( TAG_TIMER_CHECK_WIFI == idTag )
	{
		//如果检测没开启WIFI则不断检测//
    	if ( NDBeforeGameMgrObj.isWifiNetWork() )
    	{
			m_pTimer->KillTimer( this, TAG_TIMER_CHECK_WIFI );
			CloseConfirmDlg();
			StartUpdate();
    	}
	}
	else if ( TAG_TIMER_CHECK_UPDATE == idTag )
	{
        m_pTimer->KillTimer(this, TAG_TIMER_CHECK_UPDATE);
        ShowUpdateOff();
	}
	else if ( TAG_TIMER_CHECK_COPY == idTag )
	{
        int copyStatus = NDBeforeGameMgr::GetCopyStatus();
        switch (copyStatus) 
        {
            case -1:
                m_pTimer->KillTimer( this, TAG_TIMER_CHECK_COPY );
                //NSLog( @"Copy files error!" );
                exit(0);
                break;
            case 0:
                break;
            case 1:
                m_pTimer->KillTimer( this, TAG_TIMER_CHECK_COPY );
                NDBeforeGameMgrObj.doNDSdkLogin();
                ShowWaitingAni();
                break;
            default:
                break;
        }
	}
    else if ( TAG_TIMER_FIRST_RUN == idTag )
	{
		LOGD("Entry TAG_TIMER_FIRST_RUN == idTag");
		m_pTimer->KillTimer( this, TAG_TIMER_FIRST_RUN );
		CreateUpdateUILayer();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		CCLog( "@@login02: to call OnEvent_LoginOKNormal()\r\n" );

        m_iAccountID = NDBeforeGameMgrObj.GetCurrentUser();
		OnEvent_LoginOKNormal(m_iAccountID);
#else
#ifdef USE_MGSDK
		NDUIImage * pImage = (NDUIImage *)m_pLayerUpdate->GetChild( TAG_CTRL_PIC_BG);
		if ( pImage )
		{
			NDPicture * pPicture = new NDPicture;
			pPicture->Initialization( NDPath::GetUIImgPath( SZ_MOBAGE_BG_PNG_PATH ).c_str() );
			pImage->SetPicture( pPicture, true );
		}
#endif
#if CACHE_MODE == 1
    	if ( NDBeforeGameMgrObj.CheckFirstTimeRuning() )
        {
        	if ( m_pLabelPromtp )
            {
        		m_pLabelPromtp->SetText( NDCommonCString2(SZ_FIRST_INSTALL).c_str() );
        		m_pLabelPromtp->SetVisible( true );
                ShowWaitingAni();
#ifdef USE_MGSDK
        		m_pLabelPromtp->SetVisible( false );//Mobage的版本暂将文字绘在背景图上
#endif
            }
            m_pTimer->SetTimer( this, TAG_TIMER_CHECK_COPY, 0.5f );
        }
        else
#endif
        {
            NDBeforeGameMgrObj.doNDSdkLogin();
            ShowWaitingAni();
		}
#endif
    	//CreateUpdateUILayer();
		//NDBeforeGameMgrObj.CheckClientVersion(SZ_UPDATE_URL);
	}
	else if ( TAG_TIMER_LOAD_RES_OK == idTag )
	{
		m_pTimer->KillTimer( this, TAG_TIMER_LOAD_RES_OK );
		CloseWaitingAni();
		CloseUpdateUILayer();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
		//if ( m_iAccountID == 0 )
		m_iAccountID = ScriptMgrObj.excuteLuaFuncRetN( "GetAccountID", "Login_ServerUI" );
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		m_iAccountID = NDBeforeGameMgrObj.GetCurrentUser();
#endif
		ScriptMgrObj.excuteLuaFunc( "ShowUI", "Entry", m_iAccountID );
		//    ScriptMgrObj.excuteLuaFunc("ProecssLocalNotification", "MsgLoginSuc");
	}
}
Esempio n. 3
0
StageUI_Base::StageUI_Base()
{
    m_pkUIPercentLabel = NULL;
    m_pkUILayer = 0;

    m_pkUnzipProgress = 0;
    m_pkBackgroundImage = 0;
    m_pkProgressBgImage = 0;
    m_pkUnzipTextImage = 0;

    m_pkUILayer = new NDUIDialog;
    m_pkUILayer->Initialization();
    m_pkUILayer->SetAlwaysFullScreen(true);
    m_pkUILayer->NoMask();
    getPercentLabel();

    if (m_pkUILayer)
    {
        m_pkUILayer->AddChild( m_pkUIPercentLabel, 1 );
        m_pkUIPercentLabel->SetText(CONVERT_GBK_TO_UTF8("正在检查是否需要更新……"));
    }

    m_pkBackgroundImage = new NDUIImage;
    m_pkBackgroundImage->Initialization();

    m_pkUnzipTextImage = new NDUIImage;
    m_pkUnzipTextImage->Initialization();

    m_pkProgressBgImage = new NDUIImage;
    m_pkProgressBgImage->Initialization();

    m_pkUnzipProgress = new NDUIExp;
    m_pkUnzipProgress->Initialization();
    m_pkUnzipProgress->SetNoText();
    m_pkUnzipProgress->setMaskMode(true);
    m_pkUnzipProgress->setMaskPercent(0.1f);
    //m_pkUnzipProgress->SetFgDrawFirst();

    unsigned long uiBgDataSize = 0;
    unsigned long uiBgProgressDataSize = 0;
    unsigned long uiFgProgressDataSize = 0;
    unsigned long uiProgressEffectSize = 0;
    unsigned long uiUnzipTextSize = 0;

    unsigned char* pszBgImageFileData = 0;
    unsigned char* pszBgProgressImageData = 0;
    unsigned char* pszFgProgressImageData = 0;
    unsigned char* pszProgressEffectData = 0;
    unsigned char* pszUnzipTextData = 0;

    string strPath = "";
    float fWinScale = 2.0f;
    CCSize kWinSize = ccz(0,0);
    CCSize kRealWinSize = CCDirector::sharedDirector()->getWinSize();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    strPath = "assets/install_res/";
    fWinScale = 1.0f;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    strPath = "../install_res/";
    fWinScale = 2.0f;
#endif

    CCRect kRect = m_pkUILayer->GetFrameRect();
    float fHeight = CCDirector::sharedDirector()->getWinSize().height;
    float fWidth = CCDirector::sharedDirector()->getWinSize().width;

    float fWindowScale = fHeight / fWidth;
    float fRealScreenHeight = 960.0f / fWinScale;
    float fRealScreenWidth = 640.0f / fWinScale;

    float fCtrlScale = fWidth / fRealScreenWidth;
    float fCurHeight = (fHeight - fRealScreenHeight * fCtrlScale) / 2.0f * fWinScale;
    kWinSize = ccz(fRealScreenWidth * fCtrlScale * fWinScale,fRealScreenHeight * fCtrlScale * fWinScale);

    m_pkBackgroundImage->SetFrameRect(CCRectMake(0,fCurHeight,kWinSize.width,kWinSize.height));
    //m_nOffsetHeight = fCurHeight;

    m_strBgImageFile = strPath + string("bg_image.png");
    m_strBgProgressImage = strPath + string("bg_progress.png");
    m_strFgProgressImage = strPath + string("fg_progress.png");
    m_strProgressEffect = strPath + string("progress_effect.png");
    m_strUnzipTextFile = strPath + string("load_text.png");

    pszBgImageFileData =
        __getFileData(m_strBgImageFile.c_str(),"rb",&uiBgDataSize);
    pszBgProgressImageData =
        __getFileData(m_strBgProgressImage.c_str(),"rb",&uiBgProgressDataSize);
    pszFgProgressImageData =
        __getFileData(m_strFgProgressImage.c_str(),"rb",&uiFgProgressDataSize);
    pszProgressEffectData =
        __getFileData(m_strProgressEffect.c_str(),"rb",&uiProgressEffectSize);
    pszUnzipTextData =
        __getFileData(m_strUnzipTextFile.c_str(),"rb",&uiUnzipTextSize);

    if (0 == pszBgImageFileData || 0 == pszBgProgressImageData ||
            0 == pszFgProgressImageData || 0 == pszProgressEffectData || 0 == pszUnzipTextData)
    {
        WriteConErr("Data Error!!\n");
        return;
    }

    float fProgressWidth = kWinSize.width * 0.9f;

    CCRect kProgressRect = CCRectMake((kWinSize.width - fProgressWidth) / 2.0f,
                                      kWinSize.height * 0.8f + fCurHeight, fProgressWidth,
                                      fProgressWidth * 0.086207);

    // 	kProgressRect.origin.x *= fWinScale;
    // 	kProgressRect.origin.y *= fWinScale;
    // 	kProgressRect.size.width *= fWinScale;
    // 	kProgressRect.size.height *= fWinScale;

    CCRect kTextRect = kProgressRect;
    kTextRect.origin.y -= kTextRect.size.height;

    m_pkUIPercentLabel->SetFrameRect(kTextRect);

    m_pkUnzipProgress->SetFrameRect(kProgressRect);
    m_pkProgressBgImage->SetFrameRect(kProgressRect);

    //GetUIRootNew()->addDlg(m_pkUILayer);

    NDPicture* pkUnzipTextPicture = new NDPicture;
    pkUnzipTextPicture->Initialization(pszUnzipTextData, uiUnzipTextSize);

    NDPicture* pkBgPicture = new NDPicture;
    pkBgPicture->Initialization(pszBgImageFileData, uiBgDataSize);

    NDPicture* pkEffectPicture = new NDPicture;
    pkEffectPicture->Initialization(pszProgressEffectData,
                                    uiProgressEffectSize);

    NDPicture* pkBgProgressPic = new NDPicture;
    pkBgProgressPic->Initialization(pszBgProgressImageData,
                                    uiBgProgressDataSize);

    NDPicture* pkFgProgressPic = new NDPicture;
    pkFgProgressPic->Initialization(pszFgProgressImageData,
                                    uiFgProgressDataSize);

    m_pkBackgroundImage->SetPicture(pkBgPicture);
    m_pkUnzipProgress->SetPicture(pkBgProgressPic, pkFgProgressPic);
    m_pkProgressBgImage->SetPicture(pkEffectPicture);
    m_pkUnzipTextImage->SetPicture(pkUnzipTextPicture);
    //m_pkUnzipTextImage->SetFrameRect(kUnzipTextRect);

    //m_pkUILayer->SetZOrder(1000);
    GetUIRootNew()->AddChild(m_pkUILayer);
    showProgress(false);
    m_pkUILayer->AddChild(m_pkBackgroundImage, 0);
    m_pkUILayer->AddChild(m_pkProgressBgImage, 2);
    m_pkUILayer->AddChild(m_pkUnzipProgress, 1);
}