private StringWriter CreateDistroScript(bool bShowComment, bool bShowNames, bool bDefaultTexts) { StringWriter sw_Script = new StringWriter(); List <string> GumpCommands = new List <string>(); bGetDefaultText = bDefaultTexts; // define if plugin will set default text for empty elems string gump_name = GetGumpName(); GumpCommands.Add(DistroGump_GFCreateGump(gump_name, m_Designer.GumpProperties.Location)); GumpCommands.Add(""); if (!m_Designer.GumpProperties.Moveable) { GumpCommands.Add(String.Format("GFMovable({0}, 0);", gump_name)); } if (!m_Designer.GumpProperties.Closeable) { GumpCommands.Add(String.Format("GFClosable({0}, 0);", gump_name)); } if (!m_Designer.GumpProperties.Disposeable) { GumpCommands.Add(String.Format("GFDisposable({0}, 0);", gump_name)); } if (m_Designer.Stacks.Count > 0) { int radiogroup = -1; int pageindex = 0; // ================= foreach (GroupElement ge_Elements in m_Designer.Stacks) { if (pageindex > 0) { GumpCommands.Add(""); } GumpCommands.Add(DistroGump_GFPage(gump_name, ref pageindex)); // "page pageid" if (ge_Elements == null) { continue; } foreach (BaseElement be_Element in ge_Elements.GetElementsRecursive()) { if (be_Element == null) { continue; } if (bShowComment || bShowNames) { string comment = GetCommentString(be_Element, bShowComment, bShowNames); if (comment != String.Empty) { GumpCommands.Add(""); GumpCommands.Add(comment); } } Type ElementType = be_Element.GetType(); if (ElementType == typeof(HTMLElement)) { HTMLElement elem = be_Element as HTMLElement; if (elem.TextType == HTMLElementType.HTML) { GumpCommands.Add(DistroGump_GFHTMLArea(gump_name, elem)); } else { GumpCommands.Add(DistroGump_GFAddHTMLLocalized(gump_name, elem)); } } else if (ElementType == typeof(TextEntryElement)) { TextEntryElement elem = be_Element as TextEntryElement; GumpCommands.Add(DistroGump_GFTextEntry(gump_name, elem)); } else if (ElementType == typeof(LabelElement)) { LabelElement elem = be_Element as LabelElement; GumpCommands.Add(DistroGump_GFTextLine(gump_name, elem)); } else if (ElementType == typeof(AlphaElement)) { AlphaElement elem = be_Element as AlphaElement; GumpCommands.Add(DistroGump_GFAddAlphaRegion(gump_name, elem)); } else if (ElementType == typeof(BackgroundElement)) { BackgroundElement elem = be_Element as BackgroundElement; GumpCommands.Add(DistroGump_GFResizePic(gump_name, elem)); } else if (ElementType == typeof(ImageElement)) { ImageElement elem = be_Element as ImageElement; GumpCommands.Add(DistroGump_GFGumpPic(gump_name, elem)); } else if (ElementType == typeof(ItemElement)) { ItemElement elem = be_Element as ItemElement; GumpCommands.Add(DistroGump_GFTilePic(gump_name, elem)); } else if (ElementType == typeof(TiledElement)) { // TODO: Support "GFGumpPicTiled" when it´s in distro TiledElement elem = be_Element as TiledElement; GumpCommands.Add(""); GumpCommands.Add("//Gump package does not support GumpPicTiled"); GumpCommands.Add("//" + Gump_WriteGumpPicTiled(elem)); GumpCommands.Add(""); } else if (ElementType == typeof(ButtonElement)) { ButtonElement elem = be_Element as ButtonElement; GumpCommands.Add(DistroGump_GFAddButton(gump_name, elem)); } else if (ElementType == typeof(CheckboxElement)) { CheckboxElement elem = be_Element as CheckboxElement; GumpCommands.Add(DistroGump_GFCheckBox(gump_name, elem)); } else if (ElementType == typeof(RadioElement)) { RadioElement elem = be_Element as RadioElement; if (elem.Group != radiogroup) { GumpCommands.Add(String.Format("GFSetRadioGroup({0}, {1});", gump_name, elem.Group)); radiogroup = elem.Group; } GumpCommands.Add(DistroGump_GFRadioButton(gump_name, elem)); } } } } sw_Script.WriteLine("// Created {0}, with Gump Studio.", DateTime.Now); sw_Script.WriteLine("// Exported with {0} ver {1} for gump pkg", this.GetPluginInfo().PluginName, this.GetPluginInfo().Version); sw_Script.WriteLine(); sw_Script.WriteLine("use uo;"); sw_Script.WriteLine("use os;"); sw_Script.WriteLine(); sw_Script.WriteLine("include \":gumps:gumps\";"); sw_Script.WriteLine(); sw_Script.WriteLine("program gump_{0}(who)", gump_name); sw_Script.WriteLine(); foreach (string cmd in GumpCommands) { sw_Script.WriteLine("\t" + cmd); } sw_Script.WriteLine(); sw_Script.WriteLine("\tGFSendGump(who, {0});", gump_name); sw_Script.WriteLine(); sw_Script.WriteLine("endprogram"); return(sw_Script); }
public StringWriter GetSphereScript(bool bIsRevision) { StringWriter stringWriter1 = new StringWriter(); ArrayList arrayList1 = new ArrayList(); ArrayList arrayList2 = new ArrayList(); stringWriter1.WriteLine("// Created {0}, with Gump Studio.", (object)DateTime.Now); stringWriter1.WriteLine("// Exported with with {0} ver {1}.", (object)this.GetPluginInfo().PluginName, (object)this.GetPluginInfo().Version); stringWriter1.WriteLine("// Script for {0}", bIsRevision ? (object)"0.56/Revisions" : (object)"0.99/1.0"); stringWriter1.WriteLine(""); stringWriter1.WriteLine("[DIALOG {0}]", (object)this.frm_SphereExportForm.GumpName); StringWriter stringWriter2 = stringWriter1; string format = "{0}"; int num1 = bIsRevision ? 1 : 0; Point location = ((GumpProperties)this.m_Designer.GumpProperties).Location; int x = location.X; location = ((GumpProperties)this.m_Designer.GumpProperties).Location; int y = location.Y; string str = this.Gump_WriteLocation(num1 != 0, x, y); stringWriter2.WriteLine(format, (object)str); if (!((GumpProperties)this.m_Designer.GumpProperties).Closeable) { stringWriter1.WriteLine("{0}", bIsRevision ? (object)"NOCLOSE" : (object)"NoClose"); } if (!((GumpProperties)this.m_Designer.GumpProperties).Moveable) { stringWriter1.WriteLine("{0}", bIsRevision ? (object)"NOMOVE" : (object)"NoMove"); } if (!((GumpProperties)this.m_Designer.GumpProperties).Disposeable) { stringWriter1.WriteLine("{0}", bIsRevision ? (object)"NODISPOSE" : (object)"NoDispose"); } if (((ArrayList)this.m_Designer.Stacks).Count > 0) { int id1 = 0; int id2 = 0; int id3 = 0; int num2 = -1; for (int iPage = 0; iPage < ((ArrayList)this.m_Designer.Stacks).Count; ++iPage) { stringWriter1.WriteLine("{0}", (object)this.Gump_WritePage(bIsRevision, iPage)); GroupElement stack = ((ArrayList)this.m_Designer.Stacks)[iPage] as GroupElement; if (stack != null) { ArrayList elementsRecursive = stack.GetElementsRecursive(); if (elementsRecursive.Count > 0) { for (int index = 0; index < elementsRecursive.Count; ++index) { BaseElement baseElement = elementsRecursive[index] as BaseElement; if (baseElement != null) { HTMLElement htmlElement = baseElement as HTMLElement; if (htmlElement != null) { if (htmlElement.TextType == HTMLElementType.HTML) { if (bIsRevision) { string text = "HtmlGump id." + id1.ToString(); if (htmlElement.HTML != null) { arrayList2.Add((object)new SphereExporter.SphereElement(htmlElement.HTML.Length == 0 ? text : htmlElement.HTML, id1)); } else { arrayList2.Add((object)new SphereExporter.SphereElement(text, id1)); } } stringWriter1.WriteLine("{0}", (object)this.Gump_WriteHTML(bIsRevision, ((BaseElement)htmlElement).X, ((BaseElement)htmlElement).Y, ((ResizeableElement)htmlElement).Width, ((ResizeableElement)htmlElement).Height, htmlElement.ShowBackground, htmlElement.ShowScrollbar, ref id1, htmlElement.HTML)); } else { stringWriter1.WriteLine("{0}", (object)this.Gump_WriteXFHTML(bIsRevision, ((BaseElement)htmlElement).X, ((BaseElement)htmlElement).Y, ((ResizeableElement)htmlElement).Width, ((ResizeableElement)htmlElement).Height, htmlElement.ShowBackground, htmlElement.ShowScrollbar, htmlElement.CliLocID)); } } else { AlphaElement alphaElement = baseElement as AlphaElement; if (alphaElement != null) { stringWriter1.WriteLine("{0}", (object)this.Gump_WriteCheckerTrans(bIsRevision, ((BaseElement)alphaElement).X, ((BaseElement)alphaElement).Y, ((ResizeableElement)alphaElement).Width, ((ResizeableElement)alphaElement).Height)); } else { BackgroundElement backgroundElement = baseElement as BackgroundElement; if (backgroundElement != null) { stringWriter1.WriteLine("{0}", (object)this.Gump_WriteResizePic(bIsRevision, ((BaseElement)backgroundElement).X, ((BaseElement)backgroundElement).Y, ((ResizeableElement)backgroundElement).Width, ((ResizeableElement)backgroundElement).Height, backgroundElement.GumpID)); } else { ButtonElement buttonElement = baseElement as ButtonElement; if (buttonElement != null) { arrayList1.Add((object)new SphereExporter.SphereElement("// " + ((BaseElement)buttonElement).Name + "\n// " + buttonElement.Code, buttonElement.ButtonType == ButtonTypeEnum.Reply ? buttonElement.Param : id2)); stringWriter1.WriteLine("{0}", (object)this.Gump_WriteButton(bIsRevision, ((BaseElement)buttonElement).X, ((BaseElement)buttonElement).Y, buttonElement.NormalID, buttonElement.PressedID, buttonElement.ButtonType == ButtonTypeEnum.Page, buttonElement.Param, ref id2)); } else { ImageElement imageElement = baseElement as ImageElement; if (imageElement != null) { stringWriter1.WriteLine("{0}", (object)this.Gump_WriteGumpPic(bIsRevision, ((BaseElement)imageElement).X, ((BaseElement)imageElement).Y, imageElement.GumpID, imageElement.Hue.ToString())); } else { ItemElement itemElement = baseElement as ItemElement; if (itemElement != null) { stringWriter1.WriteLine("{0}", (object)this.Gump_WriteTilePic(bIsRevision, ((BaseElement)itemElement).X, ((BaseElement)itemElement).Y, itemElement.ItemID, itemElement.Hue.ToString())); } else { LabelElement labelElement = baseElement as LabelElement; if (labelElement != null) { if (bIsRevision) { string text = "Text id." + id1.ToString(); if (labelElement.Text != null) { arrayList2.Add((object)new SphereExporter.SphereElement(labelElement.Text.Length == 0 ? text : labelElement.Text, id1)); } else { arrayList2.Add((object)new SphereExporter.SphereElement(text, id1)); } } stringWriter1.WriteLine("{0}", (object)this.Gump_WriteText(bIsRevision, ((BaseElement)labelElement).X, ((BaseElement)labelElement).Y, labelElement.Hue.ToString(), labelElement.Text, ref id1)); } else { RadioElement radioElement = baseElement as RadioElement; if (radioElement != null) { if (radioElement.Group != num2) { stringWriter1.WriteLine("Group{0}", bIsRevision ? (object)(" " + radioElement.Group.ToString()) : (object)("(" + radioElement.Group.ToString() + ")")); num2 = radioElement.Group; } stringWriter1.WriteLine("{0}", (object)this.Gump_WriteRadioBox(bIsRevision, ((BaseElement)radioElement).X, ((BaseElement)radioElement).Y, ((CheckboxElement)radioElement).UnCheckedID, ((CheckboxElement)radioElement).CheckedID, radioElement.Checked, radioElement.Value)); } else { CheckboxElement checkboxElement = baseElement as CheckboxElement; if (checkboxElement != null) { stringWriter1.WriteLine("{0}", (object)this.Gump_WriteCheckBox(bIsRevision, ((BaseElement)checkboxElement).X, ((BaseElement)checkboxElement).Y, checkboxElement.UnCheckedID, checkboxElement.CheckedID, checkboxElement.Checked, ref id3)); } else { TextEntryElement textEntryElement = baseElement as TextEntryElement; if (textEntryElement != null) { if (bIsRevision) { string text = "Textentry id." + textEntryElement.ID.ToString(); if (textEntryElement.InitialText != null) { arrayList2.Add((object)new SphereExporter.SphereElement(textEntryElement.InitialText.Length == 0 ? text : textEntryElement.InitialText, id1)); } else { arrayList2.Add((object)new SphereExporter.SphereElement(text, id1)); } } stringWriter1.WriteLine("{0}", (object)this.Gump_WriteTextEntry(bIsRevision, ((BaseElement)textEntryElement).X, ((BaseElement)textEntryElement).Y, ((ResizeableElement)textEntryElement).Width, ((ResizeableElement)textEntryElement).Height, textEntryElement.Hue.ToString(), textEntryElement.InitialText, textEntryElement.ID, ref id1)); } else { TiledElement tiledElement = baseElement as TiledElement; if (tiledElement != null) { stringWriter1.WriteLine("{0}", (object)this.Gump_WriteGumpPicTiled(bIsRevision, ((BaseElement)tiledElement).X, ((BaseElement)tiledElement).Y, ((ResizeableElement)tiledElement).Width, ((ResizeableElement)tiledElement).Height, tiledElement.GumpID)); } } } } } } } } } } } } } } } } } stringWriter1.WriteLine(""); if (bIsRevision) { stringWriter1.WriteLine("[DIALOG {0} text]", (object)this.frm_SphereExportForm.GumpName); foreach (SphereExporter.SphereElement sphereElement in arrayList2) { stringWriter1.WriteLine("{0}", (object)sphereElement.sText); } stringWriter1.WriteLine(""); } stringWriter1.WriteLine("[DIALOG {0} button]", (object)this.frm_SphereExportForm.GumpName); foreach (SphereExporter.SphereElement sphereElement in arrayList1) { stringWriter1.WriteLine("ON={0}", (object)sphereElement.iId.ToString()); stringWriter1.WriteLine("{0}", (object)sphereElement.sText); stringWriter1.WriteLine(""); } stringWriter1.WriteLine("{0}", (object)this.Gump_WriteEOF()); return(stringWriter1); }
private string Gump_WriteTextEntry(TextEntryElement elem, ref List<string> texts) { int textid = texts.Count; string text = String.Concat("TextEntry id.", textid); if (elem.InitialText != null) { text = (elem.InitialText == String.Empty) ? text : elem.InitialText; } texts.Add(text); return String.Format("textentry {0} {1} {2} {3} {4} {5} {6}", elem.X, elem.Y, elem.Width, elem.Height, elem.Hue, elem.ID, textid); }
private StringWriter CreateBareScript() { StringWriter sw_Script = new StringWriter(); //ArrayList al_Buttons = new ArrayList(); //ArrayList al_Texts = new ArrayList(); List <string> GumpCommands = new List <string>(); List <string> GumpTexts = new List <string>(); sw_Script.WriteLine("// Created {0}, with Gump Studio.", DateTime.Now); sw_Script.WriteLine("// Exported with {0} ver {1}.", this.GetPluginInfo().PluginName, this.GetPluginInfo().Version); sw_Script.WriteLine(""); if (!m_Designer.GumpProperties.Moveable) { GumpCommands.Add("NoMove"); } if (!m_Designer.GumpProperties.Closeable) { GumpCommands.Add("NoClose"); } if (!m_Designer.GumpProperties.Disposeable) { GumpCommands.Add("NoDispose"); } if (m_Designer.Stacks.Count > 0) { int radiogroup = -1; int pageindex = 0; // ================= foreach (GroupElement ge_Elements in m_Designer.Stacks) { GumpCommands.Add(Gump_WritePage(ref pageindex)); // "page pageid" if (ge_Elements == null) { continue; } foreach (BaseElement be_Element in ge_Elements.GetElementsRecursive()) { if (be_Element == null) { continue; } Type ElementType = be_Element.GetType(); if (ElementType == typeof(HTMLElement)) { HTMLElement elem = be_Element as HTMLElement; if (elem.TextType == HTMLElementType.HTML) { string cmd = Gump_WriteHTMLGump(elem, ref GumpTexts); GumpCommands.Add(cmd); } else { string cmd = Gump_WriteXMFHtmlGump(elem); GumpCommands.Add(cmd); } } else if (ElementType == typeof(TextEntryElement)) { TextEntryElement elem = be_Element as TextEntryElement; string cmd = Gump_WriteTextEntry(elem, ref GumpTexts); GumpCommands.Add(cmd); } else if (ElementType == typeof(LabelElement)) { LabelElement elem = be_Element as LabelElement; string cmd = Gump_WriteText(elem, ref GumpTexts); GumpCommands.Add(cmd); } else if (ElementType == typeof(AlphaElement)) { AlphaElement elem = be_Element as AlphaElement; string cmd = Gump_WriteCheckerTrans(elem); GumpCommands.Add(cmd); } else if (ElementType == typeof(BackgroundElement)) { BackgroundElement elem = be_Element as BackgroundElement; string cmd = Gump_WriteResizePic(elem); GumpCommands.Add(cmd); } else if (ElementType == typeof(ImageElement)) { ImageElement elem = be_Element as ImageElement; string cmd = Gump_WriteGumpPic(elem); GumpCommands.Add(cmd); } else if (ElementType == typeof(ItemElement)) { ItemElement elem = be_Element as ItemElement; string cmd = Gump_WriteTilePic(elem); GumpCommands.Add(cmd); } else if (ElementType == typeof(TiledElement)) { TiledElement elem = be_Element as TiledElement; string cmd = Gump_WriteGumpPicTiled(elem); GumpCommands.Add(cmd); } else if (ElementType == typeof(ButtonElement)) { ButtonElement elem = be_Element as ButtonElement; string cmd = Gump_WriteButton(elem); GumpCommands.Add(cmd); } else if (ElementType == typeof(CheckboxElement)) { CheckboxElement elem = be_Element as CheckboxElement; string cmd = Gump_WriteCheckBox(elem); GumpCommands.Add(cmd); } else if (ElementType == typeof(RadioElement)) { RadioElement elem = be_Element as RadioElement; if (elem.Group != radiogroup) { GumpCommands.Add("group " + elem.Group); radiogroup = elem.Group; } string cmd = Gump_WriteRadioBox(elem); GumpCommands.Add(cmd); } } } } sw_Script.WriteLine(""); sw_Script.WriteLine("use uo;"); sw_Script.WriteLine("use os;"); sw_Script.WriteLine(""); sw_Script.WriteLine("program gump_{0}( who )", frm_POLExportForm.GumpName); sw_Script.WriteLine(""); sw_Script.WriteLine("\tvar gump := array {"); int i = 1; foreach (string tmpCmd in GumpCommands) { sw_Script.Write("\t\t\"{0}\"", tmpCmd); if (i == GumpCommands.Count) { sw_Script.WriteLine(""); } else { sw_Script.WriteLine(",", tmpCmd); } i++; } sw_Script.WriteLine("\t};"); sw_Script.WriteLine("\tvar data := array {"); i = 1; foreach (string tmpSe in GumpTexts) { sw_Script.Write("\t\t\"{0}\"", tmpSe); if (i == GumpTexts.Count) { sw_Script.WriteLine(""); } else { sw_Script.WriteLine(","); } i++; } sw_Script.WriteLine("\t};"); sw_Script.WriteLine(""); sw_Script.WriteLine("\tSendDialogGump( who, gump, data{0} );", Gump_Location(m_Designer.GumpProperties.Location)); sw_Script.WriteLine(""); sw_Script.WriteLine("endprogram"); return(sw_Script); }
private string DistroGump_GFTextEntry(string gump_name, TextEntryElement elem) { string text = (bGetDefaultText) ? "TextEntry" : ""; if (elem.InitialText != null) if (elem.InitialText != String.Empty) text = elem.InitialText; string hue = (elem.Hue != null) ? elem.Hue.ToString() : "0"; return String.Format("GFTextEntry({0}, {1}, {2}, {3}, {4}, {5}, \"{6}\", {7});", gump_name, elem.X, elem.Y, elem.Width, elem.Height, hue, text, elem.ID); }