#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;
return g_brush_texturelock_enabled;
}
-void Face_importSnapPlanes( bool value ){
- Face::m_quantise = value ? quantiseInteger : quantiseFloating;
-}
+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 );
-}
+ static void Import(QuantiseFunc &self, bool value) {
+ self = value ? quantiseInteger : quantiseFloating;
+ }
+};
void Brush_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
"", "Snap planes to integer grid",
- makeCallbackF(Face_importSnapPlanes),
- makeCallbackF(Face_exportSnapPlanes)
+ make_property<Face_SnapPlanes>(Face::m_quantise)
);
page.appendEntry(
"Default texture scale",
if ( g_showAlternativeTextureProjectionOption ) {
page.appendCheckBox(
"", "Use alternative texture-projection (\"brush primitives\")",
- LatchedBoolImportCaller( g_useAlternativeTextureProjection ),
- BoolExportCaller( g_useAlternativeTextureProjection.m_latched )
+ make_property(g_useAlternativeTextureProjection)
);
}
// d1223m
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;
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 ) {
// d1223m
GlobalPreferenceSystem().registerPreference(
"BrushAlwaysCaulk",
- BoolImportStringCaller( g_brush_always_caulk ),
- BoolExportStringCaller( g_brush_always_caulk ) );
+ make_property_string( g_brush_always_caulk )
+ );
}
Brush_registerCommands();
}
}
- GlobalPreferenceSystem().registerPreference( "TextureLock", BoolImportStringCaller( g_brush_texturelock_enabled ), BoolExportStringCaller( g_brush_texturelock_enabled ) );
- GlobalPreferenceSystem().registerPreference( "BrushSnapPlanes", makeBoolStringImportCallback( FreeCaller<void(bool), Face_importSnapPlanes>() ), makeBoolStringExportCallback( FreeCaller<void(const BoolImportCallback&), Face_exportSnapPlanes>() ) );
- 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 = makeCallbackF(GridStatus_onTextureLockEnabledChanged);