void Level::update(sf::Time interval) { if (!m_game->IsFocus() && !m_paused) { auto pauseScreen = GetUi()->GetChildByID("paused"); if (pauseScreen) { m_paused = true; pauseScreen->SetActive(true); } } if (sf::Keyboard::isKeyPressed(sf::Keyboard::R)) { m_next = m_filename; Next(); return; } if (m_paused) { m_ui->update(interval); if (m_game->IsFocus() && sf::Mouse::isButtonPressed(sf::Mouse::Right)) { m_paused = false; auto pauseScreen = GetUi()->GetChildByID("paused"); if (pauseScreen) { pauseScreen->SetActive(false); } } } else { engine::Node::update(interval); } }
void Level::update(sf::Time interval) { if (!m_game->IsFocus() && !m_paused) { m_paused = true; GetUi()->GetChildByID("paused")->SetActive(true); } if (m_paused) { m_ui->update(interval); if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) { m_paused = false; GetUi()->GetChildByID("paused")->SetActive(false); } } else { engine::Scene::update(interval); } }
void FnResourcesCallbackCreate(const string& sPathname, void* pvCallbackData) { static bool b = true; if ( b ) { b = false; SDL_SysWMinfo wmi = { 0 }; SDL_GetWMInfo(&wmi); SetWindowPos(wmi.window, HWND_TOP, NULL, NULL, NULL, NULL, SWP_NOMOVE|SWP_NOREPOSITION |SWP_NOSIZE); GetRender()->BeginProjection(eProjectionOrtho); { // GetUi()->FindWindow("splash")->FindChild("frame")->FindChild("frame")->FindChild("image")->ResizeBy(CVec2i(GetRandom(-2, 2), GetRandom(-2,2))); GetGlue()->HandleScript("[ui.splash.frame.frame.loading set text:'loading %s']", sPathname.c_str()); GetUi()->Render(); } GetRender()->EndProjection(eProjectionOrtho); GetRender()->Swap(); GetRender()->Update(); b = true; } }
void CAppBase::Release() { if ( 0 != --m_cRef ) return; GetInput()->Release(); GetClasses()->Release(); GetUi()->Release(); GetRender()->Release(); GetVideo()->Release(); GetResources()->Release(); GetGlue()->RemoveGlued(this); GetGlue()->Release(); }
void CBEdit::OnFocus(bool bIsFocus) { CAwsWindow::OnFocus(bIsFocus); if ( m_bIsFocus ) { // ¼¤»îÊäÈë·¨ GetUi()->ActiveIME(); // ÏÔʾ²åÈë·û ShowCaret(); } else { // ¹Ø±ÕÊäÈë·¨ GetUi()->InactiveIME(); // Òþ²Ø²åÈë·û HideCaret(); } Invalide(); }
void CAppBase::Update() { GetTime()->Update(); GetInput()->Update(); GetResources()->Update(); // GetNetwork()->Update(); GetObjects()->Update(); GetUi()->Update(); GetRender()->Update(); // if ( !s_pAcre ) // { // s_pAcre = IAcre::Create("terrain/0_0.acre"); // } }
Handled HandleMouseButtonUp(uint32 iButton, const CVec2i& vPos) { if ( 0 == iButton ) { if ( eStateDown == m_eState ) { GetUi()->ReleaseCapture(this); GetGlue()->HandleScript(m_sOnUnpress); m_eState = eStateUp; return eHandled; } } return super::HandleMouseButtonUp(iButton, vPos); }
Handled HandleMouseButtonDown(uint32 iButton, const CVec2i& vPos) { if ( 0 == iButton ) { if ( vPos.x >= 0 && vPos.x <= m_vDims.x && vPos.y >= 0 && vPos.y <= m_vDims.y ) { GetUi()->SetCapture(this); GetGlue()->HandleScript(m_sOnPress); m_eState = eStateDown; return eHandled; } } return super::HandleMouseButtonDown(iButton, vPos); }
IAwsGc* CAwsWindow::GetGc() { // 获取Gc IAwsGc* pGc = ESP_NULL; CAwsUi* pUi = GetUi(); if ( ESP_NULL != pUi ) { pGc = pUi->GetSysGc(); if ( ESP_NULL != pGc ) { CEspPoint pt = GetOrigin(); pGc->SetOrigin(pt); } } return pGc; }
void CMMenuBar::OnCreate() { // 重新设置菜单条的大小 CEspSize size = GetUi()->GetScreenSize(); m_tRect.m_ptLT.m_nX = 0; m_tRect.m_ptLT.m_nY = size.m_nHeight - m_nMenuBarHeight; m_tRect.m_ptRB.m_nX = m_tRect.m_ptLT.m_nX + size.m_nWidth; m_tRect.m_ptRB.m_nY = size.m_nHeight; m_tOrigin = m_tRect.m_ptLT; CAwsString strText; CEspRect rt(1, 1 + 3, m_nBarUnitWidth + 1, m_tRect.GetSize()->m_nHeight - 1 - 3); m_pLeftBar = new CBLabel; m_pLeftBar->Create(this, rt); m_pLeftBar->SetTextColor(m_oTextColor); m_pLeftBar->SetTextAlignment(AWS_TAM_Left); m_pLeftBar->SetTextSize(m_nFontSize); m_pLeftBar->SetBKTransparent(true); strText.LoadString(1); m_pLeftBar->SetText(strText); AddSubWnd(m_pLeftBar); if ( ESP_NULL != m_pMidCtrl ) { CEspRect rt(m_nBarUnitWidth, 0, m_tRect.m_ptRB.m_nY - m_nBarUnitWidth, m_tRect.m_ptRB.m_nY); m_pMidCtrl->Create(this, rt); AddSubWnd(m_pMidCtrl); } CEspRect rect(m_tRect.GetSize()->m_nWidth - m_nBarUnitWidth - 1, 1 + 3, m_tRect.GetSize()->m_nWidth - 1, m_tRect.GetSize()->m_nHeight - 1 - 3); m_pRightBar = new CBLabel; m_pRightBar->Create(this, rect); m_pRightBar->SetTextColor(m_oTextColor); m_pRightBar->SetTextAlignment(AWS_TAM_Right); m_pRightBar->SetBKTransparent(true); m_pRightBar->SetTextSize(m_nFontSize); strText.LoadString(2); m_pRightBar->SetText(strText); AddSubWnd(m_pRightBar); }
void CAppBase::Acquire() { if ( 1 != ++m_cRef ) return; GetGlue()->Acquire(); GetGlue()->AddGlued(this); GetResources()->Acquire(); GetVideo()->Acquire(); GetVideo()->SetWidth(800); GetVideo()->SetHeight(600); GetVideo()->ApplySettings(); GetRender()->Acquire(); GetUi()->Acquire(); GetClasses()->Acquire(); GetInput()->Acquire(); // OLD STUFF CGuid Guid; Guid.Create(); NETWORKINITSTRUCT nis; nis.Guid = Guid; // if ( !GetNetwork()->Init(nis) ) // { // return -1; // } OBJECTSINITSTRUCT ois; ois.bServer = true; if ( !GetObjects()->Init(ois) ) { return; } }
void CAwsWindow::PumpCommand(int nWndID, int nCmdID, int nParam1 /*= 0*/, int nParam2 /*= 0*/) { GetUi()->CommandRouter(nWndID, nCmdID, nParam1, nParam2); }
void CAwsWindow::EndTimer() { GetUi()->EndTimer(this); }
bool CAwsWindow::StartTimer(int nTimer) { return GetUi()->StartTimer(this, nTimer); }
void CAwsWindow::PostCommand(int nWndID, int nCmdID, int nParam1 /*= 0*/, int nParam2 /*= 0*/) { GetUi()->AddPostCommand(nWndID, nCmdID, nParam1, nParam2); }
void CAppBase::Run() { m_bRunning = true; SDL_Init(0); SDL_ShowCursor(FALSE); GetUi()->HideCursor(); GetUi()->MakeLayout("layouts/1024x768/splash.layout"); GetResources()->SetCallbackCreate(FnResourcesCallbackCreate, NULL); GetGlue()->HandleScript("[ui.splash.frame.frame.build set text:'build %s %s']", __DATE__, __TIME__); for ( int i = 0 ; i < 3 ; ++i ) { GetRender()->BeginProjection(eProjectionOrtho); { GetUi()->Render(); } GetRender()->EndProjection(eProjectionOrtho); GetRender()->Swap(); GetRender()->Update(); } SDL_SysWMinfo wmi = { 0 }; SDL_GetWMInfo(&wmi); SDL_WM_SetCaption("newLauncher", "null"); // IIni* pIni = IIni::Create("peers.ini"); string sPeer = pIni->GetGroup("peers")->GetString("peer"); GetNetwork()->Connect(sPeer, 8001); RELEASE(pIni); // GetVideo()->SetWidth(1024); // GetVideo()->SetHeight(768); // GetVideo()->ApplySettings(); GetUi()->MakeLayout("layouts/1024x768/default.layout"); GetResources()->SetCallbackCreate(NULL, NULL); GetUi()->ShowCursor(); GetGlue()->HandleScript("[ui.windows show]"); GetGlue()->HandleScript("[ui.splash fadeout]"); list<float> listTimes; while ( m_bRunning ) { static float s_fTime = GetTime()->GetTime(); Update(); Render(); float fTime = GetTime()->GetTime(); if ( listTimes.size() > 60 ) { listTimes.pop_front(); } listTimes.push_back(fTime-s_fTime); float fTotalTime = 0; for ( list<float>::iterator iter = listTimes.begin() ; iter != listTimes.end() ; ++iter ) { fTotalTime += *iter; } GetGlue()->HandleScript("[ui.windows.fps set text:'%f fps']", float(listTimes.size())/fTotalTime); s_fTime = fTime; } SDL_Quit(); }
void CAppBase::Render() { // SDL_SysWMinfo wmi = { 0 }; // SDL_GetWMInfo(&wmi); // SetWindowPos(wmi.window, HWND_TOPMOST, NULL, NULL, NULL, NULL, SWP_NOREPOSITION |SWP_NOSIZE); CCamera Camera; Camera.SetViewportDims(CVec2i(GetVideo()->GetWidth(), GetVideo()->GetHeight())); GetRender()->SetCamera(&Camera); CVec3f vDirection; vDirection.Point(g_fAzimuth, g_fElevation); Camera.SetDirection(-vDirection); CVec3f vPosition(0,0,0); vDirection *= g_fZoom; Camera.SetPosition(vPosition+vDirection+CVec3f(160,0,160)); // Camera.SetFOV(60.0f); // Camera.SetAspectRatio(4.0f/3.0f); static ITube* s_pTube = NULL; if ( !s_pTube ) { s_pTube = ITube::Create(); s_pTube->SetShader("shaders/tube.shader"); CVec3f vPoint(0,0,0); for ( int i = 0 ; i < 100 ; ++i ) { s_pTube->AddControlPoint(CVec3f(160+20.0f*sin(float(i)/10.0f), i, (160+20.0f*cos(float(i)/10.0f)))); } } GetRender()->BeginProjection(eProjectionPerspective); { GetRender()->BeginRenderPass(eRenderPassAccum); { GetScene()->Render3d(); GetRender()->RenderTube(s_pTube); } GetRender()->EndRenderPass(eRenderPassAccum); GetRender()->BeginRenderPass(eRenderPassNormal); { GetScene()->Render3d(); GetRender()->RenderTube(s_pTube); static bool once = true; static CVec3f vSrc; static CVec3f vDest; // if ( once ) { vSrc = GetRender()->Unproject(NULL, g_vMousePos, 10.0f); vDest = GetRender()->Unproject(NULL, g_vMousePos, 10000.0f); once=false; } CVec3f vDir = vDest-vSrc; vDir.Normalize(); IObject* pObject = NULL; if ( pObject = GetScene()->PickObject(vSrc, vDir) ) { Debug("Picked %s", pObject->GetClass()->GetClassDef()->GetName().c_str()); } CPlane3f plane(CVec3f(0,1,0), 0.0f); if ( plane.IntersectRay(CRay3f(vSrc, vDir), &g_vCursor3d) ) { // Debug("x,y,z = %f,%f,%f", g_vCursor3d.x, g_vCursor3d.y, g_vCursor3d.z); } else { // Debug("..."); } // GetRender()->RenderLine(CVec3f(160,0,160), vDest, CRGBA(255,255,0,255)); // GetRender()->RenderLine(CVec3f(0,0,0), vDest, CRGBA(0,255,0,255)); // GetRender()->RenderModelSkinned(&s_ModelSkinned); } GetRender()->EndRenderPass(eRenderPassNormal); } GetRender()->EndProjection(eProjectionPerspective); GetRender()->BeginProjection(eProjectionOrtho); { GetUi()->Render(); } GetRender()->EndProjection(eProjectionOrtho); GetRender()->SetCamera(NULL); GetRender()->Swap(); }