x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
GameUI.cpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\DarkPuzzle\GameEngine\GameUI.cpp
Girar
Efecto
Propiedad
Historial
#pragma once //#include "DXUT.h" #include "DarkPuzzle.h" #include "GameUI.h" #include "ScriptEngine.h" namespace DarkBattle{ //extern ScriptEngine* theScriptEngine; GameUI* GameUI::theGameUI = NULL; GameUI::GameUI(IDirect3DDevice9* pd3dDevice):GameScreen(pd3dDevice){ isEditing = false; lastElapseTime=0; dialog.Init(&resourceManager); dialog.SetCallback(GameUI::myCallback); dialog.AddStatic(0,L"FrameRate: ",10,50,200,20); dialog.AddButton(1,L"ReloadCons",10,70,100,30); dialog.AddButton(3,L"ReInit",110,70,200,30); //dialog.AddEditBox(2,L"lua code here",10,10,300,40); CDXUTIMEEditBox* pCommandEditBox; CDXUTIMEEditBox::InitDefaultElements( &dialog ); HRESULT hr = CDXUTIMEEditBox::CreateIMEEditBox(&dialog,2,L"lua code here",10,10,300,40,false,&pCommandEditBox); assert(SUCCEEDED(hr)); dialog.AddControl(pCommandEditBox); CDXUTIMEEditBox::SetImeEnableFlag( true ); //create the device resource resourceManager.OnD3D9CreateDevice(pd3dDevice); GameUI::theGameUI = this; }; void GameUI::OnFrameMove(float elapsedTime){ lastElapseTime = elapsedTime; wchar_t* buf = new wchar_t[100]; swprintf(buf,L"%f",DXUTGetFPS()); wstring str= L"Framerate: "; #ifdef _DEBUG wchar_t* buf2 = new wchar_t[100]; PROCESS_MEMORY_COUNTERS pmc; assert(GetProcessMemoryInfo(GetCurrentProcess(),&pmc,sizeof(pmc))==true); swprintf(buf2,L"%d",pmc.WorkingSetSize/1024); #endif // _DEBUG str.append(buf); #ifdef _DEBUG str.append(wstring(L" mem: ")); str.append(buf2); #endif // _DEBUG ((CDXUTStatic*)dialog.GetControl(0))->SetText(str.c_str()); SAFE_DELETE_ARRAY(buf); #ifdef _DEBUG SAFE_DELETE_ARRAY(buf2); #endif // _DEBUG }; LPSTR UnicodeToAnsi(LPCWSTR s) { if (s==NULL) return NULL; int cw=lstrlenW(s); if (cw==0) {CHAR *psz=new CHAR[1];*psz='\0';return psz;} int cc=WideCharToMultiByte(CP_ACP,0,s,cw,NULL,0,NULL,NULL); if (cc==0) return NULL; CHAR *psz=new CHAR[cc+1]; cc=WideCharToMultiByte(CP_ACP,0,s,cw,psz,cc,NULL,NULL); if (cc==0) {delete[] psz;return NULL;} psz[cc]='\0'; return psz; } VOID CALLBACK GameUI::myCallback ( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ){ if (nControlID==1){ if (nEvent==EVENT_BUTTON_CLICKED){ ScriptEngine::GetInstance()->ReLoadConstants(); } }else if (nControlID==2){ if (nEvent==EVENT_EDITBOX_STRING){ char* command = UnicodeToAnsi(((CDXUTEditBox*)pControl)->GetText()); ScriptEngine::GetInstance()->ExecuteString(command); SAFE_DELETE_ARRAY(command); GameUI::GetInstance()->isEditing = false; }else if (nEvent==EVENT_EDITBOX_CHANGE){ GameUI::GetInstance()->isEditing = true; } }else if (nControlID==3){ if (nEvent==EVENT_BUTTON_CLICKED){ ScriptEngine::GetInstance()->Initialize(); } } } GameUI* GameUI::GetInstance(){ return GameUI::theGameUI; } }
GameUI.cpp
Dirección de la página
Dirección del archivo
Anterior
46/65
Siguiente
Descargar
( 2 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.