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);
        }
Exemple #2
0
        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), "___");
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
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.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);
 }