Browse Source

small code improvements and fixes

Ivan Arkhipov 6 years ago
parent
commit
e4b9ab806f
4 changed files with 39 additions and 27 deletions
  1. 3 3
      source/cell.cpp
  2. 1 1
      source/units/unit.cpp
  3. 5 5
      ui/hotseat_game/hotseatgame.cpp
  4. 30 18
      ui/hotseat_prebattle/prebattlescene.ui

+ 3 - 3
source/cell.cpp

@@ -205,7 +205,7 @@ QRectF Cell::boundingRect() const
     return QRectF(polygon.boundingRect());
 }
 
-void Cell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+void Cell::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
 {
     polygon.clear();
     auto points = getPoints(GameProperties::CELL_MAX_RADIUS, 0);
@@ -241,13 +241,13 @@ void Cell::setHovered(bool hovered)
     hovered_ = hovered;
 }
 
-void Cell::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+void Cell::hoverEnterEvent(QGraphicsSceneHoverEvent *)
 {
     hovered_ = true;
     update();
 }
 
-void Cell::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+void Cell::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
 {
     hovered_ = false;
     update();

+ 1 - 1
source/units/unit.cpp

@@ -55,7 +55,7 @@ void Unit::loadUnitBaseClass(QString unit_folder) {
     base_class_id_ = in.readLine();
 }
 
-void Unit::loadUnitTraits(QString unit_folder) {
+void Unit::loadUnitTraits(QString ) {
    // TO BE DONE!!!
     health_points_ = rand();
     activity_points_ = rand();

+ 5 - 5
ui/hotseat_game/hotseatgame.cpp

@@ -64,8 +64,8 @@ void HotSeatGame::init() {
 void HotSeatGame::deinit()
 {
     auto field = GameManager::getInstance().getGameField();
-    for (int i = 0; i < field.size(); i++) {
-        for (int j = 0; j < field[i].size(); j++){
+    for (unsigned i = 0; i < field.size(); i++) {
+        for (unsigned j = 0; j < field[i].size(); j++){
             field[i][j]->setVisible(false);
             game_scene_->removeItem(field[i][j]);
         }
@@ -109,7 +109,7 @@ DrawSceneEventListener::DrawSceneEventListener(HotSeatGame *scene, QObject *pare
     scene_ = scene;
 }
 
-bool DrawSceneEventListener::eventFilter(QObject *watched, QEvent *event)
+bool DrawSceneEventListener::eventFilter(QObject *, QEvent *event)
 {
     if (event->type() == QEvent::Resize) {
         scene_->deinit();
@@ -122,8 +122,8 @@ bool DrawSceneEventListener::eventFilter(QObject *watched, QEvent *event)
         QMouseEvent* evt = dynamic_cast<QMouseEvent*>(event);
         auto cells = GameManager::getInstance().getGameField();
         qDebug() << evt->globalPos();
-        for (int i = 0; i < cells.size(); i++) {
-            for (int j = 0; j < cells[i].size(); j++) {
+        for (unsigned i = 0; i < cells.size(); i++) {
+            for (unsigned j = 0; j < cells[i].size(); j++) {
                 if (cells[i][j]->contains(evt->localPos())) {
                     qDebug() << "He-he!!!";
                     cells[i][j]->setHovered(true);

+ 30 - 18
ui/hotseat_prebattle/prebattlescene.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1430</width>
-    <height>1612</height>
+    <width>987</width>
+    <height>893</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -32,47 +32,56 @@
    <property name="spacing">
     <number>0</number>
    </property>
-   <item row="0" column="2" rowspan="4">
-    <spacer name="horizontalSpacer_2">
+   <item row="0" column="0" rowspan="2">
+    <spacer name="horizontalSpacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
-       <width>152</width>
+       <width>151</width>
        <height>812</height>
       </size>
      </property>
     </spacer>
    </item>
-   <item row="0" column="0" rowspan="4">
-    <spacer name="horizontalSpacer">
+   <item row="0" column="1">
+    <spacer name="verticalSpacer">
      <property name="orientation">
-      <enum>Qt::Horizontal</enum>
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::MinimumExpanding</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
-       <width>151</width>
-       <height>812</height>
+       <width>20</width>
+       <height>52</height>
       </size>
      </property>
     </spacer>
    </item>
-   <item row="3" column="1">
-    <spacer name="verticalSpacer_2">
+   <item row="0" column="2" rowspan="3">
+    <spacer name="horizontalSpacer_2">
      <property name="orientation">
-      <enum>Qt::Vertical</enum>
+      <enum>Qt::Horizontal</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
-       <width>20</width>
-       <height>52</height>
+       <width>152</width>
+       <height>812</height>
       </size>
      </property>
     </spacer>
    </item>
-   <item row="1" column="1" rowspan="2">
+   <item row="1" column="1">
     <widget class="QWidget" name="widget" native="true">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
      <property name="minimumSize">
       <size>
        <width>0</width>
@@ -882,11 +891,14 @@ color: rgb(177, 45, 45);</string>
      </layout>
     </widget>
    </item>
-   <item row="0" column="1">
-    <spacer name="verticalSpacer">
+   <item row="2" column="1">
+    <spacer name="verticalSpacer_2">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::MinimumExpanding</enum>
+     </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>