From 5243dd89f5d68a6cc7a463b525b5e7e7bf77bd77 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Wed, 11 Nov 2015 16:05:58 +0300
Subject: Fix char create dialog height.

---
 src/gui/windows/charcreatedialog.cpp | 20 +++++++++++++++-----
 src/gui/windows/charcreatedialog.h   |  1 +
 2 files changed, 16 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 9525805d4..e38e1ebae 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -137,6 +137,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
     mMaxRace(CharDB::getMaxRace()),
     mHairStyle(0),
     mHairColor(0),
+    mMaxY(0),
     mSlot(slot),
     mDefaultGender(Gender::FEMALE),
     mGender(Gender::UNSPECIFIED),
@@ -292,6 +293,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
         if (mRaceNameLabel)
             mRaceNameLabel->setPosition(nameX, y);
     }
+    mMaxY = y + 29 + getTitlePadding();
 
     updateSliders();
     setButtonsPosition(w, h);
@@ -556,8 +558,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
 
     const int w = 480;
     int h = 350;
-    const int y = 118 + 29;
-
+    int y = 118 + 29;
     for (unsigned i = 0, sz = static_cast<unsigned>(labels.size());
          i < sz; i++)
     {
@@ -583,13 +584,22 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
     {
         mAttributesLeft->setVisible(Visible_false);
         h = y;
-        setContentSize(w, h);
+    }
+    else
+    {
+        h = 290 + mAttributesLeft->getHeight() + getPadding();
     }
     if (serverFeatures->haveCreateCharGender() && y < 160)
     {
-        h = 160;
-        setContentSize(w, h);
+        if (h < 160)
+            h = 160;
     }
+    if (h < mMaxY)
+        h = mMaxY;
+
+    h += mCreateButton->getHeight();
+
+    setContentSize(w, h);
     setButtonsPosition(w, h);
 }
 
diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h
index 7ecc8a928..aa277607e 100644
--- a/src/gui/windows/charcreatedialog.h
+++ b/src/gui/windows/charcreatedialog.h
@@ -152,6 +152,7 @@ class CharCreateDialog final : public Window,
 
         int mHairStyle;
         int mHairColor;
+        int mMaxY;
 
         int mSlot;
 
-- 
cgit v1.2.3-70-g09d2