# Client side stuff
#
+#keymap_forward = KEY_KEY_W
+#keymap_backward = KEY_KEY_S
+#keymap_left = KEY_KEY_A
+#keymap_right = KEY_KEY_D
+#keymap_jump = KEY_SPACE
+#keymap_sneak = KEY_RSHIFT
+#keymap_inventory = KEY_KEY_I
+#keymap_chat = KEY_KEY_T
+#keymap_rangeselect = KEY_KEY_R
+# Some (temporary) keys for debugging
+#keymap_special1 = KEY_KEY_E
+#keymap_print_debug_stacks = KEY_KEY_P
+
#wanted_fps = 30
#fps_max = 60
#viewing_range_nodes_max = 300
# Client sources
set(minetest_SRCS
${common_SRCS}
+ keycode.cpp
clouds.cpp
clientobject.cpp
guiFurnaceMenu.cpp
void set_default_settings()
{
// Client and server
+
+ g_settings.setDefault("port", "");
+ g_settings.setDefault("name", "");
g_settings.setDefault("footprints", "false");
// Client stuff
+
+ g_settings.setDefault("keymap_forward", "KEY_KEY_W");
+ g_settings.setDefault("keymap_backward", "KEY_KEY_S");
+ g_settings.setDefault("keymap_left", "KEY_KEY_A");
+ g_settings.setDefault("keymap_right", "KEY_KEY_D");
+ g_settings.setDefault("keymap_jump", "KEY_SPACE");
+ g_settings.setDefault("keymap_sneak", "KEY_RSHIFT");
+ g_settings.setDefault("keymap_inventory", "KEY_KEY_I");
+ g_settings.setDefault("keymap_chat", "KEY_KEY_T");
+ g_settings.setDefault("keymap_rangeselect", "KEY_KEY_R");
+ // Some (temporary) keys for debugging
+ g_settings.setDefault("keymap_special1", "KEY_KEY_E");
+ g_settings.setDefault("keymap_print_debug_stacks", "KEY_KEY_P");
+
g_settings.setDefault("wanted_fps", "30");
g_settings.setDefault("fps_max", "60");
g_settings.setDefault("viewing_range_nodes_max", "300");
g_settings.setDefault("viewing_range_nodes_min", "35");
g_settings.setDefault("screenW", "800");
g_settings.setDefault("screenH", "600");
- g_settings.setDefault("port", "");
g_settings.setDefault("address", "");
- g_settings.setDefault("name", "");
g_settings.setDefault("random_input", "false");
g_settings.setDefault("client_delete_unused_sectors_timeout", "1200");
g_settings.setDefault("enable_fog", "true");
#include "materials.h"
#include "config.h"
#include "clouds.h"
+#include "keycode.h"
/*
Setting this to 1 enables a special camera mode that forces
/*
Launch menus according to keys
*/
- if(input->wasKeyDown(irr::KEY_KEY_I))
+ if(input->wasKeyDown(getKeySetting("keymap_inventory")))
{
dstream<<DTIME<<"the_game: "
<<"Launching inventory"<<std::endl;
menu->drop();
}
- else if(input->wasKeyDown(irr::KEY_ESCAPE))
+ else if(input->wasKeyDown(KEY_ESCAPE))
{
dstream<<DTIME<<"the_game: "
<<"Launching pause menu"<<std::endl;
(new GUIPauseMenu(guienv, guiroot, -1, g_gamecallback,
&g_menumgr))->drop();
}
- else if(input->wasKeyDown(irr::KEY_KEY_T))
+ else if(input->wasKeyDown(getKeySetting("keymap_chat")))
{
TextDest *dest = new TextDestChat(&client);
}
// Viewing range selection
- if(input->wasKeyDown(irr::KEY_KEY_R))
+ if(input->wasKeyDown(getKeySetting("keymap_rangeselect")))
{
if(draw_control.range_all)
{
}
// Print debug stacks
- if(input->wasKeyDown(irr::KEY_KEY_P))
+ if(input->wasKeyDown(getKeySetting("keymap_print_debug_stacks")))
{
dstream<<"-----------------------------------------"
<<std::endl;
/*
Player speed control
+ TODO: Cache the keycodes from getKeySetting
*/
{
float a_pitch,
float a_yaw*/
PlayerControl control(
- input->isKeyDown(irr::KEY_KEY_W),
- input->isKeyDown(irr::KEY_KEY_S),
- input->isKeyDown(irr::KEY_KEY_A),
- input->isKeyDown(irr::KEY_KEY_D),
- input->isKeyDown(irr::KEY_SPACE),
- input->isKeyDown(irr::KEY_KEY_E),
- input->isKeyDown(irr::KEY_LSHIFT)
- || input->isKeyDown(irr::KEY_RSHIFT),
+ input->isKeyDown(getKeySetting("keymap_forward")),
+ input->isKeyDown(getKeySetting("keymap_backward")),
+ input->isKeyDown(getKeySetting("keymap_left")),
+ input->isKeyDown(getKeySetting("keymap_right")),
+ input->isKeyDown(getKeySetting("keymap_jump")),
+ input->isKeyDown(getKeySetting("keymap_special1")),
+ input->isKeyDown(getKeySetting("keymap_sneak")),
camera_pitch,
camera_yaw
);
s32 dy = input->getMousePos().Y - displaycenter.Y;
//std::cout<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
- const float keyspeed = 500;
+ /*const float keyspeed = 500;
if(input->isKeyDown(irr::KEY_UP))
dy -= dtime * keyspeed;
if(input->isKeyDown(irr::KEY_DOWN))
if(input->isKeyDown(irr::KEY_LEFT))
dx -= dtime * keyspeed;
if(input->isKeyDown(irr::KEY_RIGHT))
- dx += dtime * keyspeed;
+ dx += dtime * keyspeed;*/
camera_yaw -= dx*0.2;
camera_pitch += dy*0.2;
#include "guiInventoryMenu.h"
#include "constants.h"
+#include "keycode.h"
void drawInventoryItem(video::IVideoDriver *driver,
gui::IGUIFont *font,
quitMenu();
return true;
}
- if(event.KeyInput.Key==KEY_KEY_I && event.KeyInput.PressedDown)
+ if(event.KeyInput.Key==getKeySetting("keymap_inventory") && event.KeyInput.PressedDown)
{
quitMenu();
return true;
--- /dev/null
+/*
+Minetest-c55
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program 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
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "keycode.h"
+#include "main.h" // For g_settings
+
+#define CHECKKEY(x){if(strcmp(name, #x)==0) return irr::x;}
+
+irr::EKEY_CODE keyname_to_keycode(const char *name)
+{
+ CHECKKEY(KEY_LBUTTON)
+ CHECKKEY(KEY_RBUTTON)
+ CHECKKEY(KEY_CANCEL)
+ CHECKKEY(KEY_MBUTTON)
+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KEY_F3)
+ CHECKKEY(KEY_F4)
+ CHECKKEY(KEY_F5)
+ CHECKKEY(KEY_F6)
+ CHECKKEY(KEY_F7)
+ CHECKKEY(KEY_F8)
+ CHECKKEY(KEY_F9)
+ CHECKKEY(KEY_F10)
+ CHECKKEY(KEY_F11)
+ CHECKKEY(KEY_F12)
+ CHECKKEY(KEY_F13)
+ CHECKKEY(KEY_F14)
+ CHECKKEY(KEY_F15)
+ CHECKKEY(KEY_F16)
+ CHECKKEY(KEY_F17)
+ CHECKKEY(KEY_F18)
+ CHECKKEY(KEY_F19)
+ CHECKKEY(KEY_F20)
+ CHECKKEY(KEY_F21)
+ CHECKKEY(KEY_F22)
+ CHECKKEY(KEY_F23)
+ CHECKKEY(KEY_F24)
+ CHECKKEY(KEY_NUMLOCK)
+ CHECKKEY(KEY_SCROLL)
+ CHECKKEY(KEY_LSHIFT)
+ CHECKKEY(KEY_RSHIFT)
+ CHECKKEY(KEY_LCONTROL)
+ CHECKKEY(KEY_RCONTROL)
+ CHECKKEY(KEY_LMENU)
+ CHECKKEY(KEY_RMENU)
+ CHECKKEY(KEY_PLUS)
+ CHECKKEY(KEY_COMMA)
+ CHECKKEY(KEY_MINUS)
+ CHECKKEY(KEY_PERIOD)
+ CHECKKEY(KEY_ATTN)
+ CHECKKEY(KEY_CRSEL)
+ CHECKKEY(KEY_EXSEL)
+ CHECKKEY(KEY_EREOF)
+ CHECKKEY(KEY_PLAY)
+ CHECKKEY(KEY_ZOOM)
+ CHECKKEY(KEY_PA1)
+ CHECKKEY(KEY_OEM_CLEAR)
+
+ return irr::KEY_KEY_CODES_COUNT;
+}
+
+/*
+ Key config
+*/
+
+// A simple cache for quicker lookup
+core::map<std::string, irr::EKEY_CODE> g_key_setting_cache;
+
+irr::EKEY_CODE getKeySetting(const char *settingname)
+{
+ core::map<std::string, irr::EKEY_CODE>::Node *n;
+ n = g_key_setting_cache.find(settingname);
+ if(n)
+ return n->getValue();
+ irr::EKEY_CODE c = keyname_to_keycode(g_settings.get(settingname).c_str());
+ g_key_setting_cache.insert(settingname, c);
+ return c;
+}
+
+
--- /dev/null
+/*
+Minetest-c55
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program 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
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "common_irrlicht.h"
+
+irr::EKEY_CODE keyname_to_keycode(const char *name);
+
+// Key configuration getter
+irr::EKEY_CODE getKeySetting(const char *settingname);
+
+
\r
TODO: Get rid of GotSplitPacketException\r
\r
-GUI:\r
-----\r
+User Interface:\r
+---------------\r
\r
-TODO: Configuration menu, at least for keys\r
+TODO: Use getKeySetting everywhere for ESC key and stuff\r
\r
Graphics:\r
---------\r
//#include "tile.h"\r
#include "materials.h"\r
#include "game.h"\r
+#include "keycode.h"\r
\r
// This makes textures\r
ITextureSource *g_texturesource = NULL;\r
if(counter1 < 0.0)\r
{\r
counter1 = 0.1*Rand(1, 40);\r
- keydown[irr::KEY_SPACE] = !keydown[irr::KEY_SPACE];\r
+ keydown[getKeySetting("keymap_jump")] =\r
+ !keydown[getKeySetting("keymap_jump")];\r
}\r
}\r
{\r
if(counter1 < 0.0)\r
{\r
counter1 = 0.1*Rand(1, 40);\r
- keydown[irr::KEY_KEY_E] = !keydown[irr::KEY_KEY_E];\r
+ keydown[getKeySetting("keymap_special1")] =\r
+ !keydown[getKeySetting("keymap_special1")];\r
}\r
}\r
{\r
if(counter1 < 0.0)\r
{\r
counter1 = 0.1*Rand(1, 40);\r
- keydown[irr::KEY_KEY_W] = !keydown[irr::KEY_KEY_W];\r
+ keydown[getKeySetting("keymap_forward")] =\r
+ !keydown[getKeySetting("keymap_forward")];\r
}\r
}\r
{\r
if(counter1 < 0.0)\r
{\r
counter1 = 0.1*Rand(1, 40);\r
- keydown[irr::KEY_KEY_A] = !keydown[irr::KEY_KEY_A];\r
+ keydown[getKeySetting("keymap_left")] =\r
+ !keydown[getKeySetting("keymap_left")];\r
}\r
}\r
{\r