mainmenu.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "main_menu/mainmenu.h"
  2. #include "gui/guiscenemanager.h"
  3. #include "soundengine.h"
  4. #include "ui_mainmenu.h"
  5. #include <QString>
  6. #include <QApplication>
  7. #include <QMovie>
  8. #include <QFileInfo>
  9. MainMenu::MainMenu(QWidget *parent) :
  10. Scene(parent),
  11. ui(new Ui::MainMenu)
  12. {
  13. ui->setupUi(this);
  14. // Load animated GIF
  15. watcher = new ButtonEventListener(this);
  16. ui->hotseat_button->installEventFilter(watcher);
  17. ui->about_us_button->installEventFilter(watcher);
  18. ui->leave_game_button->installEventFilter(watcher);
  19. }
  20. MainMenu::~MainMenu()
  21. {
  22. delete ui;
  23. delete watcher;
  24. }
  25. void MainMenu::init()
  26. {
  27. SoundEngine::getInstance().playlist().addMedia(QUrl("qrc:/assets/main_menu/main_menu_music_1.mp3"));
  28. SoundEngine::getInstance().player().play();
  29. GuiSceneManager::getInstance().show("main_menu_background");
  30. raise();
  31. }
  32. void MainMenu::deinit()
  33. {
  34. }
  35. void MainMenu::on_hotseat_button_clicked() {
  36. GuiSceneManager::getInstance().changeScene("pvp_intro");
  37. }
  38. void MainMenu::on_leave_game_button_clicked() {
  39. QApplication::exit();
  40. }
  41. void MainMenu::on_about_us_button_clicked()
  42. {
  43. GuiSceneManager::getInstance().changeScene("about_us");
  44. }