From: TimePath Date: Mon, 1 Jan 2018 05:42:25 +0000 (+1100) Subject: Callback: cleanup X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1ede3dc63143af40210a3e9c1c601028359fac11;p=xonotic%2Fnetradiant.git Callback: cleanup --- diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index 7bc9814a..9d7bc4c5 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -96,8 +96,6 @@ void loadArchiveFile( const char* filename ){ archives.push_back( filename ); } -typedef FreeCaller LoadArchiveFileCaller; - void LoadTextureFile( const char* filename ){ std::string s_filename = filename; @@ -116,10 +114,8 @@ void LoadTextureFile( const char* filename ){ } } -typedef FreeCaller LoadTextureFileCaller; - void GetTextures( const char* extension ){ - GlobalFileSystem().forEachFile( "textures/", extension, LoadTextureFileCaller(), 0 ); + GlobalFileSystem().forEachFile("textures/", extension, makeCallbackF(LoadTextureFile), 0); } void LoadShaderList( const char* filename ){ @@ -128,14 +124,12 @@ void LoadShaderList( const char* filename ){ } } -typedef FreeCaller LoadShaderListCaller; - void GetAllShaders(){ - GlobalShaderSystem().foreachShaderName( LoadShaderListCaller() ); + GlobalShaderSystem().foreachShaderName(makeCallbackF(LoadShaderList)); } void GetArchiveList(){ - GlobalFileSystem().forEachArchive( LoadArchiveFileCaller() ); + GlobalFileSystem().forEachArchive(makeCallbackF(loadArchiveFile)); globalOutputStream() << "Shaderplug: " << (const Unsigned)Shaderplug::archives.size() << " archives found.\n"; } diff --git a/libs/generic/callback.cpp b/libs/generic/callback.cpp index 4776f575..423efcea 100644 --- a/libs/generic/callback.cpp +++ b/libs/generic/callback.cpp @@ -153,10 +153,8 @@ typedef ConstMember Test3Const; void test0free(){ } -typedef FreeCaller Test0FreeCaller; void test1free( A1 ){ } -typedef FreeCaller Test1FreeCaller; void test2free( A1, A2 ){ } typedef Function Test2Free; @@ -209,7 +207,7 @@ void instantiate(){ Test test; const Test& testconst = test; { - Callback a = Test0FreeCaller(); + Callback a = makeCallbackF(&test0free)(); Callback b = Test::Test0Caller( test ); b = makeCallback( Test::Test0(), test ); Callback c = Test::Test0ConstCaller( testconst ); @@ -223,7 +221,7 @@ void instantiate(){ } { typedef Callback TestCallback1; - TestCallback1 a = Test1FreeCaller(); + TestCallback1 a = makeCallbackF(&test1free)); TestCallback1 b = Test::Test1Caller( test ); b = makeCallback( Test::Test1(), test ); TestCallback1 c = Test::Test1ConstCaller( testconst ); diff --git a/libs/generic/callback.h b/libs/generic/callback.h index 9a1c9b17..03689e83 100644 --- a/libs/generic/callback.h +++ b/libs/generic/callback.h @@ -28,126 +28,137 @@ #include #include "functional.h" -template -inline void* convertToOpaque( Type* t ){ - return t; -} -template -inline void* convertToOpaque( const Type* t ){ - return const_cast( t ); -} -template -inline void* convertToOpaque( Type& t ){ - return &t; -} -template -inline void* convertToOpaque( const Type& t ){ - return const_cast( &t ); -} - +namespace detail { -template -class ConvertFromOpaque -{ -}; + template + class CallbackBase { + void *m_environment; + Thunk_ m_thunk; + public: + typedef Thunk_ Thunk; -template -class ConvertFromOpaque -{ -public: -static Type& apply( void* p ){ - return *static_cast( p ); -} -}; + CallbackBase(void *environment, Thunk function) : m_environment(environment), m_thunk(function) { + } -template -class ConvertFromOpaque -{ -public: -static const Type& apply( void* p ){ - return *static_cast( p ); -} -}; + void *getEnvironment() const { + return m_environment; + } + Thunk getThunk() const { + return m_thunk; + } + }; -template -class ConvertFromOpaque -{ -public: -static Type* apply( void* p ){ - return static_cast( p ); -} -}; + template + inline bool operator==(const CallbackBase &self, const CallbackBase &other) { + return self.getEnvironment() == other.getEnvironment() && self.getThunk() == other.getThunk(); + } -template -class ConvertFromOpaque -{ -public: -static const Type* apply( void* p ){ - return static_cast( p ); -} -}; + template + inline bool operator!=(const CallbackBase &self, const CallbackBase &other) { + return !(self == other); + } -template -class CallbackBase -{ -void* m_environment; -Thunk_ m_thunk; -public: -typedef Thunk_ Thunk; -CallbackBase( void* environment, Thunk function ) : m_environment( environment ), m_thunk( function ){ -} -void* getEnvironment() const { - return m_environment; -} -Thunk getThunk() const { - return m_thunk; -} -}; + template + inline bool operator<(const CallbackBase &self, const CallbackBase &other) { + return self.getEnvironment() < other.getEnvironment() || + (!(other.getEnvironment() < self.getEnvironment()) && self.getThunk() < other.getThunk()); + } -template -inline bool operator==( const CallbackBase& self, const CallbackBase& other ){ - return self.getEnvironment() == other.getEnvironment() && self.getThunk() == other.getThunk(); -} -template -inline bool operator!=( const CallbackBase& self, const CallbackBase& other ){ - return !( self == other ); -} -template -inline bool operator<( const CallbackBase& self, const CallbackBase& other ){ - return self.getEnvironment() < other.getEnvironment() || - ( !( other.getEnvironment() < self.getEnvironment() ) && self.getThunk() < other.getThunk() ); } -template -class BindFirstOpaqueN; +namespace detail { -template -class BindFirstOpaqueN { - FirstBound firstBound; -public: - explicit BindFirstOpaqueN(FirstBound firstBound) : firstBound(firstBound) { + template + inline void *convertToOpaque(Type *t) { + return t; } - R operator()(Ts... args) const { - return Caller::call(firstBound, args...); + template + inline void *convertToOpaque(const Type *t) { + return const_cast( t ); } - FirstBound getBound() const { - return firstBound; + template + inline void *convertToOpaque(Type &t) { + return &t; } - static R thunk(void *environment, Ts... args) { - return Caller::call(ConvertFromOpaque::apply(environment), args...); + template + inline void *convertToOpaque(const Type &t) { + return const_cast( &t ); } - void *getEnvironment() const { - return convertToOpaque(firstBound); - } -}; + + template + class ConvertFromOpaque { + }; + + template + class ConvertFromOpaque { + public: + static Type &apply(void *p) { + return *static_cast( p ); + } + }; + + template + class ConvertFromOpaque { + public: + static const Type &apply(void *p) { + return *static_cast( p ); + } + }; + + + template + class ConvertFromOpaque { + public: + static Type *apply(void *p) { + // illegal cast + return reinterpret_cast( p ); + } + }; + + template + class ConvertFromOpaque { + public: + static const Type *apply(void *p) { + return static_cast( p ); + } + }; + + template + class BindFirstOpaqueN; + + template + class BindFirstOpaqueN { + FirstBound firstBound; + public: + explicit BindFirstOpaqueN(FirstBound firstBound) : firstBound(firstBound) { + } + + R operator()(Ts... args) const { + return Caller::call(firstBound, args...); + } + + FirstBound getBound() const { + return firstBound; + } + + static R thunk(void *environment, Ts... args) { + return Caller::call(detail::ConvertFromOpaque::apply(environment), args...); + } + + void *getEnvironment() const { + return detail::convertToOpaque(firstBound); + } + }; + +} template -using BindFirstOpaque = BindFirstOpaqueN>; +using BindFirstOpaque = detail::BindFirstOpaqueN>; /// \brief Combines a void pointer with a pointer to a function which operates on a void pointer. /// @@ -156,8 +167,8 @@ template class Callback; template -class Callback : public CallbackBase { - using Base = CallbackBase; +class Callback : public detail::CallbackBase { + using Base = detail::CallbackBase; static R nullThunk(void *, Ts...) { } @@ -201,89 +212,109 @@ namespace detail { template using unshift = Arglist; }; + + template + using ArgShift = typename detail::Arglist::shift::type; + + template + using ArgUnshift = typename detail::Arglist::template unshift::type; } template -inline Callback>::shift::type> makeCallback(const Caller &caller, get_argument callee) { - return Callback>::shift::type>(BindFirstOpaque(callee)); +inline Callback>> makeCallback(const Caller &caller, get_argument callee) { + return BindFirstOpaque(callee); } +template +class CallerShiftFirst; + +template +class CallerShiftFirst { +public: + using func = R(FirstArgument, Ts...); + + static R call(FirstArgument, Ts... args) { + return Caller::call(args...); + } +}; + template inline Callback> makeStatelessCallback(const Caller &caller) { - return makeCallback(CallerShiftFirst>::template unshift::type>(), nullptr); + return makeCallback(CallerShiftFirst, void *>>(), nullptr); } /// \brief Forms a Callback from a non-const Environment reference and a non-const Environment member-function. -/// -/// \dontinclude generic/callback.cpp -/// \skipline MemberCaller0 example -/// \until end example - template member> -using MemberCaller = BindFirstOpaque::template instance>; +using MemberCaller = BindFirstOpaque>; -/// \brief Forms a Callback from a const Environment reference and a const Environment member-function. +/// \brief Constructs a Callback1 from a non-const \p functor /// -/// \dontinclude generic/callback.cpp -/// \skipline MemberCaller0 example -/// \until end example +/// \param Functor Must define \c first_argument_type and \c operator()(first_argument_type). +template +inline Callback> makeCallback(Functor &functor) { + return MemberCaller, &Functor::operator()>(functor); +} + +/// \brief Forms a Callback from a const Environment reference and a const Environment member-function. template member> -using ConstMemberCaller = BindFirstOpaque::template instance>; +using ConstMemberCaller = BindFirstOpaque>; -/// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference. +/// \brief Constructs a Callback1 from a const \p functor /// -/// \dontinclude generic/callback.cpp -/// \skipline ReferenceCaller0 example -/// \until end example -template::template unshift::type *func> -using ReferenceCaller = BindFirstOpaque::template unshift::type>::template instance>; +/// \param Functor Must define \c first_argument_type and const \c operator()(first_argument_type). +template +inline Callback> makeCallback(const Functor &functor) { + return ConstMemberCaller, &Functor::operator()>(functor); +} + +/// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference. +template *func> +using ReferenceCaller = BindFirstOpaque, func>>; /// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference. -/// -/// \dontinclude generic/callback.cpp -/// \skipline ReferenceCaller0 example -/// \until end example -template::template unshift::type *func> -using ConstReferenceCaller = BindFirstOpaque::template unshift::type>::template instance>; +template *func> +using ConstReferenceCaller = BindFirstOpaque, func>>; /// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer. -template::template unshift::type *func> -using PointerCaller = BindFirstOpaque::template unshift::type>::template instance>; +template *func> +using PointerCaller = BindFirstOpaque, func>>; /// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer. -template::template unshift::type *func> -using ConstPointerCaller = BindFirstOpaque::template unshift::type>::template instance>; +template *func> +using ConstPointerCaller = BindFirstOpaque, func>>; + +namespace detail { + template + class FreeCaller : public BindFirstOpaque>> { + public: + FreeCaller() : BindFirstOpaque>>(nullptr) { + } + }; + + template + struct freecallwrapper; + + template + struct freecallwrapper { + using func = R(R(Ts...), Ts...); + static R call(R(*f)(Ts...), Ts... args) { + // ideally, we'd get the implementation of the function type directly. Instead, it's passed in + return f(args...); + } + }; +} /// \brief Forms a Callback from a free function template -class FreeCaller : public BindFirstOpaque::template instance, - typename detail::Arglist::template unshift::type ->> { -public: - FreeCaller() - : BindFirstOpaque::template instance, - typename detail::Arglist::template unshift::type - >>(nullptr) { - } -}; +using FreeCaller = detail::FreeCaller, F>; -/// \brief Constructs a Callback1 from a non-const \p functor -/// -/// \param Functor Must define \c first_argument_type and \c operator()(first_argument_type). -template -inline Callback> makeCallback(Functor &functor) { - return Callback>(MemberCaller, &Functor::operator()>(functor)); +template +inline Callback makeCallbackF(F *func) { + // illegal cast + return Callback(reinterpret_cast(func), BindFirstOpaque>::thunk); } -/// \brief Constructs a Callback1 from a const \p functor -/// -/// \param Functor Must define \c first_argument_type and const \c operator()(first_argument_type). -template -inline Callback> makeCallback(const Functor &functor) { - return Callback>(ConstMemberCaller, &Functor::operator()>(functor)); -} +// todo: remove using BoolImportCallback = Callback; using BoolExportCallback = Callback; diff --git a/libs/generic/functional.h b/libs/generic/functional.h index 67161ffd..2b4fe1b2 100644 --- a/libs/generic/functional.h +++ b/libs/generic/functional.h @@ -72,6 +72,30 @@ using get_result_type = typename detail::Fn>::result_type; template using get_argument = typename detail::Fn>::template get; +namespace detail { + + template + class FunctionN; + + template + class FunctionN { + public: + template + class instance { + public: + using func = R(Ts...); + + static R call(Ts... args) { + return (f)(args...); + } + }; + }; + +} + +template +using Function = typename detail::FunctionN::template instance; + namespace detail { template struct MemberFunction; @@ -83,87 +107,57 @@ namespace detail { }; } -template -using MemberFunction = typename detail::MemberFunction::type; - -template -using ConstMemberFunction = typename detail::MemberFunction::type_const; - -template -class MemberN; +namespace detail { + template + class MemberN; -template -class MemberN { -public: - template - class instance { + template + class MemberN { public: - using func = R(Object &, Ts...); - - static R call(Object &object, Ts... args) { - return (object.*f)(args...); - } + template + class instance { + public: + using func = R(Object &, Ts...); + + static R call(Object &object, Ts... args) { + return (object.*f)(args...); + } + }; }; -}; - -template func> -using Member = typename MemberN::template instance; +} template -class ConstMemberN; - -template -class ConstMemberN { -public: - template - class instance { - public: - using func = R(const Object &, Ts...); - - static R call(const Object &object, Ts... args) { - return (object.*f)(args...); - } - }; -}; +using MemberFunction = typename detail::MemberFunction::type; -template func> -using ConstMember = typename ConstMemberN::template instance; +template func> +using Member = typename detail::MemberN::template instance; -template -class FunctionN; +namespace detail { + template + class ConstMemberN; -template -class FunctionN { -public: - template - class instance { + template + class ConstMemberN { public: - using func = R(Ts...); - - static R call(Ts... args) { - return (f)(args...); - } + template + class instance { + public: + using func = R(const Object &, Ts...); + + static R call(const Object &object, Ts... args) { + return (object.*f)(args...); + } + }; }; -}; - -template -using Function = typename FunctionN::template instance; - -template -class CallerShiftFirst; +} -template -class CallerShiftFirst { -public: - using func = R(FirstArgument, Ts...); +template +using ConstMemberFunction = typename detail::MemberFunction::type_const; - static R call(FirstArgument, Ts... args) { - return Caller::call(args...); - } -}; +template func> +using ConstMember = typename detail::ConstMemberN::template instance; -template -class FunctorNInvoke; +// misc namespace detail { template @@ -181,33 +175,36 @@ namespace detail { template using seq_new = typename gens::type; -} -template -class FunctorNInvoke { - std::tuple args; + template + class FunctorNInvoke; - template - struct caller; + template + class FunctorNInvoke { + std::tuple args; - template - struct caller> { - static inline R call(FunctorNInvoke *self, Functor functor) { - (void) self; - return functor(std::get(self->args)...); - } - }; + template + struct caller; + + template + struct caller> { + static inline R call(FunctorNInvoke *self, Functor functor) { + (void) self; + return functor(std::get(self->args)...); + } + }; -public: - FunctorNInvoke(Ts... args) : args(args...) { - } + public: + FunctorNInvoke(Ts... args) : args(args...) { + } - inline R operator()(Functor functor) { - return caller>::call(this, functor); - } -}; + inline R operator()(Functor functor) { + return caller>::call(this, functor); + } + }; +} template -using FunctorInvoke = FunctorNInvoke>; +using FunctorInvoke = detail::FunctorNInvoke>; #endif diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index 6a1ec968..0499bee5 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -1442,9 +1442,6 @@ void LoadShaderFile( const char* filename ){ } } -typedef FreeCaller LoadShaderFileCaller; - - void loadGuideFile( const char* filename ){ StringOutputStream fullname( 256 ); fullname << "guides/" << filename; @@ -1466,9 +1463,6 @@ void loadGuideFile( const char* filename ){ } } -typedef FreeCaller LoadGuideFileCaller; - - CShader* Try_Shader_ForName( const char* name ){ { shaders_t::iterator i = g_ActiveShaders.find( name ); @@ -1567,9 +1561,6 @@ void ShaderList_addShaderFile( const char* dirstring ){ } } -typedef FreeCaller AddShaderFileCaller; - - /* ================== BuildShaderList @@ -1624,8 +1615,6 @@ void ShaderList_addFromArchive( const char *archivename ){ } } -typedef FreeCaller AddShaderListFromArchiveCaller; - #include "stream/filestream.h" bool shaderlist_findOrInstall( const char* enginePath, const char* toolsPath, const char* shaderPath, const char* gamename ){ @@ -1653,7 +1642,7 @@ bool shaderlist_findOrInstall( const char* enginePath, const char* toolsPath, co void Shaders_Load(){ if ( g_shaderLanguage == SHADERLANGUAGE_QUAKE4 ) { - GlobalFileSystem().forEachFile( "guides/", "guide", LoadGuideFileCaller(), 0 ); + GlobalFileSystem().forEachFile("guides/", "guide", makeCallbackF(loadGuideFile), 0); } const char* shaderPath = GlobalRadiant().getGameDescriptionKeyValue( "shaderpath" ); @@ -1675,12 +1664,12 @@ void Shaders_Load(){ shaderlist_findOrInstall( enginePath, toolsPath, path.c_str(), gamename ); } - GlobalFileSystem().forEachArchive( AddShaderListFromArchiveCaller(), false, true ); + GlobalFileSystem().forEachArchive(makeCallbackF(ShaderList_addFromArchive), false, true); DumpUnreferencedShaders(); } else { - GlobalFileSystem().forEachFile( path.c_str(), g_shadersExtension, AddShaderFileCaller(), 0 ); + GlobalFileSystem().forEachFile(path.c_str(), g_shadersExtension, makeCallbackF(ShaderList_addShaderFile), 0); } GSList *lst = l_shaderfiles; diff --git a/radiant/autosave.cpp b/radiant/autosave.cpp index 5cb91ea8..effb111e 100644 --- a/radiant/autosave.cpp +++ b/radiant/autosave.cpp @@ -186,7 +186,7 @@ void Autosave_constructPage( PreferenceGroup& group ){ Autosave_constructPreferences( page ); } void Autosave_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage(makeCallbackF(Autosave_constructPage)); } diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index 528341d9..0e190e6c 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -1216,7 +1216,7 @@ void Texdef_ToggleMoveLock(){ void Brush_registerCommands(){ - GlobalToggles_insert( "TogTexLock", FreeCaller(), ToggleItem::AddCallbackCaller( g_texdef_movelock_item ), Accelerator( 'T', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalToggles_insert( "TogTexLock", makeCallbackF(Texdef_ToggleMoveLock), ToggleItem::AddCallbackCaller( g_texdef_movelock_item ), Accelerator( 'T', (GdkModifierType)GDK_SHIFT_MASK ) ); GlobalCommands_insert( "BrushPrism", BrushPrefab::SetCaller( g_brushprism ) ); GlobalCommands_insert( "BrushCone", BrushPrefab::SetCaller( g_brushcone ) ); @@ -1231,12 +1231,12 @@ void Brush_registerCommands(){ GlobalCommands_insert( "Brush8Sided", BrushMakeSided::SetCaller( g_brushmakesided8 ), Accelerator( '8', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "Brush9Sided", BrushMakeSided::SetCaller( g_brushmakesided9 ), Accelerator( '9', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ClipSelected", FreeCaller(), Accelerator( GDK_KEY_Return ) ); - GlobalCommands_insert( "SplitSelected", FreeCaller(), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "FlipClip", FreeCaller(), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ClipSelected", makeCallbackF(ClipSelected), Accelerator( GDK_KEY_Return ) ); + GlobalCommands_insert( "SplitSelected", makeCallbackF(SplitSelected), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "FlipClip", makeCallbackF(FlipClipper), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "MakeDetail", FreeCaller(), Accelerator( 'M', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "MakeStructural", FreeCaller(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "MakeDetail", makeCallbackF(Select_MakeDetail), Accelerator( 'M', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "MakeStructural", makeCallbackF(Select_MakeStructural), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); } void Brush_constructMenu( ui::Menu menu ){ diff --git a/radiant/brushmodule.cpp b/radiant/brushmodule.cpp index bd51cf55..02e54167 100644 --- a/radiant/brushmodule.cpp +++ b/radiant/brushmodule.cpp @@ -45,18 +45,16 @@ bool getTextureLockEnabled(){ void Face_importSnapPlanes( bool value ){ Face::m_quantise = value ? quantiseInteger : quantiseFloating; } -typedef FreeCaller FaceImportSnapPlanesCaller; void Face_exportSnapPlanes( const BoolImportCallback& importer ){ importer( Face::m_quantise == quantiseInteger ); } -typedef FreeCaller FaceExportSnapPlanesCaller; void Brush_constructPreferences( PreferencesPage& page ){ page.appendCheckBox( "", "Snap planes to integer grid", - FaceImportSnapPlanesCaller(), - FaceExportSnapPlanesCaller() + makeCallbackF(Face_importSnapPlanes), + makeCallbackF(Face_exportSnapPlanes) ); page.appendEntry( "Default texture scale", @@ -80,7 +78,7 @@ void Brush_constructPage( PreferenceGroup& group ){ Brush_constructPreferences( page ); } void Brush_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(Brush_constructPage) ); } void Brush_unlatchPreferences(){ @@ -155,11 +153,11 @@ void Brush_Construct( EBrushType type ){ } GlobalPreferenceSystem().registerPreference( "TextureLock", BoolImportStringCaller( g_brush_texturelock_enabled ), BoolExportStringCaller( g_brush_texturelock_enabled ) ); - GlobalPreferenceSystem().registerPreference( "BrushSnapPlanes", makeBoolStringImportCallback( FaceImportSnapPlanesCaller() ), makeBoolStringExportCallback( FaceExportSnapPlanesCaller() ) ); + GlobalPreferenceSystem().registerPreference( "BrushSnapPlanes", makeBoolStringImportCallback( FreeCaller() ), makeBoolStringExportCallback( FreeCaller() ) ); GlobalPreferenceSystem().registerPreference( "TexdefDefaultScale", FloatImportStringCaller( g_texdef_default_scale ), FloatExportStringCaller( g_texdef_default_scale ) ); GridStatus_getTextureLockEnabled = getTextureLockEnabled; - g_texture_lock_status_changed = FreeCaller(); + g_texture_lock_status_changed = makeCallbackF(GridStatus_onTextureLockEnabledChanged); } void Brush_Destroy(){ diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index c505b1be..273f2b01 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -1391,14 +1391,12 @@ void render( const Matrix4& modelview, const Matrix4& projection ){ void ShowStatsToggle(){ g_camwindow_globals_private.m_showStats ^= 1; } -typedef FreeCaller ShowStatsToggleCaller; void ShowStatsExport( const BoolImportCallback& importer ){ importer( g_camwindow_globals_private.m_showStats ); } -typedef FreeCaller ShowStatsExportCaller; -ShowStatsExportCaller g_show_stats_caller; +FreeCaller g_show_stats_caller; BoolExportCallback g_show_stats_callback( g_show_stats_caller ); ToggleItem g_show_stats( g_show_stats_callback ); @@ -1839,7 +1837,7 @@ void Camera_constructPage( PreferenceGroup& group ){ Camera_constructPreferences( page ); } void Camera_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(Camera_constructPage) ); } #include "preferencesystem.h" @@ -1868,25 +1866,25 @@ void CameraSpeed_decrease(){ /// \brief Initialisation for things that have the same lifespan as this module. void CamWnd_Construct(){ - GlobalCommands_insert( "CenterView", FreeCaller(), Accelerator( GDK_KEY_End ) ); + GlobalCommands_insert( "CenterView", makeCallbackF(GlobalCamera_ResetAngles), Accelerator( GDK_KEY_End ) ); - GlobalToggles_insert( "ToggleCubicClip", FreeCaller(), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "CubicClipZoomIn", FreeCaller(), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "CubicClipZoomOut", FreeCaller(), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalToggles_insert( "ToggleCubicClip", makeCallbackF(Camera_ToggleFarClip), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "CubicClipZoomIn", makeCallbackF(Camera_CubeIn), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "CubicClipZoomOut", makeCallbackF(Camera_CubeOut), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "UpFloor", FreeCaller(), Accelerator( GDK_KEY_Prior ) ); - GlobalCommands_insert( "DownFloor", FreeCaller(), Accelerator( GDK_KEY_Next ) ); + GlobalCommands_insert( "UpFloor", makeCallbackF(Camera_ChangeFloorUp), Accelerator( GDK_KEY_Prior ) ); + GlobalCommands_insert( "DownFloor", makeCallbackF(Camera_ChangeFloorDown), Accelerator( GDK_KEY_Next ) ); GlobalToggles_insert( "ToggleCamera", ToggleShown::ToggleCaller( g_camera_shown ), ToggleItem::AddCallbackCaller( g_camera_shown.m_item ), Accelerator( 'C', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "LookThroughSelected", FreeCaller() ); - GlobalCommands_insert( "LookThroughCamera", FreeCaller() ); + GlobalCommands_insert( "LookThroughSelected", makeCallbackF(GlobalCamera_LookThroughSelected) ); + GlobalCommands_insert( "LookThroughCamera", makeCallbackF(GlobalCamera_LookThroughCamera) ); if ( g_pGameDescription->mGameType == "doom3" ) { - GlobalCommands_insert( "TogglePreview", FreeCaller(), Accelerator( GDK_KEY_F3 ) ); + GlobalCommands_insert( "TogglePreview", makeCallbackF(CamWnd_TogglePreview), Accelerator( GDK_KEY_F3 ) ); } - GlobalCommands_insert( "CameraSpeedInc", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "CameraSpeedDec", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CameraSpeedInc", makeCallbackF(CameraSpeed_increase), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CameraSpeedDec", makeCallbackF(CameraSpeed_decrease), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) ); GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_KEY_Up ) ); GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_KEY_Down ) ); @@ -1905,7 +1903,7 @@ void CamWnd_Construct(){ GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( GDK_KEY_Left ) ); GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( GDK_KEY_Right ) ); - GlobalToggles_insert( "ShowStats", ShowStatsToggleCaller(), ToggleItem::AddCallbackCaller( g_show_stats ) ); + 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 ) ); diff --git a/radiant/eclass_doom3.cpp b/radiant/eclass_doom3.cpp index 7a7da472..4c7525ea 100644 --- a/radiant/eclass_doom3.cpp +++ b/radiant/eclass_doom3.cpp @@ -689,7 +689,7 @@ EntityClassDoom3() : m_unrealised( 2 ){ void realise(){ if ( --m_unrealised == 0 ) { globalOutputStream() << "searching vfs directory " << makeQuoted( "def" ) << " for *.def\n"; - GlobalFileSystem().forEachFile( "def/", "def", FreeCaller() ); + GlobalFileSystem().forEachFile( "def/", "def", makeCallbackF(EntityClassDoom3_loadFile) ); { for ( Models::iterator i = g_models.begin(); i != g_models.end(); ++i ) diff --git a/radiant/entity.cpp b/radiant/entity.cpp index f480a223..feb08f6a 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -564,7 +564,7 @@ void Entity_constructPage( PreferenceGroup& group ){ Entity_constructPreferences( page ); } void Entity_registerPreferencesPage(){ - PreferencesDialog_addDisplayPage( FreeCaller() ); + PreferencesDialog_addDisplayPage( makeCallbackF(Entity_constructPage) ); } @@ -584,12 +584,12 @@ void Entity_constructMenu( ui::Menu menu ){ #include "stringio.h" void Entity_Construct(){ - GlobalCommands_insert( "EntityColor", FreeCaller(), Accelerator( 'K' ) ); - GlobalCommands_insert( "NormalizeColor", FreeCaller() ); - GlobalCommands_insert( "ConnectSelection", FreeCaller(), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "KillConnectSelection", FreeCaller(), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) ); - GlobalCommands_insert( "GroupSelection", FreeCaller() ); - GlobalCommands_insert( "UngroupSelection", FreeCaller() ); + GlobalCommands_insert( "EntityColor", makeCallbackF(Entity_setColour), Accelerator( 'K' ) ); + GlobalCommands_insert( "NormalizeColor", makeCallbackF(Entity_normalizeColor) ); + GlobalCommands_insert( "ConnectSelection", makeCallbackF(Entity_connectSelected), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "KillConnectSelection", makeCallbackF(Entity_killconnectSelected), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) ); + 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 ) ); diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 852b7639..39f61093 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -1063,7 +1063,7 @@ class EntityInspectorDraw { IdleDraw m_idleDraw; public: -EntityInspectorDraw() : m_idleDraw( FreeCaller( ) ){ +EntityInspectorDraw() : m_idleDraw( makeCallbackF(EntityInspector_updateKeyValues) ){ } void queueDraw(){ m_idleDraw.queueDraw(); diff --git a/radiant/filters.cpp b/radiant/filters.cpp index be7576c3..65472334 100644 --- a/radiant/filters.cpp +++ b/radiant/filters.cpp @@ -218,8 +218,8 @@ void Filters_constructMenu( ui::Menu menu_in_menu ){ void ConstructFilters(){ GlobalPreferenceSystem().registerPreference( "SI_Exclude", SizeImportStringCaller( g_filters_globals.exclude ), SizeExportStringCaller( g_filters_globals.exclude ) ); - GlobalCommands_insert( "InvertFilters", FreeCaller() ); - GlobalCommands_insert( "ResetFilters", FreeCaller() ); + GlobalCommands_insert( "InvertFilters", makeCallbackF(InvertFilters) ); + GlobalCommands_insert( "ResetFilters", makeCallbackF(ResetFilters) ); add_filter_command( EXCLUDE_WORLD, "FilterWorldBrushes", Accelerator( '1', (GdkModifierType)GDK_MOD1_MASK ) ); add_filter_command( EXCLUDE_ENT, "FilterEntities", Accelerator( '2', (GdkModifierType)GDK_MOD1_MASK ) ); diff --git a/radiant/grid.cpp b/radiant/grid.cpp index 08b9bb86..fa255b44 100644 --- a/radiant/grid.cpp +++ b/radiant/grid.cpp @@ -192,10 +192,10 @@ void ToggleGridSnap(){ } void Grid_registerCommands(){ - GlobalCommands_insert( "GridDown", FreeCaller(), Accelerator( '[' ) ); - GlobalCommands_insert( "GridUp", FreeCaller(), Accelerator( ']' ) ); + GlobalCommands_insert( "GridDown", makeCallbackF(GridPrev), Accelerator( '[' ) ); + GlobalCommands_insert( "GridUp", makeCallbackF(GridNext), Accelerator( ']' ) ); - GlobalCommands_insert( "ToggleGridSnap", FreeCaller() ); + GlobalCommands_insert( "ToggleGridSnap", makeCallbackF(ToggleGridSnap) ); GlobalToggles_insert( "SetGrid0.125", GridMenuItem::SetCaller( g_gridMenu0125 ), ToggleItem::AddCallbackCaller( g_gridMenu0125.m_item ) ); GlobalToggles_insert( "SetGrid0.25", GridMenuItem::SetCaller( g_gridMenu025 ), ToggleItem::AddCallbackCaller( g_gridMenu025.m_item ) ); @@ -246,7 +246,7 @@ void Grid_constructPage( PreferenceGroup& group ){ Grid_constructPreferences( page ); } void Grid_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(Grid_constructPage) ); } void Grid_construct(){ diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index f175bc51..a926d0fb 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -197,7 +197,7 @@ void GroupDialog_updatePageTitle( ui::Widget page ){ void GroupDialog_Construct(){ GlobalPreferenceSystem().registerPreference( "EntityWnd", WindowPositionTrackerImportStringCaller( g_GroupDlg.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_GroupDlg.m_position_tracker ) ); - GlobalCommands_insert( "ViewEntityInfo", FreeCaller(), Accelerator( 'N' ) ); + GlobalCommands_insert( "ViewEntityInfo", makeCallbackF(GroupDialog_ToggleShow), Accelerator( 'N' ) ); } void GroupDialog_Destroy(){ } diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 64298050..6ae00e3d 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -430,7 +430,7 @@ void Paths_constructPage( PreferenceGroup& group ){ Paths_constructPreferences( page ); } void Paths_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(Paths_constructPage) ); } @@ -2085,7 +2085,7 @@ ui::MenuItem create_misc_menu(){ } #if 0 - create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller() ); + create_menu_item_with_mnemonic( menu, "_Benchmark", makeCallbackF(GlobalCamera_Benchmark) ); #endif menu.add(create_colours_menu()); @@ -2093,7 +2093,7 @@ ui::MenuItem create_misc_menu(){ create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" ); // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 // create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller()); - create_menu_item_with_mnemonic( menu, "_Background select", FreeCaller() ); + create_menu_item_with_mnemonic( menu, "_Background select", makeCallbackF(WXY_BackgroundSelect) ); return misc_menu_item; } @@ -2150,9 +2150,9 @@ ui::MenuItem create_help_menu(){ // it will take care of hooking the Sys_OpenURL calls etc. create_game_help_menu( menu ); - create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller() ); - create_menu_item_with_mnemonic( menu, "Shortcuts list", FreeCaller() ); - create_menu_item_with_mnemonic( menu, "_About", FreeCaller() ); + create_menu_item_with_mnemonic( menu, "Bug report", makeCallbackF(OpenBugReportURL) ); + create_menu_item_with_mnemonic( menu, "Shortcuts list", makeCallbackF(DoCommandListDlg) ); + create_menu_item_with_mnemonic( menu, "_About", makeCallbackF(DoAbout) ); return help_menu_item; } @@ -3155,7 +3155,7 @@ void Layout_constructPage( PreferenceGroup& group ){ } void Layout_registerPreferencesPage(){ - PreferencesDialog_addInterfacePage( FreeCaller() ); + PreferencesDialog_addInterfacePage( makeCallbackF(Layout_constructPage) ); } @@ -3163,75 +3163,75 @@ void Layout_registerPreferencesPage(){ #include "stringio.h" void MainFrame_Construct(){ - GlobalCommands_insert( "OpenManual", FreeCaller(), Accelerator( GDK_KEY_F1 ) ); - - GlobalCommands_insert( "Sleep", FreeCaller(), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "NewMap", FreeCaller() ); - GlobalCommands_insert( "OpenMap", FreeCaller(), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ImportMap", FreeCaller() ); - GlobalCommands_insert( "SaveMap", FreeCaller(), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "SaveMapAs", FreeCaller() ); - GlobalCommands_insert( "ExportSelected", FreeCaller() ); - GlobalCommands_insert( "SaveRegion", FreeCaller() ); - GlobalCommands_insert( "RefreshReferences", FreeCaller() ); - GlobalCommands_insert( "ProjectSettings", FreeCaller() ); - GlobalCommands_insert( "Exit", FreeCaller() ); - - GlobalCommands_insert( "Undo", FreeCaller(), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "Redo", FreeCaller(), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "Copy", FreeCaller(), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "Paste", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "PasteToCamera", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "CloneSelection", FreeCaller(), Accelerator( GDK_KEY_space ) ); - GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller(), Accelerator( GDK_KEY_space, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "DeleteSelection", FreeCaller(), Accelerator( GDK_KEY_BackSpace ) ); - GlobalCommands_insert( "ParentSelection", FreeCaller() ); - GlobalCommands_insert( "UnSelectSelection", FreeCaller(), Accelerator( GDK_KEY_Escape ) ); - GlobalCommands_insert( "InvertSelection", FreeCaller(), Accelerator( 'I' ) ); - GlobalCommands_insert( "SelectInside", FreeCaller() ); - GlobalCommands_insert( "SelectTouching", FreeCaller() ); - GlobalCommands_insert( "ExpandSelectionToEntities", FreeCaller(), Accelerator( 'E', (GdkModifierType)( GDK_MOD1_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "Preferences", FreeCaller(), Accelerator( 'P' ) ); - - GlobalCommands_insert( "ToggleConsole", FreeCaller(), Accelerator( 'O' ) ); - GlobalCommands_insert( "ToggleEntityInspector", FreeCaller(), Accelerator( 'N' ) ); - GlobalCommands_insert( "EntityList", FreeCaller(), Accelerator( 'L' ) ); - - GlobalCommands_insert( "ShowHidden", FreeCaller(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "HideSelected", FreeCaller(), Accelerator( 'H' ) ); - - GlobalToggles_insert( "DragVertices", FreeCaller(), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) ); - GlobalToggles_insert( "DragEdges", FreeCaller(), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) ); - GlobalToggles_insert( "DragFaces", FreeCaller(), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) ); - - GlobalCommands_insert( "MirrorSelectionX", FreeCaller() ); - GlobalCommands_insert( "RotateSelectionX", FreeCaller() ); - GlobalCommands_insert( "MirrorSelectionY", FreeCaller() ); - GlobalCommands_insert( "RotateSelectionY", FreeCaller() ); - GlobalCommands_insert( "MirrorSelectionZ", FreeCaller() ); - GlobalCommands_insert( "RotateSelectionZ", FreeCaller() ); - - GlobalCommands_insert( "ArbitraryRotation", FreeCaller() ); - GlobalCommands_insert( "ArbitraryScale", FreeCaller() ); - - GlobalCommands_insert( "BuildMenuCustomize", FreeCaller() ); - - GlobalCommands_insert( "FindBrush", FreeCaller() ); - - GlobalCommands_insert( "MapInfo", FreeCaller(), Accelerator( 'M' ) ); - - - GlobalToggles_insert( "ToggleClipper", FreeCaller(), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) ); - - GlobalToggles_insert( "MouseTranslate", FreeCaller(), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) ); - GlobalToggles_insert( "MouseRotate", FreeCaller(), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) ); - GlobalToggles_insert( "MouseScale", FreeCaller(), ToggleItem::AddCallbackCaller( g_scalemode_button ) ); - GlobalToggles_insert( "MouseDrag", FreeCaller(), ToggleItem::AddCallbackCaller( g_dragmode_button ), Accelerator( 'Q' ) ); - - GlobalCommands_insert( "ColorSchemeOriginal", FreeCaller() ); - GlobalCommands_insert( "ColorSchemeQER", FreeCaller() ); - GlobalCommands_insert( "ColorSchemeBlackAndGreen", FreeCaller() ); - GlobalCommands_insert( "ColorSchemeYdnar", FreeCaller() ); + GlobalCommands_insert( "OpenManual", makeCallbackF(OpenHelpURL), Accelerator( GDK_KEY_F1 ) ); + + GlobalCommands_insert( "Sleep", makeCallbackF(thunk_OnSleep), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "NewMap", makeCallbackF(NewMap) ); + GlobalCommands_insert( "OpenMap", makeCallbackF(OpenMap), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ImportMap", makeCallbackF(ImportMap) ); + GlobalCommands_insert( "SaveMap", makeCallbackF(SaveMap), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "SaveMapAs", makeCallbackF(SaveMapAs) ); + GlobalCommands_insert( "ExportSelected", makeCallbackF(ExportMap) ); + GlobalCommands_insert( "SaveRegion", makeCallbackF(SaveRegion) ); + GlobalCommands_insert( "RefreshReferences", makeCallbackF(VFS_Refresh) ); + GlobalCommands_insert( "ProjectSettings", makeCallbackF(DoProjectSettings) ); + GlobalCommands_insert( "Exit", makeCallbackF(Exit) ); + + GlobalCommands_insert( "Undo", makeCallbackF(Undo), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Redo", makeCallbackF(Redo), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Copy", makeCallbackF(Copy), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Paste", makeCallbackF(Paste), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PasteToCamera", makeCallbackF(PasteToCamera), Accelerator( 'V', (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "CloneSelection", makeCallbackF(Selection_Clone), Accelerator( GDK_KEY_space ) ); + GlobalCommands_insert( "CloneSelectionAndMakeUnique", makeCallbackF(Selection_Clone_MakeUnique), Accelerator( GDK_KEY_space, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "DeleteSelection", makeCallbackF(deleteSelection), Accelerator( GDK_KEY_BackSpace ) ); + GlobalCommands_insert( "ParentSelection", makeCallbackF(Scene_parentSelected) ); + GlobalCommands_insert( "UnSelectSelection", makeCallbackF(Selection_Deselect), Accelerator( GDK_KEY_Escape ) ); + GlobalCommands_insert( "InvertSelection", makeCallbackF(Select_Invert), Accelerator( 'I' ) ); + GlobalCommands_insert( "SelectInside", makeCallbackF(Select_Inside) ); + GlobalCommands_insert( "SelectTouching", makeCallbackF(Select_Touching) ); + GlobalCommands_insert( "ExpandSelectionToEntities", makeCallbackF(Scene_ExpandSelectionToEntities), Accelerator( 'E', (GdkModifierType)( GDK_MOD1_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "Preferences", makeCallbackF(PreferencesDialog_showDialog), Accelerator( 'P' ) ); + + GlobalCommands_insert( "ToggleConsole", makeCallbackF(Console_ToggleShow), Accelerator( 'O' ) ); + GlobalCommands_insert( "ToggleEntityInspector", makeCallbackF(EntityInspector_ToggleShow), Accelerator( 'N' ) ); + GlobalCommands_insert( "EntityList", makeCallbackF(EntityList_toggleShown), Accelerator( 'L' ) ); + + GlobalCommands_insert( "ShowHidden", makeCallbackF(Select_ShowAllHidden), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "HideSelected", makeCallbackF(HideSelected), Accelerator( 'H' ) ); + + GlobalToggles_insert( "DragVertices", makeCallbackF(SelectVertexMode), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) ); + GlobalToggles_insert( "DragEdges", makeCallbackF(SelectEdgeMode), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) ); + GlobalToggles_insert( "DragFaces", makeCallbackF(SelectFaceMode), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) ); + + GlobalCommands_insert( "MirrorSelectionX", makeCallbackF(Selection_Flipx) ); + GlobalCommands_insert( "RotateSelectionX", makeCallbackF(Selection_Rotatex) ); + GlobalCommands_insert( "MirrorSelectionY", makeCallbackF(Selection_Flipy) ); + GlobalCommands_insert( "RotateSelectionY", makeCallbackF(Selection_Rotatey) ); + GlobalCommands_insert( "MirrorSelectionZ", makeCallbackF(Selection_Flipz) ); + GlobalCommands_insert( "RotateSelectionZ", makeCallbackF(Selection_Rotatez) ); + + GlobalCommands_insert( "ArbitraryRotation", makeCallbackF(DoRotateDlg) ); + GlobalCommands_insert( "ArbitraryScale", makeCallbackF(DoScaleDlg) ); + + GlobalCommands_insert( "BuildMenuCustomize", makeCallbackF(DoBuildMenu) ); + + GlobalCommands_insert( "FindBrush", makeCallbackF(DoFind) ); + + GlobalCommands_insert( "MapInfo", makeCallbackF(DoMapInfo), Accelerator( 'M' ) ); + + + GlobalToggles_insert( "ToggleClipper", makeCallbackF(ClipperMode), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) ); + + GlobalToggles_insert( "MouseTranslate", makeCallbackF(TranslateMode), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) ); + GlobalToggles_insert( "MouseRotate", makeCallbackF(RotateMode), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) ); + GlobalToggles_insert( "MouseScale", makeCallbackF(ScaleMode), ToggleItem::AddCallbackCaller( g_scalemode_button ) ); + GlobalToggles_insert( "MouseDrag", makeCallbackF(DragMode), ToggleItem::AddCallbackCaller( g_dragmode_button ), Accelerator( 'Q' ) ); + + GlobalCommands_insert( "ColorSchemeOriginal", makeCallbackF(ColorScheme_Original) ); + GlobalCommands_insert( "ColorSchemeQER", makeCallbackF(ColorScheme_QER) ); + GlobalCommands_insert( "ColorSchemeBlackAndGreen", makeCallbackF(ColorScheme_Black) ); + GlobalCommands_insert( "ColorSchemeYdnar", makeCallbackF(ColorScheme_Ydnar) ); GlobalCommands_insert( "ChooseTextureBackgroundColor", makeCallback( g_ColoursMenu.m_textureback ) ); GlobalCommands_insert( "ChooseGridBackgroundColor", makeCallback( g_ColoursMenu.m_xyback ) ); GlobalCommands_insert( "ChooseGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor ) ); @@ -3248,34 +3248,34 @@ void MainFrame_Construct(){ GlobalCommands_insert( "ChooseOrthoViewNameColor", makeCallback( g_ColoursMenu.m_viewname ) ); - GlobalCommands_insert( "CSGSubtract", FreeCaller(), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "CSGMerge", FreeCaller(), Accelerator( 'U', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "CSGHollow", FreeCaller() ); + GlobalCommands_insert( "CSGSubtract", makeCallbackF(CSG_Subtract), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CSGMerge", makeCallbackF(CSG_Merge), Accelerator( 'U', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "CSGHollow", makeCallbackF(CSG_MakeHollow) ); Grid_registerCommands(); - GlobalCommands_insert( "SnapToGrid", FreeCaller(), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "SnapToGrid", makeCallbackF(Selection_SnapToGrid), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "SelectAllOfType", FreeCaller(), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "SelectAllOfType", makeCallbackF(Select_AllOfType), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexRotateClock", FreeCaller(), Accelerator( GDK_KEY_Next, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexRotateCounter", FreeCaller(), Accelerator( GDK_KEY_Prior, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexScaleUp", FreeCaller(), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexScaleDown", FreeCaller(), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexScaleLeft", FreeCaller(), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexScaleRight", FreeCaller(), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "TexShiftUp", FreeCaller(), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexShiftDown", FreeCaller(), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexShiftLeft", FreeCaller(), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "TexShiftRight", FreeCaller(), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexRotateClock", makeCallbackF(Texdef_RotateClockwise), Accelerator( GDK_KEY_Next, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexRotateCounter", makeCallbackF(Texdef_RotateAntiClockwise), Accelerator( GDK_KEY_Prior, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexScaleUp", makeCallbackF(Texdef_ScaleUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleDown", makeCallbackF(Texdef_ScaleDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleLeft", makeCallbackF(Texdef_ScaleLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleRight", makeCallbackF(Texdef_ScaleRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexShiftUp", makeCallbackF(Texdef_ShiftUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftDown", makeCallbackF(Texdef_ShiftDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftLeft", makeCallbackF(Texdef_ShiftLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftRight", makeCallbackF(Texdef_ShiftRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "MoveSelectionDOWN", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract ) ); - GlobalCommands_insert( "MoveSelectionUP", FreeCaller(), Accelerator( GDK_KEY_KP_Add ) ); + GlobalCommands_insert( "MoveSelectionDOWN", makeCallbackF(Selection_MoveDown), Accelerator( GDK_KEY_KP_Subtract ) ); + GlobalCommands_insert( "MoveSelectionUP", makeCallbackF(Selection_MoveUp), Accelerator( GDK_KEY_KP_Add ) ); - GlobalCommands_insert( "SelectNudgeLeft", FreeCaller(), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "SelectNudgeRight", FreeCaller(), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "SelectNudgeUp", FreeCaller(), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_MOD1_MASK ) ); - GlobalCommands_insert( "SelectNudgeDown", FreeCaller(), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeLeft", makeCallbackF(Selection_NudgeLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeRight", makeCallbackF(Selection_NudgeRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeUp", makeCallbackF(Selection_NudgeUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeDown", makeCallbackF(Selection_NudgeDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_MOD1_MASK ) ); Patch_registerCommands(); XYShow_registerCommands(); @@ -3330,8 +3330,8 @@ void MainFrame_Construct(){ Layout_registerPreferencesPage(); Paths_registerPreferencesPage(); - g_brushCount.setCountChangedCallback( FreeCaller() ); - g_entityCount.setCountChangedCallback( FreeCaller() ); + g_brushCount.setCountChangedCallback( makeCallbackF(QE_brushCountChanged) ); + g_entityCount.setCountChangedCallback( makeCallbackF(QE_entityCountChanged) ); GlobalEntityCreator().setCounter( &g_entityCount ); GLWidget_sharedContextCreated = GlobalGL_sharedContextCreated; diff --git a/radiant/map.cpp b/radiant/map.cpp index 5523f431..a6833a6c 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -2161,16 +2161,16 @@ CopiedString g_strLastMap; bool g_bLoadLastMap = false; void Map_Construct(){ - GlobalCommands_insert( "RegionOff", FreeCaller() ); - GlobalCommands_insert( "RegionSetXY", FreeCaller() ); - GlobalCommands_insert( "RegionSetBrush", FreeCaller() ); - GlobalCommands_insert( "RegionSetSelection", FreeCaller(), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "RegionOff", makeCallbackF(RegionOff) ); + GlobalCommands_insert( "RegionSetXY", makeCallbackF(RegionXY) ); + 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 ) ); - PreferencesDialog_addSettingsPreferences( FreeCaller() ); + PreferencesDialog_addSettingsPreferences( makeCallbackF(Map_constructPreferences) ); GlobalEntityClassManager().attach( g_MapEntityClasses ); Radiant_attachHomePathsObserver( g_MapModuleObserver ); diff --git a/radiant/multimon.cpp b/radiant/multimon.cpp index 91385739..8a569e0b 100644 --- a/radiant/multimon.cpp +++ b/radiant/multimon.cpp @@ -92,7 +92,7 @@ void MultiMon_Construct(){ g_Multimon_enableSysMenuPopups.useLatched(); - PreferencesDialog_addInterfacePreferences( FreeCaller() ); + PreferencesDialog_addInterfacePreferences( makeCallbackF(MultiMonitor_constructPreferences) ); } void MultiMon_Destroy(){ } diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 310d1331..b6650f50 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -1033,7 +1033,7 @@ void PatchInspector_SelectionChanged( const Selectable& selectable ){ void PatchInspector_Construct(){ - GlobalCommands_insert( "PatchInspector", FreeCaller(), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) ); + 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] ) ); diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index ceca948d..a7e993ef 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -600,7 +600,7 @@ void Patch_constructPage( PreferenceGroup& group ){ Patch_constructPreferences( page ); } void Patch_registerPreferencesPage(){ - PreferencesDialog_addDisplayPage( FreeCaller() ); + PreferencesDialog_addDisplayPage( makeCallbackF(Patch_constructPage) ); } @@ -614,41 +614,41 @@ void PatchPreferences_construct(){ #include "generic/callback.h" void Patch_registerCommands(){ - GlobalCommands_insert( "InvertCurveTextureX", FreeCaller(), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "InvertCurveTextureY", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "NaturalizePatch", FreeCaller(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "PatchCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchDenseCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchVeryDenseCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchSquareCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchXactCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchXactSphere", FreeCaller() ); - GlobalCommands_insert( "PatchXactCone", FreeCaller() ); - GlobalCommands_insert( "PatchEndCap", FreeCaller() ); - GlobalCommands_insert( "PatchBevel", FreeCaller() ); - GlobalCommands_insert( "PatchSquareBevel", FreeCaller() ); - GlobalCommands_insert( "PatchSquareEndcap", FreeCaller() ); - GlobalCommands_insert( "PatchCone", FreeCaller() ); - GlobalCommands_insert( "PatchSphere", FreeCaller() ); - GlobalCommands_insert( "SimplePatchMesh", FreeCaller(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller() ); - GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "PatchInsertAddRow", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller() ); - GlobalCommands_insert( "InvertCurve", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "RedisperseRows", FreeCaller(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "RedisperseCols", FreeCaller(), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "SmoothRows", FreeCaller(), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "SmoothCols", FreeCaller(), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "MatrixTranspose", FreeCaller(), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "CapCurrentCurve", FreeCaller(), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "CycleCapTexturePatch", FreeCaller(), Accelerator( 'N', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "MakeOverlayPatch", FreeCaller(), Accelerator( 'Y' ) ); - GlobalCommands_insert( "ClearPatchOverlays", FreeCaller(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "InvertCurveTextureX", makeCallbackF(Patch_FlipTextureX), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "InvertCurveTextureY", makeCallbackF(Patch_FlipTextureY), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "NaturalizePatch", makeCallbackF(Patch_NaturalTexture), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchCylinder", makeCallbackF(Patch_Cylinder) ); + GlobalCommands_insert( "PatchDenseCylinder", makeCallbackF(Patch_DenseCylinder) ); + GlobalCommands_insert( "PatchVeryDenseCylinder", makeCallbackF(Patch_VeryDenseCylinder) ); + GlobalCommands_insert( "PatchSquareCylinder", makeCallbackF(Patch_SquareCylinder) ); + GlobalCommands_insert( "PatchXactCylinder", makeCallbackF(Patch_XactCylinder) ); + GlobalCommands_insert( "PatchXactSphere", makeCallbackF(Patch_XactSphere) ); + GlobalCommands_insert( "PatchXactCone", makeCallbackF(Patch_XactCone) ); + GlobalCommands_insert( "PatchEndCap", makeCallbackF(Patch_Endcap) ); + GlobalCommands_insert( "PatchBevel", makeCallbackF(Patch_Bevel) ); + GlobalCommands_insert( "PatchSquareBevel", makeCallbackF(Patch_SquareBevel) ); + GlobalCommands_insert( "PatchSquareEndcap", makeCallbackF(Patch_SquareEndcap) ); + GlobalCommands_insert( "PatchCone", makeCallbackF(Patch_Cone) ); + GlobalCommands_insert( "PatchSphere", makeCallbackF(Patch_Sphere) ); + GlobalCommands_insert( "SimplePatchMesh", makeCallbackF(Patch_Plane), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "PatchInsertInsertColumn", makeCallbackF(Patch_InsertInsertColumn), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchInsertAddColumn", makeCallbackF(Patch_InsertAddColumn) ); + GlobalCommands_insert( "PatchInsertInsertRow", makeCallbackF(Patch_InsertInsertRow), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchInsertAddRow", makeCallbackF(Patch_InsertAddRow) ); + GlobalCommands_insert( "PatchDeleteFirstColumn", makeCallbackF(Patch_DeleteFirstColumn) ); + GlobalCommands_insert( "PatchDeleteLastColumn", makeCallbackF(Patch_DeleteLastColumn), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchDeleteFirstRow", makeCallbackF(Patch_DeleteFirstRow), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchDeleteLastRow", makeCallbackF(Patch_DeleteLastRow) ); + GlobalCommands_insert( "InvertCurve", makeCallbackF(Patch_Invert), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "RedisperseRows", makeCallbackF(Patch_RedisperseRows), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "RedisperseCols", makeCallbackF(Patch_RedisperseCols), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "SmoothRows", makeCallbackF(Patch_SmoothRows), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "SmoothCols", makeCallbackF(Patch_SmoothCols), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "MatrixTranspose", makeCallbackF(Patch_Transpose), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "CapCurrentCurve", makeCallbackF(Patch_Cap), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CycleCapTexturePatch", makeCallbackF(Patch_CycleProjection), Accelerator( 'N', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "MakeOverlayPatch", makeCallbackF(Patch_OverlayOn), Accelerator( 'Y' ) ); + GlobalCommands_insert( "ClearPatchOverlays", makeCallbackF(Patch_OverlayOff), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) ); } void Patch_constructToolbar( ui::Toolbar toolbar ){ diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 1134d8a1..5d9dd652 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -166,7 +166,7 @@ ui::MenuItem create_plugins_menu(){ //TODO: some modules/plugins do not yet support refresh #if 0 - create_menu_item_with_mnemonic( menu, "Refresh", FreeCaller() ); + create_menu_item_with_mnemonic( menu, "Refresh", makeCallbackF(Restart) ); // NOTE: the seperator is used when doing a refresh of the list, everything past the seperator is removed g_plugins_menu_separator = menu_separator( menu ); diff --git a/radiant/points.cpp b/radiant/points.cpp index cc5ca5f5..c4a56492 100644 --- a/radiant/points.cpp +++ b/radiant/points.cpp @@ -330,9 +330,9 @@ void Pointfile_Construct(){ GlobalShaderCache().attachRenderable( s_pointfile ); - GlobalCommands_insert( "TogglePointfile", FreeCaller() ); - GlobalCommands_insert( "NextLeakSpot", FreeCaller(), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "PrevLeakSpot", FreeCaller(), Accelerator( 'L', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "TogglePointfile", makeCallbackF(Pointfile_Toggle) ); + GlobalCommands_insert( "NextLeakSpot", makeCallbackF(Pointfile_Next), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PrevLeakSpot", makeCallbackF(Pointfile_Prev), Accelerator( 'L', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); } void Pointfile_Destroy(){ diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index f3efd8db..510a1cc1 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -81,7 +81,7 @@ void Mouse_constructPage( PreferenceGroup& group ){ Mouse_constructPreferences( page ); } void Mouse_registerPreferencesPage(){ - PreferencesDialog_addInterfacePage( FreeCaller() ); + PreferencesDialog_addInterfacePage( makeCallbackF(Mouse_constructPage) ); } @@ -668,7 +668,7 @@ PreferencesPage createPage( const char* treeName, const char* frameName ){ }; ui::Window PrefsDlg::BuildDialog(){ - PreferencesDialog_addInterfacePreferences( FreeCaller() ); + PreferencesDialog_addInterfacePreferences( makeCallbackF(Interface_constructPreferences) ); Mouse_registerPreferencesPage(); ui::Window dialog = ui::Window(create_floating_window( "NetRadiant Preferences", m_parent )); diff --git a/radiant/referencecache.cpp b/radiant/referencecache.cpp index 91e0645b..b1c34c8d 100644 --- a/radiant/referencecache.cpp +++ b/radiant/referencecache.cpp @@ -471,7 +471,7 @@ struct ModelResource : public Resource void connectMap(){ MapFile* map = Node_getMapFile( m_model ); if ( map != 0 ) { - map->setChangedCallback( FreeCaller() ); + map->setChangedCallback( makeCallbackF(MapChanged) ); } } std::time_t modified() const { diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 5bfb45f4..57007112 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -1393,15 +1393,15 @@ void SurfaceInspector_constructPage( PreferenceGroup& group ){ SurfaceInspector_constructPreferences( page ); } void SurfaceInspector_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(SurfaceInspector_constructPage) ); } void SurfaceInspector_registerCommands(){ - GlobalCommands_insert( "FitTexture", FreeCaller(), Accelerator( 'B', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "SurfaceInspector", FreeCaller(), Accelerator( 'S' ) ); + GlobalCommands_insert( "FitTexture", makeCallbackF(SurfaceInspector_FitTexture), Accelerator( 'B', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "SurfaceInspector", makeCallbackF(SurfaceInspector_toggleShown), Accelerator( 'S' ) ); - GlobalCommands_insert( "FaceCopyTexture", FreeCaller() ); - GlobalCommands_insert( "FacePasteTexture", FreeCaller() ); + GlobalCommands_insert( "FaceCopyTexture", makeCallbackF(SelectedFaces_copyTexture) ); + GlobalCommands_insert( "FacePasteTexture", makeCallbackF(SelectedFaces_pasteTexture) ); } diff --git a/radiant/textures.cpp b/radiant/textures.cpp index 55f00b7e..b724c317 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -769,7 +769,7 @@ void Textures_constructPage( PreferenceGroup& group ){ Textures_constructPreferences( page ); } void Textures_registerPreferencesPage(){ - PreferencesDialog_addDisplayPage( FreeCaller() ); + PreferencesDialog_addDisplayPage( makeCallbackF(Textures_constructPage) ); } void TextureCompression_importString( const char* string ){ diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 09c7fc73..0097d9be 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -2598,7 +2598,7 @@ void TextureBrowser_constructPage( PreferenceGroup& group ){ TextureBrowser_constructPreferences( page ); } void TextureBrowser_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(TextureBrowser_constructPage) ); } @@ -2612,23 +2612,23 @@ typedef ReferenceCaller() ); - GlobalCommands_insert( "ShowUntagged", FreeCaller() ); - GlobalCommands_insert( "AddTag", FreeCaller() ); - GlobalCommands_insert( "RenameTag", FreeCaller() ); - GlobalCommands_insert( "DeleteTag", FreeCaller() ); - GlobalCommands_insert( "CopyTag", FreeCaller() ); - GlobalCommands_insert( "PasteTag", FreeCaller() ); - GlobalCommands_insert( "RefreshShaders", FreeCaller() ); - GlobalToggles_insert( "ShowInUse", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) ); - GlobalCommands_insert( "ShowAllTextures", FreeCaller(), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "ToggleTextures", FreeCaller(), Accelerator( 'T' ) ); - GlobalToggles_insert( "ToggleShowShaders", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaders_item ) ); - GlobalToggles_insert( "ToggleShowShaderlistOnly", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaderlistonly_item ) ); - GlobalToggles_insert( "FixedSize", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_fixedsize_item ) ); - GlobalToggles_insert( "FilterMissing", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) ); - GlobalToggles_insert( "FilterFallback", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hidenotex_item ) ); - GlobalToggles_insert( "EnableAlpha", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_enablealpha_item ) ); + GlobalCommands_insert( "ShaderInfo", makeCallbackF(TextureBrowser_shaderInfo) ); + GlobalCommands_insert( "ShowUntagged", makeCallbackF(TextureBrowser_showUntagged) ); + GlobalCommands_insert( "AddTag", makeCallbackF(TextureBrowser_addTag) ); + GlobalCommands_insert( "RenameTag", makeCallbackF(TextureBrowser_renameTag) ); + GlobalCommands_insert( "DeleteTag", makeCallbackF(TextureBrowser_deleteTag) ); + GlobalCommands_insert( "CopyTag", makeCallbackF(TextureBrowser_copyTag) ); + GlobalCommands_insert( "PasteTag", makeCallbackF(TextureBrowser_pasteTag) ); + GlobalCommands_insert( "RefreshShaders", makeCallbackF(VFS_Refresh) ); + GlobalToggles_insert( "ShowInUse", makeCallbackF(TextureBrowser_ToggleHideUnused), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) ); + GlobalCommands_insert( "ShowAllTextures", makeCallbackF(TextureBrowser_showAll), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ToggleTextures", makeCallbackF(TextureBrowser_toggleShow), Accelerator( 'T' ) ); + GlobalToggles_insert( "ToggleShowShaders", makeCallbackF(TextureBrowser_ToggleShowShaders), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaders_item ) ); + GlobalToggles_insert( "ToggleShowShaderlistOnly", makeCallbackF(TextureBrowser_ToggleShowShaderListOnly), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaderlistonly_item ) ); + GlobalToggles_insert( "FixedSize", makeCallbackF(TextureBrowser_FixedSize), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_fixedsize_item ) ); + GlobalToggles_insert( "FilterMissing", makeCallbackF(TextureBrowser_FilterMissing), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) ); + 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 ) ), diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index d36738a1..d5f6eb7c 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -190,7 +190,7 @@ void Build_constructPage( PreferenceGroup& group ){ Build_constructPreferences( page ); } void Build_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(Build_constructPage) ); } #include "preferencesystem.h" diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 9e296f42..d6f22833 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -2708,7 +2708,7 @@ void Orthographic_constructPage( PreferenceGroup& group ){ Orthographic_constructPreferences( page ); } void Orthographic_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(Orthographic_constructPage) ); } void Clipper_constructPreferences( PreferencesPage& page ){ @@ -2719,7 +2719,7 @@ void Clipper_constructPage( PreferenceGroup& group ){ Clipper_constructPreferences( page ); } void Clipper_registerPreferencesPage(){ - PreferencesDialog_addSettingsPage( FreeCaller() ); + PreferencesDialog_addSettingsPage( makeCallbackF(Clipper_constructPage) ); } @@ -2740,21 +2740,21 @@ typedef ConstReferenceCaller(), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "ToggleSizePaint", FreeCaller(), Accelerator( 'J' ) ); - GlobalCommands_insert( "ToggleGrid", FreeCaller(), Accelerator( '0' ) ); + GlobalCommands_insert( "ToggleCrosshairs", makeCallbackF(ToggleShowCrosshair), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "ToggleSizePaint", makeCallbackF(ToggleShowSizeInfo), Accelerator( 'J' ) ); + GlobalCommands_insert( "ToggleGrid", makeCallbackF(ToggleShowGrid), Accelerator( '0' ) ); GlobalToggles_insert( "ToggleView", ToggleShown::ToggleCaller( g_xy_top_shown ), ToggleItem::AddCallbackCaller( g_xy_top_shown.m_item ), Accelerator( 'V', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalToggles_insert( "ToggleSideView", ToggleShown::ToggleCaller( g_yz_side_shown ), ToggleItem::AddCallbackCaller( g_yz_side_shown.m_item ) ); GlobalToggles_insert( "ToggleFrontView", ToggleShown::ToggleCaller( g_xz_front_shown ), ToggleItem::AddCallbackCaller( g_xz_front_shown.m_item ) ); - GlobalCommands_insert( "NextView", FreeCaller(), Accelerator( GDK_KEY_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); // fixme: doesn't show its shortcut - GlobalCommands_insert( "ZoomIn", FreeCaller(), Accelerator( GDK_KEY_Delete ) ); - GlobalCommands_insert( "ZoomOut", FreeCaller(), Accelerator( GDK_KEY_Insert ) ); - GlobalCommands_insert( "ViewTop", FreeCaller(), Accelerator( GDK_KEY_KP_Home ) ); - GlobalCommands_insert( "ViewSide", FreeCaller(), Accelerator( GDK_KEY_KP_Page_Down ) ); - GlobalCommands_insert( "ViewFront", FreeCaller(), Accelerator( GDK_KEY_KP_End ) ); - GlobalCommands_insert( "Zoom100", FreeCaller() ); - GlobalCommands_insert( "CenterXYView", FreeCaller(), Accelerator( GDK_KEY_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "NextView", makeCallbackF(XY_Next), Accelerator( GDK_KEY_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); // fixme: doesn't show its shortcut + GlobalCommands_insert( "ZoomIn", makeCallbackF(XY_ZoomIn), Accelerator( GDK_KEY_Delete ) ); + GlobalCommands_insert( "ZoomOut", makeCallbackF(XY_ZoomOut), Accelerator( GDK_KEY_Insert ) ); + GlobalCommands_insert( "ViewTop", makeCallbackF(XY_Top), Accelerator( GDK_KEY_KP_Home ) ); + GlobalCommands_insert( "ViewSide", makeCallbackF(XY_Side), Accelerator( GDK_KEY_KP_Page_Down ) ); + GlobalCommands_insert( "ViewFront", makeCallbackF(XY_Front), Accelerator( GDK_KEY_KP_End ) ); + 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 ) );