Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void AddAsset(List<AssetItem> assets, ObjDefinition obj)
ObjID = obj.ObjId,
ObjDefinition = obj,
Icon = IconManager.GetTextureIcon(icon),
Aliases = obj.Meta.Aliases.ToArray(),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ private List<ObjDefinition> UpdateSearch(List<ObjDefinition> objects)
objects[i].Label.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;

HasText |= objects[i].ObjId.ToString().IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;
HasText |= objects[i].Meta.Aliases.Any(s => s.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0);

if (isSearch && HasText || !isSearch)
filtered.Add(objects[i]);
Expand Down
387 changes: 362 additions & 25 deletions Plugins/TurboLibrary/Editors/MapEditor/MapObjEditor/MapObjectUI.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ private EditableObject Create(Obj obj)

//Set the UI label and property tag
render.UINode.Header = GetNodeHeader(obj);
render.UINode.Aliases = obj.Meta.Aliases;
render.UINode.Tag = obj;
render.UINode.ContextMenus.Add(new MenuItemModel("EXPORT", () => ExportModel()));
//Set custom UI properties
Expand Down Expand Up @@ -673,8 +674,8 @@ private EditableObject AddObject(int id, bool spawnAtCursor = false)
var ob = rend.UINode.Tag as Obj;

//Reset parameters to defaults
if (ParamDatabase.ParameterDefaults.ContainsKey(ob.ObjId))
ob.Params = ParamDatabase.ParameterDefaults[ob.ObjId].ToList();
for (int i = 0; i < ob.Meta.Params.Length; i++)
ob.Params[i] = ob.Meta.Params[i].Default;

//Define some parameters based on the existing objects in the scene

Expand Down Expand Up @@ -711,8 +712,8 @@ private EditableObject EditObject(EditableObject render, int id)
Add(editedRender);

//Reset parameters to defaults
if (ParamDatabase.ParameterDefaults.ContainsKey(obj.ObjId))
obj.Params = ParamDatabase.ParameterDefaults[obj.ObjId].ToList();
for (int i = 0; i < obj.Meta.Params.Length; i++)
obj.Params[i] = obj.Meta.Params[i].Default;

//Keep the same node order
Root.Children.Remove(editedRender.UINode);
Expand Down
38 changes: 28 additions & 10 deletions Plugins/TurboLibrary/FileData/Muunt/MapObj/Obj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,37 @@ public void SetLinkIndex(string name, int index)

// ---- PROPERTIES ---------------------------------------------------------------------------------------------

private int _objId;
public ObjDefinition ObjDef { get; private set; }
private MapObjMeta _objMeta; // local copy in case no corresponding ObjDefinition exists

/// <summary>
/// Gets or sets the ID determining the type of this object.
/// </summary>
[ByamlMember]
public int ObjId { get; set; }
public int ObjId {
get { return _objId; }
set {
if (_objId == value)
return;
// ObjId changes, should update the corresponding definition as well
_objId = value;
ObjDef = null;
_objMeta = null;
if (GlobalSettings.ObjDatabase.ContainsKey(value))
ObjDef = GlobalSettings.ObjDatabase[this.ObjId];
else
_objMeta = GlobalSettings.ParamDataBase.GetMeta(value);
}
}

public MapObjMeta Meta { get
{
if (ObjDef is not null)
return ObjDef.Meta;
return _objMeta;
}
}

[BindGUI("MULTI2P", Category = "OBJECT", ColumnIndex = 0, Control = BindControl.ToggleButton)]
public bool HasMulti2P
Expand Down Expand Up @@ -259,14 +285,6 @@ public string Label
[ByamlMember]
public List<float> Params { get; set; }

public string[] GetParameterNames()
{
if (ParamDatabase.ParameterObjs.ContainsKey(ObjId))
return ParamDatabase.ParameterObjs[ObjId];
else
return new string[8];
}

public bool IsSkybox
{
get
Expand All @@ -286,7 +304,7 @@ public Obj()
this.Translate = new ByamlVector3F();
this.Scale = new ByamlVector3F(1, 1, 1);
this.Rotate = new ByamlVector3F();
ObjId = 1018;
ObjId = 1018; // Meta is updated by updating objId

Params = new List<float>();
for (int i = 0; i < 8; i++)
Expand Down
Loading