PreBattleScene.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "hotseatgame/gui/PreBattleScene.h"
  2. #include "Player.h"
  3. #include "PlayerManager.h"
  4. #include "Race.h"
  5. #include "RaceManager.h"
  6. #include "hotseatgame/gui/RaceIcon.h"
  7. #include "hotseatgame/gui/UnitIcon.h"
  8. #include "gui/GuiSceneManager.h"
  9. #include "ui_PreBattleScene.h"
  10. #include <QMessageBox>
  11. PreBattleScene::PreBattleScene(QWidget *parent) :
  12. Scene(parent),
  13. ui(new Ui::PreBattleScene)
  14. {
  15. ui->setupUi(this);
  16. }
  17. PreBattleScene::~PreBattleScene()
  18. {
  19. delete ui;
  20. }
  21. void PreBattleScene::init() {
  22. Player *player = PlayerManager::getInstance().getPlayer(0);
  23. ui->race_icon_1_->setRaceIcon(player->getRace()->getRaceIcon());
  24. ui->race_icon_1_->resize(128, 128);
  25. ui->race_icon_1_->setState(5);
  26. units_player_1_.resize(10);
  27. auto units = player->getUnitsAsVector();
  28. for (unsigned i = 0; i < 10; i++) {
  29. units_player_1_[i] = new UnitIcon();
  30. if (i < units.size())
  31. units_player_1_[i]->setUnitIcon(units[i]->getUnitIcon());
  32. else
  33. units_player_1_[i]->setUnitIcon("norace", "nounit");
  34. units_player_1_[i]->setState(5);
  35. ui->units_player_1_layout_->addWidget(units_player_1_[i], i / 5, i % 5);
  36. }
  37. player = PlayerManager::getInstance().getPlayer(1);
  38. ui->race_icon_2_->setRaceIcon(player->getRace()->getRaceIcon());
  39. ui->race_icon_2_->resize(128, 128);
  40. ui->race_icon_2_->setState(5);
  41. units_player_2_.resize(10);
  42. units = player->getUnitsAsVector();
  43. for (unsigned i = 0; i < 10; i++) {
  44. units_player_2_[i] = new UnitIcon();
  45. if (i < units.size())
  46. units_player_2_[i]->setUnitIcon(units[i]->getUnitIcon());
  47. else
  48. units_player_2_[i]->setUnitIcon("norace", "nounit");
  49. units_player_2_[i]->setState(5);
  50. ui->units_player_2_layout_->addWidget(units_player_2_[i], i / 5, i % 5);
  51. }
  52. setWindowState(Qt::WindowFullScreen);
  53. }
  54. void PreBattleScene::on_start_battle_clicked()
  55. {
  56. //QMessageBox msg(QMessageBox::Information, "Нельзя сотворить здесь!", "Не ну имейте терпение! Всё будет! Но попозже... :)");
  57. //msg.exec();
  58. //GuiSceneManager::getInstance().changeScene("main_menu");
  59. GuiSceneManager::getInstance().showDetachedScene("hotseatgame");
  60. }