public static void LoadNewBrushFiles(string[] absNames) { try { foreach (string f in absNames) { TerrainBrush b = FindBrushByFilename(f); if (b == null) { b = TerrainConversionHelpers.CreateBrush(f); } else { TerrainConversionHelpers.CheckBrushModified(b); continue; } if (b == null || !b.Valid) { continue; } _allBrushes.Add(b); } } catch (Exception ex) { EditorManager.DumpException(ex, true); } if (OnBrushCollectionChanged != null) { OnBrushCollectionChanged(null, EventArgs.Empty); } }
/// <summary> /// Releases all brush resources (e.g. project close /// </summary> static void FreeAllBrushes() { // unload all brushes foreach (TerrainBrush b in _allBrushes) { TerrainConversionHelpers.FreeBrush(b); } _allBrushes.Clear(); CurrentBrush = null; if (OnBrushCollectionChanged != null) { OnBrushCollectionChanged(null, EventArgs.Empty); } }
/// <summary> /// Load all default brushes from the directory /// </summary> static void LoadAllBrushes() { if (!EditorManager.EngineManager.IsInitialized()) { return; } try { FreeAllBrushes(); string dir = AbsoluteBrushFilePath; string[] files = Directory.GetFiles(dir, "*.bmp"); foreach (string f in files) { TerrainBrush b = TerrainConversionHelpers.CreateBrush(f); if (b == null || !b.Valid) { continue; } _allBrushes.Add(b); } } catch (Exception ex) { EditorManager.DumpException(ex, true); } if (OnBrushCollectionChanged != null) { OnBrushCollectionChanged(null, EventArgs.Empty); } if (!string.IsNullOrEmpty(_preferredBrushName)) { TerrainBrush b = FindBrush(_preferredBrushName); if (b != null) { CurrentBrush = b; } } if (CurrentBrush == null) { CurrentBrush = FindBrush("Smooth1"); // preferred brush to start with } if (CurrentBrush == null && _allBrushes.Count > 0) { CurrentBrush = (TerrainBrush)_allBrushes[0]; } }