prebattlescene.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "gui/prebattlescene.h"
  2. #include "player.h"
  3. #include "playermanager.h"
  4. #include "race.h"
  5. #include "racemanager.h"
  6. #include "gui/raceicon.h"
  7. #include "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 (int 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 (int 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. }
  53. void PreBattleScene::on_start_battle_clicked()
  54. {
  55. QMessageBox msg(QMessageBox::Information, "Нельзя сотворить здесь!", "Не ну имейте терпение! Всё будет! Но попозже... :)");
  56. msg.exec();
  57. GuiSceneManager::getInstance().changeScene("main_menu");
  58. }