summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-08 19:41:19 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-08 19:41:19 +0300
commit30ef016b0a14f36dc480284e2d775295b5501dd4 (patch)
treea269c0983efb8dc9160bfe10b1dba26a302aff0c /src/gui
parent25a6eae7f4fb561bbf930be28ee09510b40ebc80 (diff)
downloadManaVerse-30ef016b0a14f36dc480284e2d775295b5501dd4.tar.gz
ManaVerse-30ef016b0a14f36dc480284e2d775295b5501dd4.tar.bz2
ManaVerse-30ef016b0a14f36dc480284e2d775295b5501dd4.tar.xz
ManaVerse-30ef016b0a14f36dc480284e2d775295b5501dd4.zip
Move most input code from keyboardconfig to inputmanager.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chatwindow.cpp9
-rw-r--r--src/gui/inventorywindow.cpp7
-rw-r--r--src/gui/outfitwindow.cpp3
-rw-r--r--src/gui/setup_keyboard.cpp23
-rw-r--r--src/gui/socialwindow.cpp1
-rw-r--r--src/gui/statuspopup.cpp5
-rw-r--r--src/gui/viewport.cpp13
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp3
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp3
-rw-r--r--src/gui/windowmenu.cpp4
10 files changed, 41 insertions, 30 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 4040c3ce0..3832e5850 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -27,6 +27,7 @@
#include "commandhandler.h"
#include "configuration.h"
#include "guild.h"
+#include "inputmanager.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "party.h"
@@ -783,18 +784,18 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mCurHist = mHistory.end();
mChatInput->setText("");
}
- else if (keyboard.isActionActive(Input::KEY_AUTOCOMPLETE_CHAT) &&
+ else if (inputManager.isActionActive(Input::KEY_AUTOCOMPLETE_CHAT) &&
mChatInput->getText() != "")
{
autoComplete();
return;
}
- else if (keyboard.isActionActive(Input::KEY_DEACTIVATE_CHAT) &&
+ else if (inputManager.isActionActive(Input::KEY_DEACTIVATE_CHAT) &&
mChatInput->isVisible())
{
mChatInput->processVisible(false);
}
- else if (keyboard.isActionActive(Input::KEY_CHAT_PREV_HISTORY) &&
+ else if (inputManager.isActionActive(Input::KEY_CHAT_PREV_HISTORY) &&
mChatInput->isVisible())
{
ChatTab *tab = getFocused();
@@ -826,7 +827,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatInput->getText().length()));
}
}
- else if (keyboard.isActionActive(Input::KEY_CHAT_NEXT_HISTORY) &&
+ else if (inputManager.isActionActive(Input::KEY_CHAT_NEXT_HISTORY) &&
mChatInput->isVisible())
{
ChatTab *tab = getFocused();
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 54b1801b8..f905bb5b9 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -26,6 +26,7 @@
#include "inventory.h"
#include "item.h"
#include "units.h"
+#include "inputmanager.h"
#include "keyboardconfig.h"
#include "playerinfo.h"
@@ -344,7 +345,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
}
else
{
- if (keyboard.isActionActive(Input::KEY_MOD))
+ if (inputManager.isActionActive(Input::KEY_MOD))
{
Net::getInventoryHandler()->dropItem(
item, item->getQuantity());
@@ -389,11 +390,11 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
Window::mouseClicked(event);
- const bool mod = (isStorageActive() && keyboard.isActionActive(
+ const bool mod = (isStorageActive() && inputManager.isActionActive(
Input::KEY_MOD));
const bool mod2 = (tradeWindow && tradeWindow->isVisible()
- && keyboard.isActionActive(Input::KEY_MOD));
+ && inputManager.isActionActive(Input::KEY_MOD));
if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT)
{
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 6168af665..1552d793f 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -26,6 +26,7 @@
#include "emoteshortcut.h"
#include "equipment.h"
#include "graphics.h"
+#include "inputmanager.h"
#include "inventory.h"
#include "item.h"
#include "keyboardconfig.h"
@@ -506,7 +507,7 @@ std::string OutfitWindow::keyName(int number)
{
if (number < 0 || number >= SHORTCUT_EMOTES)
return "";
- return keyboard.getKeyStringLong(Input::KEY_EMOTE_1 + number);
+ return inputManager.getKeyStringLong(Input::KEY_EMOTE_1 + number);
}
void OutfitWindow::next()
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 2d8c1c28d..ee06fa4a7 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -23,6 +23,7 @@
#include "gui/setup_keyboard.h"
+#include "inputmanager.h"
#include "keyboardconfig.h"
#include "gui/okdialog.h"
@@ -747,7 +748,7 @@ Setup_Keyboard::Setup_Keyboard():
mKeyList(new ListBox(mKeyListModel)),
mKeySetting(false)
{
- keyboard.setSetupKeyboard(this);
+ inputManager.setSetupKeyboard(this);
setName(_("Keyboard"));
refreshKeys();
@@ -800,7 +801,7 @@ void Setup_Keyboard::apply()
keyUnresolved();
int key1, key2;
- if (keyboard.hasConflicts(key1, key2))
+ if (inputManager.hasConflicts(key1, key2))
{
int s1 = keyToSetupData(key1);
int s2 = keyToSetupData(key2);
@@ -812,14 +813,14 @@ void Setup_Keyboard::apply()
setupActionData[s2].name.c_str()), DIALOG_ERROR);
}
keyboard.setEnabled(true);
- keyboard.store();
+ inputManager.store();
}
void Setup_Keyboard::cancel()
{
keyUnresolved();
- keyboard.retrieve();
+ inputManager.retrieve();
keyboard.setEnabled(true);
refreshKeys();
@@ -858,7 +859,7 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
{
const SetupActionData &key = setupActionData[i];
int ik = key.actionId;
- keyboard.setNewKeyIndex(ik);
+ inputManager.setNewKeyIndex(ik);
mKeyListModel->setElementAt(i, std::string(
gettext(key.name.c_str())) + ": ?");
}
@@ -870,15 +871,15 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
{
const SetupActionData &key = setupActionData[i];
int ik = key.actionId;
- keyboard.setNewKeyIndex(ik);
+ inputManager.setNewKeyIndex(ik);
refreshAssignedKey(mKeyList->getSelected());
- keyboard.unassignKey();
+ inputManager.unassignKey();
}
mAssignKeyButton->setEnabled(true);
}
else if (event.getId() == "makeDefault")
{
- keyboard.makeDefault();
+ inputManager.makeDefault();
refreshKeys();
}
}
@@ -897,7 +898,7 @@ void Setup_Keyboard::refreshAssignedKey(int index)
{
mKeyListModel->setElementAt(index, strprintf("%s: %s",
gettext(key.name.c_str()),
- keyboard.getKeyStringLong(key.actionId).c_str()));
+ inputManager.getKeyStringLong(key.actionId).c_str()));
}
}
@@ -931,7 +932,7 @@ void Setup_Keyboard::keyUnresolved()
{
if (mKeySetting)
{
- newKeyCallback(keyboard.getNewKeyIndex());
- keyboard.setNewKeyIndex(Input::KEY_NO_VALUE);
+ newKeyCallback(inputManager.getNewKeyIndex());
+ inputManager.setNewKeyIndex(Input::KEY_NO_VALUE);
}
}
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 361e94037..458fe1450 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -24,6 +24,7 @@
#include "actorspritemanager.h"
#include "guild.h"
#include "guildmanager.h"
+#include "inputmanager.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "logger.h"
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index 420ffaf3d..cc0f5c030 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -32,6 +32,7 @@
#include "gui/widgets/textbox.h"
#include "graphics.h"
+#include "inputmanager.h"
#include "localplayer.h"
#include "units.h"
#include "keyboardconfig.h"
@@ -188,13 +189,13 @@ void StatusPopup::view(int x, int y)
void StatusPopup::setLabelText(gcn::Label *label, const char *text, int key)
{
label->setCaption(strprintf("%s %s", text,
- keyboard.getKeyValueString(key).c_str()));
+ inputManager.getKeyValueString(key).c_str()));
}
void StatusPopup::setLabelText2(gcn::Label *label, std::string text, int key)
{
label->setCaption(strprintf("%s %s", text.c_str(),
- keyboard.getKeyValueString(key).c_str()));
+ inputManager.getKeyValueString(key).c_str()));
label->adjustSize();
}
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 6c6580f21..59b7377f4 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -28,6 +28,7 @@
#include "configuration.h"
#include "graphics.h"
#include "itemshortcut.h"
+#include "inputmanager.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "map.h"
@@ -504,17 +505,17 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
}
}
else if (player_node->withinAttackRange(mHoverBeing) ||
- keyboard.isActionActive(Input::KEY_ATTACK))
+ inputManager.isActionActive(Input::KEY_ATTACK))
{
validateSpeed();
if (player_node != mHoverBeing)
{
player_node->attack(mHoverBeing,
- !keyboard.isActionActive(Input::KEY_TARGET));
+ !inputManager.isActionActive(Input::KEY_TARGET));
return;
}
}
- else if (!keyboard.isActionActive(Input::KEY_ATTACK))
+ else if (!inputManager.isActionActive(Input::KEY_ATTACK))
{
validateSpeed();
if (player_node != mHoverBeing)
@@ -532,7 +533,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
player_node->pickUp(mHoverItem);
}
// Just walk around
- else if (!keyboard.isActionActive(Input::KEY_ATTACK))
+ else if (!inputManager.isActionActive(Input::KEY_ATTACK))
{
validateSpeed();
player_node->stopAttack();
@@ -933,8 +934,8 @@ void Viewport::returnCamera()
void Viewport::validateSpeed()
{
- if (!keyboard.isActionActive(Input::KEY_TARGET_ATTACK)
- && !keyboard.isActionActive(Input::KEY_ATTACK))
+ if (!inputManager.isActionActive(Input::KEY_TARGET_ATTACK)
+ && !inputManager.isActionActive(Input::KEY_ATTACK))
{
if (Game::instance())
Game::instance()->setValidSpeed();
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index f46ee579c..f1f040966 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -25,6 +25,7 @@
#include "configuration.h"
#include "emoteshortcut.h"
#include "graphics.h"
+#include "inputmanager.h"
#include "inventory.h"
#include "item.h"
#include "itemshortcut.h"
@@ -117,7 +118,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
g->drawImage(mBackgroundImg, emoteX, emoteY);
// Draw emote keyboard shortcut.
- std::string key = keyboard.getKeyValueString(
+ std::string key = inputManager.getKeyValueString(
Input::KEY_EMOTE_1 + i);
graphics->setColor(getForegroundColor());
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 981491dd7..a6f7f60a3 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -25,6 +25,7 @@
#include "configuration.h"
#include "graphics.h"
#include "inventory.h"
+#include "inputmanager.h"
#include "item.h"
#include "itemshortcut.h"
#include "spellshortcut.h"
@@ -121,7 +122,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
g->drawImage(mBackgroundImg, itemX, itemY);
// Draw item keyboard shortcut.
- std::string key = keyboard.getKeyValueString(
+ std::string key = inputManager.getKeyValueString(
Input::KEY_SHORTCUT_1 + i);
graphics->setColor(getForegroundColor());
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index bb7a989ea..12085578b 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -24,6 +24,7 @@
#include "emoteshortcut.h"
#include "graphics.h"
+#include "inputmanager.h"
#include "keyboardconfig.h"
#include "gui/didyouknowwindow.h"
@@ -308,7 +309,8 @@ void WindowMenu::mouseMoved(gcn::MouseEvent &event)
if (key != Input::KEY_NO_VALUE)
{
mTextPopup->show(x + getX(), y + getY(), btn->getDescription(),
- strprintf(_("Key: %s"), keyboard.getKeyValueString(key).c_str()));
+ strprintf(_("Key: %s"), inputManager.getKeyValueString(
+ key).c_str()));
}
else
{