clean up toggleProjection code

This commit is contained in:
Rudolf Polzer 2010-10-10 13:53:40 +02:00
parent 2b0a97c814
commit 112586a3cf
3 changed files with 20 additions and 16 deletions

View File

@ -91,25 +91,25 @@ void Brush_registerPreferencesPage()
} }
void Brush_unlatchPreferences() void Brush_unlatchPreferences()
{
Brush_toggleProjection(0);
}
void Brush_toggleProjection(int i)
{ {
if(g_showAlternativeTextureProjectionOption) if(g_showAlternativeTextureProjectionOption)
{ {
g_useAlternativeTextureProjection.useLatched(); g_useAlternativeTextureProjection.m_value = g_useAlternativeTextureProjection.m_latched ^ i;
globalErrorStream() << "Unlatched g_useAlternativeTextureProjection (" << g_useAlternativeTextureProjection.m_value << ")\n";
Brush::destroyStatic(); Brush::destroyStatic();
Brush::constructStatic(g_useAlternativeTextureProjection.m_value ? eBrushTypeQuake3BP : eBrushTypeQuake3); Brush::constructStatic(g_useAlternativeTextureProjection.m_value ? eBrushTypeQuake3BP : eBrushTypeQuake3);
} }
} }
void Brush_toggleProjection() int Brush_toggleProjectionCount()
{ {
if(g_showAlternativeTextureProjectionOption) if(g_showAlternativeTextureProjectionOption)
{ return 2;
g_useAlternativeTextureProjection.m_value = !g_useAlternativeTextureProjection.m_value; return 1;
globalErrorStream() << "Toggled g_useAlternativeTextureProjection (" << g_useAlternativeTextureProjection.m_value << ")\n";
Brush::destroyStatic();
Brush::constructStatic(g_useAlternativeTextureProjection.m_value ? eBrushTypeQuake3BP : eBrushTypeQuake3);
}
} }
void Brush_Construct(EBrushType type) void Brush_Construct(EBrushType type)

View File

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
void Brush_clipperColourChanged(); void Brush_clipperColourChanged();
void Brush_unlatchPreferences(); void Brush_unlatchPreferences();
void Brush_toggleProjection(); int Brush_toggleProjectionCount();
void Brush_toggleProjection(int i);
#endif #endif

View File

@ -1046,12 +1046,15 @@ void Map_LoadFile (const char *filename)
if(format->wrongFormat) if(format->wrongFormat)
{ {
// try toggling BrushPrimitives // try toggling BrushPrimitives
Map_Free(); for(i = 1; i < Brush_toggleProjectionCount(); ++i)
Brush_toggleProjection(); {
g_map.m_name = filename; Map_Free();
Map_UpdateTitle(g_map); Brush_toggleProjection(i);
g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str()); g_map.m_name = filename;
g_map.m_resource->attach(g_map); 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()); Node_getTraversable(GlobalSceneGraph().root())->traverse(entity_updateworldspawn());