فهرست منبع

Added prebattle scene. Completed first aim-point.

Ivan Arkhipov 6 سال پیش
والد
کامیت
5a8ee66893

BIN
assets/common/icon.ico


BIN
assets/common/pergam.png


BIN
assets/pvp_intro/pre-battle1.jpg


+ 8 - 3
client.pro

@@ -41,7 +41,8 @@ SOURCES += \
     source/units/warrior.cpp \
     source/gui/scene.cpp \
     source/gui/raceicon.cpp \
-    source/playermanager.cpp
+    source/playermanager.cpp \
+    source/gui/prebattlescene.cpp
 
 HEADERS += \
     include/gui/uniticon.h \
@@ -60,13 +61,17 @@ HEADERS += \
     include/units/warrior.h \
     include/gui/scene.h \
     include/gui/raceicon.h \
-    include/playermanager.h
+    include/playermanager.h \
+    include/gui/prebattlescene.h
 
 FORMS += \
     include/gui/gui.ui \
     include/gui/recruitmentscene.ui \
     include/gui/mainmenu.ui \
-    include/gui/playervsplayerintro.ui
+    include/gui/playervsplayerintro.ui \
+    include/gui/prebattlescene.ui
 
 RESOURCES += \
     gui.qrc
+
+RC_ICONS = $$PWD/assets/common/icon.ico

+ 3 - 0
gui.qrc

@@ -757,5 +757,8 @@
         <file>assets/window/thick_opaque-border-top.png</file>
         <file>assets/window/thick_opaque-border-topleft.png</file>
         <file>assets/window/thick_opaque-border-topright.png</file>
+        <file>assets/common/icon.ico</file>
+        <file>assets/common/pergam.png</file>
+        <file>assets/pvp_intro/pre-battle1.jpg</file>
     </qresource>
 </RCC>

+ 35 - 0
include/gui/prebattlescene.h

@@ -0,0 +1,35 @@
+#ifndef PREBATTLESCENE_H
+#define PREBATTLESCENE_H
+
+#include <QWidget>
+
+#include "gui/scene.h"
+
+#include <vector>
+
+class UnitIcon;
+
+namespace Ui {
+class PreBattleScene;
+}
+
+class PreBattleScene : public Scene
+{
+    Q_OBJECT
+
+public:
+    explicit PreBattleScene(QWidget *parent = 0);
+    ~PreBattleScene();
+
+    void init() override;
+
+private slots:
+    void on_start_battle_clicked();
+
+private:
+    std::vector<UnitIcon*> units_player_1_;
+    std::vector<UnitIcon*> units_player_2_;
+    Ui::PreBattleScene *ui;
+};
+
+#endif // PREBATTLESCENE_H

+ 171 - 0
include/gui/prebattlescene.ui

@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreBattleScene</class>
+ <widget class="QWidget" name="PreBattleScene">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>940</width>
+    <height>720</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>10</y>
+     <width>981</width>
+     <height>651</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/common/pergam.png&quot; width=&quot;940&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>340</x>
+     <y>280</y>
+     <width>301</width>
+     <height>211</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/pvp_intro/pre-battle1.jpg&quot; width=&quot;300&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="units_player_2_" native="true">
+   <property name="geometry">
+    <rect>
+     <x>550</x>
+     <y>140</y>
+     <width>320</width>
+     <height>128</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="units_player_2_layout_">
+    <property name="leftMargin">
+     <number>0</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>0</number>
+    </property>
+    <property name="bottomMargin">
+     <number>0</number>
+    </property>
+    <property name="spacing">
+     <number>0</number>
+    </property>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="units_player_1_" native="true">
+   <property name="geometry">
+    <rect>
+     <x>110</x>
+     <y>140</y>
+     <width>320</width>
+     <height>128</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="units_player_1_layout_">
+    <property name="leftMargin">
+     <number>0</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>0</number>
+    </property>
+    <property name="bottomMargin">
+     <number>0</number>
+    </property>
+    <property name="spacing">
+     <number>0</number>
+    </property>
+   </layout>
+  </widget>
+  <widget class="QPushButton" name="start_battle">
+   <property name="geometry">
+    <rect>
+     <x>650</x>
+     <y>510</y>
+     <width>231</width>
+     <height>71</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>В бой!</string>
+   </property>
+  </widget>
+  <widget class="RaceIcon" name="race_icon_1_">
+   <property name="geometry">
+    <rect>
+     <x>110</x>
+     <y>300</y>
+     <width>128</width>
+     <height>128</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>TextLabel</string>
+   </property>
+  </widget>
+  <widget class="RaceIcon" name="race_icon_2_">
+   <property name="geometry">
+    <rect>
+     <x>710</x>
+     <y>300</y>
+     <width>128</width>
+     <height>128</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>TextLabel</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="title_1">
+   <property name="geometry">
+    <rect>
+     <x>110</x>
+     <y>80</y>
+     <width>320</width>
+     <height>61</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:24pt; color:#b12d2d;&quot;&gt;Игрок 1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="title_2">
+   <property name="geometry">
+    <rect>
+     <x>550</x>
+     <y>80</y>
+     <width>320</width>
+     <height>61</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:24pt; color:#b12d2d;&quot;&gt;Игрок 2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>RaceIcon</class>
+   <extends>QLabel</extends>
+   <header>gui/raceicon.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

+ 1 - 3
source/gui/gui.cpp

@@ -8,9 +8,7 @@ GUI::GUI(QWidget *parent) :
     ui_(new Ui::GUI), dx_(0), dy_(0)
 {
     ui_->setupUi(this);
-
-    //rq_scene_ = new RecruitmentScene(ui_->main_content_);   /// Инициализируем графическую сцену выбора юнитов
-    //rq_scene_->show();
+    setWindowTitle("Супер-мега-клёвая-игрушка-название-которой-мы-ещё-не-придумали");
 }
 
 GUI::~GUI()

+ 3 - 0
source/gui/guiscenemanager.cpp

@@ -3,6 +3,7 @@
 #include "gui/detatchedwidget.h"
 #include "gui/mainmenu.h"
 #include "gui/playervsplayerintro.h"
+#include "gui/prebattlescene.h"
 
 GuiSceneManager::GuiSceneManager(QObject *parent) : QObject(parent) {
     gui_ = new GUI();
@@ -12,6 +13,7 @@ GuiSceneManager::GuiSceneManager(QObject *parent) : QObject(parent) {
     registerScene("main_menu", new MainMenu(gui_->mainContentScene()));
     registerScene("pvp_intro", new PlayerVsPlayerIntro(gui_->mainContentScene()));
     registerScene("recruit_army", new RecruitmentScene(gui_->mainContentScene()));
+    registerScene("prebattle", new PreBattleScene(gui_->mainContentScene()));
 
     changeScene("main_menu");
 }
@@ -41,6 +43,7 @@ bool GuiSceneManager::changeScene(QString scene_name, QString args) {
         scenes_[current_scene_]->hide();
 
     scenes_[scene_name]->parseArgs(args);
+    scenes_[scene_name]->init();
     scenes_[scene_name]->show();
     current_scene_ = scene_name;
     return true;

+ 71 - 0
source/gui/prebattlescene.cpp

@@ -0,0 +1,71 @@
+
+#include "gui/prebattlescene.h"
+
+#include "player.h"
+#include "playermanager.h"
+#include "race.h"
+#include "racemanager.h"
+
+#include "gui/raceicon.h"
+#include "gui/uniticon.h"
+#include "gui/guiscenemanager.h"
+#include "ui_prebattlescene.h"
+
+#include <QMessageBox>
+
+PreBattleScene::PreBattleScene(QWidget *parent) :
+    Scene(parent),
+    ui(new Ui::PreBattleScene)
+{
+    ui->setupUi(this);
+}
+
+PreBattleScene::~PreBattleScene()
+{
+    delete ui;
+}
+
+void PreBattleScene::init() {
+    Player *player = PlayerManager::getInstance().getPlayer(0);
+
+    ui->race_icon_1_->setRaceIcon(player->getRace()->getRaceIcon());
+    ui->race_icon_1_->resize(128, 128);
+    ui->race_icon_1_->setState(5);
+
+    units_player_1_.resize(10);
+    auto units = player->getUnitsAsVector();
+    for (int i = 0; i < 10; i++) {
+        units_player_1_[i] = new UnitIcon();
+        if (i < units.size())
+            units_player_1_[i]->setUnitIcon(units[i]->getUnitIcon());
+        else
+            units_player_1_[i]->setUnitIcon("norace", "nounit");
+        units_player_1_[i]->setState(5);
+        ui->units_player_1_layout_->addWidget(units_player_1_[i], i / 5, i % 5);
+    }
+
+    player = PlayerManager::getInstance().getPlayer(1);
+    ui->race_icon_2_->setRaceIcon(player->getRace()->getRaceIcon());
+    ui->race_icon_2_->resize(128, 128);
+    ui->race_icon_2_->setState(5);
+
+    units_player_2_.resize(10);
+    units = player->getUnitsAsVector();
+    for (int i = 0; i < 10; i++) {
+        units_player_2_[i] = new UnitIcon();
+        if (i < units.size())
+            units_player_2_[i]->setUnitIcon(units[i]->getUnitIcon());
+        else
+            units_player_2_[i]->setUnitIcon("norace", "nounit");
+        units_player_2_[i]->setState(5);
+        ui->units_player_2_layout_->addWidget(units_player_2_[i], i / 5, i % 5);
+    }
+}
+
+void PreBattleScene::on_start_battle_clicked()
+{
+    QMessageBox msg(QMessageBox::Information, "Нельзя сотворить здесь!", "Не ну имейте терпение! Всё будет! Но попозже... :)");
+    msg.exec();
+
+    GuiSceneManager::getInstance().changeScene("main_menu");
+}

+ 2 - 0
source/gui/recruitmentscene.cpp

@@ -423,5 +423,7 @@ void RecruitmentScene::on_apply_clicked()
     if (current_player_id_ == 0) {
         qDebug() << "Changing to 1";
         GuiSceneManager::getInstance().changeScene("recruit_army", "1|" + QString::number(available_money_));
+    } else {
+        GuiSceneManager::getInstance().changeScene("prebattle");
     }
 }