Support deleting GUI Object event handlers following rP666, refs #5387.
[0ad.git] / binaries / data / mods / public / gui / pregame / SplashscreenHandler.js
blob753e5bc5f289fb3c69437f028a5ec8b19df978c1
1 class SplashScreenHandler
3         constructor(initData, hotloadData)
4         {
5                 this.showSplashScreen = hotloadData ? hotloadData.showSplashScreen : initData && initData.isStartup;
7                 this.mainMenuPage = Engine.GetGUIObjectByName("mainMenuPage");
8                 this.mainMenuPage.onTick = this.onFirstTick.bind(this);
9         }
11         getHotloadData()
12         {
13                 // Only show splash screen(s) once at startup, but not again after hotloading
14                 return {
15                         "showSplashScreen": this.showSplashScreen
16                 };
17         }
19         // Don't call this from the init function in order to not crash when opening the new page on init on hotloading
20         // and not possibly crash when opening the new page on init and throwing a JS error.
21         onFirstTick()
22         {
23                 if (this.showSplashScreen)
24                         this.openPage();
26                 delete this.mainMenuPage.onTick;
27         }
29         openPage()
30         {
31                 this.showSplashScreen = false;
33                 if (Engine.ConfigDB_GetValue("user", "gui.splashscreen.enable") === "true" ||
34                     Engine.ConfigDB_GetValue("user", "gui.splashscreen.version") < Engine.GetFileMTime("gui/splashscreen/splashscreen.txt"))
35                         Engine.PushGuiPage("page_splashscreen.xml", {}, this.showRenderPathMessage);
36                 else
37                         this.showRenderPathMessage();
38         }
40         showRenderPathMessage()
41         {
42                 // Warn about removing fixed render path
43                 if (Engine.Renderer_GetRenderPath() != "fixed")
44                         return;
46                 messageBox(
47                         600, 300,
48                         "[font=\"sans-bold-16\"]" +
49                         sprintf(translate("%(warning)s You appear to be using non-shader (fixed function) graphics. This option will be removed in a future 0 A.D. release, to allow for more advanced graphics features. We advise upgrading your graphics card to a more recent, shader-compatible model."), {
50                                 "warning": coloredText("Warning:", "200 20 20")
51                         }) +
52                         "\n\n" +
53                         // Translation: This is the second paragraph of a warning. The
54                         // warning explains that the user is using “non-shader“ graphics,
55                         // and that in the future this will not be supported by the game, so
56                         // the user will need a better graphics card.
57                         translate("Please press \"Read More\" for more information or \"OK\" to continue."),
58                         translate("WARNING!"),
59                         [translate("OK"), translate("Read More")],
60                         [
61                                 null,
62                                 () => {
63                                         Engine.OpenURL("https://www.wildfiregames.com/forum/index.php?showtopic=16734");
64                                 }
65                         ]);
66         }