]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Introduce Property<T> to simplify preferences system
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 3 Jan 2018 02:39:43 +0000 (13:39 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 3 Jan 2018 03:46:58 +0000 (14:46 +1100)
45 files changed:
include/ientity.h
include/preferencesystem.cpp
include/preferencesystem.h
libs/CMakeLists.txt
libs/generic/callback.h
libs/gtkutil/accelerator.h
libs/gtkutil/widget.cpp
libs/gtkutil/widget.h
libs/gtkutil/window.cpp
libs/gtkutil/window.h
libs/property.h [new file with mode: 0644]
libs/stringio.h
plugins/entity/entity.cpp
radiant/autosave.cpp
radiant/brushmanip.cpp
radiant/brushmodule.cpp
radiant/build.cpp
radiant/camwindow.cpp
radiant/commands.cpp
radiant/commands.h
radiant/dialog.cpp
radiant/dialog.h
radiant/entity.cpp
radiant/entityinspector.cpp
radiant/entitylist.cpp
radiant/filters.cpp
radiant/grid.cpp
radiant/groupdialog.cpp
radiant/groupdialog.h
radiant/mainframe.cpp
radiant/map.cpp
radiant/mru.cpp
radiant/multimon.cpp
radiant/patchdialog.cpp
radiant/patchmanip.cpp
radiant/preferencedictionary.h
radiant/preferences.cpp
radiant/preferences.h
radiant/surfacedialog.cpp
radiant/textures.cpp
radiant/texwindow.cpp
radiant/texwindow.h
radiant/undo.cpp
radiant/watchbsp.cpp
radiant/xywindow.cpp

index 0ea6e25d3c3b7e780b180461e427e0eade897410..dd3f253c8082be09116f28f25c213f776adae627 100644 (file)
@@ -124,7 +124,7 @@ virtual void setCounter( Counter* counter ) = 0;
 virtual void connectEntities( const scene::Path& e1, const scene::Path& e2, int index ) = 0;
 
 virtual void setLightRadii( bool lightRadii ) = 0;
-virtual bool getLightRadii() = 0;
+virtual bool getLightRadii() const = 0;
 virtual void setShowNames( bool showNames ) = 0;
 virtual bool getShowNames() = 0;
 virtual void setShowAngles( bool showAngles ) = 0;
index 5476f9d647a36c7f6c91cbed42a8d5c7bdc571aa..5796d76f0fbd44db47b0ddc1004010818c9eda2e 100644 (file)
@@ -76,13 +76,13 @@ void importString( const char* value ){
        m_observer.onChanged();
 }
 typedef MemberCaller<StringPreference, void(const char*), &StringPreference::importString> ImportStringCaller;
-void exportString( ImportExportCallback<const char *>::Import_t& importer ){
+void exportString( Callback<void(const char *)>& importer ){
        importer( m_string.c_str() );
 }
-typedef MemberCaller<StringPreference, void(ImportExportCallback<const char *>::Import_t&), &StringPreference::exportString> ExportStringCaller;
+typedef MemberCaller<StringPreference, void(Callback<void(const char *)>&), &StringPreference::exportString> ExportStringCaller;
 };
 
-inline void int_export( int i, ImportExportCallback<const char *>::Import_t& importer ){
+inline void int_export( int i, Callback<void(const char *)>& importer ){
        char buffer[16];
        sprintf( buffer, "%d", i );
        importer( buffer );
@@ -114,10 +114,10 @@ void importString( const char* value ){
        m_observer.onChanged();
 }
 typedef MemberCaller<IntPreference, void(const char*), &IntPreference::importString> ImportStringCaller;
-void exportString( ImportExportCallback<const char *>::Import_t& importer ){
+void exportString( Callback<void(const char *)>& importer ){
        int_export( m_int, importer );
 }
-typedef MemberCaller<IntPreference, void(ImportExportCallback<const char *>::Import_t&), &IntPreference::exportString> ExportStringCaller;
+typedef MemberCaller<IntPreference, void(Callback<void(const char *)>&), &IntPreference::exportString> ExportStringCaller;
 };
 
 class IntPreferenceImporter
index a82676ec0b65e920006b03c694a8ad3cb4cd1b10..6479ec91d32e7adabafc1d654d5b85611717754c 100644 (file)
 
 #include "generic/constant.h"
 #include "generic/callback.h"
+#include "property.h"
 
-class PreferenceSystem
-{
+class PreferenceSystem {
 public:
-INTEGER_CONSTANT( Version, 1 );
-STRING_CONSTANT( Name, "preferences" );
+       INTEGER_CONSTANT(Version, 1);
+       STRING_CONSTANT(Name, "preferences");
 
-virtual void registerPreference( const char* name, const ImportExportCallback<const char *>::Import_t& importer, const ImportExportCallback<const char *>::Export_t& exporter ) = 0;
+       virtual void registerPreference(const char *name, const Property<const char *> &cb) = 0;
 };
 
+template<class Self>
+Property<const char *> make_property_string(Self &it) {
+       return make_property<PropertyAdaptor<Self, const char *>>(it);
+}
+
+template<class I, class Self>
+Property<const char *> make_property_string(Self &it) {
+       return make_property_chain<PropertyImpl<detail::propertyimpl_other<I>, const char *>, I>(it);
+}
+
+template<class I>
+Property<const char *> make_property_string() {
+       return make_property_chain<PropertyImpl<detail::propertyimpl_other_free<I>, const char *>, I>();
+}
+
 #include "modulesystem.h"
 
 template<typename Type>
index 9094354e83cfe53274b09a4d2a18076aa935ad52..9f5f834c9bb2dcfcad442c03712b8f7077667d3d 100644 (file)
@@ -39,6 +39,7 @@ add_library(libs
         fs_path.h
         globaldefs.h
         imagelib.h
+        property.h
         instancelib.h
         maplib.h
         moduleobservers.h
index 26772880385d04336583bf1d09ef281b32d6f35c..577dd9d958bd337082f9c2479c5c1803e664c1a3 100644 (file)
@@ -69,65 +69,92 @@ namespace detail {
 
 namespace detail {
 
-       template<typename Type>
-       inline void *convertToOpaque(Type *t) {
-               return t;
-       }
+       template<class Type>
+       struct ConvertFromOpaque {
+       };
 
-       template<typename Type>
-       inline void *convertToOpaque(const Type *t) {
-               return const_cast<Type *>( t );
-       }
+       // reference
 
-       template<typename Type>
-       inline void *convertToOpaque(Type &t) {
+       template<class T>
+       inline const void *convertToOpaque(const T &t) {
                return &t;
        }
 
-       template<typename Type>
-       inline void *convertToOpaque(const Type &t) {
-               return const_cast<Type *>( &t );
-       }
-
-
-       template<typename Type>
-       class ConvertFromOpaque {
+       template<class T>
+       struct ConvertFromOpaque<const T &> {
+               static T const &apply(void *p) {
+                       return *static_cast<const T *>(p);
+               }
        };
 
-       template<typename Type>
-       class ConvertFromOpaque<Type &> {
-       public:
-               static Type &apply(void *p) {
-                       return *static_cast<Type *>( p );
+       template<class T>
+       inline void *convertToOpaque(T &t) {
+               return &t;
+       }
+
+       template<class T>
+       struct ConvertFromOpaque<T &> {
+               static T &apply(void *p) {
+                       return *static_cast<T *>( p );
                }
        };
 
-       template<typename Type>
-       class ConvertFromOpaque<const Type &> {
-       public:
-               static const Type &apply(void *p) {
-                       return *static_cast<Type *>( p );
+       // pointer
+
+       template<class T>
+       inline const void *convertToOpaque(const T *t) {
+               return t;
+       }
+
+       template<class T>
+       struct ConvertFromOpaque<const T *> {
+               static const T *apply(void *p) {
+                       return static_cast<const T *>(p);
                }
        };
 
+       template<class T>
+       inline void *convertToOpaque(T *t) {
+               return t;
+       }
 
-       template<typename Type>
-       class ConvertFromOpaque<Type *> {
-       public:
-               static Type *apply(void *p) {
-                       // illegal cast
-                       return reinterpret_cast<Type *>( p );
+       template<class T>
+       struct ConvertFromOpaque<T *> {
+               static T *apply(void *p) {
+                       return static_cast<T *>(p);
                }
        };
 
-       template<typename Type>
-       class ConvertFromOpaque<const Type *> {
-       public:
-               static const Type *apply(void *p) {
-                       return static_cast<Type *>( p );
+       // function pointer
+
+       template<class R, class... Ts>
+       inline const void *convertToOpaque(R(*const &t)(Ts...)) {
+               return &t;
+       }
+
+       template<class R, class... Ts>
+       struct ConvertFromOpaque<R(*const &)(Ts...)> {
+               using Type = R(*)(Ts...);
+
+               static Type const &apply(void *p) {
+                       return *static_cast<Type *>(p);
                }
        };
 
+    template<class R, class... Ts>
+    inline void *convertToOpaque(R(*&t)(Ts...)) {
+        return &t;
+    }
+
+    template<class R, class... Ts>
+    struct ConvertFromOpaque<R(*&)(Ts...)> {
+        using Type = R(*)(Ts...);
+
+        static Type &apply(void *p) {
+            return *static_cast<Type *>(p);
+        }
+    };
+
        template<class Caller, class F>
        class BindFirstOpaqueN;
 
@@ -147,11 +174,15 @@ namespace detail {
                }
 
                static R thunk(void *environment, Ts... args) {
-                       return Caller::call(detail::ConvertFromOpaque<FirstBound>::apply(environment), args...);
+                       return thunk_(detail::ConvertFromOpaque<FirstBound>::apply(environment), args...);
+               }
+
+               static R thunk_(FirstBound environment, Ts... args) {
+                       return Caller::call(environment, args...);
                }
 
                void *getEnvironment() const {
-                       return detail::convertToOpaque(firstBound);
+                       return const_cast<void *>(detail::convertToOpaque(firstBound));
                }
        };
 
@@ -291,15 +322,16 @@ namespace detail {
                }
        };
 
-       template <class F>
-       struct freecallwrapper;
+       template<class F>
+       struct FreeCallerWrapper;
+
+       template<class R, class... Ts>
+       struct FreeCallerWrapper<R(Ts...)> {
+               using func = R(void *, Ts...);
 
-       template <class R, class... Ts>
-       struct freecallwrapper<R(Ts...)> {
-               using func = R(R(Ts...), Ts...);
-               static R call(R(*f)(Ts...), Ts... args) {
+               static R call(void *f, Ts... args) {
                        // ideally, we'd get the implementation of the function type directly. Instead, it's passed in
-                       return f(args...);
+                       return reinterpret_cast<R(*)(Ts...)>(f)(args...);
                }
        };
 }
@@ -308,18 +340,10 @@ namespace detail {
 template<class F, F *func>
 using FreeCaller = detail::FreeCaller<Function<F, func>, F>;
 
-template<class F>
-inline Callback<F> makeCallbackF(F *func) {
-       // illegal cast
-       return Callback<F>(reinterpret_cast<void *>(func), BindFirstOpaque<detail::freecallwrapper<F>>::thunk);
+template<class R, class... Ts>
+inline Callback<R(Ts...)> makeCallbackF(R(*func)(Ts...)) {
+    void *pVoid = reinterpret_cast<void *>(func);
+    return BindFirstOpaque<detail::FreeCallerWrapper<R(Ts...)>>(pVoid);
 }
 
-template <class T>
-struct ImportExportCallback {
-       using Import_t = Callback<void(T)>;
-       Import_t Import;
-       using Export_t = Callback<void(const Callback<void(T)> &)>;
-    Export_t Export;
-};
-
 #endif
index f2be18214d8154d1a7ff596a98fa8dabd802740c..528dd6bb9269ac18d6c8f44f06117c1b4c2638c8 100644 (file)
@@ -26,6 +26,7 @@
 #include <gdk/gdk.h>
 
 #include "generic/callback.h"
+#include "property.h"
 
 // ignore numlock
 #define ALLOWED_MODIFIERS ( ~( GDK_MOD2_MASK | GDK_LOCK_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK ) )
@@ -111,8 +112,8 @@ class Toggle
 {
 public:
 Command m_command;
-ImportExportCallback<bool>::Export_t m_exportCallback;
-Toggle( const Callback<void()>& callback, const Accelerator& accelerator, const ImportExportCallback<bool>::Export_t& exportCallback ) : m_command( callback, accelerator ), m_exportCallback( exportCallback ){
+Callback<void(const Callback<void(bool)> &)> m_exportCallback;
+Toggle( const Callback<void()>& callback, const Accelerator& accelerator, const Callback<void(const Callback<void(bool)> &)>& exportCallback ) : m_command( callback, accelerator ), m_exportCallback( exportCallback ){
 }
 };
 
index db429083595dd4d1a79ad947d98e7d7aa70cad6b..9d9c1a8d33e2e4f87e7c5182b813d36267269790 100644 (file)
@@ -39,7 +39,7 @@ bool ToggleShown::active() const
     }
 }
 
-void ToggleShown::exportActive(const ImportExportCallback<bool>::Import_t &importCallback)
+void ToggleShown::exportActive(const Callback<void(bool)> &importCallback)
 {
     importCallback(active());
 }
index 0cc8da3f3d2be36776d4f5f216e86d4c247b4aa4..52b7d9c46485e1ae519ed6d95fc0c265373addf3 100644 (file)
 #include "generic/callback.h"
 #include "warnings.h"
 #include "debugging/debugging.h"
+#include "property.h"
 
 class ToggleItem {
-    ImportExportCallback<bool>::Export_t m_exportCallback;
-    typedef std::list<ImportExportCallback<bool>::Import_t> ImportCallbacks;
+    Callback<void(const Callback<void(bool)> &)> m_exportCallback;
+    typedef std::list<Callback<void(bool)>> ImportCallbacks;
     ImportCallbacks m_importCallbacks;
 public:
-    ToggleItem(const ImportExportCallback<bool>::Export_t &exportCallback) : m_exportCallback(exportCallback)
+    ToggleItem(const Callback<void(const Callback<void(bool)> &)> &exportCallback) : m_exportCallback(exportCallback)
     {
     }
 
@@ -45,13 +46,13 @@ public:
         }
     }
 
-    void addCallback(const ImportExportCallback<bool>::Import_t &callback)
+    void addCallback(const Callback<void(bool)> &callback)
     {
         m_importCallbacks.push_back(callback);
         m_exportCallback(callback);
     }
 
-    typedef MemberCaller<ToggleItem, void(const ImportExportCallback<bool>::Import_t &), &ToggleItem::addCallback> AddCallbackCaller;
+    typedef MemberCaller<ToggleItem, void(const Callback<void(bool)> &), &ToggleItem::addCallback> AddCallbackCaller;
 };
 
 class ToggleShown {
@@ -77,9 +78,9 @@ public:
 
     bool active() const;
 
-    void exportActive(const ImportExportCallback<bool>::Import_t &importCallback);
+    void exportActive(const Callback<void(bool)> &importCallback);
 
-    typedef MemberCaller<ToggleShown, void(const ImportExportCallback<bool>::Import_t &), &ToggleShown::exportActive> ActiveCaller;
+    typedef MemberCaller<ToggleShown, void(const Callback<void(bool)> &), &ToggleShown::exportActive> ActiveCaller;
 
     void set(bool shown);
 
index e2d7ec39a0938d54617947b2f97ca03e86bc3731..11b6efeb21cd043373859011100ac7a7d676efd0 100644 (file)
@@ -183,30 +183,30 @@ void window_set_position(ui::Window window, const WindowPosition &position)
        gtk_window_set_default_size( window, position.w, position.h );
 }
 
-void WindowPosition_Parse(WindowPosition &position, const char *value)
+void WindowPosition_String::Import(WindowPosition &position, const char *value)
 {
        if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) {
                position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position
        }
 }
 
-void WindowPosition_Write(const WindowPosition &position, const ImportExportCallback<const char *>::Import_t &importCallback)
+void WindowPosition_String::Export(const WindowPosition &self, const Callback<void(const char *)> &returnz)
 {
        char buffer[64];
-       sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h );
-       importCallback( buffer );
+       sprintf( buffer, "%d %d %d %d", self.x, self.y, self.w, self.h );
+       returnz( buffer );
 }
 
-void WindowPositionTracker_importString(WindowPositionTracker &self, const char *value)
+void WindowPositionTracker_String::Import(WindowPositionTracker &self, const char *value)
 {
        WindowPosition position;
-       WindowPosition_Parse( position, value );
+       WindowPosition_String::Import( position, value );
        self.setPosition( position );
 }
 
-void WindowPositionTracker_exportString(const WindowPositionTracker &self, const ImportExportCallback<const char *>::Import_t &importer)
+void WindowPositionTracker_String::Export(const WindowPositionTracker &self, const Callback<void(const char *)> &returnz)
 {
-       WindowPosition_Write( self.getPosition(), importer );
+       WindowPosition_String::Export( self.getPosition(), returnz );
 }
 
 gboolean WindowPositionTracker::configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self)
index 83b4c00beed832a392433ff47dc3f2118956cdf5..69135f833f897bae273569133d746b325047449d 100644 (file)
@@ -66,14 +66,13 @@ void window_get_position(ui::Window window, WindowPosition &position);
 
 void window_set_position(ui::Window window, const WindowPosition &position);
 
-void WindowPosition_Parse(WindowPosition &position, const char *value);
+struct WindowPosition_String {
 
-typedef ReferenceCaller<WindowPosition, void(const char *), WindowPosition_Parse> WindowPositionImportStringCaller;
+    static void Export(const WindowPosition &self, const Callback<void(const char *)> &returnz);
 
-void WindowPosition_Write(const WindowPosition &position, const ImportExportCallback<const char *>::Import_t &importCallback);
-
-typedef ConstReferenceCaller<WindowPosition, void(const ImportExportCallback<const char *>::Import_t &), WindowPosition_Write> WindowPositionExportStringCaller;
+    static void Import(WindowPosition &self, const char *value);
 
+};
 
 class WindowPositionTracker {
     WindowPosition m_position;
@@ -97,13 +96,10 @@ public:
 };
 
 
-void WindowPositionTracker_importString(WindowPositionTracker &self, const char *value);
-
-typedef ReferenceCaller<WindowPositionTracker, void(const char *), WindowPositionTracker_importString> WindowPositionTrackerImportStringCaller;
-
-void WindowPositionTracker_exportString(const WindowPositionTracker &self, const ImportExportCallback<const char *>::Import_t &importer);
-
-typedef ConstReferenceCaller<WindowPositionTracker, void(const ImportExportCallback<const char *>::Import_t &), WindowPositionTracker_exportString> WindowPositionTrackerExportStringCaller;
+struct WindowPositionTracker_String {
+    static void Export(const WindowPositionTracker &self, const Callback<void(const char *)> &returnz);
 
+    static void Import(WindowPositionTracker &self, const char *value);
+};
 
 #endif
diff --git a/libs/property.h b/libs/property.h
new file mode 100644 (file)
index 0000000..abdb32f
--- /dev/null
@@ -0,0 +1,167 @@
+#ifndef INCLUDED_IMPORTEXPORT_H
+#define INCLUDED_IMPORTEXPORT_H
+
+#include "generic/callback.h"
+#include "string/string.h"
+
+template<class T>
+struct Property {
+    // todo: just return T, don't use continuation passing style
+    Callback<void(const Callback<void(T)> &returnz)> get;
+    Callback<void(T value)> set;
+};
+
+// implementation
+
+template<class Self, class T = Self>
+struct PropertyImpl {
+    static void Export(const Self &self, const Callback<void(T)> &returnz) {
+        returnz(self);
+    }
+
+    static void Import(Self &self, T value) {
+        self = value;
+    }
+};
+
+namespace detail {
+
+    template<class I>
+    using propertyimpl_self = typename std::remove_reference<get_argument<decltype(&I::Import), 0>>::type;
+
+    template<class I>
+    using propertyimpl_other = get_argument<decltype(&I::Import), 1>;
+
+    template<class I>
+    using propertyimpl_other_free = get_argument<decltype(&I::Import), 0>;
+
+}
+
+// adaptor
+
+template<
+        class Self,
+        class T = Self,
+        class I = PropertyImpl<Self, T>
+>
+struct PropertyAdaptor {
+    using Type = Self;
+    using Other = T;
+
+    using Get = ConstReferenceCaller<Self, void(const Callback<void(T)> &), I::Export>;
+    using Set = ReferenceCaller<Self, void(T), I::Import>;
+};
+
+template<
+        class T,
+        class I
+>
+struct PropertyAdaptorFree {
+    using Other = T;
+
+    using Get = FreeCaller<void(const Callback<void(T)> &), I::Export>;
+    using Set = FreeCaller<void(T), I::Import>;
+};
+
+// explicit full
+
+template<class A>
+Property<typename A::Other> make_property(typename A::Type &self) {
+    return {typename A::Get(self), typename A::Set(self)};
+}
+
+template<class A>
+Property<typename A::Other> make_property() {
+    return {typename A::Get(), typename A::Set()};
+}
+
+// explicit impl
+
+template<class I, class Self = detail::propertyimpl_self<I>, class T = detail::propertyimpl_other<I>>
+using property_impl = PropertyAdaptor<Self, T, I>;
+
+template<class I, class Self, class T = detail::propertyimpl_other<I>>
+Property<T> make_property(Self &self) {
+    return make_property<property_impl<I>>(self);
+}
+
+template<class I, class T = detail::propertyimpl_other_free<I>>
+using property_impl_free = PropertyAdaptorFree<T, I>;
+
+template<class I, class T = detail::propertyimpl_other_free<I>>
+Property<T> make_property() {
+    return make_property<property_impl_free<I>>();
+}
+
+// implicit
+
+template<class Self, class T = Self>
+Property<T> make_property(Self &self) {
+    return make_property<PropertyAdaptor<Self, T>>(self);
+}
+
+// chain
+
+template<class I_Outer, class I_Inner>
+Property<detail::propertyimpl_other<I_Outer>> make_property_chain(detail::propertyimpl_self<I_Inner> &it) {
+    using DST = detail::propertyimpl_other<I_Outer>;
+    using SRC = detail::propertyimpl_self<I_Outer>;
+    using X = detail::propertyimpl_self<I_Inner>;
+
+    using A = property_impl<I_Inner>;
+    struct I {
+        static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
+            PropertyImpl<SRC, DST>::Export(value, self);
+        }
+
+        static void Export(const X &self, const Callback<void(DST)> &returnz) {
+            A::Get::thunk_(self, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
+        }
+
+        static void Import(X &self, DST value) {
+            SRC out;
+            PropertyImpl<SRC, DST>::Import(out, value);
+            A::Set::thunk_(self, out);
+        }
+    };
+    return make_property<PropertyAdaptor<X, DST, I>>(it);
+}
+
+template<class I_Outer, class I_Inner>
+Property<detail::propertyimpl_other<I_Outer>> make_property_chain() {
+    using DST = detail::propertyimpl_other<I_Outer>;
+    using SRC = detail::propertyimpl_self<I_Outer>;
+
+    using A = property_impl_free<I_Inner>;
+    struct I {
+        static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
+            PropertyImpl<SRC, DST>::Export(value, self);
+        }
+
+        static void Export(const Callback<void(DST)> &returnz) {
+            A::Get::thunk_(nullptr, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
+        }
+
+        static void Import(DST value) {
+            SRC out;
+            PropertyImpl<SRC, DST>::Import(out, value);
+            A::Set::thunk_(nullptr, out);
+        }
+    };
+    return make_property<PropertyAdaptorFree<DST, I>>();
+}
+
+// specializations
+
+template<>
+struct PropertyImpl<CopiedString, const char *> {
+    static void Export(const CopiedString &self, const Callback<void(const char *)> &returnz) {
+        returnz(self.c_str());
+    }
+
+    static void Import(CopiedString &self, const char *value) {
+        self = value;
+    }
+};
+
+#endif
index 0eb5d337269f161cfb14a258b1dbf0c8928723c9..47772ee47845d139e9bac1e625811a893249bbc1 100644 (file)
@@ -29,6 +29,7 @@
 #include "iscriplib.h"
 #include "string/string.h"
 #include "generic/callback.h"
+#include "property.h"
 
 inline float string_read_float( const char* string ){
        return static_cast<float>( atof( string ) );
@@ -287,183 +288,78 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream,
 }
 
 
-
-
-inline void CopiedString_importString( CopiedString& self, const char* string ){
-       self = string;
-}
-typedef ReferenceCaller<CopiedString, void(const char*), CopiedString_importString> CopiedStringImportStringCaller;
-inline void CopiedString_exportString( const CopiedString& self, const ImportExportCallback<const char *>::Import_t& importer ){
-       importer( self.c_str() );
-}
-typedef ConstReferenceCaller<CopiedString, void(const ImportExportCallback<const char *>::Import_t&), CopiedString_exportString> CopiedStringExportStringCaller;
-
-inline void Bool_importString( bool& self, const char* string ){
-       self = string_equal( string, "true" );
-}
-typedef ReferenceCaller<bool, void(const char*), Bool_importString> BoolImportStringCaller;
-inline void Bool_exportString( const bool& self, const ImportExportCallback<const char *>::Import_t& importer ){
-       importer( self ? "true" : "false" );
-}
-typedef ConstReferenceCaller<bool, void(const ImportExportCallback<const char *>::Import_t&), Bool_exportString> BoolExportStringCaller;
-
-inline void Int_importString( int& self, const char* string ){
-       if ( !string_parse_int( string, self ) ) {
-               self = 0;
-       }
-}
-typedef ReferenceCaller<int, void(const char*), Int_importString> IntImportStringCaller;
-inline void Int_exportString( const int& self, const ImportExportCallback<const char *>::Import_t& importer ){
-       char buffer[16];
-       sprintf( buffer, "%d", self );
-       importer( buffer );
-}
-typedef ConstReferenceCaller<int, void(const ImportExportCallback<const char *>::Import_t&), Int_exportString> IntExportStringCaller;
-
-inline void Size_importString( std::size_t& self, const char* string ){
-       int i;
-       if ( string_parse_int( string, i ) && i >= 0 ) {
-               self = i;
-       }
-       else
-       {
-               self = 0;
+template<>
+struct PropertyImpl<bool, const char *> {
+       static void Export(const bool &self, const Callback<void(const char *)> &returnz) {
+               returnz(self ? "true" : "false");
        }
-}
-typedef ReferenceCaller<std::size_t, void(const char*), Size_importString> SizeImportStringCaller;
-inline void Size_exportString( const std::size_t& self, const ImportExportCallback<const char *>::Import_t& importer ){
-       char buffer[16];
-       sprintf( buffer, "%u", Unsigned( self ) );
-       importer( buffer );
-}
-typedef ConstReferenceCaller<std::size_t, void(const ImportExportCallback<const char *>::Import_t&), Size_exportString> SizeExportStringCaller;
 
-inline void Float_importString( float& self, const char* string ){
-       if ( !string_parse_float( string, self ) ) {
-               self = 0;
-       }
-}
-typedef ReferenceCaller<float, void(const char*), Float_importString> FloatImportStringCaller;
-inline void Float_exportString( const float& self, const ImportExportCallback<const char *>::Import_t& importer ){
-       char buffer[16];
-       sprintf( buffer, "%g", self );
-       importer( buffer );
-}
-typedef ConstReferenceCaller<float, void(const ImportExportCallback<const char *>::Import_t&), Float_exportString> FloatExportStringCaller;
+    static void Import(bool &self, const char *value) {
+        self = string_equal(value, "true");
+    }
+};
 
-inline void Vector3_importString( Vector3& self, const char* string ){
-       if ( !string_parse_vector3( string, self ) ) {
-               self = Vector3( 0, 0, 0 );
+template<>
+struct PropertyImpl<int, const char *> {
+       static void Export(const int &self, const Callback<void(const char *)> &returnz) {
+               char buffer[16];
+               sprintf(buffer, "%d", self);
+               returnz(buffer);
        }
-}
-typedef ReferenceCaller<Vector3, void(const char*), Vector3_importString> Vector3ImportStringCaller;
-inline void Vector3_exportString( const Vector3& self, const ImportExportCallback<const char *>::Import_t& importer ){
-       char buffer[64];
-       sprintf( buffer, "%g %g %g", self[0], self[1], self[2] );
-       importer( buffer );
-}
-typedef ConstReferenceCaller<Vector3, void(const ImportExportCallback<const char *>::Import_t&), Vector3_exportString> Vector3ExportStringCaller;
-
 
-
-template<typename FirstArgument, typename Caller, typename FirstConversion>
-class ImportConvert1
-{
-public:
-static void thunk( void* environment, FirstArgument firstArgument ){
-       Caller::thunk( environment, FirstConversion( firstArgument ) );
-}
+    static void Import(int &self, const char *value) {
+        if (!string_parse_int(value, self)) {
+            self = 0;
+        }
+    }
 };
 
+template<>
+struct PropertyImpl<std::size_t, const char *> {
+       static void Export(const std::size_t &self, const Callback<void(const char *)> &returnz) {
+               char buffer[16];
+               sprintf(buffer, "%u", Unsigned(self));
+               returnz(buffer);
+       }
 
-class BoolFromString
-{
-bool m_value;
-public:
-BoolFromString( const char* string ){
-       Bool_importString( m_value, string );
-}
-operator bool() const
-{
-       return m_value;
-}
+    static void Import(std::size_t &self, const char *value) {
+        int i;
+        if (string_parse_int(value, i) && i >= 0) {
+            self = i;
+        } else {
+            self = 0;
+        }
+    }
 };
 
-inline void Bool_toString( const ImportExportCallback<const char *>::Import_t& self, bool value ){
-       Bool_exportString( value, self );
-}
-typedef ConstReferenceCaller<ImportExportCallback<const char *>::Import_t, void(bool), Bool_toString> BoolToString;
-
-
-template<typename Caller>
-inline ImportExportCallback<const char *>::Import_t makeBoolStringImportCallback( const Caller& caller ){
-       return ImportExportCallback<const char *>::Import_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Import_t, 0>, Caller, BoolFromString>::thunk );
-}
-
-template<typename Caller>
-inline ImportExportCallback<const char *>::Export_t makeBoolStringExportCallback( const Caller& caller ){
-       return ImportExportCallback<const char *>::Export_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Export_t, 0>, Caller, BoolToString>::thunk );
-}
-
+template<>
+struct PropertyImpl<float, const char *> {
+       static void Export(const float &self, const Callback<void(const char *)> &returnz) {
+               char buffer[16];
+               sprintf(buffer, "%g", self);
+               returnz(buffer);
+       }
 
-class IntFromString
-{
-int m_value;
-public:
-IntFromString( const char* string ){
-       Int_importString( m_value, string );
-}
-operator int() const
-{
-       return m_value;
-}
+    static void Import(float &self, const char *value) {
+        if (!string_parse_float(value, self)) {
+            self = 0;
+        }
+    }
 };
 
-inline void Int_toString( const ImportExportCallback<const char *>::Import_t& self, int value ){
-       Int_exportString( value, self );
-}
-typedef ConstReferenceCaller<ImportExportCallback<const char *>::Import_t, void(int), Int_toString> IntToString;
-
-
-template<typename Caller>
-inline ImportExportCallback<const char *>::Import_t makeIntStringImportCallback( const Caller& caller ){
-       return ImportExportCallback<const char *>::Import_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Import_t, 0>, Caller, IntFromString>::thunk );
-}
-
-template<typename Caller>
-inline ImportExportCallback<const char *>::Export_t makeIntStringExportCallback( const Caller& caller ){
-       return ImportExportCallback<const char *>::Export_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Export_t, 0>, Caller, IntToString>::thunk );
-}
-
-
+template<>
+struct PropertyImpl<Vector3, const char *> {
+       static void Export(const Vector3 &self, const Callback<void(const char *)> &returnz) {
+               char buffer[64];
+               sprintf(buffer, "%g %g %g", self[0], self[1], self[2]);
+               returnz(buffer);
+       }
 
-class SizeFromString
-{
-std::size_t m_value;
-public:
-SizeFromString( const char* string ){
-       Size_importString( m_value, string );
-}
-operator std::size_t() const
-{
-       return m_value;
-}
+    static void Import(Vector3 &self, const char *value) {
+        if (!string_parse_vector3(value, self)) {
+            self = Vector3(0, 0, 0);
+        }
+    }
 };
 
-inline void Size_toString( const ImportExportCallback<const char *>::Import_t& self, std::size_t value ){
-       Size_exportString( value, self );
-}
-typedef ConstReferenceCaller<ImportExportCallback<const char *>::Import_t, void(std::size_t), Size_toString> SizeToString;
-
-
-template<typename Caller>
-inline ImportExportCallback<const char *>::Import_t makeSizeStringImportCallback( const Caller& caller ){
-       return ImportExportCallback<const char *>::Import_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Import_t, 0>, Caller, SizeFromString>::thunk );
-}
-
-template<typename Caller>
-inline ImportExportCallback<const char *>::Export_t makeSizeStringExportCallback( const Caller& caller ){
-       return ImportExportCallback<const char *>::Export_t( caller.getEnvironment(), ImportConvert1<get_argument<ImportExportCallback<const char *>::Export_t, 0>, Caller, SizeToString>::thunk );
-}
-
 #endif
index 1f286e05512481bf4abeba7ddbc073de58072bf9..dfd2a6408c4aa878cf062e357976b9aa8bd71fda 100644 (file)
@@ -229,7 +229,7 @@ void connectEntities( const scene::Path& path, const scene::Path& targetPath, in
 void setLightRadii( bool lightRadii ){
        g_lightRadii = lightRadii;
 }
-bool getLightRadii(){
+bool getLightRadii() const {
        return g_lightRadii;
 }
 void setShowNames( bool showNames ){
@@ -330,10 +330,10 @@ void Entity_Construct( EGameType gameType ){
                Static<KeyIsName>::instance().m_nameKey = "targetname";
        }
 
-       GlobalPreferenceSystem().registerPreference( "SI_ShowNames", BoolImportStringCaller( g_showNames ), BoolExportStringCaller( g_showNames ) );
-       GlobalPreferenceSystem().registerPreference( "SI_ShowAngles", BoolImportStringCaller( g_showAngles ), BoolExportStringCaller( g_showAngles ) );
-       GlobalPreferenceSystem().registerPreference( "NewLightStyle", BoolImportStringCaller( g_newLightDraw ), BoolExportStringCaller( g_newLightDraw ) );
-       GlobalPreferenceSystem().registerPreference( "LightRadiuses", BoolImportStringCaller( g_lightRadii ), BoolExportStringCaller( g_lightRadii ) );
+       GlobalPreferenceSystem().registerPreference( "SI_ShowNames", make_property_string( g_showNames ) );
+       GlobalPreferenceSystem().registerPreference( "SI_ShowAngles", make_property_string( g_showAngles ) );
+       GlobalPreferenceSystem().registerPreference( "NewLightStyle", make_property_string( g_newLightDraw ) );
+       GlobalPreferenceSystem().registerPreference( "LightRadiuses", make_property_string( g_lightRadii ) );
 
        Entity_InitFilters();
        LightType lightType = LIGHTTYPE_DEFAULT;
index effb111e0c173d54562b65ad554ed303106ca339..c3eaf7660bc347f5aa587adb6735413d89a7c0a3 100644 (file)
@@ -194,9 +194,9 @@ void Autosave_registerPreferencesPage(){
 #include "stringio.h"
 
 void Autosave_Construct(){
-       GlobalPreferenceSystem().registerPreference( "Autosave", BoolImportStringCaller( g_AutoSave_Enabled ), BoolExportStringCaller( g_AutoSave_Enabled ) );
-       GlobalPreferenceSystem().registerPreference( "AutosaveMinutes", IntImportStringCaller( m_AutoSave_Frequency ), IntExportStringCaller( m_AutoSave_Frequency ) );
-       GlobalPreferenceSystem().registerPreference( "Snapshots", BoolImportStringCaller( g_SnapShots_Enabled ), BoolExportStringCaller( g_SnapShots_Enabled ) );
+       GlobalPreferenceSystem().registerPreference( "Autosave", make_property_string( g_AutoSave_Enabled ) );
+       GlobalPreferenceSystem().registerPreference( "AutosaveMinutes", make_property_string( m_AutoSave_Frequency ) );
+       GlobalPreferenceSystem().registerPreference( "Snapshots", make_property_string( g_SnapShots_Enabled ) );
 
        Autosave_registerPreferencesPage();
 }
index 0e190e6c9c8f83db72e1258b6ec8d51b962ffe92..abee96d0eaa56b9bd949d0bcb1dcca93596e385c 100644 (file)
@@ -1202,7 +1202,7 @@ void FlipClipper(){
 
 
 Callback<void()> g_texture_lock_status_changed;
-BoolExportCaller g_texdef_movelock_caller( g_brush_texturelock_enabled );
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_texdef_movelock_caller( g_brush_texturelock_enabled );
 ToggleItem g_texdef_movelock_item( g_texdef_movelock_caller );
 
 void Texdef_ToggleMoveLock(){
index fb67b498cbf3e56e53ef7d1da023824d7de23e14..2ab573e514601c7d8b451eca7a8caa448b1e1ae3 100644 (file)
@@ -42,19 +42,20 @@ bool getTextureLockEnabled(){
        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 ImportExportCallback<bool>::Import_t& 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",
@@ -63,7 +64,7 @@ void Brush_constructPreferences( PreferencesPage& page ){
        if ( g_showAlternativeTextureProjectionOption ) {
                page.appendCheckBox(
                        "", "Use alternative texture-projection (\"brush primitives\")",
-                       mkImportExportCallback(g_useAlternativeTextureProjection)
+                       make_property(g_useAlternativeTextureProjection)
                        );
        }
        // d1223m
@@ -110,8 +111,7 @@ 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();
 
@@ -122,8 +122,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();
@@ -151,9 +151,9 @@ void Brush_Construct( EBrushType type ){
                }
        }
 
-       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 ImportExportCallback<bool>::Import_t&), 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);
index a1eab6c36a392a395b814816bc45c7eaa002c087..47d8fff41a60987a8637e6d8fa1bf5314b36aa01 100644 (file)
@@ -1026,7 +1026,7 @@ void SaveBuildMenu(){
 #include "stringio.h"
 
 void BuildMenu_Construct(){
-       GlobalPreferenceSystem().registerPreference( "BuildMenu", CopiedStringImportStringCaller( g_buildMenu ), CopiedStringExportStringCaller( g_buildMenu ) );
+       GlobalPreferenceSystem().registerPreference( "BuildMenu", make_property_string( g_buildMenu ) );
        LoadBuildMenu();
 }
 void BuildMenu_Destroy(){
index 11ea6b230b5f1a52116dee21bc998e0a5b7be47d..04110ee7ab11f13fca10b49e36c77857ee31fe50 100644 (file)
@@ -1039,36 +1039,35 @@ void CamWnd_Move_Discrete_Disable( CamWnd& camwnd ){
        command_disconnect_accelerator( "CameraAngleDown" );
 }
 
-void CamWnd_Move_Discrete_Import( CamWnd& camwnd, bool value ){
-       if ( g_camwindow_globals_private.m_bCamDiscrete ) {
-               CamWnd_Move_Discrete_Disable( camwnd );
+struct CamWnd_Move_Discrete {
+       static void Export(const Callback<void(bool)> &returnz) {
+               returnz(g_camwindow_globals_private.m_bCamDiscrete);
        }
-       else
-       {
-               CamWnd_Move_Disable( camwnd );
-       }
-
-       g_camwindow_globals_private.m_bCamDiscrete = value;
 
-       if ( g_camwindow_globals_private.m_bCamDiscrete ) {
-               CamWnd_Move_Discrete_Enable( camwnd );
-       }
-       else
-       {
-               CamWnd_Move_Enable( camwnd );
+       static void Import(bool value) {
+               if (g_camwnd) {
+                       Import_(*g_camwnd, value);
+               } else {
+                       g_camwindow_globals_private.m_bCamDiscrete = value;
+               }
        }
-}
 
-void CamWnd_Move_Discrete_Import( bool value ){
-       if ( g_camwnd != 0 ) {
-               CamWnd_Move_Discrete_Import( *g_camwnd, value );
-       }
-       else
-       {
+       static void Import_(CamWnd &camwnd, bool value) {
+               if (g_camwindow_globals_private.m_bCamDiscrete) {
+                       CamWnd_Move_Discrete_Disable(camwnd);
+               } else {
+                       CamWnd_Move_Disable(camwnd);
+               }
+
                g_camwindow_globals_private.m_bCamDiscrete = value;
-       }
-}
 
+               if (g_camwindow_globals_private.m_bCamDiscrete) {
+                       CamWnd_Move_Discrete_Enable(camwnd);
+               } else {
+                       CamWnd_Move_Enable(camwnd);
+               }
+       }
+};
 
 
 void CamWnd_Add_Handlers_Move( CamWnd& camwnd ){
@@ -1392,12 +1391,12 @@ void ShowStatsToggle(){
        g_camwindow_globals_private.m_showStats ^= 1;
 }
 
-void ShowStatsExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowStatsExport( const Callback<void(bool)> &importer ){
        importer( g_camwindow_globals_private.m_showStats );
 }
 
-FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowStatsExport> g_show_stats_caller;
-ImportExportCallback<bool>::Export_t g_show_stats_callback( g_show_stats_caller );
+FreeCaller<void(const Callback<void(bool)>&), ShowStatsExport> g_show_stats_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_stats_callback( g_show_stats_caller );
 ToggleItem g_show_stats( g_show_stats_callback );
 
 void CamWnd::Cam_Draw(){
@@ -1640,7 +1639,7 @@ bool Camera_GetFarClip(){
        return g_camwindow_globals_private.m_bCubicClipping;
 }
 
-BoolExportCaller g_getfarclip_caller( g_camwindow_globals_private.m_bCubicClipping );
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_getfarclip_caller( g_camwindow_globals_private.m_bCubicClipping );
 ToggleItem g_getfarclip_item( g_getfarclip_caller );
 
 void Camera_SetFarClip( bool value ){
@@ -1651,6 +1650,16 @@ void Camera_SetFarClip( bool value ){
        CamWnd_Update( camwnd );
 }
 
+struct Camera_FarClip {
+       static void Export(const Callback<void(bool)> &returnz) {
+               returnz(g_camwindow_globals_private.m_bCubicClipping);
+       }
+
+       static void Import(bool value) {
+               Camera_SetFarClip(value);
+       }
+};
+
 void Camera_ToggleFarClip(){
        Camera_SetFarClip( !Camera_GetFarClip() );
 }
@@ -1745,46 +1754,43 @@ void GlobalCamera_LookThroughCamera(){
        CamWnd_LookThroughCamera( *g_camwnd );
 }
 
-
-void RenderModeImport( int value ){
-       switch ( value )
-       {
-       case 0:
-               CamWnd_SetMode( cd_wire );
-               break;
-       case 1:
-               CamWnd_SetMode( cd_solid );
-               break;
-       case 2:
-               CamWnd_SetMode( cd_texture );
-               break;
-       case 3:
-               CamWnd_SetMode( cd_lighting );
-               break;
-       default:
-               CamWnd_SetMode( cd_texture );
+struct RenderMode {
+       static void Export(const Callback<void(int)> &returnz) {
+               switch (CamWnd_GetMode()) {
+                       case cd_wire:
+                               returnz(0);
+                               break;
+                       case cd_solid:
+                               returnz(1);
+                               break;
+                       case cd_texture:
+                               returnz(2);
+                               break;
+                       case cd_lighting:
+                               returnz(3);
+                               break;
+               }
        }
-}
-typedef FreeCaller<void(int), RenderModeImport> RenderModeImportCaller;
 
-void RenderModeExport( const ImportExportCallback<int>::Import_t& importer ){
-       switch ( CamWnd_GetMode() )
-       {
-       case cd_wire:
-               importer( 0 );
-               break;
-       case cd_solid:
-               importer( 1 );
-               break;
-       case cd_texture:
-               importer( 2 );
-               break;
-       case cd_lighting:
-               importer( 3 );
-               break;
+       static void Import(int value) {
+               switch (value) {
+                       case 0:
+                               CamWnd_SetMode(cd_wire);
+                               break;
+                       case 1:
+                               CamWnd_SetMode(cd_solid);
+                               break;
+                       case 2:
+                               CamWnd_SetMode(cd_texture);
+                               break;
+                       case 3:
+                               CamWnd_SetMode(cd_lighting);
+                               break;
+                       default:
+                               CamWnd_SetMode(cd_texture);
+               }
        }
-}
-typedef FreeCaller<void(const ImportExportCallback<int>::Import_t&), RenderModeExport> RenderModeExportCaller;
+};
 
 void Camera_constructPreferences( PreferencesPage& page ){
        page.appendSlider( "Movement Speed", g_camwindow_globals_private.m_nMoveSpeed, TRUE, 0, 0, 100, MIN_CAM_SPEED, MAX_CAM_SPEED, 1, 10 );
@@ -1793,13 +1799,11 @@ void Camera_constructPreferences( PreferencesPage& page ){
        page.appendCheckBox( "", "Invert mouse vertical axis", g_camwindow_globals_private.m_bCamInverseMouse );
        page.appendCheckBox(
                "", "Discrete movement",
-               {FreeCaller<void(bool), CamWnd_Move_Discrete_Import>(),
-               BoolExportCaller( g_camwindow_globals_private.m_bCamDiscrete )}
+               make_property<CamWnd_Move_Discrete>()
                );
        page.appendCheckBox(
                "", "Enable far-clip plane",
-               {FreeCaller<void(bool), Camera_SetFarClip>(),
-               BoolExportCaller( g_camwindow_globals_private.m_bCubicClipping )}
+               make_property<Camera_FarClip>()
                );
 
        if ( g_pGameDescription->mGameType == "doom3" ) {
@@ -1808,8 +1812,7 @@ void Camera_constructPreferences( PreferencesPage& page ){
                page.appendCombo(
                        "Render Mode",
                        STRING_ARRAY_RANGE( render_mode ),
-                       {ImportExportCallback<int>::Import_t( RenderModeImportCaller() ),
-                       ImportExportCallback<int>::Export_t( RenderModeExportCaller() )}
+                       make_property<RenderMode>()
                        );
        }
        else
@@ -1819,8 +1822,7 @@ void Camera_constructPreferences( PreferencesPage& page ){
                page.appendCombo(
                        "Render Mode",
                        STRING_ARRAY_RANGE( render_mode ),
-                       {ImportExportCallback<int>::Import_t( RenderModeImportCaller() ),
-                       ImportExportCallback<int>::Export_t( RenderModeExportCaller() )}
+                       make_property<RenderMode>()
                        );
        }
 
@@ -1844,8 +1846,6 @@ void Camera_registerPreferencesPage(){
 #include "stringio.h"
 #include "dialog.h"
 
-typedef FreeCaller<void(bool), CamWnd_Move_Discrete_Import> CamWndMoveDiscreteImportCaller;
-
 void CameraSpeed_increase(){
        if ( g_camwindow_globals_private.m_nMoveSpeed <= ( MAX_CAM_SPEED - CAM_SPEED_STEP - 10 ) ) {
                g_camwindow_globals_private.m_nMoveSpeed += CAM_SPEED_STEP;
@@ -1905,18 +1905,18 @@ void CamWnd_Construct(){
 
        GlobalToggles_insert( "ShowStats", makeCallbackF(ShowStatsToggle), ToggleItem::AddCallbackCaller( g_show_stats ) );
 
-       GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) );
-       GlobalPreferenceSystem().registerPreference( "MoveSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ) );
-       GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", BoolImportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ) );
-       GlobalPreferenceSystem().registerPreference( "AngleSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ) );
-       GlobalPreferenceSystem().registerPreference( "CamInverseMouse", BoolImportStringCaller( g_camwindow_globals_private.m_bCamInverseMouse ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamInverseMouse ) );
-       GlobalPreferenceSystem().registerPreference( "CamDiscrete", makeBoolStringImportCallback( CamWndMoveDiscreteImportCaller() ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamDiscrete ) );
-       GlobalPreferenceSystem().registerPreference( "CubicClipping", BoolImportStringCaller( g_camwindow_globals_private.m_bCubicClipping ), BoolExportStringCaller( g_camwindow_globals_private.m_bCubicClipping ) );
-       GlobalPreferenceSystem().registerPreference( "CubicScale", IntImportStringCaller( g_camwindow_globals.m_nCubicScale ), IntExportStringCaller( g_camwindow_globals.m_nCubicScale ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors4", Vector3ImportStringCaller( g_camwindow_globals.color_cameraback ), Vector3ExportStringCaller( g_camwindow_globals.color_cameraback ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors12", Vector3ImportStringCaller( g_camwindow_globals.color_selbrushes3d ), Vector3ExportStringCaller( g_camwindow_globals.color_selbrushes3d ) );
-       GlobalPreferenceSystem().registerPreference( "CameraRenderMode", makeIntStringImportCallback( RenderModeImportCaller() ), makeIntStringExportCallback( RenderModeExportCaller() ) );
-       GlobalPreferenceSystem().registerPreference( "StrafeMode", IntImportStringCaller( g_camwindow_globals_private.m_nStrafeMode ), IntExportStringCaller( g_camwindow_globals_private.m_nStrafeMode ) );
+       GlobalPreferenceSystem().registerPreference( "ShowStats", make_property_string( g_camwindow_globals_private.m_showStats ) );
+       GlobalPreferenceSystem().registerPreference( "MoveSpeed", make_property_string( g_camwindow_globals_private.m_nMoveSpeed ) );
+       GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", make_property_string( g_camwindow_globals_private.m_bCamLinkSpeed ) );
+       GlobalPreferenceSystem().registerPreference( "AngleSpeed", make_property_string( g_camwindow_globals_private.m_nAngleSpeed ) );
+       GlobalPreferenceSystem().registerPreference( "CamInverseMouse", make_property_string( g_camwindow_globals_private.m_bCamInverseMouse ) );
+       GlobalPreferenceSystem().registerPreference( "CamDiscrete", make_property_string<CamWnd_Move_Discrete>());
+       GlobalPreferenceSystem().registerPreference( "CubicClipping", make_property_string( g_camwindow_globals_private.m_bCubicClipping ) );
+       GlobalPreferenceSystem().registerPreference( "CubicScale", make_property_string( g_camwindow_globals.m_nCubicScale ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors4", make_property_string( g_camwindow_globals.color_cameraback ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors12", make_property_string( g_camwindow_globals.color_selbrushes3d ) );
+       GlobalPreferenceSystem().registerPreference( "CameraRenderMode", make_property_string<RenderMode>() );
+       GlobalPreferenceSystem().registerPreference( "StrafeMode", make_property_string( g_camwindow_globals_private.m_nStrafeMode ) );
 
        CamWnd_constructStatic();
 
index 299958dc00ddb93713cf68802f4d5419c0f07c75..93823894f3c480f7c917eb89511122c6c58d2b07 100644 (file)
@@ -87,7 +87,7 @@ typedef std::map<CopiedString, Toggle> Toggles;
 
 Toggles g_toggles;
 
-void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const ImportExportCallback<bool>::Export_t& exportCallback, const Accelerator& accelerator ){
+void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const Callback<void(const Callback<void(bool)> &)>& exportCallback, const Accelerator& accelerator ){
        bool added = g_toggles.insert( Toggles::value_type( name, Toggle( callback, GlobalShortcuts_insert( name, accelerator ), exportCallback ) ) ).second;
        ASSERT_MESSAGE( added, "toggle already registered: " << makeQuoted( name ) );
 }
index 53f61ad1901954cd0c6a712420529f94e93e2ed7..8c6b9f19063e1a9d272e34c80c654214f1bdb4ae 100644 (file)
@@ -38,7 +38,7 @@ virtual void visit( const char* name, Accelerator& accelerator ) = 0;
 void GlobalCommands_insert( const char* name, const Callback<void()>& callback, const Accelerator& accelerator = accelerator_null() );
 const Command& GlobalCommands_find( const char* name );
 
-void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const ImportExportCallback<bool>::Export_t& exportCallback, const Accelerator& accelerator = accelerator_null() );
+void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const Callback<void(const Callback<void(bool)> &)>& exportCallback, const Accelerator& accelerator = accelerator_null() );
 const Toggle& GlobalToggles_find( const char* name );
 
 void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback<void()>& keyDown, const Callback<void()>& keyUp );
index 9de0a3332df2c4be780ac03e3a3f7b97705c59b4..ff215079610f2fbf31b2d3aadcffba36e737a405 100644 (file)
@@ -107,164 +107,141 @@ DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lo
 }
 
 
-template<
-               typename Type_,
-               typename Other_ = Type_,
-               class T = impexp<Type_, Other_>
->
-class ImportExport {
-public:
-       using Type = Type_;
-       using Other = Other_;
-
-       using ImportCaller = ReferenceCaller<Type, void(Other), T::Import>;
-       using ExportCaller = ReferenceCaller<Type, void(const Callback<void(Other)> &), T::Export>;
-};
-
-
-using BoolImportExport = ImportExport<bool>;
-
 struct BoolToggle {
-       static void Import(GtkToggleButton &widget, bool value) {
-               gtk_toggle_button_set_active(&widget, value);
+       static void Export(const GtkToggleButton &self, const Callback<void(bool)> &returnz) {
+               returnz(gtk_toggle_button_get_active(const_cast<GtkToggleButton *>(&self)) != FALSE);
        }
 
-       static void Export(GtkToggleButton &widget, const ImportExportCallback<bool>::Import_t &importCallback) {
-               importCallback(gtk_toggle_button_get_active(&widget) != FALSE);
+       static void Import(GtkToggleButton &self, bool value) {
+               gtk_toggle_button_set_active(&self, value);
        }
 };
 
-using BoolToggleImportExport = ImportExport<GtkToggleButton, bool, BoolToggle>;
-
-using IntImportExport = ImportExport<int>;
+using BoolToggleImportExport = PropertyAdaptor<GtkToggleButton, bool, BoolToggle>;
 
 struct IntEntry {
-       static void Import(GtkEntry &widget, int value) {
-               entry_set_int(ui::Entry(&widget), value);
+       static void Export(const GtkEntry &self, const Callback<void(int)> &returnz) {
+               returnz(atoi(gtk_entry_get_text(const_cast<GtkEntry *>(&self))));
        }
 
-       static void Export(GtkEntry &widget, const ImportExportCallback<int>::Import_t &importCallback) {
-               importCallback(atoi(gtk_entry_get_text(&widget)));
+       static void Import(GtkEntry &self, int value) {
+               entry_set_int(ui::Entry(&self), value);
        }
 };
 
-using IntEntryImportExport = ImportExport<GtkEntry, int, IntEntry>;
+using IntEntryImportExport = PropertyAdaptor<GtkEntry, int, IntEntry>;
 
 struct IntRadio {
-       static void Import(GtkRadioButton &widget, int index) {
-               radio_button_set_active(ui::RadioButton(&widget), index);
+       static void Export(const GtkRadioButton &self, const Callback<void(int)> &returnz) {
+               returnz(radio_button_get_active(ui::RadioButton(const_cast<GtkRadioButton *>(&self))));
        }
 
-       static void Export(GtkRadioButton &widget, const ImportExportCallback<int>::Import_t &importCallback) {
-               importCallback(radio_button_get_active(ui::RadioButton(&widget)));
+       static void Import(GtkRadioButton &self, int value) {
+               radio_button_set_active(ui::RadioButton(&self), value);
        }
 };
 
-using IntRadioImportExport = ImportExport<GtkRadioButton, int, IntRadio>;
+using IntRadioImportExport = PropertyAdaptor<GtkRadioButton, int, IntRadio>;
 
 struct IntCombo {
-       static void Import(GtkComboBox &widget, int value) {
-               gtk_combo_box_set_active(&widget, value);
+       static void Export(const GtkComboBox &self, const Callback<void(int)> &returnz) {
+               returnz(gtk_combo_box_get_active(const_cast<GtkComboBox *>(&self)));
        }
 
-       static void Export(GtkComboBox &widget, const ImportExportCallback<int>::Import_t &importCallback) {
-               importCallback(gtk_combo_box_get_active(&widget));
+       static void Import(GtkComboBox &self, int value) {
+               gtk_combo_box_set_active(&self, value);
        }
 };
 
-using IntComboImportExport = ImportExport<GtkComboBox, int, IntCombo>;
+using IntComboImportExport = PropertyAdaptor<GtkComboBox, int, IntCombo>;
 
 struct IntAdjustment {
-       static void Import(GtkAdjustment &widget, int value) {
-               gtk_adjustment_set_value(&widget, value);
+       static void Export(const GtkAdjustment &self, const Callback<void(int)> &returnz) {
+               returnz((int) gtk_adjustment_get_value(const_cast<GtkAdjustment *>(&self)));
        }
 
-       static void Export(GtkAdjustment &widget, const ImportExportCallback<int>::Import_t &importCallback) {
-               importCallback((int) gtk_adjustment_get_value(&widget));
+       static void Import(GtkAdjustment &self, int value) {
+               gtk_adjustment_set_value(&self, value);
        }
 };
 
-using IntAdjustmentImportExport = ImportExport<GtkAdjustment, int, IntAdjustment>;
+using IntAdjustmentImportExport = PropertyAdaptor<GtkAdjustment, int, IntAdjustment>;
 
 struct IntSpinner {
-       static void Import(GtkSpinButton &widget, int value) {
-               gtk_spin_button_set_value(&widget, value);
+       static void Export(const GtkSpinButton &self, const Callback<void(int)> &returnz) {
+               returnz(gtk_spin_button_get_value_as_int(const_cast<GtkSpinButton *>(&self)));
        }
 
-       static void Export(GtkSpinButton &widget, const ImportExportCallback<int>::Import_t &importCallback) {
-               importCallback(gtk_spin_button_get_value_as_int(&widget));
+       static void Import(GtkSpinButton &self, int value) {
+               gtk_spin_button_set_value(&self, value);
        }
 };
 
-using IntSpinnerImportExport = ImportExport<GtkSpinButton, int, IntSpinner>;
+using IntSpinnerImportExport = PropertyAdaptor<GtkSpinButton, int, IntSpinner>;
 
-using StringImportExport = ImportExport<CopiedString, const char *>;
+using StringImportExport = PropertyAdaptor<CopiedString, const char *>;
 
 struct TextEntry {
-       static void Import(GtkEntry &widget, const char *text) {
-               ui::Entry(&widget).text(text);
+       static void Export(const GtkEntry &self, const Callback<void(const char *)> &returnz) {
+               returnz(gtk_entry_get_text(const_cast<GtkEntry *>(&self)));
        }
 
-       static void Export(GtkEntry &widget, const ImportExportCallback<const char *>::Import_t &importCallback) {
-               importCallback(gtk_entry_get_text(&widget));
+       static void Import(GtkEntry &self, const char *value) {
+               ui::Entry(&self).text(value);
        }
 };
 
-using TextEntryImportExport = ImportExport<GtkEntry, const char *, TextEntry>;
-
-using SizeImportExport = ImportExport<std::size_t>;
+using TextEntryImportExport = PropertyAdaptor<GtkEntry, const char *, TextEntry>;
 
 struct SizeEntry {
-       static void Import(GtkEntry &widget, std::size_t value) {
-               entry_set_int(ui::Entry(&widget), int(value));
-       }
-
-       static void Export(GtkEntry &widget, const ImportExportCallback<std::size_t>::Import_t &importCallback) {
-               int value = atoi(gtk_entry_get_text(&widget));
+       static void Export(const GtkEntry &self, const Callback<void(std::size_t)> &returnz) {
+               int value = atoi(gtk_entry_get_text(const_cast<GtkEntry *>(&self)));
                if (value < 0) {
                        value = 0;
                }
-               importCallback(value);
+               returnz(value);
        }
-};
 
-using SizeEntryImportExport = ImportExport<GtkEntry, std::size_t, SizeEntry>;
+       static void Import(GtkEntry &self, std::size_t value) {
+               entry_set_int(ui::Entry(&self), int(value));
+       }
+};
 
-using FloatImportExport = ImportExport<float>;
+using SizeEntryImportExport = PropertyAdaptor<GtkEntry, std::size_t, SizeEntry>;
 
 struct FloatEntry {
-       static void Import(GtkEntry &widget, float value) {
-               entry_set_float(ui::Entry(&widget), value);
+       static void Export(const GtkEntry &self, const Callback<void(float)> &returnz) {
+               returnz((float) atof(gtk_entry_get_text(const_cast<GtkEntry *>(&self))));
        }
 
-       static void Export(GtkEntry &widget, const ImportExportCallback<float>::Import_t &importCallback) {
-               importCallback((float) atof(gtk_entry_get_text(&widget)));
+       static void Import(GtkEntry &self, float value) {
+               entry_set_float(ui::Entry(&self), value);
        }
 };
 
-using FloatEntryImportExport = ImportExport<GtkEntry, float, FloatEntry>;
+using FloatEntryImportExport = PropertyAdaptor<GtkEntry, float, FloatEntry>;
 
 struct FloatSpinner {
-       static void Import(GtkSpinButton &widget, float value) {
-               gtk_spin_button_set_value(&widget, value);
+       static void Export(const GtkSpinButton &self, const Callback<void(float)> &returnz) {
+               returnz(float(gtk_spin_button_get_value(const_cast<GtkSpinButton *>(&self))));
        }
 
-       static void Export(GtkSpinButton &widget, const ImportExportCallback<float>::Import_t &importCallback) {
-               importCallback(float(gtk_spin_button_get_value(&widget)));
+       static void Import(GtkSpinButton &self, float value) {
+               gtk_spin_button_set_value(&self, value);
        }
 };
 
-using FloatSpinnerImportExport = ImportExport<GtkSpinButton, float, FloatSpinner>;
+using FloatSpinnerImportExport = PropertyAdaptor<GtkSpinButton, float, FloatSpinner>;
 
 
 
 template<typename T>
 class CallbackDialogData : public DLG_DATA {
-       ImportExportCallback<T> m_cbWidget;
-       ImportExportCallback<T> m_cbViewer;
+       Property<T> m_cbWidget;
+       Property<T> m_cbViewer;
 
 public:
-       CallbackDialogData(const ImportExportCallback<T> &cbWidget, const ImportExportCallback<T> &cbViewer)
+       CallbackDialogData(const Property<T> &cbWidget, const Property<T> &cbViewer)
                        : m_cbWidget(cbWidget), m_cbViewer(cbViewer) {
        }
 
@@ -273,11 +250,11 @@ public:
        }
 
        void importData() const {
-               m_cbViewer.Export(m_cbWidget.Import);
+               m_cbViewer.get(m_cbWidget.set);
        }
 
        void exportData() const {
-               m_cbWidget.Export(m_cbViewer.Import);
+               m_cbWidget.get(m_cbViewer.set);
        }
 };
 
@@ -285,10 +262,8 @@ template<typename Widget, typename Viewer>
 void AddData(DialogDataList &data, typename Widget::Type &widget, typename Viewer::Type &viewer) {
        data.push_back(
                        new CallbackDialogData<typename Widget::Other>(
-                                       {typename Widget::ImportCaller(widget),
-                                        typename Widget::ExportCaller(widget)},
-                                       {typename Viewer::ImportCaller(viewer),
-                                        typename Viewer::ExportCaller(viewer)}
+                                       make_property<Widget>(widget),
+                                       make_property<Viewer>(viewer)
                        )
        );
 }
@@ -297,12 +272,11 @@ template<typename Widget>
 void AddCustomData(
                DialogDataList &data,
                typename Widget::Type &widget,
-               ImportExportCallback<typename Widget::Other> const &cbViewer
+               Property<typename Widget::Other> const &cbViewer
 ) {
        data.push_back(
                        new CallbackDialogData<typename Widget::Other>(
-                                       {typename Widget::ImportCaller(widget),
-                                        typename Widget::ExportCaller(widget)},
+                                       make_property<Widget>(widget),
                                        cbViewer
                        )
        );
@@ -356,76 +330,76 @@ void Dialog::Destroy(){
 }
 
 
-void Dialog::AddBoolToggleData( GtkToggleButton& widget, ImportExportCallback<bool> const &cb ){
+void Dialog::AddBoolToggleData( GtkToggleButton& widget, Property<bool> const &cb ){
        AddCustomData<BoolToggleImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddIntRadioData( GtkRadioButton& widget, ImportExportCallback<int> const &cb ){
+void Dialog::AddIntRadioData( GtkRadioButton& widget, Property<int> const &cb ){
        AddCustomData<IntRadioImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddTextEntryData( GtkEntry& widget, ImportExportCallback<const char *> const &cb ){
+void Dialog::AddTextEntryData( GtkEntry& widget, Property<const char *> const &cb ){
        AddCustomData<TextEntryImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddIntEntryData( GtkEntry& widget, ImportExportCallback<int> const &cb ){
+void Dialog::AddIntEntryData( GtkEntry& widget, Property<int> const &cb ){
        AddCustomData<IntEntryImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddSizeEntryData( GtkEntry& widget, ImportExportCallback<std::size_t> const &cb ){
+void Dialog::AddSizeEntryData( GtkEntry& widget, Property<std::size_t> const &cb ){
        AddCustomData<SizeEntryImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddFloatEntryData( GtkEntry& widget, ImportExportCallback<float> const &cb ){
+void Dialog::AddFloatEntryData( GtkEntry& widget, Property<float> const &cb ){
        AddCustomData<FloatEntryImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, ImportExportCallback<float> const &cb ){
+void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, Property<float> const &cb ){
        AddCustomData<FloatSpinnerImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddIntSpinnerData( GtkSpinButton& widget, ImportExportCallback<int> const &cb ){
+void Dialog::AddIntSpinnerData( GtkSpinButton& widget, Property<int> const &cb ){
        AddCustomData<IntSpinnerImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, ImportExportCallback<int> const &cb ){
+void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, Property<int> const &cb ){
        AddCustomData<IntAdjustmentImportExport>( m_data, widget, cb );
 }
 
-void Dialog::AddIntComboData( GtkComboBox& widget, ImportExportCallback<int> const &cb ){
+void Dialog::AddIntComboData( GtkComboBox& widget, Property<int> const &cb ){
        AddCustomData<IntComboImportExport>( m_data, widget, cb );
 }
 
 
 void Dialog::AddDialogData( GtkToggleButton& widget, bool& data ){
-       AddData<BoolToggleImportExport, BoolImportExport>( m_data, widget, data );
+       AddData<BoolToggleImportExport, PropertyAdaptor<bool>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkRadioButton& widget, int& data ){
-       AddData<IntRadioImportExport, IntImportExport>( m_data, widget, data );
+       AddData<IntRadioImportExport, PropertyAdaptor<int>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkEntry& widget, CopiedString& data ){
        AddData<TextEntryImportExport, StringImportExport>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkEntry& widget, int& data ){
-       AddData<IntEntryImportExport, IntImportExport>( m_data, widget, data );
+       AddData<IntEntryImportExport, PropertyAdaptor<int>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkEntry& widget, std::size_t& data ){
-       AddData<SizeEntryImportExport, SizeImportExport>( m_data, widget, data );
+       AddData<SizeEntryImportExport, PropertyAdaptor<std::size_t>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkEntry& widget, float& data ){
-       AddData<FloatEntryImportExport, FloatImportExport>( m_data, widget, data );
+       AddData<FloatEntryImportExport, PropertyAdaptor<float>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkSpinButton& widget, float& data ){
-       AddData<FloatSpinnerImportExport, FloatImportExport>( m_data, widget, data );
+       AddData<FloatSpinnerImportExport, PropertyAdaptor<float>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkSpinButton& widget, int& data ){
-       AddData<IntSpinnerImportExport, IntImportExport>( m_data, widget, data );
+       AddData<IntSpinnerImportExport, PropertyAdaptor<int>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkAdjustment& widget, int& data ){
-       AddData<IntAdjustmentImportExport, IntImportExport>( m_data, widget, data );
+       AddData<IntAdjustmentImportExport, PropertyAdaptor<int>>( m_data, widget, data );
 }
 void Dialog::AddDialogData( GtkComboBox& widget, int& data ){
-       AddData<IntComboImportExport, IntImportExport>( m_data, widget, data );
+       AddData<IntComboImportExport, PropertyAdaptor<int>>( m_data, widget, data );
 }
 
 void Dialog::exportData(){
@@ -466,7 +440,7 @@ EMessageBoxReturn Dialog::DoModal(){
 }
 
 
-ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, ImportExportCallback<bool> const &cb ){
+ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, Property<bool> const &cb ){
        auto check = ui::CheckButton( flag );
        check.show();
        AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), cb );
@@ -476,10 +450,10 @@ ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char
 }
 
 ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data ){
-       return addCheckBox(vbox, name, flag, mkImportExportCallback(data));
+       return addCheckBox(vbox, name, flag, make_property(data));
 }
 
-void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, ImportExportCallback<int> const &cb ){
+void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, Property<int> const &cb ){
        auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
        alignment.show();
        {
@@ -501,7 +475,7 @@ void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values,
 }
 
 void Dialog::addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values ){
-       addCombo(vbox, name, values, mkImportExportCallback(data));
+       addCombo(vbox, name, values, make_property(data));
 }
 
 void Dialog::addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
@@ -525,7 +499,7 @@ void Dialog::addSlider( ui::VBox vbox, const char* name, int& data, gboolean dra
 
        // adjustment
        auto adj = ui::Adjustment( value, lower, upper, step_increment, page_increment, 0 );
-       AddIntAdjustmentData(*GTK_ADJUSTMENT(adj), mkImportExportCallback(data));
+       AddIntAdjustmentData(*GTK_ADJUSTMENT(adj), make_property(data));
 
        // scale
        auto alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 );
@@ -543,7 +517,7 @@ void Dialog::addSlider( ui::VBox vbox, const char* name, int& data, gboolean dra
        DialogVBox_packRow( vbox, row );
 }
 
-void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, ImportExportCallback<int> const &cb ){
+void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, Property<int> const &cb ){
        auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
        alignment.show();;
        {
@@ -557,10 +531,10 @@ void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names,
 }
 
 void Dialog::addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names ){
-       addRadio(vbox, name, names, mkImportExportCallback(data));
+       addRadio(vbox, name, names, make_property(data));
 }
 
-void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, ImportExportCallback<int> const &cb ){
+void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, Property<int> const &cb ){
     auto table = ui::Table(2, icons.last - icons.first, FALSE);
     table.show();
 
@@ -589,31 +563,31 @@ void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange ic
 }
 
 void Dialog::addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons ){
-       addRadioIcons(vbox, name, icons, mkImportExportCallback(data));
+       addRadioIcons(vbox, name, icons, make_property(data));
 }
 
-ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, ImportExportCallback<int> const &cb ){
+ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, Property<int> const &cb ){
        DialogEntryRow row( DialogEntryRow_new( name ) );
        AddIntEntryData( *GTK_ENTRY(row.m_entry), cb );
        DialogVBox_packRow( vbox, row.m_row );
        return row.m_row;
 }
 
-ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, ImportExportCallback<std::size_t> const &cb ){
+ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, Property<std::size_t> const &cb ){
        DialogEntryRow row( DialogEntryRow_new( name ) );
        AddSizeEntryData( *GTK_ENTRY(row.m_entry), cb );
        DialogVBox_packRow( vbox, row.m_row );
        return row.m_row;
 }
 
-ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, ImportExportCallback<float> const &cb ){
+ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, Property<float> const &cb ){
        DialogEntryRow row( DialogEntryRow_new( name ) );
        AddFloatEntryData( *GTK_ENTRY(row.m_entry), cb );
        DialogVBox_packRow( vbox, row.m_row );
        return row.m_row;
 }
 
-ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, ImportExportCallback<const char *> const &cb ){
+ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, Property<const char *> const &cb ){
        PathEntry pathEntry = PathEntry_new();
        pathEntry.m_button.connect( "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry );
 
@@ -626,10 +600,10 @@ ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_di
 }
 
 ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool browse_directory ){
-    return addPathEntry(vbox, name, browse_directory, mkImportExportCallback<CopiedString, const char *>(data));
+    return addPathEntry(vbox, name, browse_directory, make_property<CopiedString, const char *>(data));
 }
 
-ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, ImportExportCallback<int> const &cb ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, Property<int> const &cb ){
        DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
        AddIntSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), cb );
        DialogVBox_packRow( vbox, row.m_row );
@@ -637,10 +611,10 @@ ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value
 }
 
 ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper ){
-       return addSpinner(vbox, name, value, lower, upper, mkImportExportCallback(data));
+       return addSpinner(vbox, name, value, lower, upper, make_property(data));
 }
 
-ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, ImportExportCallback<float> const &cb ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, Property<float> const &cb ){
        DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
        AddFloatSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), cb );
        DialogVBox_packRow( vbox, row.m_row );
index cf2b2362d809ccd483abf66098e3b1864e41d1c5..0147eb2cddffae9df6c5ca32e9c333f7087726e2 100644 (file)
 
 #include <list>
 #include <uilib/uilib.h>
+#include "property.h"
 
 #include "generic/callback.h"
 #include "gtkutil/dialog.h"
 #include "generic/callback.h"
 #include "string/string.h"
 
-template<class Self, class T = Self>
-struct impexp {
-    static void Import(Self &self, T value) {
-        self = value;
-    }
-
-    static void Export(Self &self, const Callback<void(T)> &importCallback) {
-        importCallback(self);
-    }
-};
-
-template<class Self, class T = Self>
-ImportExportCallback<T> mkImportExportCallback(Self &self) {
-    return {
-            ReferenceCaller<Self, void(T), impexp<Self, T>::Import>(self),
-            ReferenceCaller<Self, void(const Callback<void(T)> &), impexp<Self, T>::Export>(self)
-    };
-}
-
-#define BoolImport impexp<bool>::Import
-#define BoolExport impexp<bool>::Export
-
-typedef ReferenceCaller<bool, void(const Callback<void(bool)> &), BoolExport> BoolExportCaller;
-
-#define IntImport impexp<int>::Import
-#define IntExport impexp<int>::Export
-
-typedef ReferenceCaller<int, void(const Callback<void(int)> &), IntExport> IntExportCaller;
-
-#define SizeImport impexp<std::size_t>::Import
-#define SizeExport impexp<std::size_t>::Export
-
-
-#define FloatImport impexp<float>::Import
-#define FloatExport impexp<float>::Export
-
-typedef ReferenceCaller<float, void(const Callback<void(float)> &), FloatExport> FloatExportCaller;
-
-#define StringImport impexp<CopiedString, const char *>::Import
-#define StringExport impexp<CopiedString, const char *>::Export
-
-template<>
-struct impexp<CopiedString, const char *> {
-    static void Import(CopiedString &self, const char *value) {
-        self = value;
-    }
-
-    static void Export(CopiedString &self, const Callback<void(const char *)> &importCallback) {
-        importCallback(self.c_str());
-    }
-};
-
-typedef ReferenceCaller<CopiedString, void(const Callback<void(const char *)> &), StringExport> StringExportCaller;
-
-
 struct DLG_DATA
 {
        virtual ~DLG_DATA() = default;
@@ -132,66 +78,66 @@ const ui::Window GetWidget() const {
        return m_window;
 }
 
-    ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, ImportExportCallback<bool> const &cb);
+    ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, Property<bool> const &cb);
 ui::CheckButton addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data );
 
-    void addCombo(ui::VBox vbox, const char *name, StringArrayRange values, ImportExportCallback<int> const &cb);
+    void addCombo(ui::VBox vbox, const char *name, StringArrayRange values, Property<int> const &cb);
 void addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values );
 void addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment );
 
-    void addRadio(ui::VBox vbox, const char *name, StringArrayRange names, ImportExportCallback<int> const &cb);
+    void addRadio(ui::VBox vbox, const char *name, StringArrayRange names, Property<int> const &cb);
 void addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names );
 
-    void addRadioIcons(ui::VBox vbox, const char *name, StringArrayRange icons, ImportExportCallback<int> const &cb);
+    void addRadioIcons(ui::VBox vbox, const char *name, StringArrayRange icons, Property<int> const &cb);
 void addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons );
 
-    ui::Widget addIntEntry(ui::VBox vbox, const char *name, ImportExportCallback<int> const &cb);
+    ui::Widget addIntEntry(ui::VBox vbox, const char *name, Property<int> const &cb);
 ui::Widget addEntry( ui::VBox vbox, const char* name, int& data ){
-    return addIntEntry(vbox, name, mkImportExportCallback(data));
+    return addIntEntry(vbox, name, make_property(data));
 }
 
-    ui::Widget addSizeEntry(ui::VBox vbox, const char *name, ImportExportCallback<std::size_t> const &cb);
+    ui::Widget addSizeEntry(ui::VBox vbox, const char *name, Property<std::size_t> const &cb);
 ui::Widget addEntry( ui::VBox vbox, const char* name, std::size_t& data ){
-    return addSizeEntry(vbox, name, mkImportExportCallback(data));
+    return addSizeEntry(vbox, name, make_property(data));
 }
 
-    ui::Widget addFloatEntry(ui::VBox vbox, const char *name, ImportExportCallback<float> const &cb);
+    ui::Widget addFloatEntry(ui::VBox vbox, const char *name, Property<float> const &cb);
 ui::Widget addEntry( ui::VBox vbox, const char* name, float& data ){
-    return addFloatEntry(vbox, name, mkImportExportCallback(data));
+    return addFloatEntry(vbox, name, make_property(data));
 }
 
     ui::Widget
-    addPathEntry(ui::VBox vbox, const char *name, bool browse_directory, ImportExportCallback<const char *> const &cb);
+    addPathEntry(ui::VBox vbox, const char *name, bool browse_directory, Property<const char *> const &cb);
 ui::Widget addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool directory );
 ui::SpinButton addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper );
 
     ui::SpinButton
-    addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, ImportExportCallback<int> const &cb);
+    addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, Property<int> const &cb);
 
     ui::SpinButton addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper,
-                              ImportExportCallback<float> const &cb);
+                              Property<float> const &cb);
 
 protected:
 
-    void AddBoolToggleData(struct _GtkToggleButton &object, ImportExportCallback<bool> const &cb);
+    void AddBoolToggleData(struct _GtkToggleButton &object, Property<bool> const &cb);
 
-    void AddIntRadioData(struct _GtkRadioButton &object, ImportExportCallback<int> const &cb);
+    void AddIntRadioData(struct _GtkRadioButton &object, Property<int> const &cb);
 
-    void AddTextEntryData(struct _GtkEntry &object, ImportExportCallback<const char *> const &cb);
+    void AddTextEntryData(struct _GtkEntry &object, Property<const char *> const &cb);
 
-    void AddIntEntryData(struct _GtkEntry &object, ImportExportCallback<int> const &cb);
+    void AddIntEntryData(struct _GtkEntry &object, Property<int> const &cb);
 
-    void AddSizeEntryData(struct _GtkEntry &object, ImportExportCallback<std::size_t> const &cb);
+    void AddSizeEntryData(struct _GtkEntry &object, Property<std::size_t> const &cb);
 
-    void AddFloatEntryData(struct _GtkEntry &object, ImportExportCallback<float> const &cb);
+    void AddFloatEntryData(struct _GtkEntry &object, Property<float> const &cb);
 
-    void AddFloatSpinnerData(struct _GtkSpinButton &object, ImportExportCallback<float> const &cb);
+    void AddFloatSpinnerData(struct _GtkSpinButton &object, Property<float> const &cb);
 
-    void AddIntSpinnerData(struct _GtkSpinButton &object, ImportExportCallback<int> const &cb);
+    void AddIntSpinnerData(struct _GtkSpinButton &object, Property<int> const &cb);
 
-    void AddIntAdjustmentData(struct _GtkAdjustment &object, ImportExportCallback<int> const &cb);
+    void AddIntAdjustmentData(struct _GtkAdjustment &object, Property<int> const &cb);
 
-    void AddIntComboData(struct _GtkComboBox &object, ImportExportCallback<int> const &cb);
+    void AddIntComboData(struct _GtkComboBox &object, Property<int> const &cb);
 
 void AddDialogData( struct _GtkToggleButton& object, bool& data );
 void AddDialogData( struct _GtkRadioButton& object, int& data );
index 1c02828e728aef0fda60f8fffa5f6e6f0ade3126..2952684df04ee93645c1fafdb4da6d8261f5f7c9 100644 (file)
@@ -542,22 +542,21 @@ const char* misc_model_dialog( ui::Widget parent ){
        return 0;
 }
 
-void LightRadiiImport( EntityCreator& self, bool value ){
-       self.setLightRadii( value );
-}
-typedef ReferenceCaller<EntityCreator, void(bool), LightRadiiImport> LightRadiiImportCaller;
+struct LightRadii {
+       static void Export(const EntityCreator &self, const Callback<void(bool)> &returnz) {
+               returnz(self.getLightRadii());
+       }
 
-void LightRadiiExport( EntityCreator& self, const ImportExportCallback<bool>::Import_t& importer ){
-       importer( self.getLightRadii() );
-}
-typedef ReferenceCaller<EntityCreator, void(const ImportExportCallback<bool>::Import_t&), LightRadiiExport> LightRadiiExportCaller;
+       static void Import(EntityCreator &self, bool value) {
+               self.setLightRadii(value);
+       }
+};
 
 void Entity_constructPreferences( PreferencesPage& page ){
        page.appendCheckBox(
-               "Show", "Light Radii",
-               {LightRadiiImportCaller( GlobalEntityCreator() ),
-               LightRadiiExportCaller( GlobalEntityCreator() )}
-               );
+                       "Show", "Light Radii",
+                       make_property<LightRadii>(GlobalEntityCreator())
+       );
 }
 void Entity_constructPage( PreferenceGroup& group ){
        PreferencesPage page( group.createPage( "Entities", "Entity Display Preferences" ) );
@@ -591,8 +590,8 @@ void Entity_Construct(){
        GlobalCommands_insert( "GroupSelection", makeCallbackF(Entity_groupSelected) );
        GlobalCommands_insert( "UngroupSelection", makeCallbackF(Entity_ungroupSelected) );
 
-       GlobalPreferenceSystem().registerPreference( "SI_Colors5", Vector3ImportStringCaller( g_entity_globals.color_entity ), Vector3ExportStringCaller( g_entity_globals.color_entity ) );
-       GlobalPreferenceSystem().registerPreference( "LastLightIntensity", IntImportStringCaller( g_iLastLightIntensity ), IntExportStringCaller( g_iLastLightIntensity ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors5", make_property_string( g_entity_globals.color_entity ) );
+       GlobalPreferenceSystem().registerPreference( "LastLightIntensity", make_property_string( g_iLastLightIntensity ) );
 
        Entity_registerPreferencesPage();
 }
index 39f61093556e595362a5cbbd6828c008009e4294..65b69327090c29b6513673f8a62b2ea6c5171700 100644 (file)
@@ -1574,8 +1574,8 @@ EntityInspector g_EntityInspector;
 void EntityInspector_construct(){
        GlobalEntityClassManager().attach( g_EntityInspector );
 
-       GlobalPreferenceSystem().registerPreference( "EntitySplit1", IntImportStringCaller( g_entitysplit1_position ), IntExportStringCaller( g_entitysplit1_position ) );
-       GlobalPreferenceSystem().registerPreference( "EntitySplit2", IntImportStringCaller( g_entitysplit2_position ), IntExportStringCaller( g_entitysplit2_position ) );
+       GlobalPreferenceSystem().registerPreference( "EntitySplit1", make_property_string( g_entitysplit1_position ) );
+       GlobalPreferenceSystem().registerPreference( "EntitySplit2", make_property_string( g_entitysplit2_position ) );
 
 }
 
index 9218027d51d3b67c2b85ece9c203bb0e2e8f4de6..877eba238dd410812e41094dcccbea3a7e750716 100644 (file)
@@ -375,7 +375,7 @@ void EntityList_Construct(){
 
        getEntityList().m_positionTracker.setPosition( c_default_window_pos );
 
-       GlobalPreferenceSystem().registerPreference( "EntityInfoDlg", WindowPositionTrackerImportStringCaller( getEntityList().m_positionTracker ), WindowPositionTrackerExportStringCaller( getEntityList().m_positionTracker ) );
+       GlobalPreferenceSystem().registerPreference( "EntityInfoDlg", make_property<WindowPositionTracker_String>( getEntityList().m_positionTracker ) );
 
        typedef FreeCaller<void(const Selectable&), EntityList_SelectionChanged> EntityListSelectionChangedCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( EntityListSelectionChangedCaller() );
index 9764f4af5a817dfe63f5e522d104c788aa3ef99b..3957af62e41b74fd9df16a629fb07b006d0ce800 100644 (file)
@@ -127,10 +127,10 @@ ToggleFilterFlag( unsigned int mask ) : m_mask( mask ), m_item( ActiveCaller( *t
 }
 ToggleFilterFlag( const ToggleFilterFlag& other ) : m_mask( other.m_mask ), m_item( ActiveCaller( *this ) ){
 }
-void active( const ImportExportCallback<bool>::Import_t& importCallback ){
+void active( const Callback<void(bool)> &importCallback ){
        importCallback( ( g_filters_globals.exclude & m_mask ) != 0 );
 }
-typedef MemberCaller<ToggleFilterFlag, void(const ImportExportCallback<bool>::Import_t&), &ToggleFilterFlag::active> ActiveCaller;
+typedef MemberCaller<ToggleFilterFlag, void(const Callback<void(bool)>&), &ToggleFilterFlag::active> ActiveCaller;
 void toggle(){
        g_filters_globals.exclude ^= m_mask;
        m_item.update();
@@ -216,7 +216,7 @@ void Filters_constructMenu( ui::Menu menu_in_menu ){
 #include "stringio.h"
 
 void ConstructFilters(){
-       GlobalPreferenceSystem().registerPreference( "SI_Exclude", SizeImportStringCaller( g_filters_globals.exclude ), SizeExportStringCaller( g_filters_globals.exclude ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Exclude", make_property_string( g_filters_globals.exclude ) );
 
        GlobalCommands_insert( "InvertFilters", makeCallbackF(InvertFilters) );
        GlobalCommands_insert( "ResetFilters", makeCallbackF(ResetFilters) );
index be267002a7ec66508bfa6e8fc2259b7731161b1b..df1e1c1a2e0df41a3a0607f6813622a1f036c3f2 100644 (file)
@@ -134,10 +134,10 @@ void set(){
        setGridPower( m_id );
 }
 typedef MemberCaller<GridMenuItem, void(), &GridMenuItem::set> SetCaller;
-void active( const ImportExportCallback<bool>::Import_t& importCallback ){
+void active( const Callback<void(bool)> &importCallback ){
        importCallback( g_grid_power == m_id );
 }
-typedef MemberCaller<GridMenuItem, void(const ImportExportCallback<bool>::Import_t&), &GridMenuItem::active> ExportCaller;
+typedef MemberCaller<GridMenuItem, void(const Callback<void(bool)>&), &GridMenuItem::active> ExportCaller;
 };
 
 GridMenuItem g_gridMenu0125( GRIDPOWER_0125 );
@@ -254,7 +254,7 @@ void Grid_construct(){
 
        g_grid_default = GridDefault_forGridPower( GRIDPOWER_8 );
 
-       GlobalPreferenceSystem().registerPreference( "GridDefault", IntImportStringCaller( g_grid_default ), IntExportStringCaller( g_grid_default ) );
+       GlobalPreferenceSystem().registerPreference( "GridDefault", make_property_string( g_grid_default ) );
 
        g_grid_power = GridPower_forGridDefault( g_grid_default );
        g_gridsize = GridSize_forGridPower( g_grid_power );
index 280988973d55d2be763783a1f30aec272fc04a74..f6847dd90253d30dc0f60319c8d09ba1b293615c 100644 (file)
@@ -71,7 +71,7 @@ namespace
 GroupDlg g_GroupDlg;
 
 std::size_t g_current_page;
-std::vector<ImportExportCallback<const char *>::Export_t> g_pages;
+std::vector<Callback<void(const Callback<void(const char *)> &)>> g_pages;
 }
 
 void GroupDialog_updatePageTitle( ui::Window window, std::size_t pageIndex ){
@@ -123,7 +123,7 @@ void GroupDlg::Create( ui::Window parent ){
 }
 
 
-ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const ImportExportCallback<const char *>::Export_t& title ){
+ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const Callback<void(const Callback<void(const char *)> &)>& title ){
        ui::Widget w = ui::Label( tabLabel );
        w.show();
        ui::Widget page = ui::Widget(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) ));
@@ -195,7 +195,7 @@ void GroupDialog_updatePageTitle( ui::Widget page ){
 #include "preferencesystem.h"
 
 void GroupDialog_Construct(){
-       GlobalPreferenceSystem().registerPreference( "EntityWnd", WindowPositionTrackerImportStringCaller( g_GroupDlg.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_GroupDlg.m_position_tracker ) );
+       GlobalPreferenceSystem().registerPreference( "EntityWnd", make_property<WindowPositionTracker_String>( g_GroupDlg.m_position_tracker ) );
 
        GlobalCommands_insert( "ViewEntityInfo", makeCallbackF(GroupDialog_ToggleShow), Accelerator( 'N' ) );
 }
index 8f1a31eea96f70ce33119fdbacd32723710a0e0c..f136f382c02f116f2c62123f5467f6f315a51b11 100644 (file)
@@ -23,6 +23,7 @@
 #define INCLUDED_GROUPDIALOG_H
 
 #include <uilib/uilib.h>
+#include "property.h"
 #include "generic/callback.h"
 
 void GroupDialog_Construct();
@@ -33,11 +34,11 @@ void GroupDialog_destroyWindow();
 ui::Window GroupDialog_getWindow();
 void GroupDialog_show();
 
-inline void RawStringExport( const char* string, const ImportExportCallback<const char *>::Import_t& importer ){
+inline void RawStringExport( const char* string, const Callback<void(const char *)> &importer ){
        importer( string );
 }
-typedef ConstPointerCaller<char, void(const ImportExportCallback<const char *>::Import_t&), RawStringExport> RawStringExportCaller;
-ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const ImportExportCallback<const char *>::Export_t& title );
+typedef ConstPointerCaller<char, void(const Callback<void(const char *)> &), RawStringExport> RawStringExportCaller;
+ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const Callback<void(const Callback<void(const char *)> &)>& title );
 
 void GroupDialog_showPage( ui::Widget page );
 void GroupDialog_updatePageTitle( ui::Widget page );
index c4d2f40dcdb29ae7db3f2991cfb00ffd3c0f443c..a569ea75e2f7482bef1e633ac0eb02c535fa4e61 100644 (file)
@@ -414,16 +414,18 @@ const char* GameToolsPath_get(){
        return g_strGameToolsPath.c_str();
 }
 
-void EnginePathImport( CopiedString& self, const char* value ){
-       setEnginePath( value );
-}
-typedef ReferenceCaller<CopiedString, void(const char*), EnginePathImport> EnginePathImportCaller;
+struct EnginePath {
+       static void Export(const CopiedString &self, const Callback<void(const char *)> &returnz) {
+               returnz(self.c_str());
+       }
+
+       static void Import(CopiedString &self, const char *value) {
+               setEnginePath(value);
+       }
+};
 
 void Paths_constructPreferences( PreferencesPage& page ){
-       page.appendPathEntry( "Engine Path", true,
-                                                 {ImportExportCallback<const char *>::Import_t( EnginePathImportCaller( g_strEnginePath ) ),
-                                                  ImportExportCallback<const char *>::Export_t( StringExportCaller( g_strEnginePath ) )}
-                                                 );
+       page.appendPathEntry( "Engine Path", true, make_property<EnginePath>(g_strEnginePath) );
 }
 void Paths_constructPage( PreferenceGroup& group ){
        PreferencesPage page( group.createPage( "Paths", "Path Settings" ) );
@@ -999,24 +1001,24 @@ template<bool( *BoolFunction ) ( )>
 class BoolFunctionExport
 {
 public:
-static void apply( const ImportExportCallback<bool>::Import_t& importCallback ){
+static void apply( const Callback<void(bool)> & importCallback ){
        importCallback( BoolFunction() );
 }
 };
 
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
 EdgeModeApplyCaller g_edgeMode_button_caller;
-ImportExportCallback<bool>::Export_t g_edgeMode_button_callback( g_edgeMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_edgeMode_button_callback( g_edgeMode_button_caller );
 ToggleItem g_edgeMode_button( g_edgeMode_button_callback );
 
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
 VertexModeApplyCaller g_vertexMode_button_caller;
-ImportExportCallback<bool>::Export_t g_vertexMode_button_callback( g_vertexMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_vertexMode_button_callback( g_vertexMode_button_caller );
 ToggleItem g_vertexMode_button( g_vertexMode_button_callback );
 
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
 FaceModeApplyCaller g_faceMode_button_caller;
-ImportExportCallback<bool>::Export_t g_faceMode_button_callback( g_faceMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_faceMode_button_callback( g_faceMode_button_caller );
 ToggleItem g_faceMode_button( g_faceMode_button_callback );
 
 void ComponentModeChanged(){
@@ -1290,44 +1292,44 @@ void Selection_NudgeRight(){
 }
 
 
-void TranslateToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
+void TranslateToolExport( const Callback<void(bool)> & importCallback ){
        importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eTranslate );
 }
 
-void RotateToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
+void RotateToolExport( const Callback<void(bool)> & importCallback ){
        importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eRotate );
 }
 
-void ScaleToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
+void ScaleToolExport( const Callback<void(bool)> & importCallback ){
        importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eScale );
 }
 
-void DragToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
+void DragToolExport( const Callback<void(bool)> & importCallback ){
        importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eDrag );
 }
 
-void ClipperToolExport( const ImportExportCallback<bool>::Import_t& importCallback ){
+void ClipperToolExport( const Callback<void(bool)> & importCallback ){
        importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip );
 }
 
-FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TranslateToolExport> g_translatemode_button_caller;
-ImportExportCallback<bool>::Export_t g_translatemode_button_callback( g_translatemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), TranslateToolExport> g_translatemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_translatemode_button_callback( g_translatemode_button_caller );
 ToggleItem g_translatemode_button( g_translatemode_button_callback );
 
-FreeCaller<void(const ImportExportCallback<bool>::Import_t&), RotateToolExport> g_rotatemode_button_caller;
-ImportExportCallback<bool>::Export_t g_rotatemode_button_callback( g_rotatemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), RotateToolExport> g_rotatemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_rotatemode_button_callback( g_rotatemode_button_caller );
 ToggleItem g_rotatemode_button( g_rotatemode_button_callback );
 
-FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ScaleToolExport> g_scalemode_button_caller;
-ImportExportCallback<bool>::Export_t g_scalemode_button_callback( g_scalemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), ScaleToolExport> g_scalemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_scalemode_button_callback( g_scalemode_button_caller );
 ToggleItem g_scalemode_button( g_scalemode_button_callback );
 
-FreeCaller<void(const ImportExportCallback<bool>::Import_t&), DragToolExport> g_dragmode_button_caller;
-ImportExportCallback<bool>::Export_t g_dragmode_button_callback( g_dragmode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), DragToolExport> g_dragmode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_dragmode_button_callback( g_dragmode_button_caller );
 ToggleItem g_dragmode_button( g_dragmode_button_callback );
 
-FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ClipperToolExport> g_clipper_button_caller;
-ImportExportCallback<bool>::Export_t g_clipper_button_callback( g_clipper_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), ClipperToolExport> g_clipper_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_clipper_button_callback( g_clipper_button_caller );
 ToggleItem g_clipper_button( g_clipper_button_callback );
 
 void ToolChanged(){
@@ -3126,22 +3128,22 @@ void Layout_constructPreferences( PreferencesPage& page ){
                page.appendRadioIcons(
                        "Window Layout",
                        STRING_ARRAY_RANGE( layouts ),
-                       mkImportExportCallback( g_Layout_viewStyle )
+                       make_property( g_Layout_viewStyle )
                        );
        }
        page.appendCheckBox(
                "", "Detachable Menus",
-               mkImportExportCallback( g_Layout_enableDetachableMenus )
+               make_property( g_Layout_enableDetachableMenus )
                );
        if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) {
                page.appendCheckBox(
                        "", "Patch Toolbar",
-                       mkImportExportCallback( g_Layout_enablePatchToolbar )
+                       make_property( g_Layout_enablePatchToolbar )
                        );
        }
        page.appendCheckBox(
                "", "Plugin Toolbar",
-               mkImportExportCallback( g_Layout_enablePluginToolbar )
+               make_property( g_Layout_enablePluginToolbar )
                );
 }
 
@@ -3279,25 +3281,25 @@ void MainFrame_Construct(){
        typedef FreeCaller<void(const Selectable&), ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( ComponentModeSelectionChangedCaller() );
 
-       GlobalPreferenceSystem().registerPreference( "DetachableMenus", BoolImportStringCaller( g_Layout_enableDetachableMenus.m_latched ), BoolExportStringCaller( g_Layout_enableDetachableMenus.m_latched ) );
-       GlobalPreferenceSystem().registerPreference( "PatchToolBar", BoolImportStringCaller( g_Layout_enablePatchToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) );
-       GlobalPreferenceSystem().registerPreference( "PluginToolBar", BoolImportStringCaller( g_Layout_enablePluginToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) );
-       GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", IntImportStringCaller( g_Layout_viewStyle.m_latched ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) );
-       GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) );
-       GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) );
-       GlobalPreferenceSystem().registerPreference( "CamWidth", IntImportStringCaller( g_layout_globals.nCamWidth ), IntExportStringCaller( g_layout_globals.nCamWidth ) );
-       GlobalPreferenceSystem().registerPreference( "CamHeight", IntImportStringCaller( g_layout_globals.nCamHeight ), IntExportStringCaller( g_layout_globals.nCamHeight ) );
-
-       GlobalPreferenceSystem().registerPreference( "State", IntImportStringCaller( g_layout_globals.nState ), IntExportStringCaller( g_layout_globals.nState ) );
-       GlobalPreferenceSystem().registerPreference( "PositionX", IntImportStringCaller( g_layout_globals.m_position.x ), IntExportStringCaller( g_layout_globals.m_position.x ) );
-       GlobalPreferenceSystem().registerPreference( "PositionY", IntImportStringCaller( g_layout_globals.m_position.y ), IntExportStringCaller( g_layout_globals.m_position.y ) );
-       GlobalPreferenceSystem().registerPreference( "Width", IntImportStringCaller( g_layout_globals.m_position.w ), IntExportStringCaller( g_layout_globals.m_position.w ) );
-       GlobalPreferenceSystem().registerPreference( "Height", IntImportStringCaller( g_layout_globals.m_position.h ), IntExportStringCaller( g_layout_globals.m_position.h ) );
-
-       GlobalPreferenceSystem().registerPreference( "CamWnd", WindowPositionTrackerImportStringCaller( g_posCamWnd ), WindowPositionTrackerExportStringCaller( g_posCamWnd ) );
-       GlobalPreferenceSystem().registerPreference( "XYWnd", WindowPositionTrackerImportStringCaller( g_posXYWnd ), WindowPositionTrackerExportStringCaller( g_posXYWnd ) );
-       GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) );
-       GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) );
+       GlobalPreferenceSystem().registerPreference( "DetachableMenus", make_property_string( g_Layout_enableDetachableMenus.m_latched ) );
+       GlobalPreferenceSystem().registerPreference( "PatchToolBar", make_property_string( g_Layout_enablePatchToolbar.m_latched ) );
+       GlobalPreferenceSystem().registerPreference( "PluginToolBar", make_property_string( g_Layout_enablePluginToolbar.m_latched ) );
+       GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", make_property_string( g_Layout_viewStyle.m_latched ) );
+       GlobalPreferenceSystem().registerPreference( "XYHeight", make_property_string( g_layout_globals.nXYHeight ) );
+       GlobalPreferenceSystem().registerPreference( "XYWidth", make_property_string( g_layout_globals.nXYWidth ) );
+       GlobalPreferenceSystem().registerPreference( "CamWidth", make_property_string( g_layout_globals.nCamWidth ) );
+       GlobalPreferenceSystem().registerPreference( "CamHeight", make_property_string( g_layout_globals.nCamHeight ) );
+
+       GlobalPreferenceSystem().registerPreference( "State", make_property_string( g_layout_globals.nState ) );
+       GlobalPreferenceSystem().registerPreference( "PositionX", make_property_string( g_layout_globals.m_position.x ) );
+       GlobalPreferenceSystem().registerPreference( "PositionY", make_property_string( g_layout_globals.m_position.y ) );
+       GlobalPreferenceSystem().registerPreference( "Width", make_property_string( g_layout_globals.m_position.w ) );
+       GlobalPreferenceSystem().registerPreference( "Height", make_property_string( g_layout_globals.m_position.h ) );
+
+       GlobalPreferenceSystem().registerPreference( "CamWnd", make_property<WindowPositionTracker_String>(g_posCamWnd) );
+       GlobalPreferenceSystem().registerPreference( "XYWnd", make_property<WindowPositionTracker_String>(g_posXYWnd) );
+       GlobalPreferenceSystem().registerPreference( "YZWnd", make_property<WindowPositionTracker_String>(g_posYZWnd) );
+       GlobalPreferenceSystem().registerPreference( "XZWnd", make_property<WindowPositionTracker_String>(g_posXZWnd) );
 
        {
                const char* ENGINEPATH_ATTRIBUTE =
@@ -3316,7 +3318,7 @@ void MainFrame_Construct(){
                g_strEnginePath = path.c_str();
        }
 
-       GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
+       GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) );
 
        g_Layout_viewStyle.useLatched();
        g_Layout_enableDetachableMenus.useLatched();
@@ -3346,7 +3348,7 @@ void MainFrame_Destroy(){
 
 
 void GLWindow_Construct(){
-       GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) );
+       GlobalPreferenceSystem().registerPreference( "MouseButtons", make_property_string( g_glwindow_globals.m_nMouseType ) );
 }
 
 void GLWindow_Destroy(){
index a6833a6c55560f388c89d89c7b64bf82842a8abc..3275184b6b30a6a11082b300baebf8932e4aaacf 100644 (file)
@@ -1788,7 +1788,7 @@ const char* getMapsPath(){
 
 const char* getLastFolderPath(){
        if (g_strLastFolder.empty()) {
-               GlobalPreferenceSystem().registerPreference( "LastFolder", CopiedStringImportStringCaller( g_strLastFolder ), CopiedStringExportStringCaller( g_strLastFolder ) );
+               GlobalPreferenceSystem().registerPreference( "LastFolder", make_property_string( g_strLastFolder ) );
                if (g_strLastFolder.empty()) {
                        g_strLastFolder = g_qeglobals.m_userGamePath;
                }
@@ -2166,9 +2166,9 @@ void Map_Construct(){
        GlobalCommands_insert( "RegionSetBrush", makeCallbackF(RegionBrush) );
        GlobalCommands_insert( "RegionSetSelection", makeCallbackF(RegionSelected), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
 
-       GlobalPreferenceSystem().registerPreference( "LastMap", CopiedStringImportStringCaller( g_strLastMap ), CopiedStringExportStringCaller( g_strLastMap ) );
-       GlobalPreferenceSystem().registerPreference( "LoadLastMap", BoolImportStringCaller( g_bLoadLastMap ), BoolExportStringCaller( g_bLoadLastMap ) );
-       GlobalPreferenceSystem().registerPreference( "MapInfoDlg", WindowPositionImportStringCaller( g_posMapInfoWnd ), WindowPositionExportStringCaller( g_posMapInfoWnd ) );
+       GlobalPreferenceSystem().registerPreference( "LastMap", make_property_string( g_strLastMap ) );
+       GlobalPreferenceSystem().registerPreference( "LoadLastMap", make_property_string( g_bLoadLastMap ) );
+       GlobalPreferenceSystem().registerPreference( "MapInfoDlg", make_property<WindowPosition_String>( g_posMapInfoWnd ) );
 
        PreferencesDialog_addSettingsPreferences( makeCallbackF(Map_constructPreferences) );
 
index aef04cbc033abc058386914643ecec571868f458..9a4a1d755edcbea11d8e29db23b25688a8790160 100644 (file)
@@ -219,11 +219,11 @@ void MRU_constructMenu( ui::Menu menu ){
 #include "stringio.h"
 
 void MRU_Construct(){
-       GlobalPreferenceSystem().registerPreference( "Count", SizeImportStringCaller( MRU_used ), SizeExportStringCaller( MRU_used ) );
+       GlobalPreferenceSystem().registerPreference( "Count", make_property_string( MRU_used ) );
 
        for ( std::size_t i = 0; i != MRU_MAX; ++i )
        {
-               GlobalPreferenceSystem().registerPreference( MRU_keys[i], CopiedStringImportStringCaller( MRU_filenames[i] ), CopiedStringExportStringCaller( MRU_filenames[i] ) );
+               GlobalPreferenceSystem().registerPreference( MRU_keys[i], make_property_string( MRU_filenames[i] ) );
        }
 
        MRU_Init();
index b626f435ee3da36b6a3aebeee40d09f0931cc69d..38ed3f302ce3a657e2f8571af44eec25b94bc2f4 100644 (file)
@@ -86,8 +86,8 @@ void MultiMon_Construct(){
                g_multimon_globals.m_bStartOnPrimMon = true;
        }
 
-       GlobalPreferenceSystem().registerPreference( "StartOnPrimMon", BoolImportStringCaller( g_multimon_globals.m_bStartOnPrimMon ), BoolExportStringCaller( g_multimon_globals.m_bStartOnPrimMon ) );
-       GlobalPreferenceSystem().registerPreference( "NoSysMenuPopups", BoolImportStringCaller( g_Multimon_enableSysMenuPopups.m_latched ), BoolExportStringCaller( g_Multimon_enableSysMenuPopups.m_latched ) );
+       GlobalPreferenceSystem().registerPreference( "StartOnPrimMon", make_property_string( g_multimon_globals.m_bStartOnPrimMon ) );
+       GlobalPreferenceSystem().registerPreference( "NoSysMenuPopups", make_property_string( g_Multimon_enableSysMenuPopups.m_latched ) );
 
        g_Multimon_enableSysMenuPopups.useLatched();
 
index b6650f50851d1cb0d688640dd7d61b77fb655eaa..830378327f9b951c78bfdb805add0af4d0c66f0a 100644 (file)
@@ -1035,12 +1035,12 @@ void PatchInspector_SelectionChanged( const Selectable& selectable ){
 void PatchInspector_Construct(){
        GlobalCommands_insert( "PatchInspector", makeCallbackF(PatchInspector_toggleShown), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) );
 
-       GlobalPreferenceSystem().registerPreference( "PatchWnd", WindowPositionTrackerImportStringCaller( g_PatchInspector.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_PatchInspector.m_position_tracker ) );
-       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", FloatImportStringCaller( g_pi_globals.scale[0] ), FloatExportStringCaller( g_pi_globals.scale[0] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", FloatImportStringCaller( g_pi_globals.scale[1] ), FloatExportStringCaller( g_pi_globals.scale[1] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", FloatImportStringCaller( g_pi_globals.shift[0] ), FloatExportStringCaller( g_pi_globals.shift[0] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", FloatImportStringCaller( g_pi_globals.shift[1] ), FloatExportStringCaller( g_pi_globals.shift[1] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", FloatImportStringCaller( g_pi_globals.rotate ), FloatExportStringCaller( g_pi_globals.rotate ) );
+       GlobalPreferenceSystem().registerPreference( "PatchWnd", make_property<WindowPositionTracker_String>( g_PatchInspector.m_position_tracker ) );
+       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", make_property_string( g_pi_globals.scale[0] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", make_property_string( g_pi_globals.scale[1] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", make_property_string( g_pi_globals.shift[0] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", make_property_string( g_pi_globals.shift[1] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", make_property_string( g_pi_globals.rotate ) );
 
        typedef FreeCaller<void(const Selectable&), PatchInspector_SelectionChanged> PatchInspectorSelectionChangedCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( PatchInspectorSelectionChangedCaller() );
index a7e993ef896b458971bd626b22ce9712940760a4..60ee490f5d4fcac0ea0e390417b69f8284422d0c 100644 (file)
@@ -607,7 +607,7 @@ void Patch_registerPreferencesPage(){
 #include "preferencesystem.h"
 
 void PatchPreferences_construct(){
-       GlobalPreferenceSystem().registerPreference( "Subdivisions", IntImportStringCaller( g_PatchSubdivideThreshold ), IntExportStringCaller( g_PatchSubdivideThreshold ) );
+       GlobalPreferenceSystem().registerPreference( "Subdivisions", make_property_string( g_PatchSubdivideThreshold ) );
 }
 
 
index eed7b1c9a69db5f4ebfa421a0c6ae8b47a83b765..382271ee8a9795ceaa786d9622d7c1d40361d8df 100644 (file)
@@ -33,17 +33,16 @@ class PreferenceDictionary : public PreferenceSystem
 {
 class PreferenceEntry
 {
-ImportExportCallback<const char *>::Import_t m_importer;
-ImportExportCallback<const char *>::Export_t m_exporter;
+Property<const char *> m_cb;
 public:
-PreferenceEntry( const ImportExportCallback<const char *>::Import_t& importer, const ImportExportCallback<const char *>::Export_t& exporter )
-       : m_importer( importer ), m_exporter( exporter ){
+PreferenceEntry( const Property<const char *>& cb )
+       : m_cb( cb ){
 }
 void importString( const char* string ){
-       m_importer( string );
+       m_cb.set( string );
 }
-void exportString( const ImportExportCallback<const char *>::Import_t& importer ){
-       m_exporter( importer );
+void exportString( const Callback<void(const char *)> & importer ){
+       m_cb.get( importer );
 }
 };
 
@@ -66,11 +65,11 @@ iterator find( const char* name ){
        return m_preferences.find( name );
 }
 
-void registerPreference( const char* name, const ImportExportCallback<const char *>::Import_t& importer, const ImportExportCallback<const char *>::Export_t& exporter ){
-       m_preferences.insert( PreferenceEntries::value_type( name, PreferenceEntry( importer, exporter ) ) );
+void registerPreference( const char* name, const Property<const char *>& cb ){
+       m_preferences.insert( PreferenceEntries::value_type( name, PreferenceEntry( cb ) ) );
        PreferenceCache::iterator i = m_cache.find( name );
        if ( i != m_cache.end() ) {
-               importer( ( *i ).second.c_str() );
+               cb.set( i->second.c_str() );
                m_cache.erase( i );
        }
 }
index ea3dbe44c7dff63864a92bdcc82a4b84d32dfbf5..ea993de5e6b1cbcae7bb3f80d26bec4f6e0ed7a6 100644 (file)
@@ -216,18 +216,22 @@ bool Preferences_Save_Safe( PreferenceDictionary& preferences, const char* filen
 }
 
 
+struct LogConsole {
+       static void Export(const Callback<void(bool)> &returnz) {
+               returnz(g_Console_enableLogging);
+       }
 
-void LogConsole_importString( const char* string ){
-       g_Console_enableLogging = string_equal( string, "true" );
-       Sys_LogFile( g_Console_enableLogging );
-}
-typedef FreeCaller<void(const char*), LogConsole_importString> LogConsoleImportStringCaller;
+       static void Import(bool value) {
+               g_Console_enableLogging = value;
+               Sys_LogFile(g_Console_enableLogging);
+       }
+};
 
 
 void RegisterGlobalPreferences( PreferenceSystem& preferences ){
-       preferences.registerPreference( "gamefile", CopiedStringImportStringCaller( g_GamesDialog.m_sGameFile ), CopiedStringExportStringCaller( g_GamesDialog.m_sGameFile ) );
-       preferences.registerPreference( "gamePrompt", BoolImportStringCaller( g_GamesDialog.m_bGamePrompt ), BoolExportStringCaller( g_GamesDialog.m_bGamePrompt ) );
-       preferences.registerPreference( "log console", LogConsoleImportStringCaller(), BoolExportStringCaller( g_Console_enableLogging ) );
+       preferences.registerPreference( "gamefile", make_property_string( g_GamesDialog.m_sGameFile ) );
+       preferences.registerPreference( "gamePrompt", make_property_string( g_GamesDialog.m_bGamePrompt ) );
+       preferences.registerPreference( "log console", make_property_string<LogConsole>() );
 }
 
 
@@ -280,7 +284,7 @@ void CGameDialog::GameFileImport( int value ){
        m_sGameFile = ( *iGame )->mGameFile;
 }
 
-void CGameDialog::GameFileExport( const ImportExportCallback<int>::Import_t& importCallback ) const {
+void CGameDialog::GameFileExport( const Callback<void(int)> & importCallback ) const {
        // use m_sGameFile to set value
        std::list<CGameDescription *>::const_iterator iGame;
        int i = 0;
@@ -295,13 +299,15 @@ void CGameDialog::GameFileExport( const ImportExportCallback<int>::Import_t& imp
        importCallback( m_nComboSelect );
 }
 
-void CGameDialog_GameFileImport( CGameDialog& self, int value ){
-       self.GameFileImport( value );
-}
+struct CGameDialog_GameFile {
+       static void Export(const CGameDialog &self, const Callback<void(int)> &returnz) {
+               self.GameFileExport(returnz);
+       }
 
-void CGameDialog_GameFileExport( CGameDialog& self, const ImportExportCallback<int>::Import_t& importCallback ){
-       self.GameFileExport( importCallback );
-}
+       static void Import(CGameDialog &self, int value) {
+               self.GameFileImport(value);
+       }
+};
 
 void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){
        std::vector<const char*> games;
@@ -313,8 +319,7 @@ void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){
        page.appendCombo(
                "Select the game",
                StringArrayRange( &( *games.begin() ), &( *games.end() ) ),
-               {ReferenceCaller<CGameDialog, void(int), CGameDialog_GameFileImport>( *this ),
-               ReferenceCaller<CGameDialog, void(const ImportExportCallback<int>::Import_t&), CGameDialog_GameFileExport>( *this )}
+               make_property<CGameDialog_GameFile>(*this)
                );
        page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt );
 }
@@ -914,39 +919,36 @@ void PreferencesDialog_showDialog(){
        }
 }
 
+struct GameName {
+       static void Export(const Callback<void(const char *)> &returnz) {
+               returnz(gamename_get());
+       }
 
+       static void Import(const char *value) {
+               gamename_set(value);
+       }
+};
 
+struct GameMode {
+       static void Export(const Callback<void(const char *)> &returnz) {
+               returnz(gamemode_get());
+       }
 
-
-void GameName_importString( const char* value ){
-       gamename_set( value );
-}
-typedef FreeCaller<void(const char*), GameName_importString> GameNameImportStringCaller;
-void GameName_exportString( const ImportExportCallback<const char *>::Import_t& importer ){
-       importer( gamename_get() );
-}
-typedef FreeCaller<void(const ImportExportCallback<const char *>::Import_t&), GameName_exportString> GameNameExportStringCaller;
-
-void GameMode_importString( const char* value ){
-       gamemode_set( value );
-}
-typedef FreeCaller<void(const char*), GameMode_importString> GameModeImportStringCaller;
-void GameMode_exportString( const ImportExportCallback<const char *>::Import_t& importer ){
-       importer( gamemode_get() );
-}
-typedef FreeCaller<void(const ImportExportCallback<const char *>::Import_t&), GameMode_exportString> GameModeExportStringCaller;
-
+       static void Import(const char *value) {
+               gamemode_set(value);
+       }
+};
 
 void RegisterPreferences( PreferenceSystem& preferences ){
 #if GDEF_OS_WINDOWS
-       preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useWin32Editor ), BoolExportStringCaller( g_TextEditor_useWin32Editor ) );
+       preferences.registerPreference( "UseCustomShaderEditor", make_property_string( g_TextEditor_useWin32Editor ) );
 #else
-       preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useCustomEditor ), BoolExportStringCaller( g_TextEditor_useCustomEditor ) );
-       preferences.registerPreference( "CustomShaderEditorCommand", CopiedStringImportStringCaller( g_TextEditor_editorCommand ), CopiedStringExportStringCaller( g_TextEditor_editorCommand ) );
+       preferences.registerPreference( "UseCustomShaderEditor", make_property_string( g_TextEditor_useCustomEditor ) );
+       preferences.registerPreference( "CustomShaderEditorCommand", make_property_string( g_TextEditor_editorCommand ) );
 #endif
 
-       preferences.registerPreference( "GameName", GameNameImportStringCaller(), GameNameExportStringCaller() );
-       preferences.registerPreference( "GameMode", GameModeImportStringCaller(), GameModeExportStringCaller() );
+       preferences.registerPreference( "GameName", make_property<GameName>() );
+       preferences.registerPreference( "GameMode", make_property<GameMode>() );
 }
 
 void Preferences_Init(){
index 8d7f93aeb32b6b5f4d0c17918023382848dd1ebf..59dd60daaa0c6e42633932892511d91fa594429c 100644 (file)
@@ -33,6 +33,7 @@
 #include "dialog.h"
 #include <list>
 #include <map>
+#include "property.h"
 
 void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton );
 
@@ -46,10 +47,10 @@ PreferencesPage( Dialog& dialog, ui::VBox vbox ) : m_dialog( dialog ), m_vbox( v
 ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){
        return m_dialog.addCheckBox( m_vbox, name, flag, data );
 }
-ui::CheckButton appendCheckBox( const char* name, const char* flag, ImportExportCallback<bool> const &cb ){
+ui::CheckButton appendCheckBox( const char* name, const char* flag, Property<bool> const &cb ){
        return m_dialog.addCheckBox( m_vbox, name, flag, cb );
 }
-void appendCombo( const char* name, StringArrayRange values, ImportExportCallback<int> const &cb ){
+void appendCombo( const char* name, StringArrayRange values, Property<int> const &cb ){
        m_dialog.addCombo( m_vbox, name, values, cb );
 }
 void appendCombo( const char* name, int& data, StringArrayRange values ){
@@ -58,37 +59,37 @@ void appendCombo( const char* name, int& data, StringArrayRange values ){
 void appendSlider( const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
        m_dialog.addSlider( m_vbox, name, data, draw_value, low, high, value, lower, upper, step_increment, page_increment );
 }
-void appendRadio( const char* name, StringArrayRange names, ImportExportCallback<int> const &cb ){
+void appendRadio( const char* name, StringArrayRange names, Property<int> const &cb ){
        m_dialog.addRadio( m_vbox, name, names, cb );
 }
 void appendRadio( const char* name, int& data, StringArrayRange names ){
        m_dialog.addRadio( m_vbox, name, data, names );
 }
-void appendRadioIcons( const char* name, StringArrayRange icons, ImportExportCallback<int> const &cb ){
+void appendRadioIcons( const char* name, StringArrayRange icons, Property<int> const &cb ){
        m_dialog.addRadioIcons( m_vbox, name, icons, cb );
 }
 void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){
        m_dialog.addRadioIcons( m_vbox, name, data, icons );
 }
-ui::Widget appendEntry( const char* name, ImportExportCallback<int> const &cb ){
+ui::Widget appendEntry( const char* name, Property<int> const &cb ){
        return m_dialog.addIntEntry( m_vbox, name, cb );
 }
 ui::Widget appendEntry( const char* name, int& data ){
        return m_dialog.addEntry( m_vbox, name, data );
 }
-ui::Widget appendEntry( const char* name, ImportExportCallback<std::size_t> const &cb){
+ui::Widget appendEntry( const char* name, Property<std::size_t> const &cb){
        return m_dialog.addSizeEntry( m_vbox, name, cb );
 }
 ui::Widget appendEntry( const char* name, std::size_t& data ){
        return m_dialog.addEntry( m_vbox, name, data );
 }
-ui::Widget appendEntry( const char* name, ImportExportCallback<float> const &cb ){
+ui::Widget appendEntry( const char* name, Property<float> const &cb ){
        return m_dialog.addFloatEntry( m_vbox, name, cb );
 }
 ui::Widget appendEntry( const char* name, float& data ){
        return m_dialog.addEntry( m_vbox, name, data );
 }
-ui::Widget appendPathEntry( const char* name, bool browse_directory, ImportExportCallback<const char *> const &cb ){
+ui::Widget appendPathEntry( const char* name, bool browse_directory, Property<const char *> const &cb ){
        return m_dialog.addPathEntry( m_vbox, name, browse_directory, cb );
 }
 ui::Widget appendPathEntry( const char* name, CopiedString& data, bool directory ){
@@ -97,10 +98,10 @@ ui::Widget appendPathEntry( const char* name, CopiedString& data, bool directory
 ui::SpinButton appendSpinner( const char* name, int& data, double value, double lower, double upper ){
        return m_dialog.addSpinner( m_vbox, name, data, value, lower, upper );
 }
-ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, ImportExportCallback<int> const &cb ){
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, Property<int> const &cb ){
        return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
 }
-ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, ImportExportCallback<float> const &cb ){
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, Property<float> const &cb ){
        return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
 }
 };
@@ -137,21 +138,25 @@ public:
     void useLatched() {
         m_value = m_latched;
     }
+};
 
-    void import(Value value) {
-        m_latched = value;
-        if (m_latched != m_value) {
-            PreferencesDialog_restartRequired(m_description);
-        }
-    }
+template<class T>
+struct PropertyImpl<LatchedValue<T>, T> {
+       static void Export(const LatchedValue<T> &self, const Callback<void(T)> &returnz) {
+               returnz(self.m_latched);
+       }
+
+       static void Import(LatchedValue<T> &self, T value) {
+               self.m_latched = value;
+               if (value != self.m_value) {
+                       PreferencesDialog_restartRequired(self.m_description);
+               }
+       }
 };
 
-template<class Self, class T = Self>
-ImportExportCallback<T> mkImportExportCallback(LatchedValue<Self> &self) {
-       return {
-                       MemberCaller<LatchedValue<Self>, void(T), &LatchedValue<Self>::import>(self),
-                       ReferenceCaller<Self, void(const Callback<void(T)> &), impexp<Self, T>::Export>(self.m_latched)
-       };
+template<class T>
+Property<T> make_property(LatchedValue<T> &self) {
+       return make_property<LatchedValue<T>, T>(self);
 }
 
 /*!
@@ -275,7 +280,7 @@ void DoGameDialog();
 ui::Window BuildDialog();
 
 void GameFileImport( int value );
-void GameFileExport( const ImportExportCallback<int>::Import_t& importCallback ) const;
+void GameFileExport( const Callback<void(int)> & importCallback ) const;
 
 /*!
    construction of the dialog frame
index 57007112446f6ef73a2543bf51e11838e54da3e6..89df8a77bafae027e186e77f1d3a887403228d09 100644 (file)
@@ -162,8 +162,6 @@ NonModalEntry m_valueEntry;
 ui::Entry m_valueEntryWidget{ui::null};
 public:
 WindowPositionTracker m_positionTracker;
-WindowPositionTrackerImportStringCaller m_importPosition;
-WindowPositionTrackerExportStringCaller m_exportPosition;
 
 // Dialog Data
 float m_fitHorizontal;
@@ -190,8 +188,6 @@ SurfaceInspector() :
        m_rotateEntry( Increment::ApplyCaller( m_rotateIncrement ), Increment::CancelCaller( m_rotateIncrement ) ),
        m_idleDraw( UpdateCaller( *this ) ),
        m_valueEntry( ApplyFlagsCaller( *this ), UpdateCaller( *this ) ),
-       m_importPosition( m_positionTracker ),
-       m_exportPosition( m_positionTracker ),
        m_hshiftIncrement( g_si_globals.shift[0] ),
        m_vshiftIncrement( g_si_globals.shift[1] ),
        m_hscaleIncrement( g_si_globals.scale[0] ),
@@ -1415,13 +1411,13 @@ void SurfaceInspector_Construct(){
 
        FaceTextureClipboard_setDefault();
 
-       GlobalPreferenceSystem().registerPreference( "SurfaceWnd", getSurfaceInspector().m_importPosition, getSurfaceInspector().m_exportPosition );
-       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale1", FloatImportStringCaller( g_si_globals.scale[0] ), FloatExportStringCaller( g_si_globals.scale[0] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale2", FloatImportStringCaller( g_si_globals.scale[1] ), FloatExportStringCaller( g_si_globals.scale[1] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift1", FloatImportStringCaller( g_si_globals.shift[0] ), FloatExportStringCaller( g_si_globals.shift[0] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift2", FloatImportStringCaller( g_si_globals.shift[1] ), FloatExportStringCaller( g_si_globals.shift[1] ) );
-       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Rotate", FloatImportStringCaller( g_si_globals.rotate ), FloatExportStringCaller( g_si_globals.rotate ) );
-       GlobalPreferenceSystem().registerPreference( "SnapTToGrid", BoolImportStringCaller( g_si_globals.m_bSnapTToGrid ), BoolExportStringCaller( g_si_globals.m_bSnapTToGrid ) );
+       GlobalPreferenceSystem().registerPreference( "SurfaceWnd", make_property<WindowPositionTracker_String>( getSurfaceInspector().m_positionTracker) );
+       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale1", make_property_string( g_si_globals.scale[0] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale2", make_property_string( g_si_globals.scale[1] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift1", make_property_string( g_si_globals.shift[0] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift2", make_property_string( g_si_globals.shift[1] ) );
+       GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Rotate", make_property_string( g_si_globals.rotate ) );
+       GlobalPreferenceSystem().registerPreference( "SnapTToGrid", make_property_string( g_si_globals.m_bSnapTToGrid ) );
 
        typedef FreeCaller<void(const Selectable&), SurfaceInspector_SelectionChanged> SurfaceInspectorSelectionChangedCaller;
        GlobalSelectionSystem().addSelectionChangeCallback( SurfaceInspectorSelectionChangedCaller() );
index eb98984620a3b71f669947b538ae823c891fc2d4..02f706b90e0629d6df7808ea62f3f88067abcba7 100644 (file)
@@ -621,99 +621,106 @@ void Textures_UpdateTextureCompressionFormat(){
        Textures_setTextureComponents( texture_components );
 }
 
-void TextureCompressionImport( TextureCompressionFormat& self, int value ){
-       if ( !g_texture_globals.m_bOpenGLCompressionSupported
-                && g_texture_globals.m_bS3CompressionSupported
-                && value >= 1 ) {
-               ++value;
-       }
-       switch ( value )
-       {
-       case 0:
-               self = TEXTURECOMPRESSION_NONE;
-               break;
-       case 1:
-               self = TEXTURECOMPRESSION_RGBA;
-               break;
-       case 2:
-               self = TEXTURECOMPRESSION_RGBA_S3TC_DXT1;
-               break;
-       case 3:
-               self = TEXTURECOMPRESSION_RGBA_S3TC_DXT3;
-               break;
-       case 4:
-               self = TEXTURECOMPRESSION_RGBA_S3TC_DXT5;
-               break;
-       }
-       Textures_UpdateTextureCompressionFormat();
-}
-typedef ReferenceCaller<TextureCompressionFormat, void(int), TextureCompressionImport> TextureCompressionImportCaller;
+struct TextureCompression {
+    static void Export(const TextureCompressionFormat &self, const Callback<void(int)> &returnz) {
+        returnz(self);
+    }
+
+    static void Import(TextureCompressionFormat &self, int value) {
+        if (!g_texture_globals.m_bOpenGLCompressionSupported
+            && g_texture_globals.m_bS3CompressionSupported
+            && value >= 1) {
+            ++value;
+        }
+        switch (value) {
+            case 0:
+                self = TEXTURECOMPRESSION_NONE;
+                break;
+            case 1:
+                self = TEXTURECOMPRESSION_RGBA;
+                break;
+            case 2:
+                self = TEXTURECOMPRESSION_RGBA_S3TC_DXT1;
+                break;
+            case 3:
+                self = TEXTURECOMPRESSION_RGBA_S3TC_DXT3;
+                break;
+            case 4:
+                self = TEXTURECOMPRESSION_RGBA_S3TC_DXT5;
+                break;
+        }
+        Textures_UpdateTextureCompressionFormat();
+    }
+};
 
-void TextureGammaImport( float& self, float value ){
-       if ( self != value ) {
-               Textures_Unrealise();
-               self = value;
-               Textures_Realise();
+struct TextureGamma {
+       static void Export(const float &self, const Callback<void(float)> &returnz) {
+               returnz(self);
        }
-}
-typedef ReferenceCaller<float, void(float), TextureGammaImport> TextureGammaImportCaller;
 
-void TextureModeImport( ETexturesMode& self, int value ){
-       switch ( value )
-       {
-       case 0:
-               Textures_SetMode( eTextures_NEAREST );
-               break;
-       case 1:
-               Textures_SetMode( eTextures_NEAREST_MIPMAP_NEAREST );
-               break;
-       case 2:
-               Textures_SetMode( eTextures_LINEAR );
-               break;
-       case 3:
-               Textures_SetMode( eTextures_NEAREST_MIPMAP_LINEAR );
-               break;
-       case 4:
-               Textures_SetMode( eTextures_LINEAR_MIPMAP_NEAREST );
-               break;
-       case 5:
-               Textures_SetMode( eTextures_LINEAR_MIPMAP_LINEAR );
-               break;
-       case 6:
-               Textures_SetMode( eTextures_MAX_ANISOTROPY );
+       static void Import(float &self, float value) {
+               if (value != self) {
+                       Textures_Unrealise();
+                       self = value;
+                       Textures_Realise();
+               }
        }
-}
-typedef ReferenceCaller<ETexturesMode, void(int), TextureModeImport> TextureModeImportCaller;
+};
 
-void TextureModeExport( ETexturesMode& self, const ImportExportCallback<int>::Import_t& importer ){
-       switch ( self )
-       {
-       case eTextures_NEAREST:
-               importer( 0 );
-               break;
-       case eTextures_NEAREST_MIPMAP_NEAREST:
-               importer( 1 );
-               break;
-       case eTextures_LINEAR:
-               importer( 2 );
-               break;
-       case eTextures_NEAREST_MIPMAP_LINEAR:
-               importer( 3 );
-               break;
-       case eTextures_LINEAR_MIPMAP_NEAREST:
-               importer( 4 );
-               break;
-       case eTextures_LINEAR_MIPMAP_LINEAR:
-               importer( 5 );
-               break;
-       case eTextures_MAX_ANISOTROPY:
-               importer( 6 );
-               break;
-       default:
-               importer( 4 );
-       }
-}
-typedef ReferenceCaller<ETexturesMode, void(const ImportExportCallback<int>::Import_t&), TextureModeExport> TextureModeExportCaller;
+struct TextureMode {
+    static void Export(const ETexturesMode &self, const Callback<void(int)> &returnz) {
+        switch (self) {
+            case eTextures_NEAREST:
+                returnz(0);
+                break;
+            case eTextures_NEAREST_MIPMAP_NEAREST:
+                returnz(1);
+                break;
+            case eTextures_LINEAR:
+                returnz(2);
+                break;
+            case eTextures_NEAREST_MIPMAP_LINEAR:
+                returnz(3);
+                break;
+            case eTextures_LINEAR_MIPMAP_NEAREST:
+                returnz(4);
+                break;
+            case eTextures_LINEAR_MIPMAP_LINEAR:
+                returnz(5);
+                break;
+            case eTextures_MAX_ANISOTROPY:
+                returnz(6);
+                break;
+            default:
+                returnz(4);
+        }
+    }
+
+    static void Import(ETexturesMode &self, int value) {
+        switch (value) {
+            case 0:
+                Textures_SetMode(eTextures_NEAREST);
+                break;
+            case 1:
+                Textures_SetMode(eTextures_NEAREST_MIPMAP_NEAREST);
+                break;
+            case 2:
+                Textures_SetMode(eTextures_LINEAR);
+                break;
+            case 3:
+                Textures_SetMode(eTextures_NEAREST_MIPMAP_LINEAR);
+                break;
+            case 4:
+                Textures_SetMode(eTextures_LINEAR_MIPMAP_NEAREST);
+                break;
+            case 5:
+                Textures_SetMode(eTextures_LINEAR_MIPMAP_LINEAR);
+                break;
+            case 6:
+                Textures_SetMode(eTextures_MAX_ANISOTROPY);
+        }
+    }
+};
 
 void Textures_constructPreferences( PreferencesPage& page ){
        {
@@ -721,7 +728,7 @@ void Textures_constructPreferences( PreferencesPage& page ){
                page.appendRadio(
                        "Texture Quality",
                        STRING_ARRAY_RANGE( percentages ),
-                       mkImportExportCallback( g_Textures_textureQuality )
+                       make_property( g_Textures_textureQuality )
                        );
        }
        page.appendSpinner(
@@ -729,16 +736,14 @@ void Textures_constructPreferences( PreferencesPage& page ){
                1.0,
                0.0,
                1.0,
-               {ImportExportCallback<float>::Import_t( TextureGammaImportCaller( g_texture_globals.fGamma ) ),
-               ImportExportCallback<float>::Export_t( FloatExportCaller( g_texture_globals.fGamma ) )}
+               make_property<TextureGamma>(g_texture_globals.fGamma)
                );
        {
                const char* texture_mode[] = { "Nearest", "Nearest Mipmap", "Linear", "Bilinear", "Bilinear Mipmap", "Trilinear", "Anisotropy" };
                page.appendCombo(
                        "Texture Render Mode",
                        STRING_ARRAY_RANGE( texture_mode ),
-                       {ImportExportCallback<int>::Import_t( TextureModeImportCaller( g_texture_mode ) ),
-                       ImportExportCallback<int>::Export_t( TextureModeExportCaller( g_texture_mode ) )}
+            make_property<TextureMode>(g_texture_mode)
                        );
        }
        {
@@ -758,8 +763,7 @@ void Textures_constructPreferences( PreferencesPage& page ){
                page.appendCombo(
                        "Hardware Texture Compression",
                        compression,
-                       {TextureCompressionImportCaller( g_texture_globals.m_nTextureCompressionFormat ),
-                       IntExportCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) )}
+            make_property<TextureCompression>(g_texture_globals.m_nTextureCompressionFormat)
                        );
        }
 }
@@ -771,20 +775,24 @@ void Textures_registerPreferencesPage(){
        PreferencesDialog_addDisplayPage( makeCallbackF(Textures_constructPage) );
 }
 
-void TextureCompression_importString( const char* string ){
-       g_texture_globals.m_nTextureCompressionFormat = static_cast<TextureCompressionFormat>( atoi( string ) );
-       Textures_UpdateTextureCompressionFormat();
-}
-typedef FreeCaller<void(const char*), TextureCompression_importString> TextureCompressionImportStringCaller;
+struct TextureCompressionPreference {
+       static void Export(const Callback<void(int)> &returnz) {
+               returnz(g_texture_globals.m_nTextureCompressionFormat);
+       }
 
+       static void Import(int value) {
+               g_texture_globals.m_nTextureCompressionFormat = static_cast<TextureCompressionFormat>( value );
+               Textures_UpdateTextureCompressionFormat();
+       }
+};
 
 void Textures_Construct(){
        g_texturesmap = new TexturesMap;
 
-       GlobalPreferenceSystem().registerPreference( "TextureCompressionFormat", TextureCompressionImportStringCaller(), IntExportStringCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) ) );
-       GlobalPreferenceSystem().registerPreference( "TextureFiltering", IntImportStringCaller( reinterpret_cast<int&>( g_texture_mode ) ), IntExportStringCaller( reinterpret_cast<int&>( g_texture_mode ) ) );
-       GlobalPreferenceSystem().registerPreference( "TextureQuality", IntImportStringCaller( g_Textures_textureQuality.m_latched ), IntExportStringCaller( g_Textures_textureQuality.m_latched ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Gamma", FloatImportStringCaller( g_texture_globals.fGamma ), FloatExportStringCaller( g_texture_globals.fGamma ) );
+       GlobalPreferenceSystem().registerPreference( "TextureCompressionFormat", make_property_string<TextureCompressionPreference>() );
+       GlobalPreferenceSystem().registerPreference( "TextureFiltering", make_property_string( reinterpret_cast<int&>( g_texture_mode ) ) );
+       GlobalPreferenceSystem().registerPreference( "TextureQuality", make_property_string( g_Textures_textureQuality.m_latched ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Gamma", make_property_string( g_texture_globals.fGamma ) );
 
        g_Textures_textureQuality.useLatched();
 
index a86575bff925ed257672d70c8d88058f07c0c97b..8a760e030b5932dcaf5c8612646921868b5457f8 100644 (file)
@@ -226,26 +226,26 @@ enum StartupShaders
        STARTUPSHADERS_COMMON,
 };
 
-void TextureBrowser_hideUnusedExport( const ImportExportCallback<bool>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+void TextureBrowser_hideUnusedExport( const Callback<void(bool)> & importer );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
 
-void TextureBrowser_showShadersExport( const ImportExportCallback<bool>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+void TextureBrowser_showShadersExport( const Callback<void(bool)> & importer );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
 
-void TextureBrowser_showShaderlistOnly( const ImportExportCallback<bool>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+void TextureBrowser_showShaderlistOnly( const Callback<void(bool)> & importer );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
 
-void TextureBrowser_fixedSize( const ImportExportCallback<bool>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_fixedSize> TextureBrowserFixedSizeExport;
+void TextureBrowser_fixedSize( const Callback<void(bool)> & importer );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_fixedSize> TextureBrowserFixedSizeExport;
 
-void TextureBrowser_filterMissing( const ImportExportCallback<bool>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterMissing> TextureBrowserFilterMissingExport;
+void TextureBrowser_filterMissing( const Callback<void(bool)> & importer );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterMissing> TextureBrowserFilterMissingExport;
 
-void TextureBrowser_filterFallback( const ImportExportCallback<bool>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterFallback> TextureBrowserFilterFallbackExport;
+void TextureBrowser_filterFallback( const Callback<void(bool)> & importer );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterFallback> TextureBrowserFilterFallbackExport;
 
-void TextureBrowser_enableAlpha( const ImportExportCallback<bool>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
+void TextureBrowser_enableAlpha( const Callback<void(bool)> & importer );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
 
 class TextureBrowser
 {
@@ -671,14 +671,19 @@ void TextureBrowser_activeShadersChanged( TextureBrowser& textureBrowser ){
        g_activeShadersChangedCallbacks();
 }
 
-void TextureBrowser_importShowScrollbar( TextureBrowser& textureBrowser, bool value ){
-       textureBrowser.m_showTextureScrollbar = value;
-       if ( textureBrowser.m_texture_scroll != 0 ) {
-               textureBrowser.m_texture_scroll.visible(textureBrowser.m_showTextureScrollbar);
-               TextureBrowser_updateScroll( textureBrowser );
+struct TextureBrowser_ShowScrollbar {
+       static void Export(const TextureBrowser &self, const Callback<void(bool)> &returnz) {
+               returnz(self.m_showTextureScrollbar);
        }
-}
-typedef ReferenceCaller<TextureBrowser, void(bool), TextureBrowser_importShowScrollbar> TextureBrowserImportShowScrollbarCaller;
+
+       static void Import(TextureBrowser &self, bool value) {
+               self.m_showTextureScrollbar = value;
+               if (self.m_texture_scroll) {
+                       self.m_texture_scroll.visible(self.m_showTextureScrollbar);
+                       TextureBrowser_updateScroll(self);
+               }
+       }
+};
 
 
 /*
@@ -863,40 +868,40 @@ void TextureBrowser_ShowTagSearchResult( TextureBrowser& textureBrowser, const c
 
 bool TextureBrowser_hideUnused();
 
-void TextureBrowser_hideUnusedExport( const ImportExportCallback<bool>::Import_t& importer ){
+void TextureBrowser_hideUnusedExport( const Callback<void(bool)> & importer ){
        importer( TextureBrowser_hideUnused() );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
 
-void TextureBrowser_showShadersExport( const ImportExportCallback<bool>::Import_t& importer ){
+void TextureBrowser_showShadersExport( const Callback<void(bool)> & importer ){
        importer( GlobalTextureBrowser().m_showShaders );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
 
-void TextureBrowser_showShaderlistOnly( const ImportExportCallback<bool>::Import_t& importer ){
+void TextureBrowser_showShaderlistOnly( const Callback<void(bool)> & importer ){
        importer( g_TextureBrowser_shaderlistOnly );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
 
-void TextureBrowser_fixedSize( const ImportExportCallback<bool>::Import_t& importer ){
+void TextureBrowser_fixedSize( const Callback<void(bool)> & importer ){
        importer( g_TextureBrowser_fixedSize );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_fixedSize> TextureBrowser_FixedSizeExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_fixedSize> TextureBrowser_FixedSizeExport;
 
-void TextureBrowser_filterMissing( const ImportExportCallback<bool>::Import_t& importer ){
+void TextureBrowser_filterMissing( const Callback<void(bool)> & importer ){
        importer( g_TextureBrowser_filterMissing );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterMissing> TextureBrowser_filterMissingExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterMissing> TextureBrowser_filterMissingExport;
 
-void TextureBrowser_filterFallback( const ImportExportCallback<bool>::Import_t& importer ){
+void TextureBrowser_filterFallback( const Callback<void(bool)> & importer ){
        importer( g_TextureBrowser_filterFallback );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_filterFallback> TextureBrowser_filterFallbackExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterFallback> TextureBrowser_filterFallbackExport;
 
-void TextureBrowser_enableAlpha( const ImportExportCallback<bool>::Import_t& importer ){
+void TextureBrowser_enableAlpha( const Callback<void(bool)> & importer ){
        importer( g_TextureBrowser_enableAlpha );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
 
 void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){
        if ( hideUnused ) {
@@ -2500,7 +2505,7 @@ void TextureBrowser_EnableAlpha(){
        TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
 }
 
-void TextureBrowser_exportTitle( const ImportExportCallback<const char *>::Import_t& importer ){
+void TextureBrowser_exportTitle( const Callback<void(const char *)> & importer ){
        StringOutputStream buffer( 64 );
        buffer << "Textures: ";
        if ( !string_empty( g_TextureBrowser_currentDirectory.c_str() ) ) {
@@ -2513,72 +2518,70 @@ void TextureBrowser_exportTitle( const ImportExportCallback<const char *>::Impor
        importer( buffer.c_str() );
 }
 
-
-void TextureScaleImport( TextureBrowser& textureBrowser, int value ){
-       switch ( value )
-       {
-       case 0:
-               TextureBrowser_setScale( textureBrowser, 10 );
-               break;
-       case 1:
-               TextureBrowser_setScale( textureBrowser, 25 );
-               break;
-       case 2:
-               TextureBrowser_setScale( textureBrowser, 50 );
-               break;
-       case 3:
-               TextureBrowser_setScale( textureBrowser, 100 );
-               break;
-       case 4:
-               TextureBrowser_setScale( textureBrowser, 200 );
-               break;
-       }
-}
-typedef ReferenceCaller<TextureBrowser, void(int), TextureScaleImport> TextureScaleImportCaller;
-
-void TextureScaleExport( TextureBrowser& textureBrowser, const ImportExportCallback<int>::Import_t& importer ){
-       switch ( textureBrowser.m_textureScale )
-       {
-       case 10:
-               importer( 0 );
-               break;
-       case 25:
-               importer( 1 );
-               break;
-       case 50:
-               importer( 2 );
-               break;
-       case 100:
-               importer( 3 );
-               break;
-       case 200:
-               importer( 4 );
-               break;
+struct TextureScale {
+       static void Export(const TextureBrowser &self, const Callback<void(int)> &returnz) {
+               switch (self.m_textureScale) {
+                       case 10:
+                               returnz(0);
+                               break;
+                       case 25:
+                               returnz(1);
+                               break;
+                       case 50:
+                               returnz(2);
+                               break;
+                       case 100:
+                               returnz(3);
+                               break;
+                       case 200:
+                               returnz(4);
+                               break;
+               }
        }
-}
-typedef ReferenceCaller<TextureBrowser, void(const ImportExportCallback<int>::Import_t&), TextureScaleExport> TextureScaleExportCaller;
 
+       static void Import(TextureBrowser &self, int value) {
+               switch (value) {
+                       case 0:
+                               TextureBrowser_setScale(self, 10);
+                               break;
+                       case 1:
+                               TextureBrowser_setScale(self, 25);
+                               break;
+                       case 2:
+                               TextureBrowser_setScale(self, 50);
+                               break;
+                       case 3:
+                               TextureBrowser_setScale(self, 100);
+                               break;
+                       case 4:
+                               TextureBrowser_setScale(self, 200);
+                               break;
+               }
+       }
+};
 
-void UniformTextureSizeImport( TextureBrowser& textureBrowser, int value ){
+struct UniformTextureSize {
+       static void Export(const TextureBrowser &self, const Callback<void(int)> &returnz) {
+               returnz(g_TextureBrowser.m_uniformTextureSize);
+       }
 
-       if ( value > 16 )
-               TextureBrowser_setUniformSize( textureBrowser, value );
-}
-typedef ReferenceCaller<TextureBrowser, void(int), UniformTextureSizeImport> UniformTextureSizeImportCaller;
+       static void Import(TextureBrowser &self, int value) {
+               if (value > 16)
+                       TextureBrowser_setUniformSize(self, value);
+       }
+};
 
 void TextureBrowser_constructPreferences( PreferencesPage& page ){
        page.appendCheckBox(
                "", "Texture scrollbar",
-               {TextureBrowserImportShowScrollbarCaller( GlobalTextureBrowser() ),
-               BoolExportCaller( GlobalTextureBrowser().m_showTextureScrollbar )}
+               make_property<TextureBrowser_ShowScrollbar>(GlobalTextureBrowser())
                );
        {
                const char* texture_scale[] = { "10%", "25%", "50%", "100%", "200%" };
                page.appendCombo(
                        "Texture Thumbnail Scale",
                        STRING_ARRAY_RANGE( texture_scale ),
-                       {ImportExportCallback<int>::Import_t( TextureScaleImportCaller( GlobalTextureBrowser() ) ),
-                       ImportExportCallback<int>::Export_t( TextureScaleExportCaller( GlobalTextureBrowser() ) )}
+                       make_property<TextureScale>(GlobalTextureBrowser())
                        );
        }
        page.appendSpinner(
@@ -2605,9 +2608,6 @@ void TextureBrowser_registerPreferencesPage(){
 #include "preferencesystem.h"
 #include "stringio.h"
 
-typedef ReferenceCaller<TextureBrowser, void(std::size_t), TextureBrowser_setScale> TextureBrowserSetScaleCaller;
-
-
 
 void TextureClipboard_textureSelected( const char* shader );
 
@@ -2630,25 +2630,17 @@ void TextureBrowser_Construct(){
        GlobalToggles_insert( "FilterFallback", makeCallbackF(TextureBrowser_FilterFallback), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hidenotex_item ) );
        GlobalToggles_insert( "EnableAlpha", makeCallbackF(TextureBrowser_EnableAlpha), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_enablealpha_item ) );
 
-       GlobalPreferenceSystem().registerPreference( "TextureScale",
-                                                                                                makeSizeStringImportCallback( TextureBrowserSetScaleCaller( g_TextureBrowser ) ),
-                                                                                                SizeExportStringCaller( g_TextureBrowser.m_textureScale )
-                                                                                                );
-       GlobalPreferenceSystem().registerPreference( "UniformTextureSize",
-                                                                                                makeIntStringImportCallback(UniformTextureSizeImportCaller(g_TextureBrowser)),
-                                                                                                IntExportStringCaller(g_TextureBrowser.m_uniformTextureSize) );
-       GlobalPreferenceSystem().registerPreference( "TextureScrollbar",
-                                                                                                makeBoolStringImportCallback( TextureBrowserImportShowScrollbarCaller( g_TextureBrowser ) ),
-                                                                                                BoolExportStringCaller( GlobalTextureBrowser().m_showTextureScrollbar )
-                                                                                                );
-       GlobalPreferenceSystem().registerPreference( "ShowShaders", BoolImportStringCaller( GlobalTextureBrowser().m_showShaders ), BoolExportStringCaller( GlobalTextureBrowser().m_showShaders ) );
-       GlobalPreferenceSystem().registerPreference( "ShowShaderlistOnly", BoolImportStringCaller( g_TextureBrowser_shaderlistOnly ), BoolExportStringCaller( g_TextureBrowser_shaderlistOnly ) );
-       GlobalPreferenceSystem().registerPreference( "FixedSize", BoolImportStringCaller( g_TextureBrowser_fixedSize ), BoolExportStringCaller( g_TextureBrowser_fixedSize ) );
-       GlobalPreferenceSystem().registerPreference( "FilterMissing", BoolImportStringCaller( g_TextureBrowser_filterMissing ), BoolExportStringCaller( g_TextureBrowser_filterMissing ) );
-       GlobalPreferenceSystem().registerPreference( "EnableAlpha", BoolImportStringCaller( g_TextureBrowser_enableAlpha ), BoolExportStringCaller( g_TextureBrowser_enableAlpha ) );
-       GlobalPreferenceSystem().registerPreference( "LoadShaders", IntImportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ), IntExportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
-       GlobalPreferenceSystem().registerPreference( "WheelMouseInc", SizeImportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ), SizeExportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors0", Vector3ImportStringCaller( GlobalTextureBrowser().color_textureback ), Vector3ExportStringCaller( GlobalTextureBrowser().color_textureback ) );
+       GlobalPreferenceSystem().registerPreference( "TextureScale", make_property_string<TextureScale>(g_TextureBrowser) );
+       GlobalPreferenceSystem().registerPreference( "UniformTextureSize", make_property_string<UniformTextureSize>(g_TextureBrowser) );
+       GlobalPreferenceSystem().registerPreference( "TextureScrollbar", make_property_string<TextureBrowser_ShowScrollbar>(GlobalTextureBrowser()));
+       GlobalPreferenceSystem().registerPreference( "ShowShaders", make_property_string( GlobalTextureBrowser().m_showShaders ) );
+       GlobalPreferenceSystem().registerPreference( "ShowShaderlistOnly", make_property_string( g_TextureBrowser_shaderlistOnly ) );
+       GlobalPreferenceSystem().registerPreference( "FixedSize", make_property_string( g_TextureBrowser_fixedSize ) );
+       GlobalPreferenceSystem().registerPreference( "FilterMissing", make_property_string( g_TextureBrowser_filterMissing ) );
+       GlobalPreferenceSystem().registerPreference( "EnableAlpha", make_property_string( g_TextureBrowser_enableAlpha ) );
+       GlobalPreferenceSystem().registerPreference( "LoadShaders", make_property_string( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
+       GlobalPreferenceSystem().registerPreference( "WheelMouseInc", make_property_string( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors0", make_property_string( GlobalTextureBrowser().color_textureback ) );
 
        g_TextureBrowser.shader = texdef_name_default();
 
index 31cd4d413bcf277fea2ec4b745f6d3da91b6ae27..2d5125e4b0ac59755ca9ad3a9164ef8660fc09eb 100644 (file)
@@ -23,6 +23,7 @@
 #define INCLUDED_TEXWINDOW_H
 
 #include <uilib/uilib.h>
+#include "property.h"
 #include "math/vector.h"
 #include "generic/callback.h"
 #include "signal/signalfwd.h"
@@ -44,8 +45,8 @@ void TextureBrowser_Construct();
 void TextureBrowser_Destroy();
 
 extern ui::Widget g_page_textures;
-void TextureBrowser_exportTitle( const ImportExportCallback<const char *>::Import_t& importer );
-typedef FreeCaller<void(const ImportExportCallback<const char *>::Import_t&), TextureBrowser_exportTitle> TextureBrowserExportTitleCaller;
+void TextureBrowser_exportTitle( const Callback<void(const char *)> & importer );
+typedef FreeCaller<void(const Callback<void(const char *)> &), TextureBrowser_exportTitle> TextureBrowserExportTitleCaller;
 
 const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser );
 void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const Vector3& colour );
index b5507c5c365abf02a41903f76e1a01bb4ea05778..fb741abdd9db93059102f34a1ced0a595a78d531 100644 (file)
@@ -377,29 +377,29 @@ void trackersRedo() const {
 
 void UndoLevels_importString( RadiantUndoSystem& undo, const char* value ){
        int levels;
-       Int_importString( levels, value );
+       PropertyImpl<int, const char *>::Import( levels, value );
        undo.setLevels( levels );
 }
 typedef ReferenceCaller<RadiantUndoSystem, void(const char*), UndoLevels_importString> UndoLevelsImportStringCaller;
-void UndoLevels_exportString( const RadiantUndoSystem& undo, const ImportExportCallback<const char *>::Import_t& importer ){
-       Int_exportString( static_cast<int>( undo.getLevels() ), importer );
+void UndoLevels_exportString( const RadiantUndoSystem& undo, const Callback<void(const char *)> & importer ){
+       PropertyImpl<int, const char *>::Export( static_cast<int>( undo.getLevels() ), importer );
 }
-typedef ConstReferenceCaller<RadiantUndoSystem, void(const ImportExportCallback<const char *>::Import_t&), UndoLevels_exportString> UndoLevelsExportStringCaller;
+typedef ConstReferenceCaller<RadiantUndoSystem, void(const Callback<void(const char *)> &), UndoLevels_exportString> UndoLevelsExportStringCaller;
 
 #include "generic/callback.h"
 
-void UndoLevelsImport( RadiantUndoSystem& self, int value ){
-       self.setLevels( value );
-}
-typedef ReferenceCaller<RadiantUndoSystem, void(int), UndoLevelsImport> UndoLevelsImportCaller;
-void UndoLevelsExport( const RadiantUndoSystem& self, const ImportExportCallback<int>::Import_t& importCallback ){
-       importCallback( static_cast<int>( self.getLevels() ) );
-}
-typedef ConstReferenceCaller<RadiantUndoSystem, void(const ImportExportCallback<int>::Import_t&), UndoLevelsExport> UndoLevelsExportCaller;
+struct UndoLevels {
+    static void Export(const RadiantUndoSystem &self, const Callback<void(int)> &returnz) {
+        returnz(static_cast<int>(self.getLevels()));
+    }
 
+    static void Import(RadiantUndoSystem &self, int value) {
+        self.setLevels(value);
+    }
+};
 
 void Undo_constructPreferences( RadiantUndoSystem& undo, PreferencesPage& page ){
-       page.appendSpinner( "Undo Queue Size", 64, 0, 1024, {ImportExportCallback<int>::Import_t( UndoLevelsImportCaller( undo ) ), ImportExportCallback<int>::Export_t( UndoLevelsExportCaller( undo ) )} );
+    page.appendSpinner("Undo Queue Size", 64, 0, 1024, make_property<UndoLevels>(undo));
 }
 void Undo_constructPage( RadiantUndoSystem& undo, PreferenceGroup& group ){
        PreferencesPage page( group.createPage( "Undo", "Undo Queue Settings" ) );
@@ -421,7 +421,7 @@ typedef UndoSystem Type;
 STRING_CONSTANT( Name, "*" );
 
 UndoSystemAPI(){
-       GlobalPreferenceSystem().registerPreference( "UndoLevels", makeIntStringImportCallback( UndoLevelsImportCaller( m_undosystem ) ), makeIntStringExportCallback( UndoLevelsExportCaller( m_undosystem ) ) );
+    GlobalPreferenceSystem().registerPreference("UndoLevels", make_property_string<UndoLevels>(m_undosystem));
 
        Undo_registerPreferencesPage( m_undosystem );
 }
index d5f6eb7c916442916abf1e4b1922ecbac20edc5f..8cc81fb11ed918f132574a628047fe35c66559bc 100644 (file)
@@ -201,10 +201,10 @@ void BuildMonitor_Construct(){
 
        g_WatchBSP_Enabled = !string_equal( g_pGameDescription->getKeyValue( "no_bsp_monitor" ), "1" );
 
-       GlobalPreferenceSystem().registerPreference( "WatchBSP", BoolImportStringCaller( g_WatchBSP_Enabled ), BoolExportStringCaller( g_WatchBSP_Enabled ) );
-       GlobalPreferenceSystem().registerPreference( "RunQuake2Run", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) );
-       GlobalPreferenceSystem().registerPreference( "LeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) );
-       GlobalPreferenceSystem().registerPreference( "SleepMode", BoolImportStringCaller( g_WatchBSP_DoSleep ), BoolExportStringCaller( g_WatchBSP_DoSleep ) );
+       GlobalPreferenceSystem().registerPreference( "WatchBSP", make_property_string( g_WatchBSP_Enabled ) );
+       GlobalPreferenceSystem().registerPreference( "RunQuake2Run", make_property_string( g_WatchBSP_RunQuake ) );
+       GlobalPreferenceSystem().registerPreference( "LeakStop", make_property_string( g_WatchBSP_LeakStop ) );
+       GlobalPreferenceSystem().registerPreference( "SleepMode", make_property_string( g_WatchBSP_DoSleep ) );
 
        Build_registerPreferencesPage();
 }
index 7897df0740783b24c5e69bc64b3cd47e00c1e11c..582d7105897b4582d8a2b89823ad65d56b79d2b9 100644 (file)
@@ -2587,97 +2587,97 @@ void ShowNamesToggle(){
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowNamesToggle> ShowNamesToggleCaller;
-void ShowNamesExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowNamesExport( const Callback<void(bool)> & importer ){
        importer( GlobalEntityCreator().getShowNames() );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowNamesExport> ShowNamesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowNamesExport> ShowNamesExportCaller;
 
 void ShowAnglesToggle(){
        GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowAnglesToggle> ShowAnglesToggleCaller;
-void ShowAnglesExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowAnglesExport( const Callback<void(bool)> & importer ){
        importer( GlobalEntityCreator().getShowAngles() );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowAnglesExport> ShowAnglesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowAnglesExport> ShowAnglesExportCaller;
 
 void ShowBlocksToggle(){
        g_xywindow_globals_private.show_blocks ^= 1;
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowBlocksToggle> ShowBlocksToggleCaller;
-void ShowBlocksExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowBlocksExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_blocks );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowBlocksExport> ShowBlocksExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowBlocksExport> ShowBlocksExportCaller;
 
 void ShowCoordinatesToggle(){
        g_xywindow_globals_private.show_coordinates ^= 1;
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowCoordinatesToggle> ShowCoordinatesToggleCaller;
-void ShowCoordinatesExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowCoordinatesExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_coordinates );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowCoordinatesExport> ShowCoordinatesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowCoordinatesExport> ShowCoordinatesExportCaller;
 
 void ShowOutlineToggle(){
        g_xywindow_globals_private.show_outline ^= 1;
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowOutlineToggle> ShowOutlineToggleCaller;
-void ShowOutlineExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowOutlineExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_outline );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowOutlineExport> ShowOutlineExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowOutlineExport> ShowOutlineExportCaller;
 
 void ShowAxesToggle(){
        g_xywindow_globals_private.show_axis ^= 1;
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowAxesToggle> ShowAxesToggleCaller;
-void ShowAxesExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowAxesExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_axis );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowAxesExport> ShowAxesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowAxesExport> ShowAxesExportCaller;
 
 void ShowWorkzoneToggle(){
        g_xywindow_globals_private.d_show_work ^= 1;
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowWorkzoneToggle> ShowWorkzoneToggleCaller;
-void ShowWorkzoneExport( const ImportExportCallback<bool>::Import_t& importer ){
+void ShowWorkzoneExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.d_show_work );
 }
-typedef FreeCaller<void(const ImportExportCallback<bool>::Import_t&), ShowWorkzoneExport> ShowWorkzoneExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowWorkzoneExport> ShowWorkzoneExportCaller;
 
 ShowNamesExportCaller g_show_names_caller;
-ImportExportCallback<bool>::Export_t g_show_names_callback( g_show_names_caller );
+Callback<void(const Callback<void(bool)> &)> g_show_names_callback( g_show_names_caller );
 ToggleItem g_show_names( g_show_names_callback );
 
 ShowAnglesExportCaller g_show_angles_caller;
-ImportExportCallback<bool>::Export_t g_show_angles_callback( g_show_angles_caller );
+Callback<void(const Callback<void(bool)> &)> g_show_angles_callback( g_show_angles_caller );
 ToggleItem g_show_angles( g_show_angles_callback );
 
 ShowBlocksExportCaller g_show_blocks_caller;
-ImportExportCallback<bool>::Export_t g_show_blocks_callback( g_show_blocks_caller );
+Callback<void(const Callback<void(bool)> &)> g_show_blocks_callback( g_show_blocks_caller );
 ToggleItem g_show_blocks( g_show_blocks_callback );
 
 ShowCoordinatesExportCaller g_show_coordinates_caller;
-ImportExportCallback<bool>::Export_t g_show_coordinates_callback( g_show_coordinates_caller );
+Callback<void(const Callback<void(bool)> &)> g_show_coordinates_callback( g_show_coordinates_caller );
 ToggleItem g_show_coordinates( g_show_coordinates_callback );
 
 ShowOutlineExportCaller g_show_outline_caller;
-ImportExportCallback<bool>::Export_t g_show_outline_callback( g_show_outline_caller );
+Callback<void(const Callback<void(bool)> &)> g_show_outline_callback( g_show_outline_caller );
 ToggleItem g_show_outline( g_show_outline_callback );
 
 ShowAxesExportCaller g_show_axes_caller;
-ImportExportCallback<bool>::Export_t g_show_axes_callback( g_show_axes_caller );
+Callback<void(const Callback<void(bool)> &)> g_show_axes_callback( g_show_axes_caller );
 ToggleItem g_show_axes( g_show_axes_callback );
 
 ShowWorkzoneExportCaller g_show_workzone_caller;
-ImportExportCallback<bool>::Export_t g_show_workzone_callback( g_show_workzone_caller );
+Callback<void(const Callback<void(bool)> &)> g_show_workzone_callback( g_show_workzone_caller );
 ToggleItem g_show_workzone( g_show_workzone_callback );
 
 void XYShow_registerCommands(){
@@ -2727,16 +2727,15 @@ void Clipper_registerPreferencesPage(){
 #include "stringio.h"
 
 
+struct ToggleShown_Bool {
+       static void Export(const ToggleShown &self, const Callback<void(bool)> &returnz) {
+               returnz(self.active());
+       }
 
-
-void ToggleShown_importBool( ToggleShown& self, bool value ){
-       self.set( value );
-}
-typedef ReferenceCaller<ToggleShown, void(bool), ToggleShown_importBool> ToggleShownImportBoolCaller;
-void ToggleShown_exportBool( const ToggleShown& self, const ImportExportCallback<bool>::Import_t& importer ){
-       importer( self.active() );
-}
-typedef ConstReferenceCaller<ToggleShown, void(const ImportExportCallback<bool>::Import_t&), ToggleShown_exportBool> ToggleShownExportBoolCaller;
+       static void Import(ToggleShown &self, bool value) {
+               self.set(value);
+       }
+};
 
 
 void XYWindow_Construct(){
@@ -2756,32 +2755,32 @@ void XYWindow_Construct(){
        GlobalCommands_insert( "Zoom100", makeCallbackF(XY_Zoom100) );
        GlobalCommands_insert( "CenterXYView", makeCallbackF(XY_Focus), Accelerator( GDK_KEY_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
 
-       GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) );
-
-       GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) );
-       GlobalPreferenceSystem().registerPreference( "ChaseMouse", BoolImportStringCaller( g_xywindow_globals_private.m_bChaseMouse ), BoolExportStringCaller( g_xywindow_globals_private.m_bChaseMouse ) );
-       GlobalPreferenceSystem().registerPreference( "SizePainting", BoolImportStringCaller( g_xywindow_globals_private.m_bSizePaint ), BoolExportStringCaller( g_xywindow_globals_private.m_bSizePaint ) );
-       GlobalPreferenceSystem().registerPreference( "NoStipple", BoolImportStringCaller( g_xywindow_globals.m_bNoStipple ), BoolExportStringCaller( g_xywindow_globals.m_bNoStipple ) );
-       GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", BoolImportStringCaller( g_xywindow_globals_private.show_coordinates ), BoolExportStringCaller( g_xywindow_globals_private.show_coordinates ) );
-       GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", BoolImportStringCaller( g_xywindow_globals_private.show_outline ), BoolExportStringCaller( g_xywindow_globals_private.show_outline ) );
-       GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) );
-       GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) );
-       GlobalPreferenceSystem().registerPreference( "ShowWorkzone", BoolImportStringCaller( g_xywindow_globals_private.d_show_work ), BoolExportStringCaller( g_xywindow_globals_private.d_show_work ) );
-
-       GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", Vector3ImportStringCaller( g_xywindow_globals.AxisColorX ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorX ) );
-       GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", Vector3ImportStringCaller( g_xywindow_globals.AxisColorY ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorY ) );
-       GlobalPreferenceSystem().registerPreference( "SI_AxisColors2", Vector3ImportStringCaller( g_xywindow_globals.AxisColorZ ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorZ ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors1", Vector3ImportStringCaller( g_xywindow_globals.color_gridback ), Vector3ExportStringCaller( g_xywindow_globals.color_gridback ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors2", Vector3ImportStringCaller( g_xywindow_globals.color_gridminor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridminor ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors3", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors6", Vector3ImportStringCaller( g_xywindow_globals.color_gridblock ), Vector3ExportStringCaller( g_xywindow_globals.color_gridblock ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors7", Vector3ImportStringCaller( g_xywindow_globals.color_gridtext ), Vector3ExportStringCaller( g_xywindow_globals.color_gridtext ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors8", Vector3ImportStringCaller( g_xywindow_globals.color_brushes ), Vector3ExportStringCaller( g_xywindow_globals.color_brushes ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors14", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor_alt ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor_alt ) );
-
-
-       GlobalPreferenceSystem().registerPreference( "XZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_xz_front_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_xz_front_shown ) ) );
-       GlobalPreferenceSystem().registerPreference( "YZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_yz_side_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_yz_side_shown ) ) );
+       GlobalPreferenceSystem().registerPreference( "ClipCaulk", make_property_string( g_clip_useCaulk ) );
+
+       GlobalPreferenceSystem().registerPreference( "NewRightClick", make_property_string( g_xywindow_globals.m_bRightClick ) );
+       GlobalPreferenceSystem().registerPreference( "ChaseMouse", make_property_string( g_xywindow_globals_private.m_bChaseMouse ) );
+       GlobalPreferenceSystem().registerPreference( "SizePainting", make_property_string( g_xywindow_globals_private.m_bSizePaint ) );
+       GlobalPreferenceSystem().registerPreference( "NoStipple", make_property_string( g_xywindow_globals.m_bNoStipple ) );
+       GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", make_property_string( g_xywindow_globals_private.show_coordinates ) );
+       GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", make_property_string( g_xywindow_globals_private.show_outline ) );
+       GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", make_property_string( g_xywindow_globals_private.show_axis ) );
+       GlobalPreferenceSystem().registerPreference( "CamXYUpdate", make_property_string( g_xywindow_globals_private.m_bCamXYUpdate ) );
+       GlobalPreferenceSystem().registerPreference( "ShowWorkzone", make_property_string( g_xywindow_globals_private.d_show_work ) );
+
+       GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", make_property_string( g_xywindow_globals.AxisColorX ) );
+       GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", make_property_string( g_xywindow_globals.AxisColorY ) );
+       GlobalPreferenceSystem().registerPreference( "SI_AxisColors2", make_property_string( g_xywindow_globals.AxisColorZ ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors1", make_property_string( g_xywindow_globals.color_gridback ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors2", make_property_string( g_xywindow_globals.color_gridminor ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors3", make_property_string( g_xywindow_globals.color_gridmajor ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors6", make_property_string( g_xywindow_globals.color_gridblock ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors7", make_property_string( g_xywindow_globals.color_gridtext ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors8", make_property_string( g_xywindow_globals.color_brushes ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors14", make_property_string( g_xywindow_globals.color_gridmajor_alt ) );
+
+
+       GlobalPreferenceSystem().registerPreference( "XZVIS", make_property_string<ToggleShown_Bool>( g_xz_front_shown ) );
+       GlobalPreferenceSystem().registerPreference( "YZVIS", make_property_string<ToggleShown_Bool>( g_yz_side_shown ) );
 
        Orthographic_registerPreferencesPage();
        Clipper_registerPreferencesPage();