public void onTopButtonClick(IGumpComponent gumpComponent, object param) { GumpButton button = gumpComponent as GumpButton; if (button != null) { int idx = button.Param; var elements = m_editorState.RendererToEdit.Elements.OrderBy(element => element.Z); if (idx > 0) { foreach (BaseCompendiumPageElement element in elements) { element.Z += 1; } BaseCompendiumPageElement topElement = elements.ElementAt(0); m_editorState.SelectedElement.Z = topElement.Z - 1; m_editorState.ElementListGumpCurrentPageNumber = 0; } } m_editorState.Refresh(); }
public static CompendiumPageRenderer Deserialize(XDocument document) { CompendiumPageRenderer renderer = new CompendiumPageRenderer(); XElement page = document.Descendants("CompendiumArticle").First(); IEnumerable <XElement> compendiumElementsXml = page.Descendants("Element"); renderer.Name = page.Descendants("Name").First().Value; foreach (XElement xElement in compendiumElementsXml) { try { renderer.m_elements.Add(BaseCompendiumPageElement.CreateElement(xElement)); } catch { } } if (renderer.m_elements.Count <= 0) { renderer = null; } return(renderer); }
public void onCloneButtonClick(IGumpComponent gumpComponent, object param) { GumpButton button = gumpComponent as GumpButton; if (button != null) { var elements = m_editorState.RendererToEdit.Elements.OrderBy(element => element.Z); if (button.Param >= 0 && elements.Count() > button.Param) { BaseCompendiumPageElement newElement = elements.ElementAt(button.Param).Clone() as BaseCompendiumPageElement; if (newElement != null) { m_editorState.RendererToEdit.Elements.Add(newElement); m_editorState.ElementListGumpCurrentPageNumber = m_editorState.RendererToEdit.Elements.Count / NUMBER_OF_ELEMENTS_PER_PAGE; m_editorState.SelectedElement = newElement; m_editorState.RendererToEdit.SelectedElement = newElement; BaseCompendiumPageElement lastElement = elements.ElementAt(elements.Count() - 1); newElement.Z = lastElement.Z + 1.0; } } } m_editorState.Refresh(); }
public virtual object Clone() { BaseCompendiumPageElement element = new BaseCompendiumPageElement(); element.Name = this.Name.Clone() as string; element.ElementType = this.ElementType.Clone() as string; element.X = this.X; element.Y = this.Y; element.Z = this.Z; return element; }
public virtual object Clone() { BaseCompendiumPageElement element = new BaseCompendiumPageElement(); element.Name = this.Name.Clone() as string; element.ElementType = this.ElementType.Clone() as string; element.X = this.X; element.Y = this.Y; element.Z = this.Z; return(element); }
public virtual object Clone() { var element = new BaseCompendiumPageElement { Name = Name.Clone() as string, ElementType = ElementType.Clone() as string, X = X, Y = Y, Z = Z }; return element; }
public virtual object Clone() { var element = new BaseCompendiumPageElement { Name = Name.Clone() as string, ElementType = ElementType.Clone() as string, X = X, Y = Y, Z = Z }; return(element); }
public void setPageBySelectedElement(BaseCompendiumPageElement selectedElement) { var elements = m_editorState.RendererToEdit.Elements.OrderBy(element => element.Z); int idx = elements.FindIndex(element => element == selectedElement); int page = idx / NUMBER_OF_ELEMENTS_PER_PAGE; int totalpages = (m_editorState.RendererToEdit.Elements.Count / NUMBER_OF_ELEMENTS_PER_PAGE) + 1; if (page < 0 || page > totalpages) { page = 0; } m_editorState.ElementListGumpCurrentPageNumber = page; }
public void ChangeZOrder(IGumpComponent gumpComponent, int direction) { GumpButton button = gumpComponent as GumpButton; if (button != null) { var elements = m_editorState.RendererToEdit.Elements.OrderBy(element => element.Z); if (elements.Count() > 1) { if (direction == Z_ORDER_CHANGE_UP) { if (button.Param > 0 && elements.Count() > button.Param) { BaseCompendiumPageElement upper = elements.ElementAt(button.Param - 1); BaseCompendiumPageElement lower = elements.ElementAt(button.Param); if (upper.Z == lower.Z) { lower.Z += 0.000001; } double temp = upper.Z; upper.Z = lower.Z; lower.Z = temp; } } else if (direction == Z_ORDER_CHANGE_DOWN) { if (elements.Count() > button.Param + 1) { BaseCompendiumPageElement upper = elements.ElementAt(button.Param); BaseCompendiumPageElement lower = elements.ElementAt(button.Param + 1); if (upper.Z == lower.Z) { lower.Z += 0.000001; } double temp = upper.Z; upper.Z = lower.Z; lower.Z = temp; } } } } m_editorState.Refresh(); }
public virtual void onAddElementButtonClick(IGumpComponent gumpComponent, object param) { GumpButton button = gumpComponent as GumpButton; if (button != null) { CompendiumElementRegistrationInfo instance = g_registeredElements.Values.Where(registeredKvp => registeredKvp.Index == button.Param).First(); BaseCompendiumPageElement element = instance.Method(); element.Z = EditorState.RendererToEdit.Elements.Count; EditorState.RendererToEdit.Elements.Add(element); EditorState.RendererToEdit.SelectedElement = element; EditorState.SelectedElement = element; EditorState.ElementListGump.setPageBySelectedElement(element); } EditorState.Refresh(); }
//pass in the element XML element public static BaseCompendiumPageElement CreateElement(XElement elementXml) { BaseCompendiumPageElement elementToReturn = null; var elementType = elementXml.Descendants("Type").First().Value; if (g_registeredElements.ContainsKey(elementType)) { elementToReturn = g_registeredElements[elementType](elementXml); } else { Console.WriteLine("Cannot create Compendium Element ({0}), it was not registered.", elementType); } return(elementToReturn); }
public void onDeleteButtonClick(IGumpComponent gumpComponent, object param) { GumpButton button = gumpComponent as GumpButton; if (button != null) { try { int idx = button.Param; var elements = m_editorState.RendererToEdit.Elements.OrderBy(element => element.Z); BaseCompendiumPageElement elementToRemove = m_editorState.SelectedElement; BaseCompendiumPageElement elementToSelect = null; int count = elements.Count(); if (count > 1) { if (idx < count - 1) { elementToSelect = elements.ElementAt(idx + 1); } else if (idx == count - 1) { elementToSelect = elements.ElementAt(idx - 1); } } m_editorState.SelectedElement = elementToSelect; m_editorState.RendererToEdit.SelectedElement = elementToSelect; m_editorState.RendererToEdit.Elements.Remove(elementToRemove); } catch (Exception e) { if (Compendium.LOG_ERRORS) { Console.WriteLine("An exception was caught while trying to delete a compendium element"); Console.WriteLine(e); } } } m_editorState.Refresh(); }
public void onBottomButtonClick(IGumpComponent gumpComponent, object param) { GumpButton button = gumpComponent as GumpButton; if (button != null) { int idx = button.Param; var elements = m_editorState.RendererToEdit.Elements.OrderBy(element => element.Z); if (idx < elements.Count() - 1) { BaseCompendiumPageElement lower = elements.ElementAt(elements.Count() - 1); m_editorState.SelectedElement.Z = lower.Z + 1; var changedElements = m_editorState.RendererToEdit.Elements.OrderBy(element => element.Z); int newIdx = changedElements.FindIndex(element => element == m_editorState.SelectedElement); m_editorState.ElementListGumpCurrentPageNumber = newIdx / NUMBER_OF_ELEMENTS_PER_PAGE; } } m_editorState.Refresh(); }
public static void Configure() { BaseCompendiumPageElement.RegisterElement("LabelElement", CreateLabelElement); CompendiumPageEditor.RegisterElementType(typeof(LabelElement), CreateInstance, " Label "); }
public static void Configure() { BaseCompendiumPageElement.RegisterElement("TiledImageElement", CreateTiledImageElement); CompendiumPageEditor.RegisterElementType(typeof(TiledImageElement), CreateInstance, " TiledImage "); }
public static void Configure() { BaseCompendiumPageElement.RegisterElement("BackgroundElement", CreateBackgroundElement); CompendiumPageEditor.RegisterElementType(typeof(BackgroundElement), CreateInstance, " Background "); }
public static void Configure() { BaseCompendiumPageElement.RegisterElement("AlphaAreaElement", CreateAlphaAreaElement); CompendiumPageEditor.RegisterElementType(typeof(AlphaAreaElement), CreateInstance, " AlphaArea "); }