public virtual void HandleSwitch(GumpCheck entry, bool state) { if (SwitchHandler != null) { SwitchHandler(entry, state); } else if (Switches[entry] != null) { Switches[entry](entry, state); } }
protected void AddCheck(GumpCheck entry, Action<GumpCheck, bool> handler) { if (entry == null) { return; } if (!Switches.ContainsKey(entry)) { Switches.Add(entry, handler); } else { Switches[entry] = handler; } Add(entry); }
public virtual void Write(string name, GumpCheck e) { CreateElement(e); SetAttribute("name", name); SetAttribute("x", e.X); SetAttribute("y", e.Y); SetAttribute("switchid", e.SwitchID); SetAttribute("onid", e.ActiveID); SetAttribute("offid", e.InactiveID); SetAttribute("state", e.InitialState); Append(); }
public virtual bool CanDisplay(GumpCheck entry) { return entry != null; }
/// <summary> /// Honestly...I don't know why this is here. /// </summary> /// <param name="page">The gump to reference.</param> /// <returns>A string of the specially formatted gump entries.</returns> public string Compile(Gump page) { string ret = ""; switch (m_Style) { case "details": if (m_Background) { ret += String.Format("{{ gumppictiled {0} {1} {2} {3} {4} }}", m_X, m_Y, m_Width, m_Height, m_BackgroundID); } int colWidth = Width / m_ColCount; int i = 0; int xbase = m_X; while (i < columnValues.Count && i < m_ParentList.columns) { xbase = m_X + (i * colWidth); object obj = columnValues[i]; if (obj is string) { string caption = (string)obj; if (caption.Contains("</")) { ret += String.Format("{{ htmlgump {0} {1} {2} {3} {4} {5} {6} }}", m_X + (i * colWidth), m_Y, colWidth, m_Height, page.Intern(caption), false, false); } else { ret += String.Format("{{ text {0} {1} {2} {3} }}", m_X + (i * colWidth), m_Y, skin.NormalText, page.Intern(caption)); } } else if (obj is GumpButton) { GumpButton btn = (GumpButton)obj; ret += String.Format("{{ button {0} {1} {2} {3} {4} {5} {6} }}", xbase, m_Y, btn.NormalID, btn.PressedID, (int)btn.Type, btn.Param, btn.ButtonID); } else if (obj is GumpCheck) { GumpCheck chk = (GumpCheck)obj; ret += String.Format("{{ checkbox {0} {1} {2} {3} {4} {5} }}", xbase, m_Y, chk.ActiveID, chk.InactiveID, chk.InitialState, chk.SwitchID); } ret += String.Format("{{gumppictiled {0} {1} {2} {3} {4} }}", m_X + (i * colWidth), m_Y, skin.EntryDividerWidth, skin.EntryDividerHeight, skin.EntryDividerID); i++; } break; case "icons": string caption2 = (string)columnValues[captionID]; if (caption2.Contains("</")) { ret += String.Format("{{ htmlgump {0} {1} {2} {3} {4} {5} {6} }}", m_X, m_Y + skin.EntryCaptionPositionY, skin.EntryCaptionWidth, skin.EntryCaptionHeight, page.Intern(caption2), false, false); } else { ret += String.Format("{{ text {0} {1} {2} {3} }}", m_X, m_Y + skin.EntryCaptionPositionY, skin.NormalText, page.Intern(caption2)); } int id = skin.EntryDefaultIcon; ret += String.Format("{{ gumppictiled {0} {1} {2} {3} {4} }}", m_X, m_Y, m_Width, m_Height, m_BackgroundID); if (arguments.ContainsKey("icon")) { id = (int)arguments["icon"]; } ret += String.Format("{{ gumppictiled {0} {1} {2} {3} {4} }}", ((skin.EntryCaptionWidth - m_X) - skin.EntryIconWidth) / 2, m_Y + skin.EntryIconY, skin.EntryIconWidth, skin.EntryIconHeight, id); GumpButton btn2 = null; if (arguments.ContainsKey("button")) { btn2 = (GumpButton)arguments["button"]; ret += String.Format("{{ buttontileart {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} }}", m_X, m_Y, skin.EntryButtonUnderlay, skin.EntryButtonUnderlay, (int)btn2.Type, btn2.Param, btn2.ButtonID, skin.EntryButtonUnderlay, skin.DefaultBackgroundColor, skin.EntryIconWidth, skin.EntryIconHeight); } break; } if (m_Tooltip) { ret += String.Format("{{ tooltip {0} }}", TooltipID); } return(ret); }
/// <summary> /// The main method for putting the entry on the page. This method is accessed from the GumpList class when CommitList() is called. /// </summary> /// <param name="page">The gump to which the entry should be appended.</param> public void AppendTo(Gump page) { m_ColCount = columnValues.Count < m_ParentList.columns? columnValues.Count: m_ParentList.columns; if (m_ColCount == 0) { return; } if (m_Background) { GumpImageTiled b = new GumpImageTiled(m_X, m_Y, m_Width, m_Height, m_BackgroundID); page.Add(b); } if (m_Style == "details") { m_ParentList.DebugWrite("Details mode."); int i = 0; //int columnval = -1; int colWidth = Width / m_ColCount; int xbase = m_X; while (i < columnValues.Count && i < m_ParentList.columns) { colWidth = getWidthOfColumn(i); xbase = m_X + getCurrentXLocation(i + 1); m_ParentList.DebugWrite("Appending Columns."); try { object o = columnValues[i]; if (o is GumpButton) { GumpButton btn = (GumpButton)o; btn.X = xbase + skin.ListColumnIndent; btn.Y = m_Y; page.Add(btn); } else if (o is GumpCheck) { GumpCheck c = (GumpCheck)o; c.X = xbase + skin.ListColumnIndent; c.Y = m_Y; page.Add(c); } else if (o is GumpTextEntry) { GumpTextEntry t = (GumpTextEntry)o; t.X = xbase + skin.ListColumnIndent; t.Y = m_Y; t.Width = colWidth; t.Height = m_Height; page.Add(t); } else if (o is string) { string s = (string)o; m_ParentList.DebugWrite("stringy! " + s); if (s.Contains("</")) { GumpHtml h = new GumpHtml(xbase + skin.ListColumnIndent, m_Y, colWidth, m_Height, s, false, false); h.Parent = page; page.Add(h); } else { m_ParentList.DebugWrite("text"); GumpLabel g = new GumpLabel(xbase + skin.ListColumnIndent, m_Y, skin.NormalText, s); g.Parent = page; page.Add(g); } } i++; } catch (Exception e) { Console.WriteLine("Problem in AppendTo - " + e); i = columnValues.Count; } if (m_Dividers) { GumpImageTiled t = new GumpImageTiled(xbase + colWidth, m_Y, skin.EntryDividerWidth, skin.EntryDividerHeight, skin.EntryDividerID); page.Add(t); } } m_ParentList.DebugWrite("Done, details."); } else if (m_Style == "icons") { m_ParentList.DebugWrite("Icons mode."); Hashtable table = (Hashtable)columnValues[0]; string s = (string)table["caption"]; if (m_Background) { GumpImageTiled t = new GumpImageTiled(m_X, m_Y, m_Width, m_Height, m_BackgroundID); page.Add(t); } GumpButton button; if (arguments.ContainsKey("button")) { button = (GumpButton)arguments["button"]; page.Add(button); } else { return; } int icon = arguments["icon"] != null ? (int)arguments["icon"] : skin.EntryDefaultIcon; GumpImage im = new GumpImage((skin.EntryCaptionWidth - m_X) - skin.EntryIconWidth / 2, m_Y + skin.EntryIconY, icon); page.Add(im); if (s.Contains("</")) { GumpHtml h = new GumpHtml(m_X, m_Y, m_Width, m_Height, s, false, false); h.Parent = page; page.Add(h); } else { GumpLabel g = new GumpLabel(m_X, m_Y + skin.EntryCaptionPositionY, skin.NormalText, s); g.Parent = page; page.Add(g); } } else { Console.WriteLine("Unknown style: " + m_Style); } }
protected Packet Compile(NetState ns, bool convertToViewer = false) { IGumpWriter disp; if (ns != null && ns.Unpack) { disp = new DisplayGumpPacked(this); } else { disp = new DisplayGumpFast(this); } if (!this._Dragable) { disp.AppendLayout(_NoMove); } if (!this._Closable) { disp.AppendLayout(_NoClose); } if (!this._Disposable) { disp.AppendLayout(_NoDispose); } if (!this._Resizable) { disp.AppendLayout(_NoResize); } int count = this._Entries.Count; for (int i = 0; i < count; ++i) { GumpEntry e = this._Entries[i]; disp.AppendLayout(_BeginLayout); if (!convertToViewer) { e.AppendTo(disp); } else { GumpButton button = e as GumpButton; if (button != null) { new GumpImage(button.X, button.Y, button.NormalID).AppendTo(disp); } else { GumpImageTileButton tileButton = e as GumpImageTileButton; if (tileButton != null) { new GumpImageTiled(tileButton.X, tileButton.Y, tileButton.Width, tileButton.Height, tileButton.NormalID).AppendTo(disp); } else { GumpRadio radio = e as GumpRadio; if (radio != null) { new GumpImage(radio.X, radio.Y, radio.InitialState ? radio.ActiveID : radio.InactiveID) .AppendTo(disp); } else { GumpCheck check = e as GumpCheck; if (check != null) { new GumpImage(check.X, check.Y, check.InitialState ? check.ActiveID : check.InactiveID).AppendTo(disp); } // Process text fields } } } } disp.AppendLayout(_EndLayout); } disp.WriteStrings(this._Strings); disp.Flush(); this._TextEntries = disp.TextEntries; this._Switches = disp.Switches; return(disp as Packet); }
/// <summary> /// Used to a a Checkbox column to the list in DETAILS mode. /// </summary> /// <param name="check"></param> public void AddColumn(GumpCheck check) { if (m_Style == "details") { columnValues.Add(m_ColCount, check); m_ColCount++; } m_ParentList.DebugWrite("Column Count: "+m_ColCount); }