summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-07-24 13:54:06 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-07-24 13:54:06 +0000
commit8e3fad97a5df4bfc706b0246794b00428bd207e0 (patch)
tree92b36ee0b3180544464ed4ec3109efebc34979dc
parentdc5d9dee3f3f726d463f5f23f5902d1d0373df93 (diff)
downloadmana-client-8e3fad97a5df4bfc706b0246794b00428bd207e0.tar.gz
mana-client-8e3fad97a5df4bfc706b0246794b00428bd207e0.tar.bz2
mana-client-8e3fad97a5df4bfc706b0246794b00428bd207e0.tar.xz
mana-client-8e3fad97a5df4bfc706b0246794b00428bd207e0.zip
Fixed initialization order and added setup_keyboard.* and keyboardconfig.* to
the list of source files. Also set some missing Subversion properties.
-rw-r--r--ChangeLog18
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/gui/setup_keyboard.cpp283
-rw-r--r--src/gui/setup_keyboard.h163
-rw-r--r--src/keyboardconfig.cpp263
-rw-r--r--src/keyboardconfig.h399
-rw-r--r--src/resources/equipmentinfo.h153
8 files changed, 646 insertions, 641 deletions
diff --git a/ChangeLog b/ChangeLog
index 1d6ca15e..0edfeebb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,19 @@
-2007-07-17 Joshua Langley <joshlangley[at]optusnet.com.au>
+2007-07-24 Bjørn Lindeijer <bjorn@lindeijer.nl>
- * src/game.cpp: only one key per function.
- * src/main.cpp: keyboard configuration included.
- * src/gui/button.cpp, src/gui/button.h: default constructor and
+ * src/CMakeLists.txt, src/Makefile.am: Added setup_keyboard.* and
+ keyboardconfig.* to the list of source files.
+ * src/keyboardconfig.h: Fixed initialization order.
+
+2007-07-17 Joshua Langley <joshlangley[at]optusnet.com.au>
+
+ * src/game.cpp: Only one key per function.
+ * src/main.cpp: Keyboard configuration included.
+ * src/gui/button.cpp, src/gui/button.h: Default constructor and
init function added.
- * src/gui/setup.cpp: keyboard setup tab added.
+ * src/gui/setup.cpp: Keyboard setup tab added.
* src/gui/setup_keyboard.cpp, src/gui/setup_keyboard.h:
Add to project file, it is the keyboard setup tab.
- * src/keyboardconfig.cpp, src/keyboardconfig.h: Add to project file,
+ * src/keyboardconfig.cpp, src/keyboardconfig.h: Add to project file,
the main keyboard config operations.
2007-07-16 Eugenio Favalli <elvenprogrammer@gmail.com>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e4c7bba9..b1342e8c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -138,6 +138,8 @@ SET(SRCS
gui/setup.h
gui/setup_joystick.cpp
gui/setup_joystick.h
+ gui/setup_keyboard.cpp
+ gui/setup_keyboard.h
gui/setuptab.h
gui/setup_video.cpp
gui/setup_video.h
@@ -293,6 +295,8 @@ SET(SRCS
item.h
joystick.cpp
joystick.h
+ keyboardconfig.cpp
+ keyboardconfig.h
localplayer.cpp
localplayer.h
lockedarray.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 4f524373..3d801721 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -87,6 +87,8 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
gui/setup.h \
gui/setup_joystick.cpp \
gui/setup_joystick.h \
+ gui/setup_keyboard.cpp \
+ gui/setup_keyboard.h \
gui/setuptab.h \
gui/setup_video.cpp \
gui/setup_video.h \
@@ -242,6 +244,8 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
item.h \
joystick.cpp \
joystick.h \
+ keyboardconfig.cpp \
+ keyboardconfig.h \
localplayer.cpp \
localplayer.h \
lockedarray.h \
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 4cb39494..6a89ce8f 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -1,141 +1,142 @@
-/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include "setup_keyboard.h"
-
-#include <guichan/widgets/label.hpp>
-
-#include "button.h"
-#include "ok_dialog.h"
-
-#include "../configuration.h"
-#include "../keyboardconfig.h"
-
-#include "../utils/tostring.h"
-
-#include <SDL_keyboard.h>
-
-Setup_Keyboard::Setup_Keyboard()
-{
- setOpaque(false);
-
- keyboard.setSetupKeyboard(this);
-
- mKeyLabel = new gcn::Label[keyboard.KEY_TOTAL];
- mKeyButton = new Button[keyboard.KEY_TOTAL];
-
- for (int i=0; i < keyboard.KEY_TOTAL; i++)
- {
- refreshAssignedKey(i);
- mKeyLabel[i].setPosition(10, 10+(i*20));
- add(&mKeyLabel[i]);
-
- mKeyButton[i].setCaption("Set");
- mKeyButton[i].adjustSize();
- mKeyButton[i].addActionListener(this);
- mKeyButton[i].setActionEventId("sk"+toString(i));
- mKeyButton[i].setPosition(150,5+(i*20));
- add(&mKeyButton[i]);
- }
- mMakeDefaultButton = new Button("Default", "makeDefault", this);
- mMakeDefaultButton->setPosition(200, 5);
- mMakeDefaultButton->addActionListener(this);
- add(mMakeDefaultButton);
-}
-
-Setup_Keyboard::~Setup_Keyboard()
-{
- delete [] mKeyLabel;
- delete [] mKeyButton;
- delete mMakeDefaultButton;
-}
-
-void Setup_Keyboard::apply()
-{
- if (keyboard.hasConflicts())
- {
- new OkDialog("Key Conflict(s) Detected.",
- "One or more key conflicts has been detected. "
- "Resolve them immediately, "
- "or gameplay might result in unpredictable behaviour");
- }
- keyboard.setEnabled(true);
- keyboard.store();
-}
-
-void Setup_Keyboard::cancel()
-{
- keyboard.retrieve();
- keyboard.setEnabled(true);
- refreshKeys();
-}
-
-void Setup_Keyboard::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "makeDefault")
- {
- keyboard.makeDefault();
- refreshKeys();
- return;
- }
- for (int i=0; i < keyboard.KEY_TOTAL; i++)
- {
- if (event.getId() == "sk"+toString(i))
- {
- keyboard.setEnabled(false);
- keyboard.setNewKeyIndex(i);
- enableSetButtons(false);
- mKeyLabel[i].setCaption(keyboard.getKeyCaption(i) + ": ?");
- }
- }
-}
-
-void Setup_Keyboard::enableSetButtons(bool bValue)
-{
- for (int i=0; i < keyboard.KEY_TOTAL; i++)
- {
- mKeyButton[i].setEnabled(bValue);
- }
-}
-
-void Setup_Keyboard::refreshAssignedKey(const int index)
-{
- char *temp = SDL_GetKeyName(
- (SDLKey) keyboard.getKeyValue(index));
- mKeyLabel[index].setCaption(
- keyboard.getKeyCaption(index) + ": " + toString(temp));
- mKeyLabel[index].adjustSize();
-}
-
-void Setup_Keyboard::newKeyCallback(const int index)
-{
- refreshAssignedKey(index);
- enableSetButtons(true);
-}
-
-void Setup_Keyboard::refreshKeys()
-{
- for(int i=0; i < keyboard.KEY_TOTAL; i++)
- {
- refreshAssignedKey(i);
- }
-}
+/*
+ * The Mana World
+ * Copyright 2007 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "setup_keyboard.h"
+
+#include <guichan/widgets/label.hpp>
+
+#include "button.h"
+#include "ok_dialog.h"
+
+#include "../configuration.h"
+#include "../keyboardconfig.h"
+
+#include "../utils/tostring.h"
+
+#include <SDL_keyboard.h>
+
+Setup_Keyboard::Setup_Keyboard()
+{
+ setOpaque(false);
+
+ keyboard.setSetupKeyboard(this);
+
+ mKeyLabel = new gcn::Label[keyboard.KEY_TOTAL];
+ mKeyButton = new Button[keyboard.KEY_TOTAL];
+
+ for (int i = 0; i < keyboard.KEY_TOTAL; i++)
+ {
+ refreshAssignedKey(i);
+ mKeyLabel[i].setPosition(10, 10+(i*20));
+ add(&mKeyLabel[i]);
+
+ mKeyButton[i].setCaption("Set");
+ mKeyButton[i].adjustSize();
+ mKeyButton[i].addActionListener(this);
+ mKeyButton[i].setActionEventId("sk"+toString(i));
+ mKeyButton[i].setPosition(150,5+(i*20));
+ add(&mKeyButton[i]);
+ }
+ mMakeDefaultButton = new Button("Default", "makeDefault", this);
+ mMakeDefaultButton->setPosition(200, 5);
+ mMakeDefaultButton->addActionListener(this);
+ add(mMakeDefaultButton);
+}
+
+Setup_Keyboard::~Setup_Keyboard()
+{
+ delete [] mKeyLabel;
+ delete [] mKeyButton;
+ delete mMakeDefaultButton;
+}
+
+void Setup_Keyboard::apply()
+{
+ if (keyboard.hasConflicts())
+ {
+ new OkDialog("Key Conflict(s) Detected.",
+ "One or more key conflicts has been detected. "
+ "Resolve them immediately, "
+ "or gameplay might result in unpredictable behaviour");
+ }
+ keyboard.setEnabled(true);
+ keyboard.store();
+}
+
+void Setup_Keyboard::cancel()
+{
+ keyboard.retrieve();
+ keyboard.setEnabled(true);
+ refreshKeys();
+}
+
+void Setup_Keyboard::action(const gcn::ActionEvent &event)
+{
+ if (event.getId() == "makeDefault")
+ {
+ keyboard.makeDefault();
+ refreshKeys();
+ return;
+ }
+ for (int i = 0; i < keyboard.KEY_TOTAL; i++)
+ {
+ if (event.getId() == "sk"+toString(i))
+ {
+ keyboard.setEnabled(false);
+ keyboard.setNewKeyIndex(i);
+ enableSetButtons(false);
+ mKeyLabel[i].setCaption(keyboard.getKeyCaption(i) + ": ?");
+ }
+ }
+}
+
+void Setup_Keyboard::enableSetButtons(bool bValue)
+{
+ for (int i = 0; i < keyboard.KEY_TOTAL; i++)
+ {
+ mKeyButton[i].setEnabled(bValue);
+ }
+}
+
+void Setup_Keyboard::refreshAssignedKey(const int index)
+{
+ char *temp = SDL_GetKeyName(
+ (SDLKey) keyboard.getKeyValue(index));
+ mKeyLabel[index].setCaption(
+ keyboard.getKeyCaption(index) + ": " + toString(temp));
+ mKeyLabel[index].adjustSize();
+}
+
+void Setup_Keyboard::newKeyCallback(const int index)
+{
+ refreshAssignedKey(index);
+ enableSetButtons(true);
+}
+
+void Setup_Keyboard::refreshKeys()
+{
+ for (int i = 0; i < keyboard.KEY_TOTAL; i++)
+ {
+ refreshAssignedKey(i);
+ }
+}
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index 115a2b9a..4701487b 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -1,81 +1,82 @@
-/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#ifndef _TMW_GUI_SETUP_KEYBOARD_H
-#define _TMW_GUI_SETUP_KEYBOARD_H
-
-#include "setuptab.h"
-#include "button.h"
-#include "../guichanfwd.h"
-
-#include <guichan/actionlistener.hpp>
-
-
-#include <string>
-
-class Setup_Keyboard : public SetupTab, public gcn::ActionListener
-{
- public:
- /**
- * Constructor
- */
- Setup_Keyboard();
-
- /**
- * Destructor
- */
- ~Setup_Keyboard();
-
- void apply();
- void cancel();
-
- void action(const gcn::ActionEvent &event);
-
- /**
- * Easy way to disable/enable all the set buttons.
- */
- void enableSetButtons(bool bValue);
-
- /**
- * Get an update on the assigned key.
- */
- void refreshAssignedKey(const int index);
-
- /**
- * The callback function when a new key has been pressed.
- */
- void newKeyCallback(const int index);
-
- /**
- * Shorthand method to update all the keys.
- */
- void refreshKeys();
-
- private:
- gcn::Label *mKeyLabel;
-
- Button *mKeyButton;
-
- gcn::Button *mMakeDefaultButton;
-};
-
-#endif
+/*
+ * The Mana World
+ * Copyright 2007 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_GUI_SETUP_KEYBOARD_H
+#define _TMW_GUI_SETUP_KEYBOARD_H
+
+#include "setuptab.h"
+#include "button.h"
+#include "../guichanfwd.h"
+
+#include <guichan/actionlistener.hpp>
+
+
+#include <string>
+
+class Setup_Keyboard : public SetupTab, public gcn::ActionListener
+{
+ public:
+ /**
+ * Constructor
+ */
+ Setup_Keyboard();
+
+ /**
+ * Destructor
+ */
+ ~Setup_Keyboard();
+
+ void apply();
+ void cancel();
+
+ void action(const gcn::ActionEvent &event);
+
+ /**
+ * Easy way to disable/enable all the set buttons.
+ */
+ void enableSetButtons(bool bValue);
+
+ /**
+ * Get an update on the assigned key.
+ */
+ void refreshAssignedKey(const int index);
+
+ /**
+ * The callback function when a new key has been pressed.
+ */
+ void newKeyCallback(const int index);
+
+ /**
+ * Shorthand method to update all the keys.
+ */
+ void refreshKeys();
+
+ private:
+ gcn::Label *mKeyLabel;
+
+ Button *mKeyButton;
+
+ gcn::Button *mMakeDefaultButton;
+};
+
+#endif
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 5cce793a..277fbcd3 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -1,131 +1,132 @@
-/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include "keyboardconfig.h"
-#include "configuration.h"
-#include "log.h"
-
-#include <guichan/sdl/sdlinput.hpp>
-
-#include "gui/setup_keyboard.h"
-
-void KeyboardConfig::init()
-{
- mKey[KEY_MOVE_UP] = KeyFunction("keyMoveUp", SDLK_UP, "Move Up");
- mKey[KEY_MOVE_DOWN] = KeyFunction("keyMoveDown", SDLK_DOWN, "Move Down");
- mKey[KEY_MOVE_LEFT] = KeyFunction("keyMoveLeft", SDLK_LEFT, "Move Left");
- mKey[KEY_MOVE_RIGHT] =
- KeyFunction("keyMoveRight", SDLK_RIGHT, "Move Right");
-
- mKey[KEY_ATTACK] = KeyFunction("keyAttack", SDLK_LCTRL, "Attack");
- mKey[KEY_TARGET] = KeyFunction("keyTarget", SDLK_LSHIFT, "Target");
- mKey[KEY_TARGET_CLOSEST] =
- KeyFunction("keyTargetClosest", SDLK_a, "Target Closest");
- mKey[KEY_PICKUP] = KeyFunction("keyPickup", SDLK_z, "Pickup");
- mKey[KEY_HIDE_WINDOWS] =
- KeyFunction("keyHideWindows", SDLK_h, "Hide Windows");
- mKey[KEY_SIT] = KeyFunction("keyBeingSit", SDLK_g, "Sit");
-
- for (int i = 0; i < KEY_TOTAL; i++)
- {
- mKey[i].value = KEY_NO_VALUE;
- }
- mNewKeyIndex = KEY_NO_VALUE;
- mEnabled = true;
-
- retrieve();
-}
-
-void KeyboardConfig::destroy()
-{
- store();
-
- delete [] mActiveKeys;
-}
-
-void KeyboardConfig::retrieve()
-{
- for (int i = 0; i < KEY_TOTAL; i++)
- {
- mKey[i].value = (int) config.getValue(
- mKey[i].configField, mKey[i].defaultValue);
- }
-}
-
-void KeyboardConfig::store()
-{
- for (int i = 0; i < KEY_TOTAL; i++)
- {
- config.setValue(mKey[i].configField, mKey[i].value);
- }
-}
-
-void KeyboardConfig::makeDefault()
-{
- for (int i = 0; i < KEY_TOTAL; i++)
- {
- mKey[i].value = mKey[i].defaultValue;
- }
-}
-
-bool KeyboardConfig::hasConflicts()
-{
- int i, j;
- for (i = 0; i < KEY_TOTAL; i++)
- {
- for (j = 0; j < KEY_TOTAL; j++)
- {
- if (i != j && mKey[i].value == mKey[j].value)
- {
- return true;
- }
- }
- }
- return false;
-}
-
-void KeyboardConfig::callbackNewKey()
-{
- mSetupKey->newKeyCallback(mNewKeyIndex);
-}
-
-int KeyboardConfig::getKeyIndex(const int keyValue) const
-{
- for (int i = 0; i < KEY_TOTAL; i++)
- {
- if(keyValue == mKey[i].value)
- {
- return i;
- }
- }
- return KEY_NO_VALUE;
-}
-
-bool KeyboardConfig::isKeyActive(int index)
-{
- return mActiveKeys[ mKey[index].value];
-}
-
-void KeyboardConfig::refreshActiveKeys()
-{
- mActiveKeys = SDL_GetKeyState(NULL);
-}
+/*
+ * The Mana World
+ * Copyright 2007 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "keyboardconfig.h"
+#include "configuration.h"
+#include "log.h"
+
+#include <guichan/sdl/sdlinput.hpp>
+
+#include "gui/setup_keyboard.h"
+
+void KeyboardConfig::init()
+{
+ mKey[KEY_MOVE_UP] = KeyFunction("keyMoveUp", SDLK_UP, "Move Up");
+ mKey[KEY_MOVE_DOWN] = KeyFunction("keyMoveDown", SDLK_DOWN, "Move Down");
+ mKey[KEY_MOVE_LEFT] = KeyFunction("keyMoveLeft", SDLK_LEFT, "Move Left");
+ mKey[KEY_MOVE_RIGHT] =
+ KeyFunction("keyMoveRight", SDLK_RIGHT, "Move Right");
+
+ mKey[KEY_ATTACK] = KeyFunction("keyAttack", SDLK_LCTRL, "Attack");
+ mKey[KEY_TARGET] = KeyFunction("keyTarget", SDLK_LSHIFT, "Target");
+ mKey[KEY_TARGET_CLOSEST] =
+ KeyFunction("keyTargetClosest", SDLK_a, "Target Closest");
+ mKey[KEY_PICKUP] = KeyFunction("keyPickup", SDLK_z, "Pickup");
+ mKey[KEY_HIDE_WINDOWS] =
+ KeyFunction("keyHideWindows", SDLK_h, "Hide Windows");
+ mKey[KEY_SIT] = KeyFunction("keyBeingSit", SDLK_g, "Sit");
+
+ for (int i = 0; i < KEY_TOTAL; i++)
+ {
+ mKey[i].value = KEY_NO_VALUE;
+ }
+ mNewKeyIndex = KEY_NO_VALUE;
+ mEnabled = true;
+
+ retrieve();
+}
+
+void KeyboardConfig::destroy()
+{
+ store();
+
+ delete [] mActiveKeys;
+}
+
+void KeyboardConfig::retrieve()
+{
+ for (int i = 0; i < KEY_TOTAL; i++)
+ {
+ mKey[i].value = (int) config.getValue(
+ mKey[i].configField, mKey[i].defaultValue);
+ }
+}
+
+void KeyboardConfig::store()
+{
+ for (int i = 0; i < KEY_TOTAL; i++)
+ {
+ config.setValue(mKey[i].configField, mKey[i].value);
+ }
+}
+
+void KeyboardConfig::makeDefault()
+{
+ for (int i = 0; i < KEY_TOTAL; i++)
+ {
+ mKey[i].value = mKey[i].defaultValue;
+ }
+}
+
+bool KeyboardConfig::hasConflicts()
+{
+ int i, j;
+ for (i = 0; i < KEY_TOTAL; i++)
+ {
+ for (j = 0; j < KEY_TOTAL; j++)
+ {
+ if (i != j && mKey[i].value == mKey[j].value)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void KeyboardConfig::callbackNewKey()
+{
+ mSetupKey->newKeyCallback(mNewKeyIndex);
+}
+
+int KeyboardConfig::getKeyIndex(const int keyValue) const
+{
+ for (int i = 0; i < KEY_TOTAL; i++)
+ {
+ if(keyValue == mKey[i].value)
+ {
+ return i;
+ }
+ }
+ return KEY_NO_VALUE;
+}
+
+bool KeyboardConfig::isKeyActive(int index)
+{
+ return mActiveKeys[ mKey[index].value];
+}
+
+void KeyboardConfig::refreshActiveKeys()
+{
+ mActiveKeys = SDL_GetKeyState(NULL);
+}
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index f074e001..e2eef385 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -1,206 +1,193 @@
-/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#ifndef _TMW_KEYBOARDCONFIG_H
-#define _TMW_KEYBOARDCONFIG_H
-
-#include <string>
-
-#include "gui/setup_keyboard.h"
-
-#include <guichan/sdl/sdlinput.hpp>
-
-/**
- * Each key represents a key function. Such as 'Move up', 'Attack' etc.
- */
-struct KeyFunction
-{
- KeyFunction(){}
- KeyFunction(std::string configField, int defaultValue, std::string caption):
- configField(configField),
- defaultValue(defaultValue),
- caption(caption)
- { }
-
- std::string configField; /** Field index that is in the config file. */
- std::string caption; /** The caption value for the key function. */
- int defaultValue; /** The default key value used. */
- int value; /** The actual value that is used. */
-};
-
-class KeyboardConfig
-{
- public:
- /**
- * Initializes the keyboard config explicitly.
- */
- void init();
-
- /**
- * Destroys the keyboard config explicitly.
- */
- void destroy();
-
- /**
- * Retrieve the key values from config file.
- */
- void retrieve();
-
- /**
- * Store the key values to config file.
- */
- void store();
-
- /**
- * Make the keys their default values.
- */
- void makeDefault();
-
- /**
- * Determines if any key assignments are the same as each other.
- */
- bool hasConflicts();
-
- /**
- * Calls a function back so the key re-assignment(s) can be seen.
- */
- void callbackNewKey();
-
- /**
- * Obtain the value stored in memory.
- */
- int getKeyValue(int index) const
- {
- return mKey[index].value;
- };
-
- /**
- * Get the index of the new key to be assigned.
- */
- int getNewKeyIndex() const
- {
- return mNewKeyIndex;
- };
-
- /**
- * Get the enable flag, which will stop the user from doing actions.
- */
- bool isEnabled() const
- {
- return mEnabled;
- };
-
- /**
- * Get the key caption, providing more meaning to the user.
- */
- std::string& getKeyCaption(int index)
- {
- return mKey[index].caption;
- };
-
- /**
- * Get the key function index by providing the keys value.
- */
- int getKeyIndex(int keyValue) const;
-
- /**
- * Set the enable flag, which will stop the user from doing actions.
- */
- void setEnabled(bool flag)
- {
- mEnabled = flag;
- };
-
- /**
- * Set the index of the new key to be assigned.
- */
- void setNewKeyIndex(int value)
- {
- mNewKeyIndex = value;
- };
-
- /**
- * Set the value of the new key.
- */
- void setNewKey(int value)
- {
- mKey[mNewKeyIndex].value = value;
- };
-
- /**
- * Set a reference to the key setup window.
- */
- void setSetupKeyboard(Setup_Keyboard *setupKey)
- {
- mSetupKey = setupKey;
- };
-
- /**
- * Checks if the key is active, by providing the key function index.
- */
- bool isKeyActive(const int index);
-
- /**
- * Takes a snapshot of all the active keys.
- */
- void refreshActiveKeys();
-
- /**
- * All the key functions.
- * KEY_NO_VALUE is used in initialization, and should be unchanged.
- * KEY_MIN and KEY_TOTAL should always be first and last respectively,
- * the bare used in control loops.
- * The third element (after KEY_NO_VALUE and KEY_MIN),
- * should always equal KEY_MIN.
- * The key assignment view gets arranged according to the order of
- * these values.
- */
- enum KeyAction {
- KEY_NO_VALUE = -1,
- KEY_MOVE_UP,
- KEY_MOVE_DOWN,
- KEY_MOVE_LEFT,
- KEY_MOVE_RIGHT,
- KEY_ATTACK,
- KEY_TARGET,
- KEY_TARGET_CLOSEST,
- KEY_PICKUP,
- KEY_SIT,
- KEY_HIDE_WINDOWS,
- KEY_TOTAL
- };
- private:
- int mNewKeyIndex; /** Index of new key to be assigned */
- bool mEnabled; /** Flag to determine respond to key input */
-
- Setup_Keyboard *mSetupKey; /** Reference to setup window */
-
- KeyFunction mKey[KEY_TOTAL]; /** Pointer to all the key data */
-
- Uint8 *mActiveKeys; /** Stores a list of all the keys */
-
-};
-extern KeyboardConfig keyboard;
-
-#endif
-
-
+/*
+ * The Mana World
+ * Copyright 2007 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_KEYBOARDCONFIG_H
+#define _TMW_KEYBOARDCONFIG_H
+
+#include <string>
+
+#include "gui/setup_keyboard.h"
+
+#include <guichan/sdl/sdlinput.hpp>
+
+/**
+ * Each key represents a key function. Such as 'Move up', 'Attack' etc.
+ */
+struct KeyFunction
+{
+ KeyFunction() {}
+
+ KeyFunction(std::string configField,
+ int defaultValue,
+ std::string caption):
+ configField(configField),
+ caption(caption),
+ defaultValue(defaultValue)
+ {}
+
+ std::string configField; /** Field index that is in the config file. */
+ std::string caption; /** The caption value for the key function. */
+ int defaultValue; /** The default key value used. */
+ int value; /** The actual value that is used. */
+};
+
+class KeyboardConfig
+{
+ public:
+ /**
+ * Initializes the keyboard config explicitly.
+ */
+ void init();
+
+ /**
+ * Destroys the keyboard config explicitly.
+ */
+ void destroy();
+
+ /**
+ * Retrieve the key values from config file.
+ */
+ void retrieve();
+
+ /**
+ * Store the key values to config file.
+ */
+ void store();
+
+ /**
+ * Make the keys their default values.
+ */
+ void makeDefault();
+
+ /**
+ * Determines if any key assignments are the same as each other.
+ */
+ bool hasConflicts();
+
+ /**
+ * Calls a function back so the key re-assignment(s) can be seen.
+ */
+ void callbackNewKey();
+
+ /**
+ * Obtain the value stored in memory.
+ */
+ int getKeyValue(int index) const
+ { return mKey[index].value; }
+
+ /**
+ * Get the index of the new key to be assigned.
+ */
+ int getNewKeyIndex() const
+ { return mNewKeyIndex; }
+
+ /**
+ * Get the enable flag, which will stop the user from doing actions.
+ */
+ bool isEnabled() const
+ { return mEnabled; }
+
+ /**
+ * Get the key caption, providing more meaning to the user.
+ */
+ std::string& getKeyCaption(int index)
+ { return mKey[index].caption; }
+
+ /**
+ * Get the key function index by providing the keys value.
+ */
+ int getKeyIndex(int keyValue) const;
+
+ /**
+ * Set the enable flag, which will stop the user from doing actions.
+ */
+ void setEnabled(bool flag)
+ { mEnabled = flag; }
+
+ /**
+ * Set the index of the new key to be assigned.
+ */
+ void setNewKeyIndex(int value)
+ { mNewKeyIndex = value; }
+
+ /**
+ * Set the value of the new key.
+ */
+ void setNewKey(int value)
+ { mKey[mNewKeyIndex].value = value; }
+
+ /**
+ * Set a reference to the key setup window.
+ */
+ void setSetupKeyboard(Setup_Keyboard *setupKey)
+ { mSetupKey = setupKey; }
+
+ /**
+ * Checks if the key is active, by providing the key function index.
+ */
+ bool isKeyActive(const int index);
+
+ /**
+ * Takes a snapshot of all the active keys.
+ */
+ void refreshActiveKeys();
+
+ /**
+ * All the key functions.
+ * KEY_NO_VALUE is used in initialization, and should be unchanged.
+ * KEY_MIN and KEY_TOTAL should always be first and last respectively,
+ * the bare used in control loops.
+ * The third element (after KEY_NO_VALUE and KEY_MIN),
+ * should always equal KEY_MIN.
+ * The key assignment view gets arranged according to the order of
+ * these values.
+ */
+ enum KeyAction {
+ KEY_NO_VALUE = -1,
+ KEY_MOVE_UP,
+ KEY_MOVE_DOWN,
+ KEY_MOVE_LEFT,
+ KEY_MOVE_RIGHT,
+ KEY_ATTACK,
+ KEY_TARGET,
+ KEY_TARGET_CLOSEST,
+ KEY_PICKUP,
+ KEY_SIT,
+ KEY_HIDE_WINDOWS,
+ KEY_TOTAL
+ };
+
+ private:
+ int mNewKeyIndex; /** Index of new key to be assigned */
+ bool mEnabled; /** Flag to determine respond to key input */
+
+ Setup_Keyboard *mSetupKey; /** Reference to setup window */
+
+ KeyFunction mKey[KEY_TOTAL]; /** Pointer to all the key data */
+
+ Uint8 *mActiveKeys; /** Stores a list of all the keys */
+};
+
+extern KeyboardConfig keyboard;
+
+#endif
diff --git a/src/resources/equipmentinfo.h b/src/resources/equipmentinfo.h
index 5cd0643b..d9439c50 100644
--- a/src/resources/equipmentinfo.h
+++ b/src/resources/equipmentinfo.h
@@ -1,76 +1,77 @@
-/*
- * The Mana World
- * Copyright 2006 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id:
- */
-
-#ifndef _TMW_EQUIPMENTINFO_H_
-#define _TMW_EQUIPMENTINFO_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "spritedef.h"
-
-enum EquipmentSoundEvent
-{
- EQUIP_EVENT_STRIKE,
- EQUIP_EVENT_HIT
-};
-
-class EquipmentInfo
-{
- public:
- EquipmentInfo():
- mSlot (0),
- mAttackType(ACTION_DEFAULT)
- {
- };
-
- void
- setSlot (int slot) { mSlot = slot; }
-
- const std::string&
- getSprite(int gender) {return animationFiles[gender]; }
-
- void
- setSprite(std::string animationFile, int gender) {animationFiles[gender] = animationFile; }
-
- void
- setAttackType(std::string attackType);
-
- const SpriteAction
- getAttackType() { return mAttackType; }
-
- void
- addSound(EquipmentSoundEvent event, std::string filename);
-
- std::string
- getSound(EquipmentSoundEvent event) const;
-
- private:
- int mSlot; //not used at the moment but maybe useful on our own server
- SpriteAction mAttackType;
- std::map<int, std::string> animationFiles;
- std::map<EquipmentSoundEvent, std::vector<std::string>* > mSounds;
-};
-
-#endif
+/*
+ * The Mana World
+ * Copyright 2006 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_EQUIPMENTINFO_H_
+#define _TMW_EQUIPMENTINFO_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "spritedef.h"
+
+enum EquipmentSoundEvent
+{
+ EQUIP_EVENT_STRIKE,
+ EQUIP_EVENT_HIT
+};
+
+class EquipmentInfo
+{
+ public:
+ EquipmentInfo():
+ mSlot (0),
+ mAttackType(ACTION_DEFAULT)
+ {
+ }
+
+ void
+ setSlot (int slot) { mSlot = slot; }
+
+ const std::string&
+ getSprite(int gender) { return animationFiles[gender]; }
+
+ void
+ setSprite(const std::string &animationFile, int gender)
+ { animationFiles[gender] = animationFile; }
+
+ void
+ setAttackType(std::string attackType);
+
+ const SpriteAction
+ getAttackType() { return mAttackType; }
+
+ void
+ addSound(EquipmentSoundEvent event, std::string filename);
+
+ std::string
+ getSound(EquipmentSoundEvent event) const;
+
+ private:
+ int mSlot; //not used at the moment but maybe useful on our own server
+ SpriteAction mAttackType;
+ std::map<int, std::string> animationFiles;
+ std::map<EquipmentSoundEvent, std::vector<std::string>* > mSounds;
+};
+
+#endif