Пример #1
0
        public static FieldMetaData Get(PARAMDEF.Field def)
        {
            FieldMetaData fieldMeta = _FieldMetas[def];

            if (fieldMeta == null)
            {
                ParamMetaData pdef = ParamMetaData.Get(def.Parent);
                fieldMeta = new FieldMetaData(pdef, def);
            }
            return(fieldMeta);
        }
Пример #2
0
 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);
 }
Пример #3
0
        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;
            }
        }
Пример #4
0
 private static void Add(PARAMDEF key, ParamMetaData meta)
 {
     _ParamMetas.Add(key, meta);
 }
Пример #5
0
 public FieldMetaData(ParamMetaData parent, PARAMDEF.Field field)
 {
     _parent = parent;
     Add(field, this);
     // Blank Metadata
 }
Пример #6
0
 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.FixedOffset != 0 && searchVal > 0)
             {
                 searchVal = searchVal + meta.FixedOffset;
             }
             if (meta.OffsetSize > 0 && searchVal > 0 && ParamBank.Params[rt][(int)searchVal] == null)
             {
                 searchVal = (int)searchVal - (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);
     // This should be replaced by a proper search box with a scroll and everything
     if (_refContextCurrentAutoComplete != "")
     {
         foreach (string rt in reftypes)
         {
             if (!ParamBank.Params.ContainsKey(rt))
             {
                 continue;
             }
             ParamMetaData    meta = ParamMetaData.Get(ParamBank.Params[rt].AppliedParamdef);
             int              maxResultsPerRefType = 15 / reftypes.Count;
             Match            m    = new Regex(MassParamEditRegex.rowfilterRx).Match(_refContextCurrentAutoComplete);
             List <PARAM.Row> rows = MassParamEditRegex.GetMatchingParamRows(ParamBank.Params[rt], m, true, false);
             foreach (PARAM.Row r in rows)
             {
                 if (maxResultsPerRefType <= 0)
                 {
                     break;
                 }
                 if (ImGui.Selectable(r.ID + ": " + r.Name))
                 {
                     if (meta != null && meta.FixedOffset != 0)
                     {
                         newval = (int)r.ID - meta.FixedOffset;
                     }
                     else
                     {
                         newval = (int)r.ID;
                     }
                     _refContextCurrentAutoComplete = "";
                     return(true);
                 }
                 maxResultsPerRefType--;
             }
         }
     }
     return(false);
 }
Пример #7
0
        private void PropertyRowRefs(List <string> reftypes, dynamic oldval)
        {
            // Add named row and context menu
            // Lists located params
            ImGui.NewLine();
            int  originalValue = (int)oldval; //make sure to explicitly cast from dynamic or C# complains. Object or Convert.ToInt32 fail.
            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 && originalValue == 0)
                    {
                        continue;
                    }
                    PARAM.Row r = param[originalValue];
                    ImGui.SameLine();
                    if (r == null && originalValue > 0 && meta != null)
                    {
                        int altval = originalValue;
                        if (meta.FixedOffset != 0)
                        {
                            altval = originalValue + meta.FixedOffset;
                            hint  += meta.FixedOffset > 0 ? "+" + meta.FixedOffset.ToString() : meta.FixedOffset.ToString();
                        }
                        if (meta.OffsetSize > 0)
                        {
                            altval = altval - altval % meta.OffsetSize;
                            hint  += "+" + (originalValue % meta.OffsetSize).ToString();
                        }
                        r = ParamBank.Params[rt][altval];
                    }
                    if (r == null)
                    {
                        continue;
                    }
                    entryFound = true;
                    ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1.0f, 0.5f, 0.5f, 1.0f));
                    if (r.Name == null || r.Name.Equals(""))
                    {
                        ImGui.TextUnformatted("Unnamed Row");
                    }
                    else
                    {
                        ImGui.TextUnformatted(r.Name + hint);
                    }
                    ImGui.PopStyleColor();
                    ImGui.NewLine();
                }
            }
            ImGui.SameLine();
            if (!entryFound)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
                ImGui.TextUnformatted("___");
                ImGui.PopStyleColor();
            }
        }
Пример #8
0
        public void PropEditorParamRow(PARAM.Row row, PARAM.Row vrow, ref string propSearchString)
        {
            ParamMetaData meta = ParamMetaData.Get(row.Def);

            ImGui.Columns(2);
            ImGui.Separator();
            int id = 0;

            if (propSearchString != null)
            {
                ImGui.InputText("Search...", ref propSearchString, 255);
            }
            Regex propSearchRx = null;

            try
            {
                propSearchRx = new Regex(propSearchString.ToLower());
            }
            catch
            {
            }
            ImGui.NextColumn();
            ImGui.NextColumn();

            // 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, propSearchRx);
            PropEditorPropInfoRow(row, idProp, "ID", ref id, propSearchRx);
            ImGui.PopStyleColor();

            List <string> fieldOrder = meta != null && meta.AlternateOrder != null && ParamEditorScreen.AllowFieldReorderPreference ? meta.AlternateOrder : new List <string>();

            foreach (PARAMDEF.Field field in row.Def.Fields)
            {
                if (!fieldOrder.Contains(field.InternalName))
                {
                    fieldOrder.Add(field.InternalName);
                }
            }
            foreach (var field in fieldOrder)
            {
                if (field.Equals("-"))
                {
                    ImGui.Separator();
                    continue;
                }
                if (row[field] == null)
                {
                    continue;
                }
                List <PARAM.Cell> matches  = row.Cells.Where(cell => cell.Def.InternalName == field).ToList();
                List <PARAM.Cell> vmatches = vrow == null ? null : vrow.Cells.Where(cell => cell.Def.InternalName == field).ToList();
                for (int i = 0; i < matches.Count; i++)
                {
                    PropEditorPropCellRow(matches[i], vrow == null ? null : vmatches[i], ref id, propSearchRx);
                }
            }
            ImGui.Columns(1);
        }