Procházet zdrojové kódy

Restructured project. Implemented some gui funcs

Ivan Arkhipov před 7 roky
rodič
revize
8b71b4daa3

binární
assets/common/Scroll.png


binární
assets/common/strelka.png


binární
assets/common/unit_icon_active.png


binární
assets/common/unit_icon_default.png


binární
assets/common/unit_icon_hover.png


binární
assets/recruitscene/gold-divider-badass-book-reviews-ohOybC-clipart.jpg


binární
assets/units/norace/nounit/icon.png


binární
assets/units/warcraft/blademaster/icon.png


binární
assets/units/warcraft/chaosorc/icon.png


binární
assets/units/warcraft/nagasummoner/icon.png


binární
assets/units/warcraft/necromancer/icon.png


binární
assets/units/warcraft/ogremagi/icon.png


binární
assets/units/warcraft/raceicon.png


binární
assets/units/warcraft/rogue/icon.png


binární
assets/units/warcraft/wargraider/icon.png


binární
assets/units/warcraft/wyvern/icon.png


+ 17 - 11
client.pro

@@ -22,23 +22,29 @@ DEFINES += QT_DEPRECATED_WARNINGS
 # You can also select to disable deprecated APIs only up to a certain version of Qt.
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
+INCLUDEPATH += $$PWD/include/
+
 
 SOURCES += \
-        main.cpp \
-        gui.cpp \
-    recruitmentscene.cpp \
-    unitfactory.cpp \
-    unit.cpp
+    source/main.cpp \
+    source/gui/uniticon.cpp \
+    source/gui/gui.cpp \
+    source/gui/recruitmentscene.cpp \
+    source/unit.cpp \
+    source/unitfactory.cpp \
+    source/player.cpp
 
 HEADERS += \
-        gui.h \
-    recruitmentscene.h \
-    unitfactory.h \
-    unit.h
+    include/gui/uniticon.h \
+    include/gui/gui.h \
+    include/gui/recruitmentscene.h \
+    include/unit.h \
+    include/unitfactory.h \
+    include/player.h
 
 FORMS += \
-        gui.ui \
-    recruitmentscene.ui
+    include/gui/gui.ui \
+    include/gui/recruitmentscene.ui
 
 RESOURCES += \
     gui.qrc

+ 16 - 1
gui.qrc

@@ -1,5 +1,21 @@
 <RCC>
     <qresource prefix="/">
+        <file>assets/common/Scroll.png</file>
+        <file>assets/common/strelka.png</file>
+        <file>assets/common/unit_icon_active.png</file>
+        <file>assets/common/unit_icon_default.png</file>
+        <file>assets/common/unit_icon_hover.png</file>
+        <file>assets/recruitscene/divider.png</file>
+        <file>assets/units/norace/nounit/icon.png</file>
+        <file>assets/units/warcraft/blademaster/icon.png</file>
+        <file>assets/units/warcraft/chaosorc/icon.png</file>
+        <file>assets/units/warcraft/nagasummoner/icon.png</file>
+        <file>assets/units/warcraft/necromancer/icon.png</file>
+        <file>assets/units/warcraft/ogremagi/icon.png</file>
+        <file>assets/units/warcraft/rogue/icon.png</file>
+        <file>assets/units/warcraft/wargraider/icon.png</file>
+        <file>assets/units/warcraft/wyvern/icon.png</file>
+        <file>assets/units/warcraft/raceicon.png</file>
         <file>assets/window/thick_opaque-background.png</file>
         <file>assets/window/thick_opaque-border-botleft.png</file>
         <file>assets/window/thick_opaque-border-botright.png</file>
@@ -9,6 +25,5 @@
         <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/recruitscene/divider.png</file>
     </qresource>
 </RCC>

+ 0 - 0
gui.h → include/gui/gui.h


+ 0 - 0
gui.ui → include/gui/gui.ui


+ 6 - 0
recruitmentscene.h → include/gui/recruitmentscene.h

@@ -3,6 +3,10 @@
 
 #include <QWidget>
 
+#include <vector>
+
+class UnitIcon;
+
 namespace Ui {
 class RecruitmentScene;
 }
@@ -17,6 +21,8 @@ public:
 
 private:
     Ui::RecruitmentScene *ui;
+    UnitIcon* available_units_icons_[5];
+    UnitIcon* chosen_units_icons_[10];
 };
 
 #endif // RECRUITMENTSCENE_H

+ 461 - 0
include/gui/recruitmentscene.ui

@@ -0,0 +1,461 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RecruitmentScene</class>
+ <widget class="QWidget" name="RecruitmentScene">
+  <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="chosen_race_text_">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>120</y>
+     <width>191</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; color:#FDEAA8;&quot;&gt;Выбранная раса:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="chosen_race_image_">
+   <property name="geometry">
+    <rect>
+     <x>200</x>
+     <y>110</y>
+     <width>100</width>
+     <height>100</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/units/warcraft/raceicon.png&quot; width=&quot;100&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="available_races_text_">
+   <property name="geometry">
+    <rect>
+     <x>550</x>
+     <y>110</y>
+     <width>201</width>
+     <height>31</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:14pt; color:#FDEAA8;&quot;&gt;Доступные расы:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="available_races_list_" native="true">
+   <property name="geometry">
+    <rect>
+     <x>380</x>
+     <y>150</y>
+     <width>521</width>
+     <height>72</height>
+    </rect>
+   </property>
+   <layout class="QHBoxLayout" name="availableRacesLayout_">
+    <property name="leftMargin">
+     <number>5</number>
+    </property>
+    <property name="topMargin">
+     <number>5</number>
+    </property>
+    <property name="rightMargin">
+     <number>5</number>
+    </property>
+    <property name="bottomMargin">
+     <number>5</number>
+    </property>
+   </layout>
+  </widget>
+  <widget class="QLabel" name="divider_">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>45</y>
+     <width>940</width>
+     <height>91</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/recruitscene/divider.png&quot; width=&quot;940&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="title_">
+   <property name="geometry">
+    <rect>
+     <x>-3</x>
+     <y>0</y>
+     <width>941</width>
+     <height>71</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;Набор юнитов&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="chosen_units_label_">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>380</y>
+     <width>221</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; color:#FDEAA8;&quot;&gt;Выбранные юниты:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="available_units_text_">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>250</y>
+     <width>201</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; color:#fdeaa8;&quot;&gt;Доступные классы:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="available_units_list_" native="true">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>290</y>
+     <width>320</width>
+     <height>64</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayout">
+    <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>
+    <item row="0" column="3">
+     <layout class="QHBoxLayout" name="available_units_layout_"/>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="chosen_units_grid_" native="true">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>430</y>
+     <width>320</width>
+     <height>128</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayout_2">
+    <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>
+    <item row="0" column="0">
+     <layout class="QGridLayout" name="chosen_units_layout_">
+      <property name="spacing">
+       <number>0</number>
+      </property>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QPushButton" name="apply_">
+   <property name="geometry">
+    <rect>
+     <x>610</x>
+     <y>640</y>
+     <width>281</width>
+     <height>61</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Завершить выбор</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="description_scroll_widget_" native="true">
+   <property name="geometry">
+    <rect>
+     <x>590</x>
+     <y>250</y>
+     <width>321</width>
+     <height>441</height>
+    </rect>
+   </property>
+   <widget class="QLabel" name="background_scroll_label_">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>0</y>
+      <width>321</width>
+      <height>421</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/Scroll.png&quot; width=&quot;321&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="name_text_">
+    <property name="geometry">
+     <rect>
+      <x>80</x>
+      <y>60</y>
+      <width>161</width>
+      <height>21</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-weight:600; color:#000080;&quot;&gt;Название юнита&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="description_text_">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>90</y>
+      <width>171</width>
+      <height>161</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#000080;&quot;&gt;Здоровье:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; color:#000080;&quot;&gt;Сила:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; color:#000080;&quot;&gt;Урон:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; color:#000080;&quot;&gt;Удар:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; color:#000080;&quot;&gt;Удача:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; color:#000080;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QPushButton" name="back_button_">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>640</y>
+     <width>161</width>
+     <height>61</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Вернуться на главную</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="available_money_text_">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>160</y>
+     <width>191</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:10pt; color:#ff0000;&quot;&gt;Ресурсы: 0000000 &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="unit_spec_widget_" native="true">
+   <property name="geometry">
+    <rect>
+     <x>380</x>
+     <y>270</y>
+     <width>180</width>
+     <height>291</height>
+    </rect>
+   </property>
+   <widget class="QLabel" name="spec_title_">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>10</y>
+      <width>180</width>
+      <height>21</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:10pt; color:#fdeaa8;&quot;&gt;Специализация&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="UnitIcon" name="parent_spec_unit_">
+    <property name="geometry">
+     <rect>
+      <x>70</x>
+      <y>40</y>
+      <width>45</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/units/warcraft/blademaster/icon.png&quot; width=&quot;45&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="arrow_down_1_">
+    <property name="geometry">
+     <rect>
+      <x>80</x>
+      <y>80</y>
+      <width>31</width>
+      <height>61</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/strelka.png&quot; width=&quot;25&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="UnitIcon" name="current_spec_unit_">
+    <property name="geometry">
+     <rect>
+      <x>70</x>
+      <y>140</y>
+      <width>45</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/units/warcraft/chaosorc/icon.png&quot; width=&quot;45&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QWidget" name="next_gen_units_list_" native="true">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>240</y>
+      <width>180</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <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>
+     <item>
+      <widget class="UnitIcon" name="next_spec_unit_1_">
+       <property name="text">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/units/warcraft/rogue/icon.png&quot; width=&quot;45&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="UnitIcon" name="next_spec_unit_2_">
+       <property name="text">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/units/warcraft/ogremagi/icon.png&quot; width=&quot;45&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="UnitIcon" name="next_spec_unit_3_">
+       <property name="text">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/units/warcraft/wargraider/icon.png&quot; width=&quot;45&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="UnitIcon" name="next_spec_unit_4_">
+       <property name="text">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/units/warcraft/wyvern/icon.png&quot; width=&quot;45&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </widget>
+   <widget class="QLabel" name="arrow_down_2_">
+    <property name="geometry">
+     <rect>
+      <x>80</x>
+      <y>180</y>
+      <width>31</width>
+      <height>61</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/strelka.png&quot; width=&quot;25&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <zorder>spec_title_</zorder>
+   <zorder>arrow_down_1_</zorder>
+   <zorder>parent_spec_unit_</zorder>
+   <zorder>current_spec_unit_</zorder>
+   <zorder>next_gen_units_list_</zorder>
+   <zorder>arrow_down_2_</zorder>
+  </widget>
+  <widget class="QWidget" name="widget" native="true">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>430</y>
+     <width>320</width>
+     <height>128</height>
+    </rect>
+   </property>
+  </widget>
+  <zorder>divider_</zorder>
+  <zorder>chosen_race_text_</zorder>
+  <zorder>chosen_race_image_</zorder>
+  <zorder>available_races_text_</zorder>
+  <zorder>available_races_list_</zorder>
+  <zorder>title_</zorder>
+  <zorder>chosen_units_label_</zorder>
+  <zorder>available_units_list_</zorder>
+  <zorder>chosen_units_grid_</zorder>
+  <zorder>description_scroll_widget_</zorder>
+  <zorder>back_button_</zorder>
+  <zorder>available_units_text_</zorder>
+  <zorder>available_money_text_</zorder>
+  <zorder>apply_</zorder>
+  <zorder>unit_spec_widget_</zorder>
+  <zorder>widget</zorder>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>UnitIcon</class>
+   <extends>QLabel</extends>
+   <header>gui/uniticon.h</header>
+   <slots>
+    <signal>clicked()</signal>
+    <signal>doubleclicked()</signal>
+    <signal>hovered()</signal>
+    <signal>unhovered()</signal>
+   </slots>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

+ 64 - 0
include/gui/uniticon.h

@@ -0,0 +1,64 @@
+#ifndef UNITICON_H
+#define UNITICON_H
+
+#include <QObject>
+#include <QWidget>
+#include <QLabel>
+#include <QImage>
+#include <QPixmap>
+#include <QPainter>
+#include <QTime>
+
+#include <unit.h>
+
+class UnitIcon : public QLabel {
+Q_OBJECT
+
+public:
+    explicit UnitIcon(QWidget* parent = 0, int width = 64, int height = 64);
+    ~UnitIcon();
+    void setUnitIcon(QString racename, QString unitname);
+    void resize(int w, int h);
+    void unsetUnitIcon();
+
+    void deactivate();
+    void activate();
+
+
+protected:
+    void mousePressEvent(QMouseEvent* event);
+    void enterEvent(QEvent* event);
+    void leaveEvent(QEvent* event);
+
+
+signals:
+    void clicked();
+    void doubleclicked();
+    void hovered();
+    void unhovered();
+
+private:
+    void drawIcon();
+
+    int width_;
+    int height_;
+
+    int state_; // 0 = not initialized;
+                // 1 = default;
+                // 2 = hover;
+                // 3 = active;
+
+    QPixmap pixmap_;
+    QImage active_border_;
+    QImage hover_border_;
+    QImage default_border_;
+    QImage icon_;
+
+    QTime previous_click_time_;
+
+    Unit* unit_;
+};
+
+
+
+#endif // UNITICON_H

+ 31 - 0
include/player.h

@@ -0,0 +1,31 @@
+#ifndef INCLUDEPLAYER_H
+#define INCLUDEPLAYER_H
+
+#include <QObject>
+
+#include <set>
+
+class Unit;
+class Faction;
+
+template<class Obj, class Identifier>
+class ObjectFactory;
+
+class Player : public QObject
+{
+    Q_OBJECT
+public:
+    explicit Player(QObject *parent = nullptr);
+
+signals:
+
+public slots:
+
+private:
+    QString player_name_;
+    //std::set<Unit*> units_;
+    //Faction* faction_;
+
+};
+
+#endif // INCLUDEPLAYER_H

+ 0 - 0
unit.h → include/unit.h


+ 0 - 0
unitfactory.h → include/unitfactory.h


+ 0 - 14
recruitmentscene.cpp

@@ -1,14 +0,0 @@
-#include "recruitmentscene.h"
-#include "ui_recruitmentscene.h"
-
-RecruitmentScene::RecruitmentScene(QWidget *parent) :
-    QWidget(parent),
-    ui(new Ui::RecruitmentScene)
-{
-    ui->setupUi(this);
-}
-
-RecruitmentScene::~RecruitmentScene()
-{
-    delete ui;
-}

+ 0 - 191
recruitmentscene.ui

@@ -1,191 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>RecruitmentScene</class>
- <widget class="QWidget" name="RecruitmentScene">
-  <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="chosenRaceText_">
-   <property name="geometry">
-    <rect>
-     <x>10</x>
-     <y>120</y>
-     <width>191</width>
-     <height>91</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt; color:#b58a1e;&quot;&gt;Выбранная раса:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="chosenRaceImage_">
-   <property name="geometry">
-    <rect>
-     <x>200</x>
-     <y>110</y>
-     <width>128</width>
-     <height>128</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;div  style=&quot;background: purple&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="availableRacesText_">
-   <property name="geometry">
-    <rect>
-     <x>550</x>
-     <y>110</y>
-     <width>201</width>
-     <height>31</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:14pt; color:#b89822;&quot;&gt;Доступные расы:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QWidget" name="horizontalLayoutWidget">
-   <property name="geometry">
-    <rect>
-     <x>380</x>
-     <y>150</y>
-     <width>521</width>
-     <height>91</height>
-    </rect>
-   </property>
-   <layout class="QHBoxLayout" name="availableRacesLayout_">
-    <property name="leftMargin">
-     <number>5</number>
-    </property>
-    <property name="topMargin">
-     <number>5</number>
-    </property>
-    <property name="rightMargin">
-     <number>5</number>
-    </property>
-    <property name="bottomMargin">
-     <number>5</number>
-    </property>
-   </layout>
-  </widget>
-  <widget class="QLabel" name="divider_">
-   <property name="geometry">
-    <rect>
-     <x>0</x>
-     <y>45</y>
-     <width>940</width>
-     <height>91</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/recruitscene/divider.png&quot; width=&quot;940&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="title_">
-   <property name="geometry">
-    <rect>
-     <x>-3</x>
-     <y>0</y>
-     <width>941</width>
-     <height>71</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:#b8481c;&quot;&gt;Набор юнитов&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="chosenUnitsLabel_">
-   <property name="geometry">
-    <rect>
-     <x>10</x>
-     <y>420</y>
-     <width>221</width>
-     <height>41</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; color:#b5982e;&quot;&gt;Выбранные юниты:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label">
-   <property name="geometry">
-    <rect>
-     <x>10</x>
-     <y>300</y>
-     <width>201</width>
-     <height>31</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; color:#9e9531;&quot;&gt;Доступные юниты:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-   </property>
-  </widget>
-  <widget class="QWidget" name="gridWidget" native="true">
-   <property name="geometry">
-    <rect>
-     <x>230</x>
-     <y>280</y>
-     <width>680</width>
-     <height>64</height>
-    </rect>
-   </property>
-   <layout class="QGridLayout" name="gridLayout"/>
-  </widget>
-  <widget class="QWidget" name="gridWidget_2" native="true">
-   <property name="geometry">
-    <rect>
-     <x>230</x>
-     <y>370</y>
-     <width>680</width>
-     <height>125</height>
-    </rect>
-   </property>
-   <layout class="QGridLayout" name="gridLayout_2"/>
-  </widget>
-  <widget class="QPushButton" name="pushButton">
-   <property name="geometry">
-    <rect>
-     <x>260</x>
-     <y>610</y>
-     <width>371</width>
-     <height>51</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>Завершить выбор</string>
-   </property>
-  </widget>
-  <widget class="QWidget" name="widget" native="true">
-   <property name="geometry">
-    <rect>
-     <x>710</x>
-     <y>480</y>
-     <width>191</width>
-     <height>211</height>
-    </rect>
-   </property>
-  </widget>
-  <zorder>divider_</zorder>
-  <zorder>chosenRaceText_</zorder>
-  <zorder>chosenRaceImage_</zorder>
-  <zorder>availableRacesText_</zorder>
-  <zorder>horizontalLayoutWidget</zorder>
-  <zorder>title_</zorder>
-  <zorder>chosenUnitsLabel_</zorder>
-  <zorder>label</zorder>
-  <zorder>gridWidget</zorder>
-  <zorder>gridWidget_2</zorder>
-  <zorder>pushButton</zorder>
-  <zorder>widget</zorder>
- </widget>
- <resources/>
- <connections/>
-</ui>

+ 16 - 9
gui.cpp → source/gui/gui.cpp

@@ -1,6 +1,6 @@
-#include "gui.h"
-#include "ui_gui.h"
-#include "recruitmentscene.h"
+#include <gui/gui.h>
+#include <ui_gui.h>
+#include <gui/recruitmentscene.h>
 #include <QDebug>
 
 GUI::GUI(QWidget *parent) :
@@ -8,9 +8,9 @@ GUI::GUI(QWidget *parent) :
     ui_(new Ui::GUI), dx_(0), dy_(0)
 {
     ui_->setupUi(this);
-    rq_scene_ = new RecruitmentScene(ui_->main_content_);   /// Инициализируем графическую сцену
+
+    rq_scene_ = new RecruitmentScene(ui_->main_content_);   /// Инициализируем графическую сцену выбора юнитов
     rq_scene_->show();
-    //rq_scene_->hide();
 }
 
 GUI::~GUI()
@@ -25,8 +25,6 @@ void GUI::mouseMoveEvent( QMouseEvent* e ) {
 
         if (child == 0) {
             setGeometry(pos().x() + (pt.x() - dx_ ), pos().y() + (pt.y() - dy_ ), width(), height());
-        //    dx_ = pt.x();
-        //    dy_ = pt.y();
             return;
         }
         QString cname = child->metaObject()->className();
@@ -40,8 +38,17 @@ void GUI::mouseMoveEvent( QMouseEvent* e ) {
 }
 
 void GUI::mousePressEvent( QMouseEvent* e ) {
-    if( e->button() == Qt::LeftButton ) {
-        QPoint pt=mapFromGlobal(QCursor::pos());
+    if(e->button() == Qt::LeftButton) {
+        QPoint pt = mapFromGlobal(QCursor::pos());
+        QWidget* child=childAt(pt);
+
+        if (child == 0)
+            return;
+
+        QString cname = child->metaObject()->className();
+        if (cname == "QPushButton" || cname == "QComboBox" || cname == "QLabel")
+           return;
+
         dx_ = pt.x();
         dy_ = pt.y();
         setCursor( Qt::OpenHandCursor );

+ 52 - 0
source/gui/recruitmentscene.cpp

@@ -0,0 +1,52 @@
+#include <gui/recruitmentscene.h>
+#include <gui/uniticon.h>
+
+#include <ui_recruitmentscene.h>
+#include <QHBoxLayout>
+
+RecruitmentScene::RecruitmentScene(QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::RecruitmentScene)
+{
+    ui->setupUi(this);
+
+    for (int i = 0; i < 5; i++) {
+        available_units_icons_[i] = new UnitIcon(ui->available_units_list_);
+        ui->available_units_layout_->addWidget(available_units_icons_[i]);
+        available_units_icons_[i]->setUnitIcon("norace", "nounit");
+    }
+
+    for (int i = 0; i < 10; i++) {
+        chosen_units_icons_[i] = new UnitIcon(ui->chosen_units_grid_);
+        chosen_units_icons_[i]->setUnitIcon("warcraft", "rogue");
+        ui->chosen_units_layout_->addWidget(chosen_units_icons_[i], i / 5, i % 5);
+    }
+
+    ui->parent_spec_unit_->resize(45, 45);
+    ui->parent_spec_unit_->setUnitIcon("warcraft", "chaosorc");
+
+    ui->current_spec_unit_->resize(45, 45);
+    ui->current_spec_unit_->setUnitIcon("warcraft", "chaosorc");
+
+    ui->next_spec_unit_1_->resize(45, 45);
+    ui->next_spec_unit_2_->resize(45, 45);
+    ui->next_spec_unit_3_->resize(45, 45);
+    ui->next_spec_unit_4_->resize(45, 45);
+
+    ui->next_spec_unit_1_->setUnitIcon("warcraft", "chaosorc");
+    ui->next_spec_unit_2_->setUnitIcon("warcraft", "chaosorc");
+    ui->next_spec_unit_3_->setUnitIcon("warcraft", "chaosorc");
+    ui->next_spec_unit_4_->setUnitIcon("warcraft", "chaosorc");
+
+
+    //available_units_icons_[0]->setUnitIcon("warcraft", "blademaster");
+    //available_units_icons_[1]->setUnitIcon("warcraft", "chaosorc");
+    //available_units_icons_[2]->setUnitIcon("warcraft", "nagasummoner");
+    //available_units_icons_[3]->setUnitIcon("warcraft", "rogue");
+    //available_units_icons_[4]->setUnitIcon("warcraft", "ogremagi");
+}
+
+RecruitmentScene::~RecruitmentScene()
+{
+    delete ui;
+}

+ 115 - 0
source/gui/uniticon.cpp

@@ -0,0 +1,115 @@
+#include <gui/uniticon.h>
+#include <QDebug>
+#include <QTime>
+
+UnitIcon::UnitIcon(QWidget* parent, int width, int height)
+    : QLabel(parent)
+{
+    state_ = 0;
+    width_ = width;
+    height_ = height;
+
+    setAttribute(Qt::WA_Hover, true);
+    installEventFilter(this);
+
+    default_border_.load(":/assets/common/unit_icon_default.png");
+    hover_border_.load(":/assets/common/unit_icon_hover.png");
+    active_border_.load(":/assets/common/unit_icon_active.png");
+
+    drawIcon();
+}
+
+UnitIcon::~UnitIcon()
+{
+}
+
+void UnitIcon::drawIcon() {
+    QPixmap combined(width_, height_);
+    QPainter p(&combined);
+
+    if (state_ == 0) {
+        p.setBrush(Qt::NoBrush);
+        p.setPen(Qt::black);
+        p.drawRect(0, 0, width_, height_);
+    } else {
+        p.drawImage(QPoint(0, 0), icon_.scaled(width_, height_, Qt::KeepAspectRatio));
+    }
+
+    if (state_ == 0 || state_ == 1)
+        p.drawImage(QPoint(0, 0), default_border_.scaled(width_, height_, Qt::KeepAspectRatio));
+
+    if (state_ == 2)
+        p.drawImage(QPoint(0, 0), hover_border_.scaled(width_, height_, Qt::KeepAspectRatio));
+
+    if (state_ == 3)
+        p.drawImage(QPoint(0, 0), active_border_.scaled(width_, height_, Qt::KeepAspectRatio));
+
+    p.end();
+    setPixmap(combined);
+}
+
+void UnitIcon::setUnitIcon(QString racename, QString unitname) {
+    icon_.load(":/assets/units/" + racename + "/" + unitname + "/icon.png");
+    if (state_ == 0)
+        state_ = 1;
+    drawIcon();
+}
+
+void UnitIcon::unsetUnitIcon() {
+    state_ = 0;
+    drawIcon();
+}
+
+void UnitIcon::resize(int w, int h) {
+    width_ = w;
+    height_ = h;
+    drawIcon();
+}
+
+void UnitIcon::deactivate() {
+    if (state_ > 1)
+        state_ = 1;
+    drawIcon();
+}
+
+void UnitIcon::activate() {
+    state_ = 3;
+    drawIcon();
+}
+
+void UnitIcon::mousePressEvent(QMouseEvent*)
+{
+    if (state_ == 0)
+        return;
+
+    activate();
+
+    QTime current_time = QTime::currentTime();
+    if (current_time.msecsSinceStartOfDay() - previous_click_time_.msecsSinceStartOfDay() < 200) {
+        deactivate();
+        emit doubleclicked();
+    } else {
+        previous_click_time_ = current_time;
+        emit clicked();
+    }
+}
+
+void UnitIcon::enterEvent(QEvent*)
+{
+    if (state_ == 0 || state_ == 3)
+        return;
+
+    state_ = 2;
+    drawIcon();
+    emit hovered();
+}
+
+void UnitIcon::leaveEvent(QEvent*)
+{
+    if (state_ == 0 || state_ == 3)
+        return;
+
+    state_ = 1;
+    drawIcon();
+    emit unhovered();
+}

+ 3 - 2
main.cpp → source/main.cpp

@@ -1,5 +1,6 @@
-#include "gui.h"
-#include "recruitmentscene.h"
+#include <gui/gui.h>
+#include <gui/recruitmentscene.h>
+
 #include <QApplication>
 
 int main(int argc, char *argv[])

+ 6 - 0
source/player.cpp

@@ -0,0 +1,6 @@
+#include <player.h>
+
+Player::Player(QObject *parent) : QObject(parent)
+{
+
+}

+ 0 - 0
unit.cpp → source/unit.cpp


+ 0 - 0
unitfactory.cpp → source/unitfactory.cpp