//----------------------------------------------------------------------------------------------------------------------------------- void RacetrackScreen::AddLapNumberLabel(Color colour) { assert(m_maxLapNumber > 0); m_lapNumberLabel = new Label(Vector2(GetScreenDimensions().x * 0.9f, GetScreenDimensions().y * 0.1f), L"Lap Number: 0/" + std::to_wstring(m_maxLapNumber)); m_lapNumberLabel->SetColour(colour); AddScreenUIObject(m_lapNumberLabel, true, true); }
/*!*********************************************************************** @Function OnTouchUp @Access public @Param Touch * pTouches @Param Uint32 uiNum @Returns void @Description *************************************************************************/ void ViewGameFinished::OnTouchUp(Touch* pTouches, Uint32 uiNum) { if(m_eGUIState & enumGUISTATE_Off_Mask) return; // Scale touch to our local view coords (iPad or Retina) Float32 fCoordX = (Float32)GetScreenDimensions(false).x; Float32 fCoordY = (Float32)GetScreenDimensions(false).y; PVRTVec2 vTouchWorld((pTouches[0].fX / (Float32)GFX->GetDeviceWidth()) * fCoordX, (pTouches[0].fY / (Float32)GFX->GetDeviceHeight()) * fCoordY); PVRTVec2 vTouch = PVRTVec2(vTouchWorld.x, fCoordY - vTouchWorld.y); if(m_RectMainMenu.Contains(vTouch)) Close(); }
//----------------------------------------------------------------------------------------------------------------------------------- void BaseScreen::AddInitialUI() { // This has to be separate so we can draw it behind all the other objects m_background.reset(new Image(GetScreenDimensions(), GetScreenCentre(), m_baseScreenData->GetBackgroundAsset())); m_background->LoadContent(GetDevice()); m_background->SetShouldHaveCollider(false); AddScreenUIObject(new Label(Vector2(GetScreenCentre().x, GetScreenCentre().y * 0.25f), m_baseScreenData->GetDisplayName())); }
//_________________________________________________________________________ void PositionWindow (_HYGuiObject* twp, _String* args) { _List * argL = args->Tokenize (","); _HYWindow* tw = (_HYWindow*)twp; if (argL->lLength>=4) { long R[5], k; for (k=0; k<4; k++) { R[k] = ((_String*)(*argL)(k))->toNum(); } if (argL->lLength>4) { R[4] = ((_String*)(*argL)(4))->toNum(); } else { R[4] = 0; } _HYRect wR = GetScreenDimensions (), wiR; long W[4] = {wR.left,wR.top, wR.right, wR.bottom}; for (k=0; k<4; k++) if (R[k]<0) { R[k] = W[k] + ((k<2)?-1:1)*R[k]; } wiR.left = R[0]; wiR.right = R[2]; wiR.top = R[1]; wiR.bottom = R[3]; if (wiR.left>=wiR.right) { wiR.right = 1+wiR.left; } if (wiR.top>=wiR.bottom) { wiR.bottom = 1+wiR.top; } tw->SetPosition (wiR.left,wiR.top); tw->SetWindowRectangle (0,0,wiR.bottom-wiR.top,wiR.right-wiR.left); if (R[4]>0) { wiR.top = wiR.bottom+2; wiR.bottom = wR.bottom - 2; wiR.left = 5; wiR.right = wR.right - 2; MoveConsoleWindow (wiR); } } DeleteObject (argL); }
//________________________________________________________ void CenterWindow (_HYGuiObject* g) { _HYWindow* w = (_HYWindow*)g; _HYRect screen = GetScreenDimensions(); long cleft = 0, ctop = 0; if (screen.right>w->right) { cleft = (screen.right-w->right)/2; } if (screen.bottom>w->bottom) { ctop = (screen.bottom-w->bottom)/2; } w->_SetPosition (cleft,ctop); }
//----------------------------------------------------------------------------------------------------------------------------------- void GarageScreen::AddInitialUI() { BaseScreen::AddInitialUI(); for (const CarInfo& info : m_carInfos) { assert(info.second); AddScreenUIObject(info.second); } Button* chooseCarButton = new Button(Vector2(GetScreenCentre().x, GetScreenDimensions().y - 100), L"Drive Car"); chooseCarButton->SetClickFunction([this]() { //Transition(RacetrackScreenFactory::CreateRacetrack(GetScreenManager(), m_lessons[m_currentLesson].first)); }); AddScreenUIObject(chooseCarButton); }
//----------------------------------------------------------------------------------------------------------------------------------- void ChooseDrivingLessonScreen::AddInitialUI() { MenuScreen::AddInitialUI(); m_racetrackDescriptionContainer = new DescriptionUIContainer(GetDevice(), PlayerData::GetInstance().GetCurrentLicenseLevel()); AddScreenUIObject(m_racetrackDescriptionContainer); for (size_t index = 0, licenseLevel = PlayerData::GetInstance().GetCurrentLicenseLevel(); index <= licenseLevel; index++) { RacetrackDescriptionUI* racetrackUI = new RacetrackDescriptionUI(GetDevice(), m_lessons[index].second); m_racetrackDescriptionContainer->AddDescriptionUI(racetrackUI); } Button* playButton = new Button(Vector2(GetScreenCentre().x, GetScreenDimensions().y * 0.9f), L"Go Race"); playButton->SetClickFunction([this]() { std::string racetrackName(m_lessons[m_racetrackDescriptionContainer->GetCurrentUIIndex()].first); Transition(RacetrackScreenFactory::CreateRacetrack(GetScreenManager(), racetrackName)); }); AddScreenUIObject(playButton); }
//__________________________________________________________ _HYObjectInspector::_HYObjectInspector(void):_HYTWindow (objectInspectorTitle, false) { _HYRect canvasSettings = {30,50,30,50,HY_COMPONENT_NO_SCROLL}; _HYLabel* l1 = new _HYLabel (canvasSettings,GetOSWindowData()); canvasSettings.left = 110; canvasSettings.right = 10000; _HYPullDown* p1 = new _HYPullDown (canvasSettings,GetOSWindowData()); p1->EnableMenu(true); canvasSettings.left = canvasSettings.right = 90; _HYButtonBar* b1 = new _HYButtonBar(canvasSettings,GetOSWindowData()); canvasSettings.top = 20; canvasSettings.left = 250; canvasSettings.bottom = 10000; canvasSettings.width = HY_COMPONENT_V_SCROLL; _HYTable* ot = new _HYTable (canvasSettings,GetOSWindowData(),1,2,125,100,HY_TABLE_STATIC_TEXT); canvasSettings.width = HY_COMPONENT_NO_SCROLL|HY_COMPONENT_BORDER_B|HY_COMPONENT_BORDER_T; _HYTable* ot2 = new _HYTable (canvasSettings,GetOSWindowData(),1,2,125,20,HY_TABLE_STATIC_TEXT); ot->SetMessageRecipient (this); ot2->SetMessageRecipient (this); b1->SetMessageRecipient (this); p1->SetMessageRecipient (this); _String toolTipText ("Open window with the object"); b1->AddButton (ProcureIconResource(HY_DATAPANEL_ICON_ID+7),&toolTipText); toolTipText = "Delete selected object"; b1->AddButton (ProcureIconResource(HY_DATAPANEL_ICON_ID+3),&toolTipText); toolTipText = "Read object from file"; b1->AddButton (ProcureIconResource(HY_DATAPANEL_ICON_ID+8),&toolTipText); toolTipText = "Create new object"; b1->AddButton (ProcureIconResource(HY_DATAPANEL_ICON_ID+9),&toolTipText); b1->EnableButton(0,false); b1->EnableButton(1,false); b1->EnableButton(2,false); b1->EnableButton(3,false); b1->SetButtonDim(16); AddObject (l1); AddObject (ot); AddObject (ot2); AddObject (p1); AddObject (b1); SetTableDimensions (3,3); SetCell (0,0,b1); SetCell (0,1,p1); SetCell (0,2,p1); SetCell (1,0,ot2); SetCell (1,1,ot2); SetCell (1,2,ot2); SetCell (2,0,ot); SetCell (2,1,ot); SetCell (2,2,ot); _HYFont labelFont; #ifdef __WINDOZE__ labelFont.face = "MS Sans Serif"; labelFont.size = 10; #else #ifdef __HYPHY_GTK__ labelFont.face = _HY_SANS_FONT; labelFont.size = 12; #else labelFont.face = "Geneva"; labelFont.size = 14; #endif #endif labelFont.style = HY_FONT_PLAIN; l1->SetFont (labelFont); #ifdef __MAC__ labelFont.face = "Times"; labelFont.size = 12; #endif ot->SetFont (labelFont); ot2->SetFont (labelFont); l1->SetBackColor (boxBColor); p1->SetBackColor (boxBColor); b1->SetBackColor (boxBColor); l1->SetForeColor (boxFColor); l1->SetAlignFlags (HY_ALIGN_LEFT); l1->SetShadow(true); p1->SetAlignFlags (HY_ALIGN_LEFT); b1->SetAlignFlags (HY_ALIGN_LEFT); ot->selectionType = HY_TABLE_SEL_ROWS|HY_TABLE_DONT_SIZE|HY_TABLE_FOCUSABLE ; ot2->selectionType = HY_TABLE_SEL_ROWS|HY_TABLE_DONT_SIZE; _String cellValue ("Object ID"); ot2->SetCellData (&cellValue,0,0,HY_TABLE_BOLD|HY_TABLE_STATIC_TEXT|HY_TABLE_BEVELED|HY_TABLE_CANTSELECT|HY_TABLE_PULLDOWN,true); cellValue = "Object Info"; ot2->SetCellData (&cellValue,0,1,HY_TABLE_STATIC_TEXT|HY_TABLE_BEVELED|HY_TABLE_CANTSELECT|HY_TABLE_BOLD,true); l1->SetText (_String(" Class")); p1->AddMenuItem ("Trees",-1); p1->AddMenuItem ("Data Sets",-1); p1->AddMenuItem ("Models",-1); p1->AddMenuItem ("Likelihood Functions",-1); p1->ChangeSelection (objectInspectorObjClass,false); if (objectInspectorRect.width<0) { _HYRect screenRect = GetScreenDimensions(); SetWindowRectangle (0,0,screenRect.bottom-50,screenRect.right-20); SetPosition (screenRect.right-260,60); objectInspectorRect = GetWindowRect (); } firstTime = true; //p1->EnableItem (2,false); DeleteObject (l1); DeleteObject (p1); DeleteObject (ot); DeleteObject (b1); lastKillID = 0; }
//----------------------------------------------------------------------------------------------------------------------------------- void LevelDesignScreen::AddInitialUI() { BaseScreen::AddInitialUI(); // Add tilemap outlines to indicate size // Left vertical AddInGameUIObject(new UIObject(Vector2(4, m_tilemapDimensions.y * m_tileDimensions.y), Vector2(-2 + 0.5f * m_tileDimensions.x, 0.5f * (m_tilemapDimensions.y + 1) * m_tileDimensions.y), "GridLine.png")); // Right vertical AddInGameUIObject(new UIObject(Vector2(4, m_tilemapDimensions.y* m_tileDimensions.y), Vector2((m_tilemapDimensions.x + 0.5f) * m_tileDimensions.x + 2, 0.5f * (m_tilemapDimensions.y + 1) * m_tileDimensions.y), "GridLine.png")); // Top horizontal AddInGameUIObject(new UIObject(Vector2(m_tilemapDimensions.x* m_tileDimensions.x, 4), Vector2(0.5f * (m_tilemapDimensions.x + 1) * m_tileDimensions.x, -2 + m_tileDimensions.y * 0.5f), "GridLine.png")); // Bottom horizontal AddInGameUIObject(new UIObject(Vector2(m_tilemapDimensions.x * m_tileDimensions.x, 4), Vector2(0.5f * (m_tilemapDimensions.x + 1) * m_tileDimensions.x, (m_tilemapDimensions.y + 0.5f) * m_tileDimensions.y + 2), "GridLine.png")); int tileNumber = 1; // Used to move things onto a new row if they spill over the screen edges int rowNumber = 1; float padding = 10; Vector2 buttonSize(30, 30); // Set up the clickable tiles to change the current tile for (const std::string& tileAsset: m_tileTextureAssets) { // Stops images spilling over the edge and instead puts them on a new row if (tileNumber * (buttonSize.x + padding) > GetScreenDimensions().x - 1 * (buttonSize.x + padding)) { tileNumber = 1; rowNumber++; } ClickableImage* tileSelect = new ClickableImage(buttonSize, Vector2(tileNumber * (buttonSize.x + padding), rowNumber * (buttonSize.y + padding)), tileAsset); ScreenManager* screenManager = GetScreenManager(); tileSelect->SetClickFunction([this, tileSelect, screenManager]() { RemoveInGameUIObject(m_currentTile); m_currentTile = new Image(screenManager->GetGameMouse().GetInGamePosition(), tileSelect->GetDataAsset()); AddInGameUIObject(m_currentTile, true, true); screenManager->GetGameMouse().Flush(); }); AddScreenUIObject(tileSelect); tileNumber++; } // Label for the object type m_objectTypeLabel = new Label(GetScreenDimensions() - Vector2(200, 100), L"Normal Tile"); AddScreenUIObject(m_objectTypeLabel); // Button for serializing the level data Button* serializeButton = new Button(GetScreenDimensions() - Vector2(250, 150), L"Serialize"); serializeButton->SetClickFunction([this]() { SerializeLevel(); }); AddScreenUIObject(serializeButton); Button* deserializeButton = new Button(Vector2(250, GetScreenDimensions().y - 150), L"Deserialize"); deserializeButton->SetClickFunction([this]() { DeserializeLevel(); }); AddScreenUIObject(deserializeButton); Button* clearAllButton = new Button(Vector2(GetScreenDimensions() - Vector2(500, 150)), L"Clear All Tiles"); clearAllButton->SetClickFunction([this]() { GetInGameUIObjects()->DieAll(); }); AddScreenUIObject(clearAllButton); }
/*!*********************************************************************** @Function OnForeground @Access public @Returns void @Description *************************************************************************/ void ViewGameFinished::OnForeground() { // Screen coordinates for Menu are in Retina iPhone (i.e 960 x 640) Sint32 ViewW = GetScreenDimensions(false).x; Sint32 ViewH = GetScreenDimensions(false).y; Sint32 ViewHW = ViewW / 2; //GraphicsSystem* pGfx = GetApp()->GetGraphicsSystem(); TXChar szBuffer[256]; m_Messages.resize(5); m_Messages[0].Set(GWSTR(enumSTRING_GameOver), false, false, 0.001f); m_Messages[0].Layout(m_FontTitle, Vector2i(ViewHW, ViewH-60), enumTEXTJUSTIFY_Centre); sprintf(szBuffer, GWSTR(enumSTRING_XWins), m_pWinner->GetName()); m_Messages[1].Set(szBuffer, false, false, 0.001f); m_Messages[1].Layout(m_FontMenu, Vector2i(ViewHW, ViewH-200), enumTEXTJUSTIFY_Centre); if(m_GameData.m_uiNumPlayers == 1) { sprintf(szBuffer, GWSTR(enumSTRING_ScoreX), m_GameData.m_pPlayers[enumPLAYER_1]->GetScore()); m_Messages[2].Set(szBuffer, false, false, 0.001f); m_Messages[2].Layout(m_FontMenu, Vector2i(100, ViewH-280), enumTEXTJUSTIFY_Left); sprintf(szBuffer, GWSTR(enumSTRING_BestScoreX), m_GameData.m_pPlayers[enumPLAYER_1]->GetScore()); m_Messages[3].Set(szBuffer, false, false, 0.001f); m_Messages[3].Layout(m_FontMenu, Vector2i(100, ViewH-320), enumTEXTJUSTIFY_Left); } else { char szSprintfBuf[256]; if(m_GameData.m_eGameType == enumGWGAMETYPE_Rounds) // Print Rounds Won for each player { sprintf(szSprintfBuf, "%s %s", GWSTR(enumSTRING_Player1), GWSTR(enumSTRING_RoundsWonX)); sprintf(szBuffer, szSprintfBuf, m_GameData.m_pPlayers[enumPLAYER_1]->GetRoundsWon()); m_Messages[2].Set(szBuffer, false, false, 0.001f); m_Messages[2].Layout(m_FontMenu, Vector2i(100, ViewH-280), enumTEXTJUSTIFY_Left); sprintf(szSprintfBuf, "%s %s", GWSTR(enumSTRING_Player2), GWSTR(enumSTRING_RoundsWonX)); sprintf(szBuffer, szSprintfBuf, m_GameData.m_pPlayers[enumPLAYER_2]->GetRoundsWon()); m_Messages[3].Set(szBuffer, false, false, 0.001f); m_Messages[3].Layout(m_FontMenu, Vector2i(100, ViewH-320), enumTEXTJUSTIFY_Left); } else // Print Score for each player { sprintf(szSprintfBuf, "%s %s", GWSTR(enumSTRING_Player1), GWSTR(enumSTRING_ScoreX)); sprintf(szBuffer, szSprintfBuf, m_GameData.m_pPlayers[enumPLAYER_1]->GetScore()); m_Messages[2].Set(szBuffer, false, false, 0.001f); m_Messages[2].Layout(m_FontMenu, Vector2i(100, ViewH-280), enumTEXTJUSTIFY_Left); sprintf(szSprintfBuf, "%s %s", GWSTR(enumSTRING_Player2), GWSTR(enumSTRING_ScoreX)); sprintf(szBuffer, szSprintfBuf, m_GameData.m_pPlayers[enumPLAYER_2]->GetScore()); m_Messages[3].Set(szBuffer, false, false, 0.001f); m_Messages[3].Layout(m_FontMenu, Vector2i(100, ViewH-320), enumTEXTJUSTIFY_Left); } } m_Messages[4].Set(GWSTR(enumSTRING_MainMenu), true, false, 0.01f); m_Messages[4].Layout(m_FontMenu, Vector2i(100, 100), enumTEXTJUSTIFY_Left); m_Messages[0].pNext = &m_Messages[1]; m_Messages[1].pNext = &m_Messages[2]; m_Messages[2].pNext = &m_Messages[3]; m_Messages[3].pNext = &m_Messages[4]; m_MsgRoot = &m_Messages[0]; // --- Set Main Menu button rect m_RectMainMenu.m_fX = 100.0f; m_RectMainMenu.m_fW = m_RectMainMenu.m_fX + 250.0f; m_RectMainMenu.m_fY = 94.0f; m_RectMainMenu.m_fH = m_RectMainMenu.m_fY + 36.0f; }