X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatchmodule.cpp;h=7f273591a9947346c4829d31561f711d36996a75;hb=ad4d224ba9cbc2887c258571f93d832f5cef0272;hp=713d2122c52cfd9fc3fd194e0055c63899ce71b6;hpb=107765f0e4b543dfc346851ee5b4605cc17eb1c6;p=xonotic%2Fnetradiant.git diff --git a/radiant/patchmodule.cpp b/radiant/patchmodule.cpp index 713d2122..7f273591 100644 --- a/radiant/patchmodule.cpp +++ b/radiant/patchmodule.cpp @@ -1,23 +1,23 @@ /* -Copyright (C) 2001-2006, William Joseph. -All Rights Reserved. + Copyright (C) 2001-2006, William Joseph. + All Rights Reserved. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "patchmodule.h" @@ -29,223 +29,194 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA namespace { - std::size_t g_patchModuleCount = 0; +std::size_t g_patchModuleCount = 0; } -void Patch_Construct(EPatchType type) -{ - if(++g_patchModuleCount != 1) - { - return; - } +void Patch_Construct( EPatchType type ){ + if ( ++g_patchModuleCount != 1 ) { + return; + } - PatchFilters_construct(); + PatchFilters_construct(); - PatchPreferences_construct(); + PatchPreferences_construct(); - Patch_registerPreferencesPage(); + Patch_registerPreferencesPage(); - Patch::constructStatic(type); - PatchInstance::constructStatic(); + Patch::constructStatic( type ); + PatchInstance::constructStatic(); - if(type == ePatchTypeDoom3) - { - MAX_PATCH_WIDTH = MAX_PATCH_HEIGHT = 99; - } - else - { - MAX_PATCH_WIDTH = MAX_PATCH_HEIGHT = 15; - } + if ( type == ePatchTypeDoom3 ) { + MAX_PATCH_WIDTH = MAX_PATCH_HEIGHT = 99; + } + else + { + MAX_PATCH_WIDTH = MAX_PATCH_HEIGHT = 31; // matching q3map2 + } } -void Patch_Destroy() -{ - if(--g_patchModuleCount != 0) - { - return; - } +void Patch_Destroy(){ + if ( --g_patchModuleCount != 0 ) { + return; + } - Patch::destroyStatic(); - PatchInstance::destroyStatic(); + Patch::destroyStatic(); + PatchInstance::destroyStatic(); } class CommonPatchCreator : public PatchCreator { public: - void Patch_undoSave(scene::Node& patch) const - { - Node_getPatch(patch)->undoSave(); - } - void Patch_resize(scene::Node& patch, std::size_t width, std::size_t height) const - { - Node_getPatch(patch)->setDims(width, height); - } - PatchControlMatrix Patch_getControlPoints(scene::Node& node) const - { - Patch& patch = *Node_getPatch(node); - return PatchControlMatrix(patch.getHeight(), patch.getWidth(), patch.getControlPoints().data()); - } - void Patch_controlPointsChanged(scene::Node& patch) const - { - return Node_getPatch(patch)->controlPointsChanged(); - } - const char* Patch_getShader(scene::Node& patch) const - { - return Node_getPatch(patch)->GetShader(); - } - void Patch_setShader(scene::Node& patch, const char* shader) const - { - Node_getPatch(patch)->SetShader(shader); - } +void Patch_undoSave( scene::Node& patch ) const { + Node_getPatch( patch )->undoSave(); +} +void Patch_resize( scene::Node& patch, std::size_t width, std::size_t height ) const { + Node_getPatch( patch )->setDims( width, height ); +} +PatchControlMatrix Patch_getControlPoints( scene::Node& node ) const { + Patch& patch = *Node_getPatch( node ); + return PatchControlMatrix( patch.getHeight(), patch.getWidth(), patch.getControlPoints().data() ); +} +void Patch_controlPointsChanged( scene::Node& patch ) const { + return Node_getPatch( patch )->controlPointsChanged(); +} +const char* Patch_getShader( scene::Node& patch ) const { + return Node_getPatch( patch )->GetShader(); +} +void Patch_setShader( scene::Node& patch, const char* shader ) const { + Node_getPatch( patch )->SetShader( shader ); +} }; class Quake3PatchCreator : public CommonPatchCreator { public: - scene::Node& createPatch() - { - return (new PatchNodeQuake3())->node(); - } +scene::Node& createPatch(){ + return ( new PatchNodeQuake3() )->node(); +} }; Quake3PatchCreator g_Quake3PatchCreator; -PatchCreator& GetQuake3PatchCreator() -{ - return g_Quake3PatchCreator; +PatchCreator& GetQuake3PatchCreator(){ + return g_Quake3PatchCreator; } class Doom3PatchCreator : public CommonPatchCreator { public: - scene::Node& createPatch() - { - return (new PatchNodeDoom3(true))->node(); - } +scene::Node& createPatch(){ + return ( new PatchNodeDoom3( true ) )->node(); +} }; Doom3PatchCreator g_Doom3PatchCreator; -PatchCreator& GetDoom3PatchCreator() -{ - return g_Doom3PatchCreator; +PatchCreator& GetDoom3PatchCreator(){ + return g_Doom3PatchCreator; } class Doom3PatchDef2Creator : public CommonPatchCreator { public: - scene::Node& createPatch() - { - return (new PatchNodeDoom3())->node(); - } +scene::Node& createPatch(){ + return ( new PatchNodeDoom3() )->node(); +} }; Doom3PatchDef2Creator g_Doom3PatchDef2Creator; -PatchCreator& GetDoom3PatchDef2Creator() -{ - return g_Doom3PatchDef2Creator; +PatchCreator& GetDoom3PatchDef2Creator(){ + return g_Doom3PatchDef2Creator; } #include "modulesystem/singletonmodule.h" #include "modulesystem/moduleregistry.h" class PatchDependencies : - public GlobalRadiantModuleRef, - public GlobalSceneGraphModuleRef, - public GlobalShaderCacheModuleRef, - public GlobalSelectionModuleRef, - public GlobalOpenGLModuleRef, - public GlobalUndoModuleRef, - public GlobalFilterModuleRef + public GlobalRadiantModuleRef, + public GlobalSceneGraphModuleRef, + public GlobalShaderCacheModuleRef, + public GlobalSelectionModuleRef, + public GlobalOpenGLModuleRef, + public GlobalUndoModuleRef, + public GlobalFilterModuleRef { }; class PatchQuake3API : public TypeSystemRef { - PatchCreator* m_patchquake3; +PatchCreator* m_patchquake3; public: - typedef PatchCreator Type; - STRING_CONSTANT(Name, "quake3"); - - PatchQuake3API() - { - Patch_Construct(ePatchTypeQuake3); - - m_patchquake3 = &GetQuake3PatchCreator(); - g_patchCreator = m_patchquake3; - } - ~PatchQuake3API() - { - Patch_Destroy(); - } - PatchCreator* getTable() - { - return m_patchquake3; - } +typedef PatchCreator Type; +STRING_CONSTANT( Name, "quake3" ); + +PatchQuake3API(){ + Patch_Construct( ePatchTypeQuake3 ); + + m_patchquake3 = &GetQuake3PatchCreator(); + g_patchCreator = m_patchquake3; +} +~PatchQuake3API(){ + Patch_Destroy(); +} +PatchCreator* getTable(){ + return m_patchquake3; +} }; typedef SingletonModule PatchQuake3Module; typedef Static StaticPatchQuake3Module; -StaticRegisterModule staticRegisterPatchQuake3(StaticPatchQuake3Module::instance()); +StaticRegisterModule staticRegisterPatchQuake3( StaticPatchQuake3Module::instance() ); class PatchDoom3API : public TypeSystemRef { - PatchCreator* m_patchdoom3; +PatchCreator* m_patchdoom3; public: - typedef PatchCreator Type; - STRING_CONSTANT(Name, "doom3"); - - PatchDoom3API() - { - Patch_Construct(ePatchTypeDoom3); - - m_patchdoom3 = &GetDoom3PatchCreator(); - } - ~PatchDoom3API() - { - Patch_Destroy(); - } - PatchCreator* getTable() - { - return m_patchdoom3; - } +typedef PatchCreator Type; +STRING_CONSTANT( Name, "doom3" ); + +PatchDoom3API(){ + Patch_Construct( ePatchTypeDoom3 ); + + m_patchdoom3 = &GetDoom3PatchCreator(); +} +~PatchDoom3API(){ + Patch_Destroy(); +} +PatchCreator* getTable(){ + return m_patchdoom3; +} }; typedef SingletonModule PatchDoom3Module; typedef Static StaticPatchDoom3Module; -StaticRegisterModule staticRegisterPatchDoom3(StaticPatchDoom3Module::instance()); +StaticRegisterModule staticRegisterPatchDoom3( StaticPatchDoom3Module::instance() ); class PatchDef2Doom3API : public TypeSystemRef { - PatchCreator* m_patchdef2doom3; +PatchCreator* m_patchdef2doom3; public: - typedef PatchCreator Type; - STRING_CONSTANT(Name, "def2doom3"); - - PatchDef2Doom3API() - { - Patch_Construct(ePatchTypeDoom3); - - m_patchdef2doom3 = &GetDoom3PatchDef2Creator(); - g_patchCreator = m_patchdef2doom3; - } - ~PatchDef2Doom3API() - { - Patch_Destroy(); - } - PatchCreator* getTable() - { - return m_patchdef2doom3; - } +typedef PatchCreator Type; +STRING_CONSTANT( Name, "def2doom3" ); + +PatchDef2Doom3API(){ + Patch_Construct( ePatchTypeDoom3 ); + + m_patchdef2doom3 = &GetDoom3PatchDef2Creator(); + g_patchCreator = m_patchdef2doom3; +} +~PatchDef2Doom3API(){ + Patch_Destroy(); +} +PatchCreator* getTable(){ + return m_patchdef2doom3; +} }; typedef SingletonModule PatchDef2Doom3Module; typedef Static StaticPatchDef2Doom3Module; -StaticRegisterModule staticRegisterPatchDef2Doom3(StaticPatchDef2Doom3Module::instance()); - - - +StaticRegisterModule staticRegisterPatchDef2Doom3( StaticPatchDef2Doom3Module::instance() );