]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/brushmodule.cpp
netradiant: strip 16-bit png to 8-bit, fix #153
[xonotic/netradiant.git] / radiant / brushmodule.cpp
index bc9c18ef67671262fa6cf553bd90cec4b1e54c9b..6a9565df8906a24823573a8ff180c288d3be49bb 100644 (file)
@@ -34,7 +34,7 @@
 #include "mainframe.h"
 #include "preferences.h"
 
-LatchedBool g_useAlternativeTextureProjection( false, "Use alternative texture-projection (\"brush primitives\")" );
+LatchedValue<bool> g_useAlternativeTextureProjection( false, "Use alternative texture-projection (\"brush primitives\")" );
 bool g_showAlternativeTextureProjectionOption = false;
 bool g_brush_always_caulk;
 
@@ -42,21 +42,20 @@ bool getTextureLockEnabled(){
        return g_brush_texturelock_enabled;
 }
 
-void Face_importSnapPlanes( bool value ){
-       Face::m_quantise = value ? quantiseInteger : quantiseFloating;
-}
-typedef FreeCaller1<bool, Face_importSnapPlanes> FaceImportSnapPlanesCaller;
+struct Face_SnapPlanes {
+       static void Export(const QuantiseFunc &self, const Callback<void(bool)> &returnz) {
+               returnz(self == quantiseInteger);
+       }
 
-void Face_exportSnapPlanes( const BoolImportCallback& importer ){
-       importer( Face::m_quantise == quantiseInteger );
-}
-typedef FreeCaller1<const BoolImportCallback&, Face_exportSnapPlanes> FaceExportSnapPlanesCaller;
+       static void Import(QuantiseFunc &self, bool value) {
+               self = value ? quantiseInteger : quantiseFloating;
+       }
+};
 
 void Brush_constructPreferences( PreferencesPage& page ){
        page.appendCheckBox(
                "", "Snap planes to integer grid",
-               FaceImportSnapPlanesCaller(),
-               FaceExportSnapPlanesCaller()
+               make_property<Face_SnapPlanes>(Face::m_quantise)
                );
        page.appendEntry(
                "Default texture scale",
@@ -65,8 +64,7 @@ void Brush_constructPreferences( PreferencesPage& page ){
        if ( g_showAlternativeTextureProjectionOption ) {
                page.appendCheckBox(
                        "", "Use alternative texture-projection (\"brush primitives\")",
-                       LatchedBoolImportCaller( g_useAlternativeTextureProjection ),
-                       BoolExportCaller( g_useAlternativeTextureProjection.m_latched )
+                       make_property(g_useAlternativeTextureProjection)
                        );
        }
        // d1223m
@@ -80,7 +78,7 @@ void Brush_constructPage( PreferenceGroup& group ){
        Brush_constructPreferences( page );
 }
 void Brush_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Brush_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Brush_constructPage) );
 }
 
 void Brush_unlatchPreferences(){
@@ -102,6 +100,16 @@ int Brush_toggleFormatCount(){
        return 1;
 }
 
+void Brush_switchFormat( bool switch_format ){
+       if ( switch_format )
+       {
+               g_useAlternativeTextureProjection.m_latched = g_useAlternativeTextureProjection.m_value;
+               g_useAlternativeTextureProjection.m_value = !g_useAlternativeTextureProjection.m_value;
+               PreferencesDialog_restartRequired( g_useAlternativeTextureProjection.m_description );
+               PreferencesDialog_restartIfRequired();
+       }
+}
+
 void Brush_Construct( EBrushType type ){
        if ( type == eBrushTypeQuake3 ) {
                g_showAlternativeTextureProjectionOption = true;
@@ -113,9 +121,9 @@ void Brush_Construct( EBrushType type ){
 
                GlobalPreferenceSystem().registerPreference(
                        "AlternativeTextureProjection",
-                       BoolImportStringCaller( g_useAlternativeTextureProjection.m_latched ),
-                       BoolExportStringCaller( g_useAlternativeTextureProjection.m_latched )
+                       make_property_string( g_useAlternativeTextureProjection.m_latched )
                        );
+
                g_useAlternativeTextureProjection.useLatched();
 
                if ( g_useAlternativeTextureProjection.m_value ) {
@@ -125,8 +133,8 @@ void Brush_Construct( EBrushType type ){
                // d1223m
                GlobalPreferenceSystem().registerPreference(
                        "BrushAlwaysCaulk",
-                       BoolImportStringCaller( g_brush_always_caulk ),
-                       BoolExportStringCaller( g_brush_always_caulk ) );
+            make_property_string( g_brush_always_caulk )
+        );
        }
 
        Brush_registerCommands();
@@ -154,12 +162,12 @@ void Brush_Construct( EBrushType type ){
                }
        }
 
-       GlobalPreferenceSystem().registerPreference( "TextureLock", BoolImportStringCaller( g_brush_texturelock_enabled ), BoolExportStringCaller( g_brush_texturelock_enabled ) );
-       GlobalPreferenceSystem().registerPreference( "BrushSnapPlanes", makeBoolStringImportCallback( FaceImportSnapPlanesCaller() ), makeBoolStringExportCallback( FaceExportSnapPlanesCaller() ) );
-       GlobalPreferenceSystem().registerPreference( "TexdefDefaultScale", FloatImportStringCaller( g_texdef_default_scale ), FloatExportStringCaller( g_texdef_default_scale ) );
+       GlobalPreferenceSystem().registerPreference( "TextureLock", make_property_string( g_brush_texturelock_enabled ) );
+       GlobalPreferenceSystem().registerPreference("BrushSnapPlanes", make_property_string<Face_SnapPlanes>(Face::m_quantise));
+       GlobalPreferenceSystem().registerPreference( "TexdefDefaultScale", make_property_string( g_texdef_default_scale ) );
 
        GridStatus_getTextureLockEnabled = getTextureLockEnabled;
-       g_texture_lock_status_changed = FreeCaller<GridStatus_onTextureLockEnabledChanged>();
+       g_texture_lock_status_changed = makeCallbackF(GridStatus_onTextureLockEnabledChanged);
 }
 
 void Brush_Destroy(){
@@ -188,8 +196,8 @@ void BrushFaceData_fromFace( const BrushFaceDataCallback& callback, Face& face )
        faceData.value = face.getShader().m_flags.m_value;
        callback( faceData );
 }
-typedef ConstReferenceCaller1<BrushFaceDataCallback, Face&, BrushFaceData_fromFace> BrushFaceDataFromFaceCaller;
-typedef Callback1<Face&> FaceCallback;
+typedef ConstReferenceCaller<BrushFaceDataCallback, void(Face&), BrushFaceData_fromFace> BrushFaceDataFromFaceCaller;
+typedef Callback<void(Face&)> FaceCallback;
 
 class Quake3BrushCreator : public BrushCreator
 {