From: Jordi Mallach Date: Fri, 6 Jun 2003 11:05:00 +0000 (+0000) Subject: Make the "use special" keys configurable. This helps people using Azerty keyboards... X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=d9937094fc0c0b46e1c27451cd8313bbab919815;p=gtetrinet Make the "use special" keys configurable. This helps people using Azerty keyboards, like the French. --- diff --git a/ChangeLog b/ChangeLog index a228a05..87f1eac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2003-06-06 Jordi Mallach + + * src/config.c (config_loadconfig): load values for new keys. + Add notify functions for new gconf keys. + * src/config.h: Add new declarations and key defines. + * src/dialogs.c (prefdialog_drawkeys): Add new actions to treeview. + * src/gtetrinet (main): Notify gconf of changes to new keys. + * src/tetrinet.c (tetrinet_key): Handle new special keys. Closes + Bugzilla Bug#105117. + + * gtetrinet.schemas.in: Add schemas for new configurable game keys. + 2003-06-05 Jordi Mallach * NEWS: Update for 0.7.2. diff --git a/gtetrinet.schemas.in b/gtetrinet.schemas.in index fdfb049..34acebb 100644 --- a/gtetrinet.schemas.in +++ b/gtetrinet.schemas.in @@ -9,7 +9,7 @@ - Theme directory, should end with a '/'. + Theme directory, should end with a '/' The current theme directory. It should contain a readable "blocks.png" and a "theme.cfg". @@ -24,7 +24,7 @@ while true; do playmidi $MIDIFILE; done - Command to run to play midi files. + Command to run to play midi files This command is run when a midi file is to be played. The name of the midi file is placed in the environment variable MIDIFILE. @@ -39,7 +39,7 @@ 0 - Enable/disable sound. + Enable/disable sound Enables/Disables sound. Keep in mind that the theme that you're using must provide sounds. @@ -54,7 +54,7 @@ 0 - Enable/disable midi music. + Enable/disable midi music Enables/disables midi music. You'll need to enable sound if you want music to work. @@ -69,7 +69,7 @@ - Your nickname. + Your nickname This will be your nickname in the game. @@ -83,7 +83,7 @@ tetrinet.org - Server where you want to play. + Server where you want to play This is the server where GTetrinet will try to connect. @@ -97,7 +97,7 @@ - Your team. + Your team This will be the name of your team. @@ -111,7 +111,7 @@ Right - Key to move right. + Key to move right This key moves the block to the right. This is case insensitive. @@ -125,7 +125,7 @@ Left - Key to move left. + Key to move left This key moves the block to the left. This is case insensitive. @@ -139,7 +139,7 @@ Up - Key to rotate clockwise. + Key to rotate clockwise This key rotates the block clockwise. This is case insensitive. @@ -153,7 +153,7 @@ Control_R - Key to rotate counterclockwise. + Key to rotate counterclockwise This key rotates the block counterclockwise. This is case insensitive. @@ -167,7 +167,7 @@ Down - Key to move down. + Key to move down This key moves the block down. This is case insensitive. @@ -181,12 +181,26 @@ space - Key to drop piece. + Key to drop piece This key drops the block to the ground. This is case insensitive. + + /schemas/apps/gtetrinet/keys/message + /apps/gtetrinet/keys/message + gtetrinet + string + t + + + Key to open the fields' message dialog + This key displays the fields' message dialog. This is case insensitive. + + + + /schemas/apps/gtetrinet/keys/discard /apps/gtetrinet/keys/discard @@ -195,22 +209,92 @@ d - Key to discard special. + Key to discard special This key discards the current special. This is case insensitive. - /schemas/apps/gtetrinet/keys/message - /apps/gtetrinet/keys/message + /schemas/apps/gtetrinet/keys/special1 + /apps/gtetrinet/keys/special1 gtetrinet string - t + 1 - Key to open the fields' message dialog. - This key displays the fields' message dialog. This is case insensitive. + Key to use the current special on field 1 + This key uses the current special on Player 1's game field. + + + + + + /schemas/apps/gtetrinet/keys/special2 + /apps/gtetrinet/keys/special2 + gtetrinet + string + 2 + + + Key to use the current special on field 2 + This key uses the current special on Player 2's game field. + + + + + + /schemas/apps/gtetrinet/keys/special3 + /apps/gtetrinet/keys/special3 + gtetrinet + string + 3 + + + Key to use the current special on field 3 + This key uses the current special on Player 3's game field. + + + + + + /schemas/apps/gtetrinet/keys/special4 + /apps/gtetrinet/keys/special4 + gtetrinet + string + 4 + + + Key to use the current special on field 4 + This key uses the current special on Player 4's game field. + + + + + + /schemas/apps/gtetrinet/keys/special5 + /apps/gtetrinet/keys/special5 + gtetrinet + string + 5 + + + Key to use the current special on field 5 + This key uses the current special on Player 5's game field. + + + + + + /schemas/apps/gtetrinet/keys/special6 + /apps/gtetrinet/keys/special6 + gtetrinet + string + 6 + + + Key to use the current special on field 6 + This key uses the current special on Player 6's game field. diff --git a/src/config.c b/src/config.c index d7fe692..c7b4ad8 100644 --- a/src/config.c +++ b/src/config.c @@ -305,6 +305,61 @@ void config_loadconfig (void) else keys[K_GAMEMSG] = defaultkeys[K_GAMEMSG]; + p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special1", NULL); + if (p) + { + keys[K_SPECIAL1] = gdk_keyval_to_lower (gdk_keyval_from_name (p)); + g_free (p); + } + else + keys[K_SPECIAL1] = defaultkeys[K_SPECIAL1]; + + p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special2", NULL); + if (p) + { + keys[K_SPECIAL2] = gdk_keyval_to_lower (gdk_keyval_from_name (p)); + g_free (p); + } + else + keys[K_SPECIAL2] = defaultkeys[K_SPECIAL2]; + + p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special3", NULL); + if (p) + { + keys[K_SPECIAL3] = gdk_keyval_to_lower (gdk_keyval_from_name (p)); + g_free (p); + } + else + keys[K_SPECIAL3] = defaultkeys[K_SPECIAL3]; + + p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special4", NULL); + if (p) + { + keys[K_SPECIAL4] = gdk_keyval_to_lower (gdk_keyval_from_name (p)); + g_free (p); + } + else + keys[K_SPECIAL4] = defaultkeys[K_SPECIAL4]; + + p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special5", NULL); + if (p) + { + keys[K_SPECIAL5] = gdk_keyval_to_lower (gdk_keyval_from_name (p)); + g_free (p); + } + else + keys[K_SPECIAL5] = defaultkeys[K_SPECIAL5]; + + p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special6", NULL); + if (p) + { + keys[K_SPECIAL6] = gdk_keyval_to_lower (gdk_keyval_from_name (p)); + g_free (p); + } + else + keys[K_SPECIAL6] = defaultkeys[K_SPECIAL6]; + + /* Get the timestamp option. */ timestampsenable = gconf_client_get_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", NULL); @@ -489,6 +544,78 @@ keys_discard_changed (GConfClient *client, keys[K_DISCARD] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); } +void +keys_special1_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; + cnxn_id = cnxn_id; + + keys[K_SPECIAL1] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); +} + +void +keys_special2_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; + cnxn_id = cnxn_id; + + keys[K_SPECIAL2] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); +} + +void +keys_special3_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; + cnxn_id = cnxn_id; + + keys[K_SPECIAL3] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); +} + +void +keys_special4_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; + cnxn_id = cnxn_id; + + keys[K_SPECIAL4] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); +} + +void +keys_special5_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; + cnxn_id = cnxn_id; + + keys[K_SPECIAL5] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); +} + +void +keys_special6_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; + cnxn_id = cnxn_id; + + keys[K_SPECIAL6] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); +} + void partyline_enable_timestamps_changed (GConfClient *client, guint cnxn_id, diff --git a/src/config.h b/src/config.h index fbba64e..d8818c0 100644 --- a/src/config.h +++ b/src/config.h @@ -71,6 +71,36 @@ keys_discard_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry); +void +keys_special1_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + +void +keys_special2_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + +void +keys_special3_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + +void +keys_special4_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + +void +keys_special5_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + +void +keys_special6_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + void partyline_enable_timestamps_changed (GConfClient *client, guint cnxn_id, @@ -93,5 +123,11 @@ partyline_enable_channel_list_changed (GConfClient *client, #define K_DROP 5 #define K_DISCARD 6 #define K_GAMEMSG 7 +#define K_SPECIAL1 8 +#define K_SPECIAL2 9 +#define K_SPECIAL3 10 +#define K_SPECIAL4 11 +#define K_SPECIAL5 12 +#define K_SPECIAL6 13 /* not a key but the number of configurable keys */ -#define K_NUM 8 +#define K_NUM 14 diff --git a/src/dialogs.c b/src/dialogs.c index 757793c..96483a0 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -549,6 +549,12 @@ void prefdialog_drawkeys (void) actions[K_DROP] = _("Drop piece"); actions[K_DISCARD] = _("Discard special"); actions[K_GAMEMSG] = _("Send message"); + actions[K_SPECIAL1] = _("Special to field 1"); + actions[K_SPECIAL2] = _("Special to field 2"); + actions[K_SPECIAL3] = _("Special to field 3"); + actions[K_SPECIAL4] = _("Special to field 4"); + actions[K_SPECIAL5] = _("Special to field 5"); + actions[K_SPECIAL6] = _("Special to field 6"); gconf_keys[K_RIGHT] = g_strdup ("/apps/gtetrinet/keys/right"); gconf_keys[K_LEFT] = g_strdup ("/apps/gtetrinet/keys/left"); @@ -558,6 +564,12 @@ void prefdialog_drawkeys (void) gconf_keys[K_DROP] = g_strdup ("/apps/gtetrinet/keys/drop"); gconf_keys[K_DISCARD] = g_strdup ("/apps/gtetrinet/keys/discard"); gconf_keys[K_GAMEMSG] = g_strdup ("/apps/gtetrinet/keys/message"); + gconf_keys[K_SPECIAL1] = g_strdup ("/apps/gtetrinet/keys/special1"); + gconf_keys[K_SPECIAL2] = g_strdup ("/apps/gtetrinet/keys/special2"); + gconf_keys[K_SPECIAL3] = g_strdup ("/apps/gtetrinet/keys/special3"); + gconf_keys[K_SPECIAL4] = g_strdup ("/apps/gtetrinet/keys/special4"); + gconf_keys[K_SPECIAL5] = g_strdup ("/apps/gtetrinet/keys/special5"); + gconf_keys[K_SPECIAL6] = g_strdup ("/apps/gtetrinet/keys/special6"); for (i = 0; i < K_NUM; i ++) { gtk_list_store_append (keys_store, &iter); diff --git a/src/gtetrinet.c b/src/gtetrinet.c index e3f9f69..f1568be 100644 --- a/src/gtetrinet.c +++ b/src/gtetrinet.c @@ -178,12 +178,36 @@ int main (int argc, char *argv[]) (GConfClientNotifyFunc) keys_drop_changed, NULL, NULL, NULL); + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/message", + (GConfClientNotifyFunc) keys_message_changed, + NULL, NULL, NULL); + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/discard", - (GConfClientNotifyFunc) keys_discard_changed, + (GConfClientNotifyFunc) keys_discard_changed, NULL, NULL, NULL); - gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/message", - (GConfClientNotifyFunc) keys_message_changed, + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special1", + (GConfClientNotifyFunc) keys_special1_changed, + NULL, NULL, NULL); + + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special2", + (GConfClientNotifyFunc) keys_special2_changed, + NULL, NULL, NULL); + + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special3", + (GConfClientNotifyFunc) keys_special3_changed, + NULL, NULL, NULL); + + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special4", + (GConfClientNotifyFunc) keys_special4_changed, + NULL, NULL, NULL); + + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special5", + (GConfClientNotifyFunc) keys_special5_changed, + NULL, NULL, NULL); + + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special6", + (GConfClientNotifyFunc) keys_special6_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", diff --git a/src/tetrinet.c b/src/tetrinet.c index 879fb51..d275744 100644 --- a/src/tetrinet.c +++ b/src/tetrinet.c @@ -1749,15 +1749,23 @@ notfieldkey: else if (gdk_keyval_to_lower (keyval) == keys[K_DISCARD]) { tetrinet_specialkey(-1); } - else switch (keyval) { - case GDK_1: tetrinet_specialkey(1); break; - case GDK_2: tetrinet_specialkey(2); break; - case GDK_3: tetrinet_specialkey(3); break; - case GDK_4: tetrinet_specialkey(4); break; - case GDK_5: tetrinet_specialkey(5); break; - case GDK_6: tetrinet_specialkey(6); break; - default: - return FALSE; + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL1]) { + tetrinet_specialkey(1); + } + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL2]) { + tetrinet_specialkey(2); + } + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL3]) { + tetrinet_specialkey(3); + } + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL4]) { + tetrinet_specialkey(4); + } + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL5]) { + tetrinet_specialkey(5); + } + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL6]) { + tetrinet_specialkey(6); } tetris_drawcurrentblock (); return TRUE;