rnd-20140311-1-src
authorHolger Schemel <info@artsoft.org>
Tue, 11 Mar 2014 21:33:06 +0000 (22:33 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:01:18 +0000 (11:01 +0200)
src/config.c
src/conftime.h
src/events.c
src/init.c
src/libgame/sdl.c
src/libgame/sdl.h
src/libgame/system.c
src/libgame/system.h
src/main.c
src/screens.c

index bb1c6ee4a7d1154a0e2fce8295394088e934332c..0fec462cb670fdc757fbe480d3e942942daff3c3 100644 (file)
@@ -98,6 +98,29 @@ char *getProgramInitString()
 
 char *getWindowTitleString()
 {
+#if 1
+  static char *window_title_string = NULL;
+
+  checked_free(window_title_string);
+
+#ifdef DEBUG
+  window_title_string = checked_malloc(strlen(getProgramInitString()) + 20 +
+                                      strlen(getCompileDateString()) + 2 + 1);
+
+  sprintf(window_title_string, "%s (%d %%) [%s]",
+         getProgramInitString(), setup.window_scaling_percent,
+         getCompileDateString());
+#else
+  window_title_string = checked_malloc(strlen(getProgramInitString()) + 20);
+
+  sprintf(window_title_string, "%s (%d %%)",
+         getProgramInitString(), setup.window_scaling_percent);
+#endif
+
+  return window_title_string;
+
+#else
+
 #ifdef DEBUG
   static char *window_title_string = NULL;
 
@@ -114,4 +137,6 @@ char *getWindowTitleString()
 #else
   return getProgramInitString();
 #endif
+
+#endif
 }
index 5e5f42be3037cc97c77ff556dd0eb0c81f230a12..ea64b46dcbc2cceed201d92131779fb8eddbb03f 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2014-03-07 21:52"
+#define COMPILE_DATE_STRING "2014-03-11 22:29"
index d261a4db45f368f1ff27c8a4f8424a5662845a4a..f1d9ad1125046821b51c8e390a320825be948b80 100644 (file)
@@ -465,9 +465,11 @@ void HandleWindowEvent(WindowEvent *event)
       int new_xpercent = (100 * new_window_width  / video.width);
       int new_ypercent = (100 * new_window_height / video.height);
 
+#if 0
       printf("::: RESIZED from %d, %d to %d, %d\n",
             video.window_width, video.window_height,
             new_window_width, new_window_height);
+#endif
 
       setup.window_scaling_percent = video.window_scaling_percent =
        MIN(MAX(MIN_WINDOW_SCALING_PERCENT, MIN(new_xpercent, new_ypercent)),
@@ -476,11 +478,15 @@ void HandleWindowEvent(WindowEvent *event)
       video.window_width  = new_window_width;
       video.window_height = new_window_height;
 
+#if 0
       printf("::: setup.window_scaling_percent set to %d\n",
             setup.window_scaling_percent);
+#endif
 
       if (game_status == GAME_MODE_SETUP)
        RedrawSetupScreenAfterFullscreenToggle();
+
+      SetWindowTitle();
     }
 #else
     // prevent slightly wrong scaling factor due to rounding differences
index ec2f8b2e9a2141181dae834099456b0d80f37ef9..d6df6a85dc64a814c066c26bb9570ddd56fd2218 100644 (file)
@@ -5644,7 +5644,7 @@ void InitGfx()
 
   font_height = getFontHeight(FC_RED);
 
-#if 1
+#if 0
   DrawInitTextAlways(getWindowTitleString(), 20, FC_YELLOW);
 #else
   DrawInitTextAlways(getProgramInitString(), 20, FC_YELLOW);
index 120fe30c072926736442aa0bd26d3b1f21a4a482..bfcd7ead12e0cdc815dd3fad2bebe9f184cbe816 100644 (file)
@@ -610,6 +610,8 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
 #endif
   SDL_Surface *new_surface = NULL;
 
+  SetWindowTitle();
+
   if (*backbuffer == NULL)
     *backbuffer = CreateBitmapStruct();
 
@@ -829,6 +831,11 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
 }
 
 #if defined(TARGET_SDL2)
+void SDLSetWindowTitle()
+{
+  SDL_SetWindowTitle(sdl_window, program.window_title);
+}
+
 void SDLSetWindowScaling(int window_scaling_percent)
 {
   if (sdl_window == NULL)
@@ -847,6 +854,8 @@ void SDLSetWindowScaling(int window_scaling_percent)
   video.window_scaling_percent = window_scaling_percent;
   video.window_width  = new_window_width;
   video.window_height = new_window_height;
+
+  SetWindowTitle();
 }
 
 void SDLSetWindowScalingQuality(char *window_scaling_quality)
index 8f64ef18820c47f55dc671fbacee83bd1b9d43f8..a69e235085587cc4b149e6086e0ca27bc5cdc2a3 100644 (file)
@@ -437,6 +437,7 @@ struct MouseCursorInfo
 
 #if defined(TARGET_SDL2)
 SDL_Surface *SDL_DisplayFormat(SDL_Surface *);
+void SDLSetWindowTitle(void);
 void SDLSetWindowScaling(int);
 void SDLSetWindowScalingQuality(char *);
 void SDLSetWindowFullscreen(boolean);
index 7902f42bb80279fc126ea08d394f4ad4ed536027..fee0b17c332b2860ef43fd5d955c0d698e410332 100644 (file)
@@ -75,7 +75,11 @@ int                  FrameCounter = 0;
 
 void InitProgramInfo(char *argv0,
                     char *userdata_subdir, char *userdata_subdir_unix,
-                    char *program_title, char *window_title, char *icon_title,
+                    char *program_title,
+#if 0
+                    char *window_title,
+#endif
+                    char *icon_title,
                     char *x11_icon_filename, char *x11_iconmask_filename,
                     char *sdl_icon_filename, char *msdos_cursor_filename,
                     char *cookie_prefix, char *filename_prefix,
@@ -89,7 +93,11 @@ void InitProgramInfo(char *argv0,
   program.userdata_path = getUserGameDataDir();
 
   program.program_title = program_title;
+#if 1
+  program.window_title = "(undefined)";
+#else
   program.window_title = window_title;
+#endif
   program.icon_title = icon_title;
 
   program.x11_icon_filename = x11_icon_filename;
@@ -108,6 +116,20 @@ void InitProgramInfo(char *argv0,
   program.error_file = stderr;
 }
 
+void SetWindowTitle()
+{
+  program.window_title = program.window_title_function();
+
+#if defined(TARGET_SDL)
+  SDLSetWindowTitle();
+#endif
+}
+
+void InitWindowTitleFunction(char *(*window_title_function)(void))
+{
+  program.window_title_function = window_title_function;
+}
+
 void InitExitMessageFunction(void (*exit_message_function)(char *, va_list))
 {
   program.exit_message_function = exit_message_function;
index 1475ab69b3c7e2fd1e4ba3781680048b0108586e..b9c74003365e64ead0319b70879c65caeabc8e4c 100644 (file)
@@ -711,6 +711,7 @@ struct ProgramInfo
   int version_minor;
   int version_patch;
 
+  char *(*window_title_function)(void);
   void (*exit_message_function)(char *, va_list);
   void (*exit_function)(int);
 };
@@ -1288,9 +1289,17 @@ extern int                       FrameCounter;
 
 /* function definitions */
 
+#if 1
+void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
+                    char *, char *, char *, char *, int);
+#else
 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
                     char *, char *, char *, char *, char *, int);
+#endif
+
+void SetWindowTitle();
 
+void InitWindowTitleFunction(char *(*window_title_function)(void));
 void InitExitMessageFunction(void (*exit_message_function)(char *, va_list));
 void InitExitFunction(void (*exit_function)(int));
 void InitPlatformDependentStuff(void);
index c1982ccf5b19128369dbfa551b4633a14eadf394..53ead02dbd0448d5a0fcd18fcc4f9217c82aec70 100644 (file)
@@ -5602,14 +5602,23 @@ static void print_usage()
 
 int main(int argc, char *argv[])
 {
-  char * window_title_string = getWindowTitleString();
+#if 1
+  InitProgramInfo(argv[0], USERDATA_DIRECTORY, USERDATA_DIRECTORY_UNIX,
+                 PROGRAM_TITLE_STRING, ICON_TITLE_STRING,
+                 X11_ICON_FILENAME, X11_ICONMASK_FILENAME, SDL_ICON_FILENAME,
+                 MSDOS_POINTER_FILENAME,
+                 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
+#else
+  char *window_title_string = getWindowTitleString();
 
   InitProgramInfo(argv[0], USERDATA_DIRECTORY, USERDATA_DIRECTORY_UNIX,
                  PROGRAM_TITLE_STRING, window_title_string, ICON_TITLE_STRING,
                  X11_ICON_FILENAME, X11_ICONMASK_FILENAME, SDL_ICON_FILENAME,
                  MSDOS_POINTER_FILENAME,
                  COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
+#endif
 
+  InitWindowTitleFunction(getWindowTitleString);
   InitExitMessageFunction(DisplayExitMessage);
   InitExitFunction(CloseAllAndExit);
   InitPlatformDependentStuff();
index aeef4fece33dbe8cc71e68bf45157f5d5d2ed26c..c15d68b6466f07be46446ee6ea72f19d0ad31e18 100644 (file)
@@ -1880,6 +1880,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
   {
     game_status = GAME_MODE_LEVELNR;
 
+#if 1
+    ChangeViewportPropertiesIfNeeded();
+#endif
+
     DrawChooseLevelNr();
   }
   else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
@@ -1919,6 +1923,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
          gotoTopLevelDir();
 #endif
 
+#if 1
+         ChangeViewportPropertiesIfNeeded();
+#endif
+
          DrawChooseLevelSet();
        }
       }
@@ -1926,6 +1934,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       {
        game_status = GAME_MODE_SCORES;
 
+#if 1
+       ChangeViewportPropertiesIfNeeded();
+#endif
+
        DrawHallOfFame(-1);
       }
       else if (pos == MAIN_CONTROL_EDITOR)
@@ -1952,6 +1964,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        game_status = GAME_MODE_INFO;
        info_mode = INFO_MODE_MAIN;
 
+#if 1
+       ChangeViewportPropertiesIfNeeded();
+#endif
+
        DrawInfoScreen();
       }
       else if (pos == MAIN_CONTROL_GAME)