summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp2
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/npcdialog.cpp22
-rw-r--r--src/gui/npcdialog.h22
4 files changed, 25 insertions, 23 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 81c2abd8..479e45a6 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -264,7 +264,7 @@ bool ChatWindow::requestChatFocus()
return true;
}
-bool ChatWindow::isInputFocused()
+bool ChatWindow::isInputFocused() const
{
return mChatInput->isFocused();
}
diff --git a/src/gui/chat.h b/src/gui/chat.h
index e4865ed8..efd0b02e 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -129,7 +129,7 @@ class ChatWindow : public Window,
/**
* Checks whether ChatWindow is Focused or not.
*/
- bool isInputFocused();
+ bool isInputFocused() const;
/**
* Passes the text to the current tab as input
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 5b1d1a07..64101c0c 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -46,15 +46,13 @@
NpcDialog::NpcDialog()
: Window(_("NPC")),
- mActionState(NPC_ACTION_WAIT),
- mInputState(NPC_INPUT_NONE),
mNpcId(0),
- mDefaultString(""),
mDefaultInt(0),
- mText("")
+ mInputState(NPC_INPUT_NONE),
+ mActionState(NPC_ACTION_WAIT)
{
// Basic Window Setup
- setWindowName("NPCText");
+ setWindowName("NpcText");
setResizable(true);
setMinWidth(200);
@@ -197,11 +195,11 @@ void NpcDialog::action(const gcn::ActionEvent &event)
mIntField->setValue(mDefaultInt);
}
}
- else if(event.getId() == "plus")
+ else if (event.getId() == "plus")
{
mIntField->setValue(mIntField->getValue() + 1);
}
- else if(event.getId() == "minus")
+ else if (event.getId() == "minus")
{
mIntField->setValue(mIntField->getValue() - 1);
}
@@ -235,7 +233,7 @@ void NpcDialog::choiceRequest()
buildLayout();
}
-void NpcDialog::addChoice(std::string choice)
+void NpcDialog::addChoice(const std::string &choice)
{
mItems.push_back(choice);
}
@@ -249,7 +247,7 @@ void NpcDialog::parseListItems(const std::string &itemString)
mItems.push_back(tmp);
}
-void NpcDialog::textRequest(std::string defaultText)
+void NpcDialog::textRequest(const std::string &defaultText)
{
mActionState = NPC_ACTION_INPUT;
mInputState = NPC_INPUT_STRING;
@@ -258,7 +256,7 @@ void NpcDialog::textRequest(std::string defaultText)
buildLayout();
}
-bool NpcDialog::isInputFocused()
+bool NpcDialog::isInputFocused() const
{
return mTextField->isFocused() || mIntField->isFocused();
}
@@ -310,14 +308,14 @@ void NpcDialog::buildLayout()
place(0, 3, mListScrollArea, 5, 3);
place(3, 6, mButton, 2);
}
- else if(mInputState == NPC_INPUT_STRING)
+ else if (mInputState == NPC_INPUT_STRING)
{
place(0, 0, mScrollArea, 5, 3);
place(0, 3, mTextField, 5);
place(0, 4, mResetButton, 2);
place(3, 4, mButton, 2);
}
- else if(mInputState == NPC_INPUT_INTEGER)
+ else if (mInputState == NPC_INPUT_INTEGER)
{
place(0, 0, mScrollArea, 5, 3);
place(0, 3, mMinusButton, 1);
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 2adcc9c1..7800d828 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -111,14 +111,14 @@ class NpcDialog : public Window, public gcn::ActionListener,
std::string getElementAt(int i);
/**
- * Makes this dialog request a choice selection from the user
+ * Makes this dialog request a choice selection from the user.
*/
void choiceRequest();
/**
- * Adds a choice to the list box
+ * Adds a choice to the list box.
*/
- void addChoice(std::string);
+ void addChoice(const std::string &);
/**
* Fills the options list for an NPC dialog.
@@ -130,9 +130,9 @@ class NpcDialog : public Window, public gcn::ActionListener,
/**
* Requests a text string from the user.
*/
- void textRequest(std::string defaultText = "");
+ void textRequest(const std::string &defaultText = "");
- bool isInputFocused();
+ bool isInputFocused() const;
/**
* Requests a interger from the user.
@@ -176,24 +176,28 @@ class NpcDialog : public Window, public gcn::ActionListener,
// Will reset the text and integer input to the provided default
Button *mResetButton;
- enum NPCInputState {
+ enum NpcInputState
+ {
NPC_INPUT_NONE,
NPC_INPUT_LIST,
NPC_INPUT_STRING,
NPC_INPUT_INTEGER
};
- NPCInputState mInputState;
- enum NPCActionState {
+ enum NpcActionState
+ {
NPC_ACTION_WAIT,
NPC_ACTION_NEXT,
NPC_ACTION_INPUT,
NPC_ACTION_CLOSE
};
- NPCActionState mActionState;
+
+ NpcInputState mInputState;
+ NpcActionState mActionState;
};
// TODO: This should be made not to be global, later.
extern NpcDialog* npcDialog;
+
#endif // NPCDIALOG_H