em-dosbox icon indicating copy to clipboard operation
em-dosbox copied to clipboard

friendlier window title

Open skierpage opened this issue 6 years ago • 2 comments
trafficstars

I came across this playing the excellent MS-DOS Game collection at the Internet Archive, great work! I was confused by the games there putting, e.g. "DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: STUNT" in the window title (thus browser tab and browser history). Tabs and dropdowns cut off the end of this so you don't see what program you're running and it's quite confusing.

Em-DOSBox's GFX_SetTitle() in src/gui/sdlmain.cpp sets the title to the nerdy "DOSBox %s, CPU speed: %8d cycles, Frameskip %2d, Program: %8s",VERSION,internal_cycles,internal_frameskip,RunningProgram) a friendlier layout with the key information first would be "STUNT running in Em-DOSBox v. SVN (CPU speed: 3000 cycles, Frameskip 0)

(the misleading version "number" SVN comes from src/platform/visualc/config.h).

skierpage avatar Aug 09 '19 01:08 skierpage

The title is just what DOSBox does normally. You can see it as the window title when running DOSBox as a normal application. Here it is done via the JavaScript setWindowTitle function. This is easy to override by assigning something else to that function, although it is a bit tricky to know when to do it. You can add setWindowTitle=function(x){}; to the runWithFS() function in the standard HTML code generated when building.

I don't even know what would be a friendlier title, and think overriding the standard title setting and choosing a custom title should be up to whoever edits the web page containing the emulator.

dreamlayers avatar Dec 07 '22 06:12 dreamlayers

alternatively you can excise the title-setting from the DOSBox source code - it ain't glamorous but it works:

diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp
index aaf7c07e..e1ba77f0 100644
--- a/src/gui/sdlmain.cpp
+++ b/src/gui/sdlmain.cpp
@@ -347,11 +347,11 @@ void GFX_SetTitle(Bit32s cycles,int frameskip,bool paused){
 	}
 
 	if (paused) strcat(title," PAUSED");
-#if SDL_VERSION_ATLEAST(2,0,0)
-	SDL_SetWindowTitle(sdl.window,title); // VERSION is gone...
-#else
-	SDL_WM_SetCaption(title,VERSION);
-#endif
+// #if SDL_VERSION_ATLEAST(2,0,0)
+// 	SDL_SetWindowTitle(sdl.window,title); // VERSION is gone...
+// #else
+// 	SDL_WM_SetCaption(title,VERSION);
+// #endif
 }
 
 static unsigned char logo[32*32*4]= {
@@ -2170,11 +2170,11 @@ static void GUI_StartUp(Section * sec) {
 		LOG_MSG("SDL: You are running in 24 bpp mode, this will slow down things!");
 	}
 	GFX_Stop();
-#if SDL_VERSION_ATLEAST(2,0,0)
-	SDL_SetWindowTitle(sdl.window,"DOSBox"); // VERSION is gone...
-#else
-	SDL_WM_SetCaption("DOSBox",VERSION);
-#endif
+// #if SDL_VERSION_ATLEAST(2,0,0)
+// 	SDL_SetWindowTitle(sdl.window,"DOSBox"); // VERSION is gone...
+// #else
+// 	SDL_WM_SetCaption("DOSBox",VERSION);
+// #endif
 
 /* The endian part is intentionally disabled as somehow it produces correct results without according to rhoenie*/
 //#if SDL_BYTEORDER == SDL_BIG_ENDIAN

However then something in emscripten will simply reset the title to empty; this can be mitigated with some JS:

Module.postRun ||= [];
Module.postRun.push(() => {
  window.document.title = "My title";
}

leonid-shevtsov avatar Apr 13 '24 09:04 leonid-shevtsov