public PARAMDEF GetParamdefForParam(string paramType) { PARAMDEF pd = PARAMDEF.XmlDeserialize($@"{GetParamdefDir()}\{paramType}.xml"); MsbEditor.ParamMetaData meta = MsbEditor.ParamMetaData.XmlDeserialize($@"{GetParammetaDir()}\{paramType}.xml", pd); return(pd); }
public static FieldMetaData Get(PARAMDEF.Field def) { FieldMetaData fieldMeta = _FieldMetas[def]; if (fieldMeta == null) { ParamMetaData pdef = ParamMetaData.Get(def.Parent); fieldMeta = new FieldMetaData(pdef, pdef._xml, def); } return(fieldMeta); }
private void PropertyRowRefs(List <string> reftypes, dynamic oldval) { // Add named row and context menu // Lists located params ImGui.NewLine(); bool entryFound = false; foreach (string rt in reftypes) { string hint = ""; if (ParamBank.Params.ContainsKey(rt)) { PARAM param = ParamBank.Params[rt]; ParamMetaData meta = ParamMetaData.Get(ParamBank.Params[rt].AppliedParamdef); if (meta != null && meta.Row0Dummy && (int)oldval == 0) { continue; } PARAM.Row r = param[(int)oldval]; ImGui.SameLine(); if (r == null && (int)oldval > 0) { if (meta != null && meta.OffsetSize > 0) { // Test if previous row exists. In future, add param meta to determine size of offset int altval = (int)oldval - (int)oldval % meta.OffsetSize; r = ParamBank.Params[rt][altval]; hint = $@"(+{(int) oldval % meta.OffsetSize})"; } } if (r == null) { continue; } entryFound = true; if (r.Name == null || r.Name.Equals("")) { ImGui.TextColored(new Vector4(1.0f, 0.5f, 0.5f, 1.0f), "Unnamed Row"); } else { ImGui.TextColored(new Vector4(1.0f, 0.5f, 0.5f, 1.0f), r.Name + hint); } ImGui.NewLine(); } } ImGui.SameLine(); if (!entryFound) { ImGui.TextColored(new Vector4(0.0f, 0.0f, 0.0f, 1.0f), "___"); } }
public void PropEditorParamRow(PARAM.Row row) { IReadOnlyList <PARAM.Cell> cells = new List <PARAM.Cell>(); cells = row.Cells; ImGui.Columns(2); ImGui.Separator(); int id = 0; // This should be rewritten somehow it's super ugly ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.8f, 0.8f, 0.8f, 1.0f)); var nameProp = row.GetType().GetProperty("Name"); var idProp = row.GetType().GetProperty("ID"); PropEditorPropInfoRow(row, nameProp, "Name", ref id); PropEditorPropInfoRow(row, idProp, "ID", ref id); ImGui.PopStyleColor(); ParamMetaData meta = ParamMetaData.Get(row.Def); if (meta != null && meta.AlternateOrder != null && ParamEditorScreen.AllowFieldReorderPreference) { foreach (var field in meta.AlternateOrder) { if (field.Equals("-")) { ImGui.Separator(); continue; } if (row[field] == null) { continue; } PropEditorPropCellRow(row[field], ref id); } foreach (var cell in cells) { if (!meta.AlternateOrder.Contains(cell.Def.InternalName)) { PropEditorPropCellRow(cell, ref id); } } } else { foreach (var cell in cells) { PropEditorPropCellRow(cell, ref id); } } ImGui.Columns(1); }
public void Commit(string field) { if (_parent._xml == null) { return; } ParamMetaData.SetStringListXmlProperty("Refs", RefTypes, null, _parent._xml, "PARAMMETA", "Field", field); ParamMetaData.SetStringXmlProperty("Vref", VirtualRef, false, _parent._xml, "PARAMMETA", "Field", field); ParamMetaData.SetEnumXmlProperty("Enum", EnumType, _parent._xml, "PARAMMETA", "Field", field); ParamMetaData.SetStringXmlProperty("AltName", AltName, false, _parent._xml, "PARAMMETA", "Field", field); ParamMetaData.SetStringXmlProperty("Wiki", Wiki, true, _parent._xml, "PARAMMETA", "Field", field); ParamMetaData.SetBoolXmlProperty("IsBool", IsBool, _parent._xml, "PARAMMETA", "Field", field); }
private static void LoadParamdefs() { _paramdefs = new Dictionary <string, PARAMDEF>(); var dir = AssetLocator.GetParamdefDir(); var files = Directory.GetFiles(dir, "*.xml"); var mdir = AssetLocator.GetParammetaDir(); foreach (var f in files) { var pdef = PARAMDEF.XmlDeserialize(f); var fName = f.Substring(f.LastIndexOf('\\') + 1); ParamMetaData.XmlDeserialize($@"{mdir}\{fName}", pdef); _paramdefs.Add(pdef.ParamType, pdef); } }
public FieldMetaData(ParamMetaData parent, XmlNode fieldMeta, PARAMDEF.Field field) { _parent = parent; Add(field, this); XmlAttribute Ref = fieldMeta.Attributes["Refs"]; if (Ref != null) { RefTypes = new List <string>(Ref.InnerText.Split(",")); } XmlAttribute VRef = fieldMeta.Attributes["VRef"]; if (VRef != null) { VirtualRef = VRef.InnerText; } XmlAttribute Enum = fieldMeta.Attributes["Enum"]; if (Enum != null) { EnumType = parent.enums.GetValueOrDefault(Enum.InnerText, null); } XmlAttribute AlternateName = fieldMeta.Attributes["AltName"]; if (AlternateName != null) { AltName = AlternateName.InnerText; } XmlAttribute WikiText = fieldMeta.Attributes["Wiki"]; if (WikiText != null) { Wiki = WikiText.InnerText.Replace("\\n", "\n"); } XmlAttribute IsBoolean = fieldMeta.Attributes["IsBool"]; if (IsBoolean != null) { IsBool = true; } }
private bool PropertyRowRefsContextItems(List <string> reftypes, dynamic oldval, ref object newval) { // Add Goto statements foreach (string rt in reftypes) { if (!ParamBank.Params.ContainsKey(rt)) { continue; } int searchVal = (int)oldval; ParamMetaData meta = ParamMetaData.Get(ParamBank.Params[rt].AppliedParamdef); if (meta != null) { if (meta.Row0Dummy && searchVal == 0) { continue; } if (meta.OffsetSize > 0 && searchVal > 0 && ParamBank.Params[rt][(int)searchVal] == null) { // Test if previous row exists. In future, add param meta to determine size of offset searchVal = (int)oldval - (int)oldval % meta.OffsetSize; } } if (ParamBank.Params[rt][searchVal] != null) { if (ImGui.Selectable($@"Go to {rt}")) { EditorCommandQueue.AddCommand($@"param/select/-1/{rt}/{searchVal}"); } if (ImGui.Selectable($@"Go to {rt} in new view")) { EditorCommandQueue.AddCommand($@"param/select/new/{rt}/{searchVal}"); } } } // Add searchbar for named editing ImGui.InputText("##value", ref _refContextCurrentAutoComplete, 128); // Unordered scanthrough search for matching param entries. // This should be replaced by a proper search box with a scroll and everything if (_refContextCurrentAutoComplete != "") { foreach (string rt in reftypes) { int maxResultsPerRefType = 15 / reftypes.Count; List <PARAM.Row> rows = MassParamEditRegex.GetMatchingParamRowsByName(ParamBank.Params[rt], _refContextCurrentAutoComplete, true, false); foreach (PARAM.Row r in rows) { if (maxResultsPerRefType <= 0) { break; } if (ImGui.Selectable(r.Name)) { newval = (int)r.ID; _refContextCurrentAutoComplete = ""; return(true); } maxResultsPerRefType--; } } } return(false); }
private static void Add(PARAMDEF key, ParamMetaData meta) { _ParamMetas.Add(key, meta); }
public FieldMetaData(ParamMetaData parent, PARAMDEF.Field field) { _parent = parent; Add(field, this); // Blank Metadata }