From 3567d27ac0a472c90644ea643b48f7e85c767118 Mon Sep 17 00:00:00 2001
From: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
Date: Sat, 14 Jan 2012 14:00:06 +0100
Subject: Center the CustomServerDialog on its parent window

Also shortened the title of the Custom Server dialog to "Custom Server"
since it is also used for editing an existing custom server and not just
for adding a new one.

And used Window::center() in a bunch of places just to reduce code size.

Reviewed-by: Yohann Ferreira
---
 src/gui/customserverdialog.cpp | 3 ++-
 src/gui/npcpostdialog.cpp      | 2 +-
 src/gui/quitdialog.cpp         | 2 +-
 src/gui/skilldialog.cpp        | 2 +-
 src/gui/specialswindow.cpp     | 2 +-
 src/gui/textdialog.cpp         | 4 ++--
 6 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/gui/customserverdialog.cpp b/src/gui/customserverdialog.cpp
index 5376248a..58099599 100644
--- a/src/gui/customserverdialog.cpp
+++ b/src/gui/customserverdialog.cpp
@@ -45,7 +45,7 @@ std::string TypeListModel::getElementAt(int elementIndex)
 }
 
 CustomServerDialog::CustomServerDialog(ServerDialog *parent, int index):
-    Window(_("Add a custom Server"), true, parent),
+    Window(_("Custom Server"), true, parent),
     mServerDialog(parent),
     mIndex(index)
 {
@@ -123,6 +123,7 @@ CustomServerDialog::CustomServerDialog(ServerDialog *parent, int index):
                                 ServerInfo::TMWATHENA);
     }
 
+    setLocationRelativeTo(getParentWindow());
     setVisible(true);
 
     mNameField->requestFocus();
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index c53203be..98c6ac9c 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -76,7 +76,7 @@ NpcPostDialog::NpcPostDialog(int npcId):
     add(sendButton);
     add(cancelButton);
 
-    setLocationRelativeTo(getParent());
+    center();
 
     instances.push_back(this);
     setVisible(true);
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 3da07206..c06fdfc2 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -82,7 +82,7 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
     place(2, 0, mCancelButton);
 
     reflowLayout(150, 0);
-    setLocationRelativeTo(getParent());
+    center();
     setVisible(true);
     requestModalFocus();
     mOkButton->requestFocus();
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index f01edd98..e9f91a00 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -233,7 +233,7 @@ SkillDialog::SkillDialog():
     place(0, 5, mPointsLabel, 4);
     place(4, 5, mIncreaseButton);
 
-    setLocationRelativeTo(getParent());
+    center();
     loadWindowState();
 }
 
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 0f146fa2..acc3492e 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -89,7 +89,7 @@ SpecialsWindow::SpecialsWindow():
 
     place(0, 0, mTabs, 5, 5);
 
-    setLocationRelativeTo(getParent());
+    center();
     loadWindowState();
 }
 
diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp
index f88a6afa..08dbef00 100644
--- a/src/gui/textdialog.cpp
+++ b/src/gui/textdialog.cpp
@@ -40,7 +40,7 @@ TextDialog::TextDialog(const std::string &title, const std::string &msg,
     gcn::Button *cancelButton = new Button(_("Cancel"), "CANCEL", this);
 
     // In TextField the escape key will either cause autoComplete or lose focus
-    mTextField = new TextField("", ! autoCompleteEnabled);
+    mTextField = new TextField(std::string(), ! autoCompleteEnabled);
     if (autoCompleteEnabled)
         mTextField->setAutoComplete(actorSpriteManager->getPlayerNameLister());
 
@@ -55,7 +55,7 @@ TextDialog::TextDialog(const std::string &title, const std::string &msg,
 
     if (getParent())
     {
-        setLocationRelativeTo(getParent());
+        center();
         getParent()->moveToTop(this);
     }
     setVisible(true);
-- 
cgit v1.2.3-70-g09d2