예제 #1
0
 private bool PropertyRowRefsContextMenu(List <string> reftypes, dynamic oldval, ref object newval)
 {
     if (ImGui.BeginPopupContextItem(String.Join(',', reftypes)))
     {
         // Add Goto statements
         foreach (string rt in reftypes)
         {
             if (!ParamBank.Params.ContainsKey(rt))
             {
                 continue;
             }
             if (ParamBank.Params[rt][(int)oldval] != null && ImGui.Selectable($@"Go to {rt}"))
             {
                 EditorCommandQueue.AddCommand($@"param/select/{rt}/{oldval}");
             }
         }
         // 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 = "";
                         ImGui.EndPopup();
                         return(true);
                     }
                     maxResultsPerRefType--;
                 }
             }
         }
         ImGui.EndPopup();
     }
     return(false);
 }
예제 #2
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);
 }