Inform the slider properly.
authorRudolf Polzer <divverent@xonotic.org>
Wed, 18 Sep 2013 08:30:02 +0000 (10:30 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 18 Sep 2013 08:30:02 +0000 (10:30 +0200)
qcsrc/menu/menu.qc
qcsrc/menu/xonotic/slider_resolution.c

index 312a2dc..eb68729 100644 (file)
@@ -22,7 +22,7 @@ float conwidth_s, conheight_s, vidwidth_s, vidheight_s, vidpixelheight_s,
 void m_sync()
 {
        updateCompression();
-       vidwidth_s = vidheight_s = vidpixelheight_s = 0;
+       vidwidth_s = vidheight_s = vidpixelheight_s = 0;  // Force updateConwidths on next draw.
 
        loadAllCvars(main);
 }
index d404e80..24e9cb9 100644 (file)
@@ -4,12 +4,16 @@ CLASS(XonoticResolutionSlider) EXTENDS(XonoticTextSlider)
        METHOD(XonoticResolutionSlider, addResolution, void(entity, float, float, float))
        METHOD(XonoticResolutionSlider, loadCvars, void(entity))
        METHOD(XonoticResolutionSlider, saveCvars, void(entity))
+       METHOD(XonoticResolutionSlider, draw, void(entity))
 ENDCLASS(XonoticResolutionSlider)
 entity makeXonoticResolutionSlider();
 void updateConwidths(float width, float height, float pixelheight);
 #endif
 
 #ifdef IMPLEMENTATION
+
+/* private static */ float XonoticResolutionSlider_DataHasChanged;
+
 // Updates cvars (to be called by menu.qc at startup or on detected res change)
 void updateConwidths(float width, float height, float pixelheight)
 {
@@ -56,6 +60,7 @@ void updateConwidths(float width, float height, float pixelheight)
 
        cvar_set("vid_conwidth", ftos(rint(c_x)));
        cvar_set("vid_conheight", ftos(rint(c_y)));
+       XonoticResolutionSlider_DataHasChanged = TRUE;
 }
 entity makeXonoticResolutionSlider()
 {
@@ -124,4 +129,13 @@ void XonoticResolutionSlider_saveCvars(entity me)
                cvar_set("_menu_vid_pixelheight", argv(2));
        }
 }
+void XonoticResolutionSlider_draw(entity me)
+{
+       if (XonoticResolutionSlider_DataHasChanged)
+       {
+               XonoticResolutionSlider_DataHasChanged = FALSE;
+               me.loadCvars(me);
+       }
+       SUPER(XonoticResolutionSlider).draw(me);
+}
 #endif