void MainWindow::setMainWindowVisible(QObject *section) { //recreate Main Window with interface after we click BACK in sections delete section; scene->clear(); setMainMenu(); }
void MainWindow::setMainWindow() { //sets scene of main window with fixed size of window scene = new CustomScene(this); scene->setSceneRect(0,0,1200,620); setFixedSize(1200,620); //sets view as a central widget view = new QGraphicsView(scene); setCentralWidget(view); //sets background image ( german flag) scene->setBackgroundBrush(apperiance->brushMainMenuTexture.texture().scaled(QSize(1200,620),Qt::IgnoreAspectRatio)); //sets main menu buttons setMainMenu(); }
//void bool coreMenu::displayGameMenu(SDL_Surface* displaySurface, SDL_Event* Event) { int x=0,y=0; setMainMenu(true); if(getMainMenu() == true) { //Draw the main menu to the screen coreSurface::onDraw(displaySurface, mainMenu, 0,0); //Mouse out is default button displayed in main menu coreSurface::onDraw(displaySurface, exitButtonSheet, 507,230, 125,0,125,96); //Exit coreSurface::onDraw(displaySurface, optionsButtonSheet, 382,277, 125,0,125,96); //Options coreSurface::onDraw(displaySurface, scoreButtonSheet, 257,230, 125,0,125,96); //Score coreSurface::onDraw(displaySurface, loadButtonSheet, 132,277, 125,0,125,96); //Load coreSurface::onDraw(displaySurface, startButtonSheet, 7,230, 125,0,125,96); //Start //If the mouse moved if(Event->type == SDL_MOUSEMOTION) { //Get the mouse offsets x = Event->motion.x; y = Event->motion.y; //If the mouse is over the exit button if( ( x > 507 ) && ( x < 632 ) && ( y > 277 ) && ( y < 326 ) ) { coreSurface::onDraw(displaySurface, exitButtonSheet, 505,230, 0,0,125,96); //mouse over button } //If not else { //Set the button sprite coreSurface::onDraw(displaySurface, exitButtonSheet, 507,230, 125,0,125,96);//mouse out of button } //If the mouse is over the options button if( ( x > 382 ) && ( x < 507 ) && ( y > 277 ) && ( y < 326 ) ) { coreSurface::onDraw(displaySurface, optionsButtonSheet, 380,277, 0,0,125,96); //mouse over button } //If not else { //Set the button sprite coreSurface::onDraw(displaySurface, optionsButtonSheet, 382,277, 125,0,125,596);//mouse out of button } //If the mouse is over the score button if( ( x > 257 ) && ( x < 382 ) && ( y > 277 ) && ( y < 326 ) ) { coreSurface::onDraw(displaySurface, scoreButtonSheet, 256,230, 0,0,125,96); //mouse over button } //If not else { //Set the button sprite coreSurface::onDraw(displaySurface, scoreButtonSheet, 257,230, 125,0,125,96);//mouse out of button } //If the mouse is over the load button if( ( x > 132 ) && ( x < 257 ) && ( y > 277 ) && ( y < 326 ) ) { coreSurface::onDraw(displaySurface, loadButtonSheet, 131,278, 0,0,125,96); //mouse over button } //If not else { //Set the button sprite coreSurface::onDraw(displaySurface, loadButtonSheet, 132,277, 125,0,125,96);//mouse out of button } //If the mouse is over the start button if( ( x > 7 ) && ( x < 132 ) && ( y > 277 ) && ( y < 326 ) ) { coreSurface::onDraw(displaySurface, startButtonSheet, 7,230, 0,0,125,96); //mouse over button } //If not else { //Set the button sprite coreSurface::onDraw(displaySurface, startButtonSheet, 7,230, 125,0,125,96);//mouse out of button } } //If a mouse button was pressed if(Event->type == SDL_MOUSEBUTTONDOWN) { //If the left mouse button was pressed if( Event->button.button == SDL_BUTTON_LEFT ) { //Get the mouse offsets x = Event->button.x; y = Event->button.y; //If the mouse is over the options button if( ( x > 382 ) && ( x < 507 ) && ( y > 277 ) && ( y < 326 ) ) { //go to options/instruction menu setMainMenu(false); setOptionsMenu(true); } //If the mouse is over the exit button if( ( x > 507 ) && ( x < 632 ) && ( y > 277 ) && ( y < 326 ) ) { //Set the button sprite setMainMenu(false); isRunning = false; } //If the mouse is over the start button if( ( x > 7 ) && ( x < 132 ) && ( y > 277 ) && ( y < 326 ) ) { return false; } } } } if(getOptionsMenu() == true) { //Draw the options menu to the screen coreSurface::onDraw(displaySurface, optionsMenu, 0,0); //Display default mouse out button for back to the main menu coreSurface::onDraw(displaySurface, backButtonSheet, 257,374, 125,0,125,96); //If the mouse moved if(Event->type == SDL_MOUSEMOTION) { //Get the mouse offsets x = Event->motion.x; y = Event->motion.y; //If the mouse is over the back button if( ( x > 257 ) && ( x < 382 ) && ( y > 421 ) && ( y < 470 ) ) { //Set the button sprite coreSurface::onDraw(displaySurface, backButtonSheet, 255,374, 0,0,125,96); // mouse over button } //If not else { //Set the button sprite coreSurface::onDraw(displaySurface, backButtonSheet, 257,374, 125,0,125,96); // mouse out button } } //If a mouse button was pressed if( Event->type == SDL_MOUSEBUTTONDOWN) { //If the left mouse button was pressed if( Event->button.button == SDL_BUTTON_LEFT ) { //Get the mouse offsets x = Event->button.x; y = Event->button.y; //If the mouse is over the back button if( ( x > 257 ) && ( x < 382 ) && ( y > 421 ) && ( y < 470 ) ) { //Set the button sprite setMainMenu(true); setOptionsMenu(false); } } } } //If a key was pressed if(Event->type == SDL_KEYDOWN) { //If 9 was pressed if(Event->key.keysym.sym == SDLK_9 ) { //If there is no music playing if( Mix_PlayingMusic() == 0 ) { //Play the music Mix_PlayMusic( music, -1 ); } //If music is being played else { //If the music is paused if( Mix_PausedMusic() == 1 ) { //Resume the music Mix_ResumeMusic(); } //If the music is playing else { //Pause the music Mix_PauseMusic(); } } } //If 0 was pressed else if(Event->key.keysym.sym == SDLK_0 ) { //Stop the music Mix_HaltMusic(); } } //If X is pressed on corner of screen, quit the window if(Event->type == SDL_QUIT) { isRunning = false; } //FLIP BACKBUFFER SDL_Flip(displaySurface); return true; }