int main (int argc, const char * argv[]) { string errorMessage = ""; UserInterface ui = UserInterface(); bool startupSucceeded = ui.start(errorMessage); bool continueProgram = true; if(startupSucceeded) { while(continueProgram) { continueProgram = ui.menuLoginScreen(); if(continueProgram) { //system("CLS"); ui.mainMenu(); } } } else { cout << errorMessage << endl; } ui.save(); return 0; }
HelpScreen::HelpScreen(void) : Level(LEVEL_MENU, UserInterface()) { int windowWidth = GameApp::getInstance()->getWindowWidth(); int windowHeight = GameApp::getInstance()->getWindowHeight(); setProjectionMatrix(Matrix4::Perspective(1.0f, -100.0f, 1280.0f / 720.0f, 45.0f)); setCameraMatrix(Matrix4::Translation(Vector3(0, 0, 0))); Texture *bgTexture = Texture::getOrCreate("InstructionsBg", "resources/images/HeXcape Instructions.png"); ImageItem *background = new ImageItem(Vector2(), 0, Vector2((float) (windowWidth), (float) (windowHeight)), bgTexture); userInterface->addItem(background, "BackgroundHelp"); // Create the menu buttons ButtonItem *backButton = new ButtonItem(Vector2(900, 840), 0, Vector2(800, 120), "MenuButton", "resources/images/MenuButton.png", "resources/images/MenuButtonHov.png", "resources/images/MenuButtonPress.png", "resources/images/MenuButtonPress.png"); // Draw some text over the buttons background TextItem *backText = new TextItem(Vector2(1020, 860), 0, "Back To Menu", 72); backText->setFont("resources/fonts/Neuropol.ttf"); actionAfterFade = 0; // Set the ambience music Music *music = Music::getOrCreate("resources/audio/Doors.mp3", "MenuMusic"); userInterface->addItem(backButton, "ZBackButton"); userInterface->addItem(backText, "ZBackText"); }
HumanView::HumanView( void ) { m_pProcessManager = ENG_NEW ProcessManager; m_ViewId = gc_InvalidGameViewId; AttachLayout( shared_ptr<UserInterface>( ENG_NEW UserInterface( Resource( g_pApp->m_EngineOptions.GetGUILayoutFieName(), true ) ) ) ); if ( g_pApp->m_pEngineLogic->m_pWrold ) { m_pWorld = g_pApp->m_pEngineLogic->m_pWrold; Frustum frustum; Point screenSize = g_pApp->m_EngineOptions.GetScreenSize(); frustum.Init( ENG_PI / 4.0f, screenSize.x / screenSize.y, 0.1f, 2000.0f ); m_pCamera.reset( ENG_NEW CameraNode( Vec3(0.0f, 0.0f, 0.0f), // position in World Space Vec3( 0.0f, 0.0f, 1.0f), // look target Vec3( 0.0f, 1.0f, 0.0f) // Head is up (set to 0,-1,0 to look upside-down) , frustum ) ); ENG_ASSERT( m_pWorld && m_pCamera && _T("Out of memory") ); m_pWorld->AddChild( INVALID_ACTOR_ID, m_pCamera ); m_pWorld->SetCamera( m_pCamera ); } m_pController.reset( ENG_NEW EditorController( m_pCamera, 0, 0, true ) ); }
void Game::Run() { int iResult; userInterface = UserInterface(true); std::string myName = userInterface.InputPlayerName("your"); while (!mustShutdown) { Network::RemoteAddress param; switch (userInterface.MenuDialog()) { case UserInterface::ExitGame: { return; } case UserInterface::LocalGame: { server = new PentagoServer(PentagoServer::DEFAULT_PORT); if (!server->IsGood()) { userInterface.Show_CanNotStartServer(); delete server; server = 0; continue; } delete players[Player1]; delete players[Player2]; players[Player1] = new PlayerLocal(myName); players[Player2] = new PlayerLocal(userInterface.InputPlayerName("player 2")); param.addr = "127.0.0.1"; param.port = PentagoServer::DEFAULT_PORT; iResult = network.Connect(¶m, players, (char) PlayerBoth); if (iResult == 0) { PlayGame(); } else { userInterface.Show_CanNotConnect(¶m); } delete server; server = 0; break; } case UserInterface::StartHost: { server = new PentagoServer(PentagoServer::DEFAULT_PORT); if (!server->IsGood()) { userInterface.Show_CanNotStartServer(); delete server; server = 0; continue; } delete players[Player1]; delete players[Player2]; players[Player1] = new PlayerLocal(myName); players[Player2] = new PlayerNetwork(""); param.addr = "127.0.0.1"; param.port = PentagoServer::DEFAULT_PORT; iResult = network.Connect(¶m, players, Player1); if (iResult == 0) { if (network.WaitForConnection()) { PlayGame(); } else { //TODO: complete it } } else { userInterface.Show_CanNotConnect(¶m); } delete server; server = 0; break; } case UserInterface::ConnectToServer: { if (userInterface.GetHostAddress(¶m)) { delete players[Player2]; delete players[Player1]; players[Player1] = new PlayerNetwork(""); players[Player2] = new PlayerLocal(myName); iResult = network.Connect(¶m, players, Player2); if (iResult == 0) { PlayGame(); } else { userInterface.Show_CanNotConnect(¶m); } } break; } } } }