prebattlescene.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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("hotseatgame");
  59. }