summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-28 21:54:04 +0000
committerscarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-28 21:54:04 +0000
commiteb71aa0d04d91d3463981e6ff304282c6f482087 (patch)
tree21cc7563f4c8fa1a97c3562547d5e197097e1472 /src
parent554234f4f238305ee82504bdbb51096efaea74f0 (diff)
- nove nastaveni pro klavesy (not yet complete), smazte keyconfig
- par uprav pro win32 (ve stejnem stavu jako predchozi) git-svn-id: http://opensvn.csie.org/tuxanci_ng@177 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src')
-rw-r--r--src/base/exportFunction.c1
-rw-r--r--src/base/exportFunction.h1
-rwxr-xr-xsrc/base/modules.c4
-rw-r--r--src/base/modules.h8
-rwxr-xr-xsrc/modules/modMove.c4
-rw-r--r--src/screen/screen_settingKeys.c399
-rw-r--r--src/screen/screen_world.c11
-rw-r--r--src/widget/widget_catchkey.c2
-rw-r--r--src/widget/widget_catchkey.h2
9 files changed, 153 insertions, 279 deletions
diff --git a/src/base/exportFunction.c b/src/base/exportFunction.c
index 955c0e1..550e4ec 100644
--- a/src/base/exportFunction.c
+++ b/src/base/exportFunction.c
@@ -37,7 +37,6 @@ void initExortFunction()
{
listExportFce = newList();
}
-
void addToExportFce(char *name, void *function)
{
printf("add to export function %s\n", name);
diff --git a/src/base/exportFunction.h b/src/base/exportFunction.h
index 5f3f1d0..8e01fc9 100644
--- a/src/base/exportFunction.h
+++ b/src/base/exportFunction.h
@@ -5,6 +5,7 @@
extern void initExortFunction();
extern void addToExportFce(char *name, void *function);
+
extern void* getExportFce(char *name);
extern void quitExportFunction();
diff --git a/src/base/modules.c b/src/base/modules.c
index e84cd30..13b0ff2 100755
--- a/src/base/modules.c
+++ b/src/base/modules.c
@@ -88,9 +88,8 @@ static void* getFce(module_t *p, char *s)
static void* mapImage(char *name)
{
- void *image;
-
#ifndef __WIN32__
+ void *image;
image = dlopen (name, RTLD_LAZY);
if( image == NULL )
@@ -118,7 +117,6 @@ static void* mapImage(char *name)
);
fputs(msg, stderr);
free(msg);
- free(ret);
FreeLibrary(image);
return NULL;
}
diff --git a/src/base/modules.h b/src/base/modules.h
index 8036a6a..5ad0287 100644
--- a/src/base/modules.h
+++ b/src/base/modules.h
@@ -31,7 +31,11 @@ typedef struct export_fce_s
int (*fce_getNetTypeGame)();
int (*fce_loadDepModule)(void *name);
+#ifndef __WIN32__
void (*fce_addToExportFce)(char *name, void *function);
+#else
+ void (*fce_addToExportFce)(char *name, HINSTANCE *function);
+#endif
void* (*fce_getExportFce)(char *name);
void (*fce_getTuxProportion)(tux_t *tux, int *x,int *y, int *w, int *h);
@@ -56,7 +60,11 @@ typedef struct export_fce_s
typedef struct module_s
{
char *name;
+#ifndef __WIN32__
void *image;
+#else
+ HINSTANCE *image;
+#endif
int (*fce_init)(export_fce_t *p);
#ifndef PUBLIC_SERVER
diff --git a/src/modules/modMove.c b/src/modules/modMove.c
index 3b8d09c..f4ac84e 100755
--- a/src/modules/modMove.c
+++ b/src/modules/modMove.c
@@ -223,8 +223,8 @@ int init(export_fce_t *p)
{
export_fce = p;
- export_fce->fce_addToExportFce("move_tux", move_tux);
- export_fce->fce_addToExportFce("move_shot", move_shot);
+ export_fce->fce_addToExportFce("move_tux", (void *)move_tux);
+ export_fce->fce_addToExportFce("move_shot", (void *)move_shot);
return 0;
}
diff --git a/src/screen/screen_settingKeys.c b/src/screen/screen_settingKeys.c
index 2a6539a..4825a2f 100644
--- a/src/screen/screen_settingKeys.c
+++ b/src/screen/screen_settingKeys.c
@@ -23,11 +23,10 @@
#include "screen_settingKeys.h"
#include "widget_button.h"
#include "widget_image.h"
+#include "widget_catchkey.h"
#include "widget_label.h"
static int keytable[KEY_LENGTH];
-static char keynametable[KEY_LENGTH][STR_SIZE]={};
-static textFile_t *keytableFile;
static textFile_t *keycontrolFile;
static widget_image_t *image_backgorund;
@@ -50,20 +49,20 @@ static widget_label_t *tux_left_keyright;
static widget_label_t *tux_left_keyswitch;
static widget_label_t *tux_left_keyfire;
// key values
-static widget_label_t *tux_right_keyup_val;
-static widget_label_t *tux_right_keydown_val;
-static widget_label_t *tux_right_keyleft_val;
-static widget_label_t *tux_right_keyright_val;
-static widget_label_t *tux_right_keyswitch_val;
-static widget_label_t *tux_right_keyfire_val;
-static widget_label_t *tux_left_keyup_val;
-static widget_label_t *tux_left_keydown_val;
-static widget_label_t *tux_left_keyleft_val;
-static widget_label_t *tux_left_keyright_val;
-static widget_label_t *tux_left_keyswitch_val;
-static widget_label_t *tux_left_keyfire_val;
+static widget_catchkey_t *tux_right_keyup_val;
+static widget_catchkey_t *tux_right_keydown_val;
+static widget_catchkey_t *tux_right_keyleft_val;
+static widget_catchkey_t *tux_right_keyright_val;
+static widget_catchkey_t *tux_right_keyswitch_val;
+static widget_catchkey_t *tux_right_keyfire_val;
+static widget_catchkey_t *tux_left_keyup_val;
+static widget_catchkey_t *tux_left_keydown_val;
+static widget_catchkey_t *tux_left_keyleft_val;
+static widget_catchkey_t *tux_left_keyright_val;
+static widget_catchkey_t *tux_left_keyswitch_val;
+static widget_catchkey_t *tux_left_keyfire_val;
-static widget_catcgkey_t *catcher;
+//static widget_catchkey_t *catcher;
// todo add key images
// possible variant will be reusing widget_image for current widget_label so there wont
// be key names but only images
@@ -74,27 +73,6 @@ void startScreenSettingKeys()
playMusic("menu", MUSIC_GROUP_BASE);
#endif
}
-static int getKeyCode(char *s)
-{
- char str[STR_SIZE];
- char *find;
- int i;
-
- sprintf(str, "keycode %s = ", s);
-
- for(i = 0 ; i < keytableFile->text->count ; i++) {
- char *line;
- line = (char *) (keytableFile->text->list[i]);
- if((find = strstr(line, str)) != NULL) {
- int ret;
- ret = atoi( strchr(line, '=')+1 );
- return ret;
- }
- }
-
- return -1;
-}
-
void initKeyTable()
{
char path[STR_PATH_SIZE];
@@ -102,14 +80,6 @@ void initKeyTable()
/*
int i;
*/
- sprintf(path, PATH_CONFIG "keytable.conf");
- keytableFile = loadTextFile(path);
-
- if(keytableFile == NULL) {
- fprintf(stderr, "Don't load %s\n", path);
- return;
- }
-
sprintf(path, "%s/keycontrol.conf", getHomeDirector());
keycontrolFile = loadTextFile(path);
@@ -123,54 +93,30 @@ void initKeyTable()
fprintf(stderr, "Don't create %s\n", path);
return;
}
-
- loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_UP", val, STR_SIZE, "SDLK_UP");
- keytable[ KEY_TUX_RIGHT_MOVE_UP ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_RIGHT_MOVE_UP ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_RIGHT", val, STR_SIZE, "SDLK_RIGHT");
- keytable[ KEY_TUX_RIGHT_MOVE_RIGHT ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_RIGHT_MOVE_RIGHT ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_LEFT", val, STR_SIZE, "SDLK_LEFT");
- keytable[ KEY_TUX_RIGHT_MOVE_LEFT ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_RIGHT_MOVE_LEFT ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_DOWN", val, STR_SIZE, "SDLK_DOWN");
- keytable[ KEY_TUX_RIGHT_MOVE_DOWN ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_RIGHT_MOVE_DOWN ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_SHOOT", val, STR_SIZE, "SDLK_KP0");
- keytable[ KEY_TUX_RIGHT_SHOOT ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_RIGHT_SHOOT ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_SWITCH_WEAPON", val, STR_SIZE, "SDLK_KP1");
- keytable[ KEY_TUX_RIGHT_SWITCH_WEAPON] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_RIGHT_SWITCH_WEAPON ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_UP", val, STR_SIZE, "SDLK_w");
- keytable[ KEY_TUX_LEFT_MOVE_UP ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_LEFT_MOVE_UP ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_RIGHT", val, STR_SIZE, "SDLK_d");
- keytable[ KEY_TUX_LEFT_MOVE_RIGHT ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_LEFT_MOVE_RIGHT ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_LEFT", val, STR_SIZE, "SDLK_a");
- keytable[ KEY_TUX_LEFT_MOVE_LEFT ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_LEFT_MOVE_LEFT ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_DOWN", val, STR_SIZE, "SDLK_s");
- keytable[ KEY_TUX_LEFT_MOVE_DOWN ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_LEFT_MOVE_DOWN ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_SHOOT", val, STR_SIZE, "SDLK_q");
- keytable[ KEY_TUX_LEFT_SHOOT ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_LEFT_SHOOT ], "%s", val);
-
- loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_SWITCH_WEAPON", val, STR_SIZE, "SDLK_TAB");
- keytable[ KEY_TUX_LEFT_SWITCH_WEAPON ] = getKeyCode(val);
- sprintf(keynametable[ KEY_TUX_LEFT_SWITCH_WEAPON ], "%s", val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_UP", val, STR_SIZE, "273");
+ keytable[ KEY_TUX_RIGHT_MOVE_UP ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_RIGHT", val, STR_SIZE, "275");
+ keytable[ KEY_TUX_RIGHT_MOVE_RIGHT ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_LEFT", val, STR_SIZE, "276");
+ keytable[ KEY_TUX_RIGHT_MOVE_LEFT ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_DOWN", val, STR_SIZE, "274");
+ keytable[ KEY_TUX_RIGHT_MOVE_DOWN ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_SHOOT", val, STR_SIZE, "48");
+ keytable[ KEY_TUX_RIGHT_SHOOT ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_RIGHT_SWITCH_WEAPON", val, STR_SIZE, "49");
+ keytable[ KEY_TUX_RIGHT_SWITCH_WEAPON ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_UP", val, STR_SIZE, "119");
+ keytable[ KEY_TUX_LEFT_MOVE_UP ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_RIGHT", val, STR_SIZE, "100");
+ keytable[ KEY_TUX_LEFT_MOVE_RIGHT ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_LEFT", val, STR_SIZE, "97");
+ keytable[ KEY_TUX_LEFT_MOVE_LEFT ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_MOVE_DOWN", val, STR_SIZE, "115");
+ keytable[ KEY_TUX_LEFT_MOVE_DOWN ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_SHOOT", val, STR_SIZE, "113");
+ keytable[ KEY_TUX_LEFT_SHOOT ] = atoi(val);
+ loadValueFromConfigFile(keycontrolFile, "TUX_LEFT_SWITCH_WEAPON", val, STR_SIZE, "9");
+ keytable[ KEY_TUX_LEFT_SWITCH_WEAPON ] = atoi(val);
/*
for( i = 0 ; i < KEY_LENGTH ; i++)
@@ -208,167 +154,62 @@ void drawScreenSettingKeys()
drawWidgetLabel(tux_left_keyswitch);
drawWidgetLabel(tux_left_keyfire);
// key values
- drawWidgetLabel(tux_right_keyup_val);
- drawWidgetLabel(tux_right_keydown_val);
- drawWidgetLabel(tux_right_keyleft_val);
- drawWidgetLabel(tux_right_keyright_val);
- drawWidgetLabel(tux_right_keyswitch_val);
- drawWidgetLabel(tux_right_keyfire_val);
- drawWidgetLabel(tux_left_keyup_val);
- drawWidgetLabel(tux_left_keydown_val);
- drawWidgetLabel(tux_left_keyleft_val);
- drawWidgetLabel(tux_left_keyright_val);
- drawWidgetLabel(tux_left_keyswitch_val);
- drawWidgetLabel(tux_left_keyfire_val);
-}
-void createNewKey() {
- // create catchkey
- // redraw keyval
- // update config file
+ drawWidgetCatchkey(tux_right_keyup_val);
+ drawWidgetCatchkey(tux_right_keydown_val);
+ drawWidgetCatchkey(tux_right_keyleft_val);
+ drawWidgetCatchkey(tux_right_keyright_val);
+ drawWidgetCatchkey(tux_right_keyswitch_val);
+ drawWidgetCatchkey(tux_right_keyfire_val);
+ drawWidgetCatchkey(tux_left_keyup_val);
+ drawWidgetCatchkey(tux_left_keydown_val);
+ drawWidgetCatchkey(tux_left_keyleft_val);
+ drawWidgetCatchkey(tux_left_keyright_val);
+ drawWidgetCatchkey(tux_left_keyswitch_val);
+ drawWidgetCatchkey(tux_left_keyfire_val);
}
static void eventWidget(void *p)
{
widget_button_t *button;
- widget_label_t *label;
+ widget_catchkey_t *catcher;
button = (widget_button_t *)(p);
- label = (widget_label_t *)(p);
-
+ catcher = (widget_catchkey_t *)(p);
if(button == button_back) {
setScreen("setting");
}
- //events on picture/text
- if(label == tux_left_keyup) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keydown) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyleft) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyright) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyfire) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyswitch) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyup) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keydown) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyleft) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyright) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyswitch) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyfire) {
- //call load of new value
- //call change to config + redraw of value
- }
//events on value
- if(label == tux_left_keyup_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keydown_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyleft_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyright_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyfire_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_left_keyswitch_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyup_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keydown_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyleft_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyright_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyswitch_val) {
- //call load of new value
- //call change to config + redraw of value
- }
- if(label == tux_right_keyfire_val) {
- //call load of new value
- //call change to config + redraw of value
+ if( (catcher == tux_left_keyup_val) ||
+ (catcher == tux_left_keydown_val) ||
+ (catcher == tux_left_keyleft_val) ||
+ (catcher == tux_left_keyright_val) ||
+ (catcher == tux_left_keyfire_val) ||
+ (catcher == tux_left_keyswitch_val) ||
+ (catcher == tux_right_keyup_val) ||
+ (catcher == tux_right_keydown_val) ||
+ (catcher == tux_right_keyleft_val) ||
+ (catcher == tux_right_keyright_val) ||
+ (catcher == tux_right_keyswitch_val) ||
+ (catcher == tux_right_keyfire_val) ) {
+ // draw press any key picture
+ // check if there is no other key with new value (what to revert if yes?)
+ // allow ony one key per time change HOW THE HELL IS THIS EVEN POSSIBLE
}
}
void eventScreenSettingKeys()
{
eventWidgetButton(button_back);
- // text/image
- eventWidgetLabel(tux_right);
- eventWidgetLabel(tux_left);
- eventWidgetLabel(tux_right_keyup);
- eventWidgetLabel(tux_right_keydown);
- eventWidgetLabel(tux_right_keyleft);
- eventWidgetLabel(tux_right_keyright);
- eventWidgetLabel(tux_right_keyswitch);
- eventWidgetLabel(tux_right_keyfire);
- eventWidgetLabel(tux_left_keyup);
- eventWidgetLabel(tux_left_keydown);
- eventWidgetLabel(tux_left_keyleft);
- eventWidgetLabel(tux_left_keyright);
- eventWidgetLabel(tux_left_keyswitch);
- eventWidgetLabel(tux_left_keyfire);
- // value
- eventWidgetLabel(tux_right_val);
- eventWidgetLabel(tux_left_val);
- eventWidgetLabel(tux_right_keyup_val);
- eventWidgetLabel(tux_right_keydown_val);
- eventWidgetLabel(tux_right_keyleft_val);
- eventWidgetLabel(tux_right_keyright_val);
- eventWidgetLabel(tux_right_keyswitch_val);
- eventWidgetLabel(tux_right_keyfire_val);
- eventWidgetLabel(tux_left_keyup_val);
- eventWidgetLabel(tux_left_keydown_val);
- eventWidgetLabel(tux_left_keyleft_val);
- eventWidgetLabel(tux_left_keyright_val);
- eventWidgetLabel(tux_left_keyswitch_val);
- eventWidgetLabel(tux_left_keyfire_val);
+ eventWidgetCatchkey(tux_right_keyup_val);
+ eventWidgetCatchkey(tux_right_keydown_val);
+ eventWidgetCatchkey(tux_right_keyleft_val);
+ eventWidgetCatchkey(tux_right_keyright_val);
+ eventWidgetCatchkey(tux_right_keyswitch_val);
+ eventWidgetCatchkey(tux_right_keyfire_val);
+ eventWidgetCatchkey(tux_left_keyup_val);
+ eventWidgetCatchkey(tux_left_keydown_val);
+ eventWidgetCatchkey(tux_left_keyleft_val);
+ eventWidgetCatchkey(tux_left_keyright_val);
+ eventWidgetCatchkey(tux_left_keyswitch_val);
+ eventWidgetCatchkey(tux_left_keyfire_val);
}
void stopScreenSettingKeys()
{
@@ -398,31 +239,61 @@ void initScreenSettingKeys()
tux_right_keyfire = newWidgetLabel(getMyText("KEY_FIRE"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
tux_right_keyswitch = newWidgetLabel(getMyText("KEY_SWITCH"), WINDOW_SIZE_X/2 + tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyup_val = newWidgetLabel(keynametable[6], tux_left_keyup->x+200, tux_left->y+50, WIDGET_LABEL_LEFT);
- tux_left_keydown_val = newWidgetLabel(keynametable[9], tux_left_keyup_val->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyleft_val = newWidgetLabel(keynametable[8], tux_left_keyup_val->x, tux_left_keydown->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyright_val = newWidgetLabel(keynametable[7], tux_left_keyup_val->x, tux_left_keyleft->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyfire_val = newWidgetLabel(keynametable[10], tux_left_keyup_val->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_left_keyswitch_val = newWidgetLabel(keynametable[11], tux_left_keyup_val->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
+ tux_left_keyup_val = newWidgetCatchkey(keytable[6], tux_left_keyup->x+200, tux_left->y+50);
+ tux_left_keydown_val = newWidgetCatchkey(keytable[9], tux_left_keyup_val->x, tux_left_keyup->y + 20);
+ tux_left_keyleft_val = newWidgetCatchkey(keytable[8], tux_left_keyup_val->x, tux_left_keydown->y + 20);
+ tux_left_keyright_val = newWidgetCatchkey(keytable[7], tux_left_keyup_val->x, tux_left_keyleft->y + 20);
+ tux_left_keyfire_val = newWidgetCatchkey(keytable[10], tux_left_keyup_val->x, tux_left_keyright->y + 20);
+ tux_left_keyswitch_val = newWidgetCatchkey(keytable[11], tux_left_keyup_val->x, tux_left_keyfire->y + 20);
- tux_right_keyup_val = newWidgetLabel(keynametable[0], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left->y+50, WIDGET_LABEL_LEFT);
- tux_right_keydown_val = newWidgetLabel(keynametable[3], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyleft_val = newWidgetLabel(keynametable[2], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keydown->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyright_val = newWidgetLabel(keynametable[1], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keyleft->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyfire_val = newWidgetLabel(keynametable[4], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT);
- tux_right_keyswitch_val = newWidgetLabel(keynametable[5], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT);
+ tux_right_keyup_val = newWidgetCatchkey(keytable[0], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left->y+50);
+ tux_right_keydown_val = newWidgetCatchkey(keytable[3], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyup->y + 20);
+ tux_right_keyleft_val = newWidgetCatchkey(keytable[2], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keydown->y + 20);
+ tux_right_keyright_val = newWidgetCatchkey(keytable[1], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_right_keyleft->y + 20);
+ tux_right_keyfire_val = newWidgetCatchkey(keytable[4], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyright->y + 20);
+ tux_right_keyswitch_val = newWidgetCatchkey(keytable[5], WINDOW_SIZE_X/2 + tux_left_keyup_val->x, tux_left_keyfire->y + 20);
registerScreen( newScreen("settingKeys", startScreenSettingKeys, eventScreenSettingKeys,
drawScreenSettingKeys, stopScreenSettingKeys) );
}
void quitKeyTable()
{
- //printf("quitKeyTable\n");
destroyTextFile(keycontrolFile);
- destroyTextFile(keytableFile);
+}
+void saveKeyTable() {
+ char str[STR_SIZE];
+ sprintf(str,"%d",tux_left_keyup_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_LEFT_MOVE_UP", str);
+ sprintf(str,"%d",tux_left_keydown_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_LEFT_MOVE_DOWN", str);
+ sprintf(str,"%d",tux_left_keyleft_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_LEFT_MOVE_LEFT", str);
+ sprintf(str,"%d",tux_left_keyright_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_LEFT_MOVE_RIGHT", str);
+ sprintf(str,"%d",tux_left_keyfire_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_LEFT_MOVE_SHOOT", str);
+ sprintf(str,"%d",tux_left_keyswitch_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_LEFT_MOVE_SWITCH_WEAPON ", str);
+
+ sprintf(str,"%d",tux_right_keyup_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_UP", str);
+ sprintf(str,"%d",tux_right_keydown_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_DOWN", str);
+ sprintf(str,"%d",tux_right_keyleft_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_LEFT", str);
+ sprintf(str,"%d",tux_right_keyright_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_RIGHT", str);
+ sprintf(str,"%d",tux_right_keyfire_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_SHOOT", str);
+ sprintf(str,"%d",tux_right_keyswitch_val->key);
+ setValueInConfigFile(keycontrolFile, "TUX_RIGHT_MOVE_SWITCH_WEAPON ", str);
+
+ saveTextFile(keycontrolFile);
}
void quitScreenSettingKeys()
{
+ saveKeyTable();
+ quitKeyTable();
// key names
destroyWidgetImage(image_backgorund);
destroyWidgetLabel(tux_right);
@@ -439,18 +310,18 @@ void quitScreenSettingKeys()
destroyWidgetLabel(tux_left_keyswitch);
destroyWidgetLabel(tux_left_keyfire);
// key values
- destroyWidgetLabel(tux_right_keyup_val);
- destroyWidgetLabel(tux_right_keydown_val);
- destroyWidgetLabel(tux_right_keyleft_val);
- destroyWidgetLabel(tux_right_keyright_val);
- destroyWidgetLabel(tux_right_keyswitch_val);
- destroyWidgetLabel(tux_right_keyfire_val);
- destroyWidgetLabel(tux_left_keyup_val);
- destroyWidgetLabel(tux_left_keydown_val);
- destroyWidgetLabel(tux_left_keyleft_val);
- destroyWidgetLabel(tux_left_keyright_val);
- destroyWidgetLabel(tux_left_keyswitch_val);
- destroyWidgetLabel(tux_left_keyfire_val);
+ destroyWidgetCatchkey(tux_right_keyup_val);
+ destroyWidgetCatchkey(tux_right_keydown_val);
+ destroyWidgetCatchkey(tux_right_keyleft_val);
+ destroyWidgetCatchkey(tux_right_keyright_val);
+ destroyWidgetCatchkey(tux_right_keyswitch_val);
+ destroyWidgetCatchkey(tux_right_keyfire_val);
+ destroyWidgetCatchkey(tux_left_keyup_val);
+ destroyWidgetCatchkey(tux_left_keydown_val);
+ destroyWidgetCatchkey(tux_left_keyleft_val);
+ destroyWidgetCatchkey(tux_left_keyright_val);
+ destroyWidgetCatchkey(tux_left_keyswitch_val);
+ destroyWidgetCatchkey(tux_left_keyfire_val);
destroyWidgetButton(button_back);
}
diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c
index b253565..9e686b8 100644
--- a/src/screen/screen_world.c
+++ b/src/screen/screen_world.c
@@ -217,14 +217,11 @@ static void control_keyboard_right(tux_t *tux)
if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )countKey++;
if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )countKey++;
- if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED )
+ if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED && tux->isCanSwitchGun == TRUE )
{
- if( tux->isCanSwitchGun == TRUE )
- {
- netAction(tux, TUX_SWITCH_GUN);
- actionTux(tux, TUX_SWITCH_GUN);
- return;
- }
+ netAction(tux, TUX_SWITCH_GUN);
+ actionTux(tux, TUX_SWITCH_GUN);
+ return;
}
if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE )
diff --git a/src/widget/widget_catchkey.c b/src/widget/widget_catchkey.c
index 7443358..afdac23 100644
--- a/src/widget/widget_catchkey.c
+++ b/src/widget/widget_catchkey.c
@@ -6,7 +6,7 @@
#include "font.h"
#include "widget_catchkey.h"
-widget_catchkey_t* newWidgetCatchkey(int x, int y, int key)
+widget_catchkey_t* newWidgetCatchkey(int key, int x, int y)
{
widget_catchkey_t *new;
diff --git a/src/widget/widget_catchkey.h b/src/widget/widget_catchkey.h
index ab95bbd..0b8b080 100644
--- a/src/widget/widget_catchkey.h
+++ b/src/widget/widget_catchkey.h
@@ -18,7 +18,7 @@ typedef struct widget_catchkey_struct
bool_t active;
} widget_catchkey_t;
-extern widget_catchkey_t* newWidgetCatchkey(int x, int y, int key);
+extern widget_catchkey_t* newWidgetCatchkey(int key, int x, int y);
extern int getWidgetCatchKey(widget_catchkey_t *p);
extern void setWidgetCatchKey(widget_catchkey_t *p, int key);
extern void drawWidgetCatchkey(widget_catchkey_t *p);