/// <summary> /// Load a profile FlowLayoutPanel with checked items from this profile /// </summary> /// <param name="flp">The FLPanel</param> /// <param name="hudBar">The HudBar</param> public void LoadFlp(HudBar hudBar) { m_flp.Controls.Clear( ); List <CheckBox> tmp = new List <CheckBox>();// temp list of checkboxes in native sequence (not yet user ordered) // Fill a temp panel foreach (LItem i in Enum.GetValues(typeof(LItem))) { var cb = new CheckBox() { Name = Key(i), Text = hudBar.CfgName(i), Tag = BreakTagFromEnum(m_flowBreak[i]), Margin = new Padding(3, 0, 3, 0), Anchor = AnchorStyles.Left, AutoSize = true, AllowDrop = true, Enabled = i != LItem.MSFS, // Disable unckecking of MSFS Status // Cursor = Cursors.NoMoveVert, }; cb.Checked = m_profile[i]; cb.BackColor = BreakColorFromEnum(m_flowBreak[i]); // Mouse Handlers cb.MouseDown += Cb_MouseDown; cb.MouseUp += Cb_MouseUp; cb.MouseMove += Cb_MouseMove; cb.DragOver += Cb_DragOver; cb.DragDrop += Cb_DragDrop; cb.GiveFeedback += Cb_GiveFeedback; tmp.Add(cb); } // now load the real panel accordingly from display position 0... m_flp.SuspendLayout( ); // avoid performance issued while loading all checkboxes foreach (LItem i in Enum.GetValues(typeof(LItem))) { // we use the Enum only as position index 0... max here int idx = (int)i; // find the item to be shown at this position (find the pos value in m_sequence and get the item with it's Key) if (m_sequence.ContainsValue(idx)) { // the item to put as next one / Add sequentially to the layout panel m_flp.Controls.Add(tmp.ElementAt((int)ItemKeyFromPos(idx))); } else { // no such item ???? ; } } // only now layout the FLPanel m_flp.ResumeLayout( ); }
private static HudWidget GetNeedWidget(PawnModel model, string defName) { var def = DefDatabase <NeedDef> .GetNamed(defName, false); if (def != null) { return((HudWidget)HudBar.FromModel(new NeedModel(model, def), Theme.RegularTextStyle) ?? HudBlank.GetEmpty); } Mod.ErrorOnce($"Invalid HUD Widget, Need def '{defName}' not found", "InvalidNeedDefName" + defName); return(HudBlank.GetEmpty); }
private static HudWidgetBase GetNeedWidget(PawnModel model, string defName) { var def = DefDatabase <NeedDef> .GetNamed(defName, false); if (def != null) { return((HudWidgetBase)HudBar.FromModel(new NeedModel(model, def), Theme.RegularTextStyle) ?? HudBlank.GetEmpty); } Mod.Warning($"Invalid HUD Widget, Need def '{defName}' not found, resetting layout to default"); RequiredReset(); return(HudBlank.GetEmpty); }