[hatari-devel] Startup help message

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

Roger asked for some reminder in Hatari UI for mouse grab shortcut.

In Aranym such information is available always in the titlebar.

In Hatari, only help text is a message in statusbar (if that is enabled)
about options key, which is visible for few seconds at Hatari start.

What do you think of the attached patch that adds info about mouse
grab shortcut to the same statusbar message?

At the same time it fixes the issue that the message didn't tell
whether modifier key was needed (in case user changed F11 fullscreen
key to something else).


	- Eero
diff --git a/src/main.c b/src/main.c
index ee3c3b90..182337de 100644
--- a/src/main.c
+++ b/src/main.c
@@ -857,24 +857,50 @@ static void Main_LoadInitialConfig(void)
  */
 static void Main_StatusbarSetup(void)
 {
-	const char *name = NULL;
+	struct {
+		const int id;
+		bool mod;
+		char *name;
+	} keys[] = {
+		{ SHORTCUT_OPTIONS, false, NULL },
+		{ SHORTCUT_MOUSEGRAB, false, NULL }
+	};
+	const char *name;
+	bool named;
 	SDLKey key;
+	int i;
 
-	key = ConfigureParams.Shortcut.withoutModifier[SHORTCUT_OPTIONS];
-	if (!key)
-		key = ConfigureParams.Shortcut.withModifier[SHORTCUT_OPTIONS];
-	if (key)
-		name = SDL_GetKeyName(key);
-	if (name)
+	named = false;
+	for (i = 0; i < ARRAY_SIZE(keys); i++)
 	{
-		char message[24], *keyname;
+		key = ConfigureParams.Shortcut.withoutModifier[keys[i].id];
+		if (!key)
+		{
+			keys[i].mod = true;
+			key = ConfigureParams.Shortcut.withModifier[keys[i].id];
+			if (!key)
+				continue;
+		}
+		name = SDL_GetKeyName(key);
+		if (!name)
+			continue;
 #ifdef _MUDFLAP
 		__mf_register((void*)name, 32, __MF_TYPE_GUESS, "SDL keyname");
 #endif
-		keyname = Str_ToUpper(strdup(name));
-		snprintf(message, sizeof(message), "Press %s for Options", keyname);
-		free(keyname);
-
+		keys[i].name = Str_ToUpper(strdup(name));
+		named = true;
+	}
+	if (named)
+	{
+		char message[60];
+		snprintf(message, sizeof(message), "%s%s: options, %s%s: mouse grab toggle",
+			 keys[0].mod ? "AltGr+": "", keys[0].name,
+			 keys[1].mod ? "AltGr+": "", keys[1].name);
+		for (i = 0; i < ARRAY_SIZE(keys); i++)
+		{
+			if (keys[i].name)
+				free(keys[i].name);
+		}
 		Statusbar_AddMessage(message, 5000);
 	}
 	/* update information loaded by Main_Init() */


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/