Ticket #2116: patch_splashscreen.3.diff

File patch_splashscreen.3.diff, 3.9 KB (added by Itms, 11 years ago)
  • binaries/data/config/default.cfg

     
    2020; Enable/disable windowed mode by default. (Use Alt+Enter to toggle in the game.)
    2121windowed = false
    2222
    23 ; Enable/disable the splashscreen
    24 splashscreenenable = true
     23; Splashscreen version (date of last modification). By default, 0 to force splashscreen to appear at first launch.
     24splashscreenversion = 0
    2525
    2626; Pause the game on window focus loss (Only applicable to single player mode)
    2727pauseonfocusloss = true
  • binaries/data/mods/public/gui/splashscreen/splashscreen.xml

     
    2323        <object name="btnOK" type="button" style="StoneButton" tooltip_style="snToolTip" size="24 100%-52 188 100%-24">
    2424            OK
    2525            <action on="Press"><![CDATA[
    26             Engine.SetSplashScreenEnabled(!getGUIObjectByName("displaySplashScreen").checked);
     26            if(getGUIObjectByName("displaySplashScreen").checked)
     27                Engine.DisableSplashScreen();
    2728            Engine.PopGuiPage();
    2829            ]]></action>
    2930        </object>
  • source/gui/scripting/ScriptFunctions.cpp

     
    526526
    527527bool IsSplashScreenEnabled(void* UNUSED(cbdata))
    528528{
    529     bool splashScreenEnable = true;
    530     CFG_GET_VAL("splashscreenenable", Bool, splashScreenEnable);
    531     return splashScreenEnable;
     529    time_t splashScreenVersion = 0;
     530    CFileInfo splashFileInfo;
     531
     532    CFG_GET_VAL("splashscreenversion", Time, splashScreenVersion);
     533
     534    if(g_VFS->GetFileInfo("gui/splashscreen/splashscreen.txt", &splashFileInfo) == INFO::OK)
     535        return (splashScreenVersion != splashFileInfo.MTime());
     536    else
     537        return true;   
    532538}
    533539
    534 void SetSplashScreenEnabled(void* UNUSED(cbdata), bool enabled)
     540void DisableSplashScreen(void* UNUSED(cbdata))
    535541{
    536     CStr val = (enabled ? "true" : "false");
    537     g_ConfigDB.CreateValue(CFG_USER, "splashscreenenable")->m_String = val;
     542    CFileInfo splashFileInfo;
     543    CStr val;
     544
     545    g_VFS->GetFileInfo("gui/splashscreen/splashscreen.txt", &splashFileInfo);
     546    val = CStr::FromInt64(splashFileInfo.MTime());
     547   
     548    g_ConfigDB.CreateValue(CFG_USER, "splashscreenversion")->m_String = val;
    538549    g_ConfigDB.WriteFile(CFG_USER);
    539550}
    540551
     
    722733
    723734    // Splash screen functions
    724735    scriptInterface.RegisterFunction<bool, &IsSplashScreenEnabled>("IsSplashScreenEnabled");
    725     scriptInterface.RegisterFunction<void, bool, &SetSplashScreenEnabled>("SetSplashScreenEnabled");
     736    scriptInterface.RegisterFunction<void, &DisableSplashScreen>("DisableSplashScreen");
    726737
    727738    // Development/debugging functions
    728739    scriptInterface.RegisterFunction<void, float, &SetSimRate>("SetSimRate");
  • source/ps/Parser.cpp

     
    224224FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedShort,  unsigned short)
    225225FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedInt,    unsigned int)
    226226FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedLong,   unsigned long)
     227FUNC_IMPL_CAST_GETDOUBLE(GetTime,           time_t)
    227228
    228229// CParserTaskTypeNode
    229230// ---------------------------------------------------------------------| Class
  • source/ps/Parser.h

     
    106106    bool GetUnsignedInt(unsigned int &ret);
    107107    bool GetUnsignedLong(unsigned long &ret);
    108108    bool GetFloat(float &ret);
     109    bool GetTime(time_t &time);
    109110    bool GetDouble(double &ret);
    110111
    111112    // Memory regardless if it's an int, real, string or whatever