public void HighlightThing(Thing t) { if (highlighted == t) { return; } ClearHighlighted(); // Set new highlight highlighted = t; if (highlighted == null || highlighted.IsDisposed) { highlighted = null; return; } if (renderer.StartThings(false)) { renderer.RenderThing(t, General.Colors.Highlight, 1.0f); renderer.Finish(); renderer.Present(); } }
public void HighlightVertex(Vertex v) { if (highlighted == v) { return; } ClearHighlighted(); highlighted = v; if (highlighted == null || highlighted.IsDisposed) { highlighted = null; return; } if (renderer.StartPlotter(false)) { renderer.PlotVertex(v, ColorCollection.HIGHLIGHT); renderer.Finish(); renderer.Present(); } }
public void HighlightLinedef(Linedef l) { if (highlighted == l) { return; } ClearHighlighted(); // Set new highlight highlighted = l; if (highlighted == null || highlighted.IsDisposed) { highlighted = null; return; } if (renderer.StartPlotter(false)) { renderer.PlotLinedef(l, General.Colors.Highlight); renderer.PlotVertex(l.Start, renderer.DetermineVertexColor(l.Start)); renderer.PlotVertex(l.End, renderer.DetermineVertexColor(l.End)); renderer.Finish(); renderer.Present(); } }
void OnPaginatedUISelect(GameObject[] data, object[] customData) { if (customData != null) { string asString = customData[0] as string; if (asString != null) { Inventory forInventory = (Inventory)customData[1]; int maxButtons = (int)customData[3]; int uiIndex = (int)customData[4]; bool updateButtons = false; SelectableElement newSelection = null; // hovered over the page up button if (asString == "BACK") { currentPaginatedOffsets[uiIndex]--; if (currentPaginatedOffsets[uiIndex] != 0) { newSelection = inventoryButtonsPerInventory[uiIndex][1]; } updateButtons = true; } // hovered over the page down button else if (asString == "FWD") { currentPaginatedOffsets[uiIndex]++; bool isAtEnd = currentPaginatedOffsets[uiIndex] >= forInventory.allInventory.Count - maxButtons; if (!isAtEnd) { newSelection = inventoryButtonsPerInventory[uiIndex][maxButtons - 2]; } updateButtons = true; } if (updateButtons) { Inventory linkedInventory = (Inventory)customData[2]; UpdateUIButtons(true, forInventory, linkedInventory, maxButtons, uiIndex, (int)customData[5]); if (newSelection != null) { StartCoroutine(SetSelection(newSelection.gameObject)); } } } } }
// Start is called before the first frame update void Start() { _parent = GetComponentInParent <SelectableElement>(); if (_parent == null) { throw new Exception("Parent not found!!!"); } _submitButton = GetComponentInChildren <Button>(); _submitButton.onClick.AddListener(PlaceElement); }
public void Dispose() { SelectableElement?.Dispose(AquaticPhysics.Instance); shark?.Dispose(); chunks.Values.ToList().ForEach(chunk => chunk.Dispose()); entities.ForEach(entity => entity.Dispose(AquaticPhysics.Instance)); chunks.Clear(); chunksToUpdate.Clear(); entities.Clear(); elementsToUpdate.Clear(); }
public ScriptMode() : base() { bScriptSuccess = true; bScriptDone = false; bScriptCancelled = false; bScriptParamsRequested = false; scriptPath = General.Settings.ReadPluginSetting("selectedscriptpath", ""); CancelReason = eCancelReason.Unknown; highlighted = null; // load default hello script if (!File.Exists(scriptPath)) { scriptPath = Path.Combine(General.AppPath, @"Lua\Examples\hello.lua"); } }
public void HighlightSector(Sector s) { if (highlighted == s) { return; } ClearHighlighted(); // Set new highlight highlighted = s; if (highlighted == null || highlighted.IsDisposed) { highlighted = null; return; } if (renderer.StartPlotter(false)) { renderer.PlotSector(s, General.Colors.Highlight); renderer.Finish(); renderer.Present(); } }
/// <summary> /// Returns a string that contains the description of the action and its arguments, based on the given Linedef or Thing /// </summary> /// <param name="se">An instance of Thing or Linedef</param> /// <returns>String that contains the description of the action and its arguments for a given Linedef or Thing</returns> private string GetActionDescription(SelectableElement se) { int action = 0; int[] actionargs = new int[5]; if (se is Thing) { action = ((Thing)se).Action; actionargs = ((Thing)se).Args; } else if (se is Linedef) { action = ((Linedef)se).Action; actionargs = ((Linedef)se).Args; } if (action > 0) { LinedefActionInfo lai = General.Map.Config.GetLinedefActionInfo(action); List <string> argdescription = new List <string>(); string description = lai.Index + ": " + lai.Title; // Label style: only action, or if the element can't have any parameters if (BuilderPlug.Me.EventLineLabelStyle == 0 || General.Map.Config.LineTagIndicatesSectors) { return(description); } for (int i = 0; i < 5; i++) { if (lai.Args[i].Used) { string argstring = ""; if (BuilderPlug.Me.EventLineLabelStyle == 2) // Label style: full arguments { argstring = lai.Args[i].Title + ": "; } EnumItem ei = lai.Args[i].Enum.GetByEnumIndex(actionargs[i].ToString()); if (ei != null && BuilderPlug.Me.EventLineLabelStyle == 2) // Label style: full arguments { argstring += ei.ToString(); } else // Argument has no EnumItem or label style: short arguments { argstring += actionargs[i].ToString(); } argdescription.Add(argstring); } } description += " (" + string.Join(", ", argdescription) + ")"; return(description); } return(null); }
/// <summary> /// Sets the association to a map element. Only works with an instance of Thing, Sector, or Linedef. /// Also gets the forward and reverse associations /// </summary> /// <param name="element">An instance of Thing, Sector, or Linedef</param> public void Set(SelectableElement element) { this.element = element; things = new List <Thing>(); sectors = new List <Sector>(); linedefs = new List <Linedef>(); eventlines = new Dictionary <string, List <Line3D> >(); if (element is Sector) { Sector s = element as Sector; center = (s.Labels.Count > 0 ? s.Labels[0].position : new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2)); type = UniversalType.SectorTag; tags = new HashSet <int>(s.Tags); } else if (element is Linedef) { Linedef ld = element as Linedef; center = ld.GetCenterPoint(); type = UniversalType.LinedefTag; tags = new HashSet <int>(ld.Tags); } else if (element is Thing) { Thing t = element as Thing; center = t.Position; ThingTypeInfo ti = General.Map.Data.GetThingInfoEx(t.Type); if (ti != null) { directlinktype = ti.ThingLink; } else { directlinktype = 0; } type = UniversalType.ThingTag; tags = new HashSet <int>(new int[] { t.Tag }); } // Remove the tag 0, because nothing sensible will come from it tags.Remove(0); // Get forward and reverse associations GetAssociations(); // Cache width of label text and generate the labels textwidths = new Dictionary <string, Vector2D>(eventlines.Count); textlabels = new Dictionary <string, List <TextLabel> >(eventlines.Count); foreach (KeyValuePair <string, List <Line3D> > kvp in eventlines) { SizeF size = General.Interface.MeasureString(kvp.Key, font); textwidths[kvp.Key] = new Vector2D(size.Width, size.Height); // Create one label for each line. We might not need them all, but better // to have them all at the beginning than to generate them later textlabels[kvp.Key] = new List <TextLabel>(kvp.Value.Count); for (int i = 0; i < kvp.Value.Count; i++) { // We don't need to set the position here, since it'll be done on the fly later TextLabel l = new TextLabel(); l.AlignX = TextAlignmentX.Center; l.AlignY = TextAlignmentY.Middle; l.TransformCoords = true; l.Text = kvp.Key; textlabels[kvp.Key].Add(l); } textwidths[kvp.Key] = new Vector2D(textlabels[kvp.Key][0].TextSize.Width, textlabels[kvp.Key][0].TextSize.Height); } SetEventLineColors(); }
/// <summary> /// This selects given map element (mxd) /// </summary> public virtual void SelectMapElement(SelectableElement element) { element.Selected = true; }
private void ToggleLightPannel() { SelectableElement deselectelement = null; if (General.Editing.Mode == null || General.Map.DOOM) { return; } string currentModeName = General.Editing.Mode.GetType().Name; //display one of colorPickers or tell the user why we can't do that if (currentModeName == "ThingsMode") { if (General.Map.Map.SelectedThingsCount == 0) { // If nothing is selected try to use a highlighted object if (General.Editing.Mode.HighlightedObject != null) { ((Thing)General.Editing.Mode.HighlightedObject).Selected = true; deselectelement = (Thing)General.Editing.Mode.HighlightedObject; } else { General.Interface.DisplayStatus(StatusType.Warning, "Select or highlight some lights first!"); return; } } form = new LightColorPicker(); } else if (currentModeName == "SectorsMode") { if (General.Map.UDMF) { if (General.Map.Map.SelectedSectorsCount == 0) { if (General.Editing.Mode.HighlightedObject != null) { ((Sector)General.Editing.Mode.HighlightedObject).Selected = true; } else { General.Interface.DisplayStatus(StatusType.Warning, "Select or highlight some sectors first!"); return; } } form = new SectorColorPicker(); } else { General.Interface.DisplayStatus(StatusType.Warning, "Sector colors can only be set if map is in UDMF format!"); return; } } else if (currentModeName == "BaseVisualMode") { //nothing selected in visual mode? if (((VisualMode)General.Editing.Mode).GetSelectedVisualThings(true).Count == 0) { //check sectors int selectedSectorsCount = ((VisualMode)General.Editing.Mode).GetSelectedVisualSectors(true).Count; if (General.Map.UDMF && (selectedSectorsCount > 0 || General.Map.Map.SelectedSectorsCount > 0)) { form = new SectorColorPicker(); } else { General.Interface.DisplayStatus(StatusType.Warning, "Select some lights " + (General.Map.UDMF ? ", sectors or surfaces " : "") + "first!"); return; } } else { form = new LightColorPicker(); } } else //wrong mode { General.Interface.DisplayStatus(StatusType.Warning, "Switch to" + (General.Map.UDMF ? " Sectors," : "") + " Things or GZDoom Visual Mode first!"); return; } if (form.Setup(currentModeName)) { if (formLocation.X == 0 && formLocation.Y == 0) { Size displaySize = General.Interface.Display.Size; Point displayLocation = General.Interface.Display.LocationAbs; formLocation = new Point(displayLocation.X + displaySize.Width - form.Width - 16, displayLocation.Y + 16); } form.Location = formLocation; form.FormClosed += form_FormClosed; form.ShowDialog(General.Interface); if (deselectelement != null) { deselectelement.Selected = false; } } else { form.Dispose(); form = null; } General.Interface.RedrawDisplay(); }
// This copies properties to any other element public void CopyPropertiesTo(SelectableElement element) { element.groups = this.groups; element.Selected = this.selected; base.CopyPropertiesTo(element); }
// NOTE: must call renderer.Present() at some point after public void ClearHighlighted() { if (highlighted == null || highlighted.IsDisposed) { return; } // ano - i don't like this whole "highlighted is " way of doing things // but i don't see a better way rn if (highlighted is Linedef) { Linedef l = (Linedef)highlighted; if (renderer.StartPlotter(false)) { // Undraw previous highlight if ((l != null) && !l.IsDisposed) { renderer.PlotLinedef(l, renderer.DetermineLinedefColor(l)); renderer.PlotVertex(l.Start, renderer.DetermineVertexColor(l.Start)); renderer.PlotVertex(l.End, renderer.DetermineVertexColor(l.End)); } renderer.Finish(); } } else if (highlighted is Thing) { Thing t = (Thing)highlighted; if (renderer.StartThings(false)) { renderer.RenderThing(t, renderer.DetermineThingColor(t), 1.0f); renderer.Finish(); } } else if (highlighted is Sector) { Sector s = (Sector)highlighted; if (renderer.StartPlotter(false)) { renderer.PlotSector(s); renderer.Finish(); } } else if (highlighted is Vertex) { Vertex v = (Vertex)highlighted; if (renderer.StartPlotter(false)) { renderer.PlotVertex(v, renderer.DetermineVertexColor(v)); renderer.Finish(); } } else { Logger.WriteLogLine("LUA SCRIPTMODE UNKNOWN HIGHLIGHT CLEAR?? " + highlighted); } highlighted = null; }
void MakeItemButton(SelectableElement element, Inventory.InventorySlot slot, Inventory forInventory, Inventory linkedInventory, int maxButtons, int uiIndex, int otherIndex) { string display = slot.item.itemName + " ( x" + slot.count + " )"; MakeButton(element, display, new object[] { slot.item, forInventory, linkedInventory, maxButtons, uiIndex, otherIndex }); }
void MakeButton(SelectableElement element, string text, object[] customData) { element.elementText = text; element.uiText.SetText(text); element.customData = customData; }
// This copies properties to any other element protected void CopyPropertiesTo(SelectableElement element) { element.groups = this.groups; element.Selected = this.selected; }