public static int CompareTo(this TreeInfo info, object obj, TreeSorting sorting, SortingOrder order) { TreeInfo a, b; if (order == SortingOrder.Descending) { a = info; b = obj as TreeInfo; } else { b = info; a = obj as TreeInfo; } if (a == null || b == null) { return(-1); } string authorB, authorA = string.Empty; TreeMeshData meshDataB, meshDataA = null; bool haveMeshData = ForestBrush.Instance.TreesMeshData.TryGetValue(b.name, out meshDataB) && ForestBrush.Instance.TreesMeshData.TryGetValue(a.name, out meshDataA); bool haveAuthors = ForestBrush.Instance.TreeAuthors.TryGetValue(b.name, out authorB) && ForestBrush.Instance.TreeAuthors.TryGetValue(a.name, out authorA); if (sorting == TreeSorting.Name) { return(b.GetUncheckedLocalizedTitle().CompareTo(a.GetUncheckedLocalizedTitle())); } if (sorting == TreeSorting.Author) { if (haveAuthors) { return(authorB.CompareTo(authorA)); } } if (sorting == TreeSorting.Texture) { if (haveMeshData) { return((meshDataB.textureSize.x + meshDataB.textureSize.y).CompareTo(meshDataA.textureSize.x + meshDataA.textureSize.y)); } } if (sorting == TreeSorting.Triangles) { if (haveMeshData) { return(meshDataB.triangles.CompareTo(meshDataA.triangles)); } } return(0); }
public Settings( float panelPosX, float panelPosY, bool brushShapesOpen, bool brushEditOpen, bool brushOptionsOpen, bool showTreeMeshData, TreeSorting sorting, SortingOrder sortingOrder, FilterStyle filterStyle, IEnumerable <Brush> forestBrushes, string selectedBrush, SavedInputKey toggleTool, bool keepTreesInNewBrush, bool ignoreVanillaTrees, bool showInfoTooltip, bool playEffect, bool chargeMoney ) { this.PanelPosX = panelPosX; this.PanelPosY = panelPosY; this.BrushShapesOpen = brushShapesOpen; this.BrushEditOpen = brushEditOpen; this.BrushOptionsOpen = brushOptionsOpen; this.ShowTreeMeshData = showTreeMeshData; this.Sorting = sorting; this.SortingOrder = sortingOrder; this.FilterStyle = filterStyle; this.ToggleTool = toggleTool; this.KeepTreesInNewBrush = keepTreesInNewBrush; this.IgnoreVanillaTrees = ignoreVanillaTrees; this.ShowInfoTooltip = showInfoTooltip; this.PlayEffect = playEffect; this.ChargeMoney = chargeMoney; this.Brushes = forestBrushes.ToList(); if (this.Brushes.Count == 0) { var defaultBrush = Brush.Default(); this.Brushes.Add(defaultBrush); } this.SelectBrush(selectedBrush); }