From: Rudolf Polzer Date: Sun, 10 Oct 2010 11:53:40 +0000 (+0200) Subject: clean up toggleProjection code X-Git-Tag: xonotic-v0.5.0~177 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=112586a3cfc610616fca7a07ee258ff0350ad091;p=xonotic%2Fnetradiant.git clean up toggleProjection code --- diff --git a/radiant/brushmodule.cpp b/radiant/brushmodule.cpp index d5853f07..da508c03 100644 --- a/radiant/brushmodule.cpp +++ b/radiant/brushmodule.cpp @@ -91,25 +91,25 @@ void Brush_registerPreferencesPage() } void Brush_unlatchPreferences() +{ + Brush_toggleProjection(0); +} + +void Brush_toggleProjection(int i) { if(g_showAlternativeTextureProjectionOption) { - g_useAlternativeTextureProjection.useLatched(); - globalErrorStream() << "Unlatched g_useAlternativeTextureProjection (" << g_useAlternativeTextureProjection.m_value << ")\n"; + g_useAlternativeTextureProjection.m_value = g_useAlternativeTextureProjection.m_latched ^ i; Brush::destroyStatic(); Brush::constructStatic(g_useAlternativeTextureProjection.m_value ? eBrushTypeQuake3BP : eBrushTypeQuake3); } } -void Brush_toggleProjection() +int Brush_toggleProjectionCount() { if(g_showAlternativeTextureProjectionOption) - { - g_useAlternativeTextureProjection.m_value = !g_useAlternativeTextureProjection.m_value; - globalErrorStream() << "Toggled g_useAlternativeTextureProjection (" << g_useAlternativeTextureProjection.m_value << ")\n"; - Brush::destroyStatic(); - Brush::constructStatic(g_useAlternativeTextureProjection.m_value ? eBrushTypeQuake3BP : eBrushTypeQuake3); - } + return 2; + return 1; } void Brush_Construct(EBrushType type) diff --git a/radiant/brushmodule.h b/radiant/brushmodule.h index efb808af..4a0e40e7 100644 --- a/radiant/brushmodule.h +++ b/radiant/brushmodule.h @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void Brush_clipperColourChanged(); void Brush_unlatchPreferences(); -void Brush_toggleProjection(); +int Brush_toggleProjectionCount(); +void Brush_toggleProjection(int i); #endif diff --git a/radiant/map.cpp b/radiant/map.cpp index 339de05f..86b1123a 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -1046,12 +1046,15 @@ void Map_LoadFile (const char *filename) if(format->wrongFormat) { // try toggling BrushPrimitives - Map_Free(); - Brush_toggleProjection(); - g_map.m_name = filename; - Map_UpdateTitle(g_map); - g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str()); - g_map.m_resource->attach(g_map); + for(i = 1; i < Brush_toggleProjectionCount(); ++i) + { + Map_Free(); + Brush_toggleProjection(i); + g_map.m_name = filename; + Map_UpdateTitle(g_map); + g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str()); + g_map.m_resource->attach(g_map); + } } Node_getTraversable(GlobalSceneGraph().root())->traverse(entity_updateworldspawn());