Skip to content

Commit a3584d1

Browse files
committed
use RichBuildLayout everywhere rather than the low-level BuildLayout. it makes displaying dependencies and references a lot easier
1 parent 0ea8570 commit a3584d1

9 files changed

Lines changed: 143 additions & 40 deletions

Editor/BuildLayoutTreeView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool IterateItemsInternal(TreeViewItem parent, System.Func<TreeViewItem, bool> c
9696
return false;
9797
}
9898

99-
public void SetBuildLayout(BuildLayout buildLayout)
99+
public void SetBuildLayout(RichBuildLayout buildLayout)
100100
{
101101
var root = new TreeViewItem { id = 0, depth = -1, displayName = "Root" };
102102

@@ -108,7 +108,7 @@ public void SetBuildLayout(BuildLayout buildLayout)
108108
Reload();
109109
}
110110

111-
protected abstract void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayout);
111+
protected abstract void OnBuildTree(TreeViewItem rootItem, RichBuildLayout buildLayout);
112112

113113
protected override void BeforeRowsGUI()
114114
{

Editor/BuildLayoutView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public bool isVisible
5050
private set;
5151
}
5252

53-
public BuildLayout buildLayout
53+
public RichBuildLayout buildLayout
5454
{
5555
get;
5656
private set;
@@ -88,7 +88,7 @@ public virtual void OnDestroy()
8888
window = null;
8989
}
9090

91-
public virtual void Rebuild(BuildLayout buildLayout)
91+
public virtual void Rebuild(RichBuildLayout buildLayout)
9292
{
9393
this.buildLayout = buildLayout;
9494

Editor/BuildLayoutWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Oddworm.EditorFramework.BuildLayoutExplorer
1010
{
1111
public class BuildLayoutWindow : EditorWindow
1212
{
13-
[SerializeField] BuildLayout m_Layout;
13+
RichBuildLayout m_Layout;
1414

1515
Rect m_ViewButtonRect;
1616
Rect m_FileButtonRect;
@@ -253,7 +253,7 @@ void SaveJsonDialog()
253253

254254
void CloseBuildLayout()
255255
{
256-
m_Layout = new BuildLayout();
256+
m_Layout = new RichBuildLayout();
257257
m_LoadedPath = "";
258258

259259
foreach (var view in m_Views)
@@ -321,7 +321,7 @@ public void LoadBuildLayout(string path)
321321
{
322322
try
323323
{
324-
m_Layout = BuildLayout.Load(path);
324+
m_Layout = new RichBuildLayout(BuildLayout.Load(path));
325325
m_LoadedPath = path;
326326
}
327327
catch (System.Exception e)

Editor/BundleTreeView.cs

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public BundleTreeView(BuildLayoutWindow window)
3030
multiColumnHeader.sortedColumnIndex = ColumnIDs.size;
3131
}
3232

33-
protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayout)
33+
protected override void OnBuildTree(TreeViewItem rootItem, RichBuildLayout buildLayout)
3434
{
3535
var processed = new Dictionary<string, bool>();
3636

@@ -44,7 +44,7 @@ protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayo
4444
var bundleItem = new BundleItem
4545
{
4646
treeView = this,
47-
source = bundle,
47+
bundle = bundle,
4848
id = m_UniqueId++,
4949
depth = 0,
5050
displayName = bundle.name,
@@ -68,7 +68,7 @@ protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayo
6868
{
6969
var assetItem = new AssetItem
7070
{
71-
source = asset,
71+
asset = asset,
7272
id = m_UniqueId++,
7373
depth = assetsCategoryItem.depth + 1,
7474
displayName = asset.name
@@ -142,9 +142,10 @@ protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayo
142142
var dependencyItem = new BundleReferenceItem
143143
{
144144
treeView = this,
145+
bundle = dependency,
145146
id = m_UniqueId++,
146147
depth = categoryItem.depth + 1,
147-
displayName = dependency
148+
displayName = dependency.name
148149
};
149150
categoryItem.AddChild(dependencyItem);
150151
}
@@ -167,9 +168,10 @@ protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayo
167168
var dependencyItem = new BundleReferenceItem
168169
{
169170
treeView = this,
171+
bundle = dependency,
170172
id = m_UniqueId++,
171173
depth = categoryItem.depth + 1,
172-
displayName = dependency
174+
displayName = dependency.name
173175
};
174176
categoryItem.AddChild(dependencyItem);
175177
}
@@ -181,7 +183,7 @@ protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayo
181183
[System.Serializable]
182184
class BundleItem : BaseItem
183185
{
184-
public BuildLayout.Archive source;
186+
public RichBuildLayout.Archive bundle;
185187

186188
public BundleItem()
187189
{
@@ -197,16 +199,16 @@ public override int CompareTo(TreeViewItem other, int column)
197199
switch (column)
198200
{
199201
case ColumnIDs.name:
200-
return string.Compare(source.name, otherItem.source.name, true);
202+
return string.Compare(bundle.name, otherItem.bundle.name, true);
201203

202204
case ColumnIDs.size:
203-
return source.size.CompareTo(otherItem.source.size);
205+
return bundle.size.CompareTo(otherItem.bundle.size);
204206

205207
case ColumnIDs.compression:
206-
return string.Compare(source.compression, otherItem.source.compression, true);
208+
return string.Compare(bundle.compression, otherItem.bundle.compression, true);
207209

208210
case ColumnIDs.dependencies:
209-
return source.bundleDependencies.Count.CompareTo(otherItem.source.bundleDependencies.Count);
211+
return bundle.bundleDependencies.Count.CompareTo(otherItem.bundle.bundleDependencies.Count);
210212
}
211213

212214
return 0;
@@ -217,19 +219,20 @@ public override void OnGUI(Rect position, int column)
217219
switch(column)
218220
{
219221
case ColumnIDs.name:
220-
EditorGUI.LabelField(position, source.name);
222+
EditorGUI.LabelField(position, bundle.name);
221223
break;
222224

223225
case ColumnIDs.size:
224-
EditorGUI.LabelField(position, $"{EditorUtility.FormatBytes(source.size)}");
226+
EditorGUI.LabelField(position, $"{EditorUtility.FormatBytes(bundle.size)}");
225227
break;
226228

227229
case ColumnIDs.compression:
228-
EditorGUI.LabelField(position, source.compression);
230+
EditorGUI.LabelField(position, bundle.compression);
229231
break;
230232

231233
case ColumnIDs.dependencies:
232-
EditorGUI.LabelField(position, $"{source.bundleDependencies.Count}");
234+
var dependencyCount = bundle.bundleDependencies.Count + bundle.expandedBundleDependencies.Count;
235+
EditorGUI.LabelField(position, $"{dependencyCount}");
233236
break;
234237
}
235238
}
@@ -269,7 +272,7 @@ public override void OnGUI(Rect position, int column)
269272
[System.Serializable]
270273
class AssetItem : BaseItem
271274
{
272-
public BuildLayout.ExplicitAsset source;
275+
public RichBuildLayout.Asset asset;
273276

274277
public override int CompareTo(TreeViewItem other, int column)
275278
{
@@ -280,7 +283,10 @@ public override int CompareTo(TreeViewItem other, int column)
280283
switch (column)
281284
{
282285
case ColumnIDs.name:
283-
return string.Compare(source.name, otherItem.source.name, true);
286+
return string.Compare(asset.name, otherItem.asset.name, true);
287+
288+
case ColumnIDs.size:
289+
return asset.size.CompareTo(otherItem.asset.size);
284290
}
285291

286292
return 0;
@@ -291,7 +297,11 @@ public override void OnGUI(Rect position, int column)
291297
switch (column)
292298
{
293299
case ColumnIDs.name:
294-
EditorGUI.LabelField(position, source.name);
300+
EditorGUI.LabelField(position, asset.name);
301+
break;
302+
303+
case ColumnIDs.size:
304+
EditorGUI.LabelField(position, EditorUtility.FormatBytes(asset.size), Styles.ghostLabelStyle);
295305
break;
296306
}
297307
}
@@ -329,6 +339,8 @@ public override void OnGUI(Rect position, int column)
329339
[System.Serializable]
330340
class BundleReferenceItem : BaseItem
331341
{
342+
public RichBuildLayout.Archive bundle;
343+
332344
public override int CompareTo(TreeViewItem other, int column)
333345
{
334346
var otherItem = other as BundleReferenceItem;
@@ -339,6 +351,9 @@ public override int CompareTo(TreeViewItem other, int column)
339351
{
340352
case ColumnIDs.name:
341353
return string.Compare(displayName, otherItem.displayName, true);
354+
355+
case ColumnIDs.size:
356+
return bundle.size.CompareTo(otherItem.bundle.size);
342357
}
343358

344359
return 0;
@@ -356,6 +371,19 @@ public override void OnGUI(Rect position, int column)
356371
EditorGUI.LabelField(position, displayName);
357372
}
358373
break;
374+
375+
case ColumnIDs.size:
376+
EditorGUI.LabelField(position, EditorUtility.FormatBytes(bundle.size), Styles.ghostLabelStyle);
377+
break;
378+
379+
case ColumnIDs.compression:
380+
EditorGUI.LabelField(position, bundle.compression, Styles.ghostLabelStyle);
381+
break;
382+
383+
case ColumnIDs.dependencies:
384+
var dependencyCount = bundle.bundleDependencies.Count + bundle.expandedBundleDependencies.Count;
385+
EditorGUI.LabelField(position, $"{dependencyCount}", Styles.ghostLabelStyle);
386+
break;
359387
}
360388
}
361389

Editor/BundlesView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public override void Awake()
2121
m_SearchField = new SearchField(window);
2222
}
2323

24-
public override void Rebuild(BuildLayout buildLayout)
24+
public override void Rebuild(RichBuildLayout buildLayout)
2525
{
2626
base.Rebuild(buildLayout);
2727

Editor/GroupTreeView.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public GroupTreeView(BuildLayoutWindow window)
2828
}
2929

3030

31-
protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayout)
31+
protected override void OnBuildTree(TreeViewItem rootItem, RichBuildLayout buildLayout)
3232
{
3333
foreach (var group in buildLayout.groups)
3434
{
@@ -63,7 +63,7 @@ protected override void OnBuildTree(TreeViewItem rootItem, BuildLayout buildLayo
6363
[System.Serializable]
6464
class GroupItem : BaseItem
6565
{
66-
public BuildLayout.Group group;
66+
public RichBuildLayout.Group group;
6767

6868
public GroupItem()
6969
{
@@ -113,7 +113,7 @@ public override void OnGUI(Rect position, int column)
113113
[System.Serializable]
114114
class BundleItem : BaseItem
115115
{
116-
public BuildLayout.Archive bundle;
116+
public RichBuildLayout.Archive bundle;
117117

118118
public override int CompareTo(TreeViewItem other, int column)
119119
{
@@ -145,11 +145,11 @@ public override void OnGUI(Rect position, int column)
145145
break;
146146

147147
case ColumnIDs.size:
148-
EditorGUI.LabelField(position, $"{EditorUtility.FormatBytes(bundle.size)}");
148+
EditorGUI.LabelField(position, $"{EditorUtility.FormatBytes(bundle.size)}", Styles.ghostLabelStyle);
149149
break;
150150

151151
case ColumnIDs.bundles:
152-
EditorGUI.LabelField(position, $"1");
152+
EditorGUI.LabelField(position, $"1", Styles.ghostLabelStyle);
153153
break;
154154
}
155155
}

Editor/GroupsView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void OnSelectedItemChanged(TreeViewItem selectedItem)
4141
Selection.activeObject = asset;
4242
}
4343

44-
public override void Rebuild(BuildLayout buildLayout)
44+
public override void Rebuild(RichBuildLayout buildLayout)
4545
{
4646
base.Rebuild(buildLayout);
4747

0 commit comments

Comments
 (0)