Re: [crossfire] [PATCH 1/2] Keybindings: multiple changes

2013-11-02 Thread Kevin Zheng
Committed in r19090.

To the best of my knowledge, Crossfire doesn't have a formal patch
review process. By the time everyone reviews it, bit rot will have
already set in. Best to commit it now and fix issues later if needed.

On 11/02/2013 18:24, Arvid Brodin wrote:
> * Show all keybindings (incl default ones) in both 'unbind' and the 
> keybindings
>   dialog. (Should reduce confusion for new users.)

I almost want to say that I miss the old behavior. If feasible, I'd
really like to see a "show non-default bindings only" checkbox.

Cheers,
Kevin Zheng
___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire


Re: [crossfire] [RFC 2/3] Misc keybinding fixes and changes

2013-11-02 Thread Kevin Zheng
On 11/02/2013 11:04, Arvid Brodin wrote:
> That's something of a tall order. :) It's a lot of work learning how
> _one_ client works; learning two clients and then trying do do only
> changes that benefit both (and doesn't break any) of them could be
> very limiting. (Is the Windows compatibility broken on the gtk client?)

Maintaining the Windows port of the GTKv2 client is difficult. Nicholas
tried to build a Windows version from trunk, with limited success.

> Are there any code dependencies between jxclient and the gtk client? 

No, not that I am aware of.

> I noticed the gtk client code is split between the folders common/
> and gtk-v2/. I found references to something called the x11 client
> in the code, and I assumed that that was an old client that had since
> been removed. It was apparently called cfclient, later renamed 
> crossfire-client-x11. If this has been removed, perhaps it would be a 
> good idea to merge the common/ folder into the gtk-v2/ folder?

You've probably noticed that the sources in common/ are built into a
shared library. The intention was to share some code between the several
different versions of the client (X11, SDL, OpenGL, GTKv1, GTKv2). Now,
it seems a little unnecessary (unless someone decides to bring back
another client).

Thanks,
Kevin Zheng
___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire


[crossfire] [PATCH 2/2] Character-specific keybinding files

2013-11-02 Thread Arvid Brodin
Today, keybindings are saved as ~/.crossfire/keys. That means you
cannot have different key bindings for each character.

This patch changes that so that keybindings are saved as 
~/.crossfire/.keys. So if your character is named
Leopold, the keybindings are saved to ~/.crossfire/Leopold.keys.

When play is entered with a character, the client tries to load 
keybindings in the following order:

~/.crossfire/.keys
~/.crossfire/keys
/def_keys

If none of the files are found, it instead uses the default built-
in keybindings.


-- 
Arvid
>From 5edd5746ffc9b8cae259b2792d15302569891804 Mon Sep 17 00:00:00 2001
From: Arvid Brodin 
Date: Mon, 28 Oct 2013 02:04:20 +0100
Subject: [PATCH 2/4] Added player character specific keybinding files.


Signed-off-by: Arvid Brodin 
---
 common/client.h  |  13 ++--
 common/metaserver.c  |   4 --
 gtk-v2/src/account.c |   5 ++
 gtk-v2/src/create_char.c |   4 ++
 gtk-v2/src/gtk2proto.h   |   1 +
 gtk-v2/src/keys.c| 165 ---
 6 files changed, 100 insertions(+), 92 deletions(-)

diff --git a/common/client.h b/common/client.h
index 75d3a54..cb0779a 100644
--- a/common/client.h
+++ b/common/client.h
@@ -40,8 +40,6 @@
 #  include 
 #endif
 
-#define MULTKEYS
-
 #define VERSION_CS 1023
 #define VERSION_SC 1029
 
@@ -349,10 +347,13 @@ typedef struct Player_Struct {
 uint16  mapxres,mapyres;/**< Resolution to draw on the magic
  *   map. Only used in client-specific
  *   code, so it should move there. */
-#ifdef MULTKEYS
-charname[ 40 ]; /**< Player's name, for player-specific
- *   key files */
-#endif
+char*name;  /**< Name of PC, set and freed in account.c
+ *   play_character() (using data returned
+ *   from server to AccountPlayersCmd, via
+ *   character_choose window,
+ *   OR in
+ *   send_create_player_to_server() when
+ *   new character created. */
 } Client_Player;
 
 /**
diff --git a/common/metaserver.c b/common/metaserver.c
index 3170335..2d68972 100644
--- a/common/metaserver.c
+++ b/common/metaserver.c
@@ -1041,11 +1041,7 @@ int metaserver_select(char *sel)
 
 snprintf(buf, sizeof(buf), "Trying to connect to %s:%d", server_name, port);
 draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_METASERVER, buf);
-#ifdef MULTKEYS
 csocket.fd = init_connection(server_name, port);
-#else
-csocket.fd = init_connection(server_ip, port);
-#endif
 if (csocket.fd == -1) {
 draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_METASERVER,
   "Unable to connect to server.");
diff --git a/gtk-v2/src/account.c b/gtk-v2/src/account.c
index 0ed45b8..59c4d64 100644
--- a/gtk-v2/src/account.c
+++ b/gtk-v2/src/account.c
@@ -502,6 +502,11 @@ static void play_character(const char *name)
 SockList_AddString(&sl, "accountplay ");
 SockList_AddString(&sl, name);
 SockList_Send(&sl, csocket.fd);
+
+if (cpl.name)
+free(cpl.name);
+cpl.name = strdup(name);
+keybindings_init();
 }
 
 /**
diff --git a/gtk-v2/src/create_char.c b/gtk-v2/src/create_char.c
index 567d11a..ef6e709 100644
--- a/gtk-v2/src/create_char.c
+++ b/gtk-v2/src/create_char.c
@@ -357,6 +357,10 @@ static void send_create_player_to_server()
 
 SockList_Send(&sl, csocket.fd);
 
+if (cpl.name)
+free(cpl.name);
+cpl.name = strdup(char_name);
+keybindings_init();
 }
 
 
diff --git a/gtk-v2/src/gtk2proto.h b/gtk-v2/src/gtk2proto.h
index 26f7c6e..0e894a5 100644
--- a/gtk-v2/src/gtk2proto.h
+++ b/gtk-v2/src/gtk2proto.h
@@ -112,6 +112,7 @@ extern void animate_inventory(void);
 extern void animate_look(void);
 extern void inventory_tick(void);
 /* keys.c */
+extern void keybindings_init();
 extern void keys_init(GtkWidget *window_root);
 extern void bind_key(char *params);
 extern void unbind_key(const char *params);
diff --git a/gtk-v2/src/keys.c b/gtk-v2/src/keys.c
index de9682c..ea64d51 100644
--- a/gtk-v2/src/keys.c
+++ b/gtk-v2/src/keys.c
@@ -471,24 +471,40 @@ static void init_default_keybindings(void)
 }
 }
 
+static int parse_keys_file(char *filename)
+{
+int line = 0;
+FILE *fp;
+char buf[BIG_BUF];
+
+CONVERT_FILESPEC_TO_OS_FORMAT(filename);
+LOG(LOG_INFO, "gtk-v2::init_keys",
+"Trying to open keybinding file %s", filename);
+
+fp = fopen(filename, "r");
+if (fp == NULL)
+return -1;
+
+while (fgets(buf, BIG_BUF, fp)) {
+line++;
+buf[BIG_BUF - 1] = '\0';
+parse_keybind_line(buf, line);
+}
+
+fclose(fp);
+return 0;
+}
+
 /**
- * Reads in the keybindings, an

[crossfire] [PATCH 0/2] Work on keys.c and the keybinding system

2013-11-02 Thread Arvid Brodin
I have generated a new set of patches without the removal of the 
functionality to re-bind key modifiers, and with some minor 
improvements. Otherwise, they are the same as before.

These apply on top of current svn repository (rev 19089).


I think we should still remove the functionality that allows one 
to rebind the modifier keys, for two reasons:

* It doesn't seem to work. Try it out on rev 19089 - the bind is
  successful (when you press the bound key the corresponding "Run"/
  "Shift" indicator lights up), but as soon as you press a direction
  key, the Run/Fire modifier is lost, and you only get a normal 
  direction press.

* Patch #2 introduces character-specific keys files. It would be
  nice to take the opportunity to change the format of that file
  in the same go, to correspond with the Ctrl and Shift keys (so
  "C" for Ctrl, instead of todays "R" for run, etc).


-- 
Arvid
___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire


Re: [crossfire] [RFC 2/3] Misc keybinding fixes and changes

2013-11-02 Thread Arvid Brodin
On 2013-11-01 04:54, David Hurst wrote:
> I'd be of the view, if it isn't reducing a functionality but
> re-implementing it in a more useful way (be it more flexible, faster,
> or any other good reason) then it has my support.

This could better be described as removing an arcane feature to simplify 
the code and to make room for other improvements in the future. (Do you 
use the feature of rebinding the Run, Shift, Alt or Meta keys?)

> Perhaps another perspective is that if you change it, and things
> don't work out, it is a lot easier to backtrack and try and different
> approach, than it is to have abandoned the idea before anyone got to
> play with it and never know what we were missing in the first place
> :).
> 
> I would mention that at the moment windows users are really limited
> to the jxclient, so do try and make a change that can be implemented
> on both the gtk and jxclient.

That's something of a tall order. :) It's a lot of work learning how
_one_ client works; learning two clients and then trying do do only
changes that benefit both (and doesn't break any) of them could be
very limiting. (Is the Windows compatibility broken on the gtk client?)

Are there any code dependencies between jxclient and the gtk client? 

I noticed the gtk client code is split between the folders common/
and gtk-v2/. I found references to something called the x11 client
in the code, and I assumed that that was an old client that had since
been removed. It was apparently called cfclient, later renamed 
crossfire-client-x11. If this has been removed, perhaps it would be a 
good idea to merge the common/ folder into the gtk-v2/ folder?

(BTW, I've been working exclusively on the code in 
https://svn.code.sf.net/p/crossfire/code/client/trunk)



-- 
Arvid
___
crossfire mailing list
crossfire@metalforge.org
http://mailman.metalforge.org/mailman/listinfo/crossfire