From 5107e23905d9d5c259a4dc324159a0cc0ac4bd79 Mon Sep 17 00:00:00 2001 From: Armin Burgmeier Date: Thu, 17 Sep 2015 20:03:53 -0400 Subject: [PATCH] Select sane defaults for background material and texture in editor (#1402) --- src/editor/C4ToolsDlg.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/editor/C4ToolsDlg.cpp b/src/editor/C4ToolsDlg.cpp index 36b1e7db5..c2273ef47 100644 --- a/src/editor/C4ToolsDlg.cpp +++ b/src/editor/C4ToolsDlg.cpp @@ -76,8 +76,30 @@ void C4ToolsDlg::SetTexture(const char *szTexture) Console.ToolsDlgSelectTexture(this, szTexture); return; } + SCopy(szTexture,Texture,C4M_MaxName); NeedPreviewUpdate(); + + // If the front texture changes, reset the background texture + // to something sensible. + int32_t mat = MaterialMap.Get(Material); + if (mat != MNone) + { + const C4Material* material = &MaterialMap.Map[mat]; + if(DensitySemiSolid(material->Density)) + { + if (!SEqual(BackMaterial, C4TLS_MatSky)) + { + SelectBackMaterial("Tunnel"); + SelectBackTexture("tunnel"); + } + } + else + { + SelectBackMaterial(Material); + SelectBackTexture(Texture); + } + } } void C4ToolsDlg::SetBackMaterial(const char *szMaterial) @@ -101,6 +123,7 @@ void C4ToolsDlg::SetBackTexture(const char *szTexture) Console.ToolsDlgSelectBackTexture(this, szTexture); return; } + SCopy(szTexture,BackTexture,C4M_MaxName); }