private void DrawColorPicker(string name, string tooltip, uint value, uint defaultValue, Action <uint> setter) { const ImGuiColorEditFlags flags = ImGuiColorEditFlags.AlphaPreviewHalf | ImGuiColorEditFlags.NoInputs; var tmp = ImGui.ColorConvertU32ToFloat4(value); if (ImGui.ColorEdit4($"##{name}", ref tmp, flags)) { ChangeAndSave(ImGui.ColorConvertFloat4ToU32(tmp), value, setter); } ImGui.SameLine(); if (ImGui.Button($"Default##{name}")) { ChangeAndSave(defaultValue, value, setter); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip( $"Reset to default: #{defaultValue & 0xFF:X2}{(defaultValue >> 8) & 0xFF:X2}{(defaultValue >> 16) & 0xFF:X2}{defaultValue >> 24:X2}"); } ImGui.SameLine(); ImGui.Text(name); if (ImGui.IsItemHovered()) { ImGui.SetTooltip(tooltip); } }
public static void EndFramedGroup() { var borderColor = ImGui.ColorConvertFloat4ToU32(ImGui.GetStyle().Colors[( int )ImGuiCol.Border]); var itemSpacing = ImGui.GetStyle().ItemSpacing; var frameHeight = ImGui.GetFrameHeight(); var halfFrameHeight = new Vector2(ImGui.GetFrameHeight() / 2, 0); ImGui.PopItemWidth(); ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero); ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero); ImGui.EndGroup(); // Close fourth group ImGui.EndGroup(); // Close third group ImGui.SameLine(); // Ensure right distance. ImGui.Dummy(halfFrameHeight); // Ensure bottom distance ImGui.Dummy(Vector2.UnitY * (frameHeight / 2 - itemSpacing.Y)); ImGui.EndGroup(); // Close second group var itemMin = ImGui.GetItemRectMin(); var itemMax = ImGui.GetItemRectMax(); var(currentLabelMin, currentLabelMax) = LabelStack[^ 1];
public static void EndFramedGroup() { var borderColor = ImGui.ColorConvertFloat4ToU32(ImGui.GetStyle().Colors[( int )ImGuiCol.Border]); var itemSpacing = ImGui.GetStyle().ItemSpacing; var frameHeight = ImGui.GetFrameHeight(); var halfFrameHeight = new Vector2(ImGui.GetFrameHeight() / 2, 0); ImGui.PopItemWidth(); ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, ZeroVector); ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, ZeroVector); ImGui.EndGroup(); // Close fourth group ImGui.EndGroup(); // Close third group ImGui.SameLine(); // Ensure right distance. ImGui.Dummy(halfFrameHeight); // Ensure bottom distance ImGui.Dummy(new Vector2(0, frameHeight / 2 - itemSpacing.Y)); ImGui.EndGroup(); // Close second group var itemMin = ImGui.GetItemRectMin(); var itemMax = ImGui.GetItemRectMax(); var(currentLabelMin, currentLabelMax) = labelStack[labelStack.Count - 1]; labelStack.RemoveAt(labelStack.Count - 1); var halfFrame = new Vector2(frameHeight / 8, frameHeight / 2); currentLabelMin.X -= itemSpacing.X; currentLabelMax.X += itemSpacing.X; var frameMin = itemMin + halfFrame; var frameMax = itemMax - new Vector2(halfFrame.X, 0); // Left DrawClippedRect(new Vector2(-float.MaxValue, -float.MaxValue), new Vector2(currentLabelMin.X, float.MaxValue), frameMin, frameMax, borderColor, halfFrame.X); // Right DrawClippedRect(new Vector2(currentLabelMax.X, -float.MaxValue), new Vector2(float.MaxValue, float.MaxValue), frameMin, frameMax, borderColor, halfFrame.X); // Top DrawClippedRect(new Vector2(currentLabelMin.X, -float.MaxValue), new Vector2(currentLabelMax.X, currentLabelMin.Y), frameMin, frameMax, borderColor, halfFrame.X); // Bottom DrawClippedRect(new Vector2(currentLabelMin.X, currentLabelMax.Y), new Vector2(currentLabelMax.X, float.MaxValue), frameMin, frameMax, borderColor, halfFrame.X); ImGui.PopStyleVar(2); // This seems wrong? // ImGui.SetWindowSize( new Vector2( ImGui.GetWindowSize().X + frameHeight, ImGui.GetWindowSize().Y ) ); ImGui.Dummy(ZeroVector); ImGui.EndGroup(); // Close first group }
void DisplayButtons(string name, List <ToolbuttonData> DisplayToolButtons) { if (ImGui.Begin(name, _flags)) { uint unclickedcolor; uint clickedcolour; ImGuiCol buttonidx = ImGuiCol.Button; unsafe { Vector4 *unclickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.Button); Vector4 *clickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.ButtonActive); unclickedcolor = ImGui.ColorConvertFloat4ToU32(*unclickedcolorv); clickedcolour = ImGui.ColorConvertFloat4ToU32(*clickedcolorv); } //Store the colors for pressed and unpressed buttons uint iterations = 0; //displays the default toolbar menu icons foreach (var button in DisplayToolButtons)//For each button { string id = iterations.ToString(); ImGui.PushID(id); if (button.GetActive != null) //If the windows state can be checked { if (button.GetActive()) //If the window is open { ImGui.PushStyleColor(buttonidx, clickedcolour); //Have the button be "pressed" } else//If closed { ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally } } if (ImGui.ImageButton(button.Picture, BtnSizes))//Make the button { button.OnClick(); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(button.TooltipText); } ImGui.PopID(); iterations++; } ImGui.PushStyleColor(buttonidx, unclickedcolor); ImGui.End(); } }
public static bool BufferingBar(string label, float value, Vector2 sizeArg, Vector4 bgCol, Vector4 fgCol) { value = Math.Clamp(value, 0, 1); //ImGuiWindow* window = GetCurrentWindow(); //if (window->SkipItems) // return false; ImGuiStylePtr style = ImGui.GetStyle(); uint id = ImGui.GetID(label); Vector2 pos = ImGui.GetWindowPos() + ImGui.GetCursorPos() - new Vector2(ImGui.GetScrollX(), ImGui.GetScrollY()); Vector2 size = sizeArg; size.X -= style.FramePadding.X * 2; //const ImRect bb(pos, ImVec2(pos.x +size.x, pos.y + size.y)); //ItemSize(bb, style.FramePadding.y); //if (!ItemAdd(bb, id)) // return false; // Render float circleStart = size.X * (0.7f + 0.3f * value); float circleEnd = size.X; float circleWidth = circleEnd - circleStart; uint bgColorInt = ImGui.ColorConvertFloat4ToU32(bgCol); uint fgColorInt = ImGui.ColorConvertFloat4ToU32(fgCol); ImGui.GetWindowDrawList().AddRectFilled(pos, new Vector2(pos.X + circleStart, pos.Y + size.Y), bgColorInt); ImGui.GetWindowDrawList().AddRectFilled(pos, new Vector2(pos.X + circleStart * value, pos.Y + size.Y), fgColorInt); float t = (float)ImGui.GetTime(); float r = size.Y / 2; float speed = 1.5f; float a = speed * 0; float b = speed * 0.333f; float c = speed * 0.666f; float o1 = (circleWidth + r) * (t + a - speed * (int)((t + a) / speed)) / speed; float o2 = (circleWidth + r) * (t + b - speed * (int)((t + b) / speed)) / speed; float o3 = (circleWidth + r) * (t + c - speed * (int)((t + c) / speed)) / speed; ImGui.GetWindowDrawList().AddCircleFilled(new Vector2(pos.X + circleEnd - o1, pos.Y + r), r, bgColorInt); ImGui.GetWindowDrawList().AddCircleFilled(new Vector2(pos.X + circleEnd - o2, pos.Y + r), r, bgColorInt); ImGui.GetWindowDrawList().AddCircleFilled(new Vector2(pos.X + circleEnd - o3, pos.Y + r), r, bgColorInt); ImGui.SetCursorPos(new Vector2(style.WindowPadding.X, ImGui.GetCursorPos().Y + size.Y + style.FramePadding.Y)); return(true); }
private static void DrawLines(IReadOnlyList <Vector2> points, Vector2 location, float size) { uint iconColor = ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 1)); ImDrawListPtr drawList = ImGui.GetWindowDrawList(); for (int i = 0; i < points.Count; i += 2) { Vector2 vector1 = (points[i] / 100) * size; Vector2 vector2 = (points[i + 1] / 100) * size; drawList.AddLine(location + vector1, location + vector2, iconColor); } }
private void ProgressBar(ProgressStep currentStep) { var yProgressBar = _yOffset + 32f * 4; var xProgressBar = _xOffset + Margin; var upperLeft = new Vector2(xProgressBar, yProgressBar); var lowerRightY = yProgressBar + ProgressbarHeight; var lowerRightOutline = new Vector2(xProgressBar + ProgressbarWidth, lowerRightY); var lowerRightFilled = new Vector2((float)(xProgressBar + ProgressbarWidth * currentStep.ProgressPercentage), lowerRightY); ImGui.GetWindowDrawList().AddRect(upperLeft, lowerRightOutline, ImGui.ColorConvertFloat4ToU32(new Vector4(0.2f, 0.4f, 1.0f, 1.0f))); ImGui.GetWindowDrawList().AddRectFilled(upperLeft, lowerRightFilled, ImGui.ColorConvertFloat4ToU32(new Vector4(0.6f, 0.2f, 1.0f, 1.0f))); }
public static void EndGroupFrame() { var style = ImGui.GetStyle(); if (style.FramePadding.X > 0) { ImGui.Unindent(); } ImGui.Dummy(new Vector2(0, style.FramePadding.Y)); ImGui.EndGroup(); ImGui.GetWindowDrawList().AddRect( ImGui.GetItemRectMin(), new Vector2(ImGui.GetColumnWidth() + style.FramePadding.X + ImGui.GetWindowPos().X, ImGui.GetItemRectMax().Y), ImGui.ColorConvertFloat4ToU32(style.Colors[(int)ImGuiCol.Separator]), style.FrameRounding, ImDrawFlags.None, 1.5f); }
public static void EndBorderedGroup(Num.Vector2 minPadding, Num.Vector2 maxPadding = default(Num.Vector2)) { ImGui.EndGroup(); // attempt to size the border around the content to frame it Num.Vector4 color = ImGui.GetStyle().Colors[(int)ImGuiCol.Border]; Num.Vector2 min = ImGui.GetItemRectMin(); Num.Vector2 max = ImGui.GetItemRectMax(); max.X = min.X + ImGui.GetContentRegionAvail().X; ImGui.GetWindowDrawList().AddRect(min - minPadding, max + maxPadding, ImGui.ColorConvertFloat4ToU32(color)); // this fits just the content, not the full width //ImGui.GetWindowDrawList().AddRect( ImGui.GetItemRectMin() - padding, ImGui.GetItemRectMax() + padding, packedColor ); }
public override void OnGUIInspector(object userData) { Camera camera = userData as Camera; if (camera == null) { return; } base.OnGUIInspector(userData); if (ImGui.CollapsingHeader("Camera##Inspector", treeNodeFlags)) { float r = 0, g = 0, b = 0, a = 0;; Vector4 color = ImGui.ColorConvertU32ToFloat4(camera.clearColor); a = color.X; b = color.Y; g = color.Z; r = color.W; Vector4 color4 = Vector4.Zero; color4.X = r; color4.Y = g; color4.Z = b; color4.W = a; ImGui.ColorEdit4("Background", ref color4); ImGui.SameLine(); if (ImGui.Button("↙##Inspector##Camera##PickColor")) { ImGui.OpenPopup("PickColor##RightMenu##Inspector##Camera"); } if (ImGui.BeginPopup("PickColor##RightMenu##Inspector##Camera")) { ImGui.ColorPicker4("PickColor##Inspector##Camera#", ref color4); ImGui.EndPopup(); } color.W = color4.X; color.Z = color4.Y; color.Y = color4.Z; color.X = color4.W; camera.clearColor = ImGui.ColorConvertFloat4ToU32(color4); } }
public static void RenderSpinner(Vector2 position, float radius, int thickness) { float time = (float)ImGui.GetTime(); uint color = ImGui.ColorConvertFloat4ToU32(new Vector4(0.5f, 0.5f, 0.5f, 1)); ImDrawListPtr drawList = ImGui.GetWindowDrawList(); int num_segments = 30; int start = (int)MathF.Abs(MathF.Sin(time * 1.8f) * (num_segments - 5)); float a_min = MathF.PI * 2.0f * (start) / num_segments; float a_max = MathF.PI * 2.0f * ((float)num_segments - 3) / num_segments; var centre = new Vector2(position.X + radius, position.Y + radius + ImGui.GetStyle().FramePadding.Y); drawList.PathClear(); for (int i = 0; i < num_segments; i++) { float a = a_min + (i / (float)num_segments) * (a_max - a_min); var location = new Vector2(centre.X + MathF.Cos(a + time * 8) * radius, centre.Y + MathF.Sin(a + time * 8) * radius); drawList.PathLineTo(location); } drawList.PathStroke(color, false, thickness); }
static uint ColorInt(Color4 c, float aMod = 1f) { return(ImGui.ColorConvertFloat4ToU32(new Vector4( c.R, c.G, c.B, c.A * aMod ))); }
internal override void Display() { float xpad = 24; float ypad = 16; float x = _btnSize + xpad; float y = (_btnSize + ypad) * ToolButtons.Count; ImGui.SetNextWindowSize(new Vector2(x, y)); if (ImGui.Begin("##Toolbar", _flags)) { uint unclickedcolor; uint clickedcolour; ImGuiCol buttonidx = ImGuiCol.Button; unsafe { Vector4 *unclickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.Button); Vector4 *clickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.ButtonActive); unclickedcolor = ImGui.ColorConvertFloat4ToU32(*unclickedcolorv); clickedcolour = ImGui.ColorConvertFloat4ToU32(*clickedcolorv); } //Store the colors for pressed and unpressed buttons uint iterations = 0; //displays the default toolbar menu icons foreach (var button in ToolButtons)//For each button { string id = iterations.ToString(); ImGui.PushID(id); if (button.GetActive != null) //If the windows state can be checked { if (button.GetActive()) //If the window is open { ImGui.PushStyleColor(buttonidx, clickedcolour); //Have the button be "pressed" } else//If closed { ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally } } if (ImGui.ImageButton(button.Picture, BtnSizes))//Make the button { button.OnClick(); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(button.TooltipText); } ImGui.PopID(); iterations++; } ImGui.PushStyleColor(buttonidx, unclickedcolor); ImGui.End(); } }
void Draw() { if (!Open) { if (WasOpen) { p.Config.Save(); WasOpen = false; p.Log("Configuration saved"); } return; } WasOpen = true; ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, new Vector2(700, 200)); if (ImGui.Begin("Splatoon", ref Open)) { #if DEBUG ImGui.PushStyleColor(ImGuiCol.Text, Colors.Orange); ImGuiEx.TextCentered("Unlimited edition v" + Splatoon.Ver); ImGui.PopStyleColor(); #endif if (ImGui.CollapsingHeader("General settings")) { ImGuiEx.SizedText("Circle smoothness:", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(100f); ImGui.DragInt("##circlesmoothness", ref p.Config.segments, 0.1f, 10, 150); ImGui.SameLine(); ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("You can't draw circles. They are all fake.\n" + "Every circle is techincally a polygon.\n" + "The higher this number is, the rounder your circle will be.\n" + "But it will also increase processing power needed to display circles.\n" + "If you are using many circles or your CPU is on weaker side,\n" + "consider lowering this value. Generally it's best to keep it\n" + "as low as possible as long as you are satisfied with look."); } ImGuiEx.SizedText("Drawing distance:", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(100f); ImGui.DragFloat("##maxdistance", ref p.Config.maxdistance, 0.25f, 10f, 200f); ImGui.SameLine(); ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Only try to draw objects that are not \n" + "further away from you than this value"); } ImGuiEx.SizedText("Draw only when Y camera rotation is higher than:", WidthLayout * 2); ImGui.SameLine(); ImGui.SetNextItemWidth(150f); ImGui.DragFloat("##camymax", ref p.Config.maxcamY, 0.005f, -1.48353f, 0.78540f, p.Config.maxcamY.ToString("0.#####")); ImGui.SameLine(); ImGui.Text("Current: " + p.CamAngleY); if (ImGui.Button("Open debug window")) { p.DebugGui.Open = true; } } ImGui.Checkbox("Allow layout deletion", ref enableDeletion); ImGui.SameLine(); ImGui.Checkbox("Allow elements deletion", ref enableDeletionElement); ImGui.SetNextItemWidth(350f); ImGui.InputTextWithHint("##lname", "Unique layout name", ref lname, 100); lname.Trim(); ImGui.SameLine(); if (ImGui.Button("Add layout")) { if (p.Config.Layouts.ContainsKey(lname)) { p.Log("Error: this name already exists", true); } else if (lname.Length == 0) { p.Log("Error: you must name layout", true); } else if (lname.Contains("~")) { p.Log("Name can't contain reserved characters: ~", true); } else { p.Config.Layouts.Add(lname, new Layout()); lname = ""; } } ImGui.SameLine(); ImGui.Text("Import layout from:"); ImGui.SameLine(); if (ImGui.Button("clipboard")) { try { ImportFromText(Clipboard.GetText()); } catch (Exception e) { p.Log(e.Message + "\n" + e.StackTrace); } } /*ImGui.SameLine(); * if (ImGui.Button("file")) * { * try * { * using (OpenFileDialog openFileDialog = new OpenFileDialog()) * { * openFileDialog.Filter = "json files (*.json)|*.json"; * openFileDialog.FilterIndex = 0; * openFileDialog.RestoreDirectory = true; * openFileDialog.Title = "Select file to import"; * * if (openFileDialog.ShowDialog() == DialogResult.OK) * { * //Read the contents of the file into a stream * var fileStream = openFileDialog.OpenFile(); * * using (StreamReader reader = new StreamReader(fileStream)) * { * ImportFromText(reader.ReadToEnd()); * } * } * } * } * catch (Exception e) * { * p.Log(e.Message + "\n" + e.StackTrace); * } * }*/ ImGui.BeginChild("##layoutlist"); var open = false; foreach (var i in p.Config.Layouts.Keys.ToArray()) { var colored = false; if (!p.Config.Layouts[i].Enabled) { colored = true; ImGui.PushStyleColor(ImGuiCol.Text, Colors.Gray); } else if (p.Config.Layouts[i].DisableDisabling) { colored = true; ImGui.PushStyleColor(ImGuiCol.Text, Colors.Orange); } if ((curEdit == null || curEdit == i) && ImGui.CollapsingHeader(i)) { if (colored) { ImGui.PopStyleColor(); colored = false; } open = true; curEdit = i; if (enableDeletion) { ImGui.PushStyleColor(ImGuiCol.Button, Colors.Red); if (ImGui.Button("Delete##dltlt" + i)) { p.Config.Layouts.Remove(i); enableDeletion = false; } ImGui.PopStyleColor(); ImGui.SameLine(); } if (p.Config.Layouts.ContainsKey(i)) { ImGui.Checkbox("Enabled##" + i, ref p.Config.Layouts[i].Enabled); ImGui.SameLine(); ImGui.Checkbox("Prevent disabling with mass disabling commands##" + i, ref p.Config.Layouts[i].DisableDisabling); if (ImGui.Button("Export to clipboard")) { Clipboard.SetText(i + "~" + JsonConvert.SerializeObject(p.Config.Layouts[i], Formatting.None, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore })); } ImGui.SameLine(); if (ImGui.Button("Copy enable command")) { Clipboard.SetText("/splatoon enable " + i); } ImGui.SameLine(); if (ImGui.Button("Copy disable command")) { Clipboard.SetText("/splatoon disable " + i); } ImGuiEx.SizedText("Display conditions:", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); ImGui.Combo("##dcn" + i, ref p.Config.Layouts[i].DCond, Layout.DisplayConditions, Layout.DisplayConditions.Length); ImGuiEx.SizedText("Visibility of layout:", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); ImGui.Combo("##vsb" + i, ref p.Config.Layouts[i].Visibility, Layout.VisibilityType, Layout.VisibilityType.Length); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Not yet implemented"); } p.Config.Layouts[i].Visibility = 0; if (p.Config.Layouts[i].Visibility > 0) { ImGui.SameLine(); ImGui.Checkbox("Auto-hide on leaving combat##" + i, ref p.Config.Layouts[i].AutoHideOutCombat); } if (p.Config.Layouts[i].Visibility == 2 || p.Config.Layouts[i].Visibility == 3) { ImGuiEx.SizedText("Message trigger to show:", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); ImGui.InputTextWithHint("##msgshow" + i, "Case-insensitive (partial) message", ref p.Config.Layouts[i].MessageToWatch, 100); } if (p.Config.Layouts[i].Visibility == 1 || p.Config.Layouts[i].Visibility == 2) { ImGuiEx.SizedText("Visibility time:", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(50f); ImGui.DragInt("##btbg" + i, ref p.Config.Layouts[i].BattleTimeBegin, 1f, 0, 60 * 20); ImGui.SameLine(); ImGui.Text("-"); ImGui.SameLine(); ImGui.SetNextItemWidth(50f); ImGui.DragInt("##bte" + i, ref p.Config.Layouts[i].BattleTimeEnd, 1f, p.Config.Layouts[i].BattleTimeBegin, 60 * 20); ImGui.SameLine(); ImGui.Text(DateTimeOffset.FromUnixTimeSeconds(p.Config.Layouts[i].BattleTimeBegin).ToString("mm:ss") + " - " + DateTimeOffset.FromUnixTimeSeconds(p.Config.Layouts[i].BattleTimeEnd).ToString("mm:ss")); } if (p.Config.Layouts[i].Visibility == 3) { ImGuiEx.SizedText("Message trigger to hide:", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); ImGui.InputTextWithHint("##msghide" + i, "Case-insensitive (partial) message", ref p.Config.Layouts[i].MessageToWatchForEnd, 100); } ImGuiEx.SizedText("Zone lock: ", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); if (ImGui.BeginCombo("##zlk" + i, p.Config.Layouts[i].ZoneLock == 0 ? "All zones" : p.Config.Layouts[i].ZoneLock + " / " + p.Zones[p.Config.Layouts[i].ZoneLock].PlaceName.Value.Name)) { ImGui.InputTextWithHint("##zfltr" + i, "Filter", ref zlockf, 100); if (ImGui.Selectable("All zones")) { p.Config.Layouts[i].ZoneLock = 0; } ImGui.PushStyleColor(ImGuiCol.Text, 0xff00ffff); if (ImGui.Selectable("Current zone: " + p._pi.ClientState.TerritoryType + " / " + p.Zones[p._pi.ClientState.TerritoryType].PlaceName.Value.Name)) { p.Config.Layouts[i].ZoneLock = p._pi.ClientState.TerritoryType; } ImGui.PopStyleColor(); foreach (var z in p.Zones) { if (z.Value.PlaceName.Value.Name.ToString().Length == 0) { continue; } var s = z.Key + " / " + z.Value.PlaceName.Value.Name; if (!s.ToLower().Contains(zlockf)) { continue; } if (ImGui.Selectable(s)) { p.Config.Layouts[i].ZoneLock = z.Key; } } ImGui.EndCombo(); } var jprev = new List <string>(); if (p.Config.Layouts[i].JobLock == 0) { jprev.Add("All jobs"); } else { foreach (var k in p.Jobs) { if (Bitmask.IsBitSet(p.Config.Layouts[i].JobLock, k.Key)) { jprev.Add(k.Value); } } } ImGuiEx.SizedText("Job lock", WidthLayout); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); if (ImGui.BeginCombo("##joblock" + i, jprev.Count < 3?string.Join(", ", jprev): jprev.Count + " jobs")) { ImGui.InputTextWithHint("##joblockfltr" + i, "Filter", ref jobFilter, 100); foreach (var k in p.Jobs) { if (!k.Key.ToString().Contains(jobFilter) && !k.Value.Contains(jobFilter)) { continue; } if (k.Key == 0) { continue; } var col = false; if (Bitmask.IsBitSet(p.Config.Layouts[i].JobLock, k.Key)) { ImGui.PushStyleColor(ImGuiCol.Button, Colors.Red); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, Colors.Red); col = true; } if (ImGui.SmallButton(k.Key + " / " + k.Value + "##selectjob" + i)) { if (Bitmask.IsBitSet(p.Config.Layouts[i].JobLock, k.Key)) { Bitmask.ResetBit(ref p.Config.Layouts[i].JobLock, k.Key); } else { Bitmask.SetBit(ref p.Config.Layouts[i].JobLock, k.Key); } } if (col) { ImGui.PopStyleColor(2); } } ImGui.EndCombo(); } ImGui.PushItemWidth(WidthCombo); ImGui.InputTextWithHint("##elnameadd" + i, "Unique element name", ref ename, 100); ImGui.PopItemWidth(); ImGui.SameLine(); if (ImGui.Button("Add element##addelement" + i)) { if (p.Config.Layouts[i].Elements.ContainsKey(ename)) { p.Log("Error: this name already exists", true); } else if (ename.Length == 0) { p.Log("Error: you must name layout", true); } else { var el = new Element(0); el.refX = p._pi.ClientState.LocalPlayer.Position.X; el.refY = p._pi.ClientState.LocalPlayer.Position.Y; el.refZ = p._pi.ClientState.LocalPlayer.Position.Z; p.Config.Layouts[i].Elements.Add(ename, el); ename = ""; } } foreach (var k in p.Config.Layouts[i].Elements.Keys.ToArray()) { var el = p.Config.Layouts[i].Elements[k]; var elcolored = false; if (!el.Enabled) { ImGui.PushStyleColor(ImGuiCol.Text, Colors.Gray); elcolored = true; } if (ImGui.CollapsingHeader(i + " / " + k + "##elem" + i + k)) { if (elcolored) { ImGui.PopStyleColor(); elcolored = false; } if (enableDeletionElement) { ImGui.PushStyleColor(ImGuiCol.Button, Colors.Orange); if (ImGui.Button("Delete##elemdel" + i + k)) { p.Config.Layouts[i].Elements.Remove(k); } ImGui.PopStyleColor(); ImGui.SameLine(); } if (p.Config.Layouts[i].Elements.ContainsKey(k)) { ImGui.Checkbox("Enabled##" + i + k, ref el.Enabled); ImGuiEx.SizedText("Element type:", WidthElement); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); ImGui.Combo("##elemselecttype" + i + k, ref el.type, Element.ElementTypes, Element.ElementTypes.Length); if (el.type == 0 || el.type == 2) { ImGuiEx.SizedText("Reference position: ", WidthElement); ImGui.SameLine(); ImGui.PushItemWidth(60f); ImGui.Text("X:"); ImGui.SameLine(); ImGui.DragFloat("##refx" + i + k, ref el.refX, 0.02f, float.MinValue, float.MaxValue); ImGui.SameLine(); ImGui.Text("Y:"); ImGui.SameLine(); ImGui.DragFloat("##refy" + i + k, ref el.refY, 0.02f, float.MinValue, float.MaxValue); ImGui.SameLine(); ImGui.Text("Z:"); ImGui.SameLine(); ImGui.DragFloat("##refz" + i + k, ref el.refZ, 0.02f, float.MinValue, float.MaxValue); ImGui.SameLine(); if (ImGui.Button("Set to my position##ref" + i + k)) { el.refX = p._pi.ClientState.LocalPlayer.Position.X; el.refY = p._pi.ClientState.LocalPlayer.Position.Y; el.refZ = p._pi.ClientState.LocalPlayer.Position.Z; } ImGui.SameLine(); if (ImGui.Button("Set to 0 0 0##ref" + i + k)) { el.refX = 0; el.refY = 0; el.refZ = 0; } ImGui.PopItemWidth(); } else if (el.type == 1) { ImGuiEx.SizedText("Targeted actor: ", WidthElement); ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); ImGui.Combo("##actortype" + i + k, ref el.refActorType, Element.ActorTypes, Element.ActorTypes.Length); if (el.refActorType == 0) { ImGui.SameLine(); ImGui.SetNextItemWidth(WidthCombo); ImGui.InputTextWithHint("##actorname" + i + k, "Case-insensitive (partial) name", ref el.refActorName, 100); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Keep in mind that searching actor by name is\n" + "relatively resource expensive operation. \n" + "Try to keep amount of these down to reasonable number."); } if (p._pi.ClientState.Targets.CurrentTarget != null) { ImGui.SameLine(); if (ImGui.Button("Target##btarget" + i + k)) { el.refActorName = p._pi.ClientState.Targets.CurrentTarget.Name; } } } } ImGuiEx.SizedText("Offset: ", WidthElement); ImGui.SameLine(); ImGui.PushItemWidth(60f); ImGui.Text("X:"); ImGui.SameLine(); ImGui.DragFloat("##offx" + i + k, ref el.offX, 0.02f, float.MinValue, float.MaxValue); ImGui.SameLine(); ImGui.Text("Y:"); ImGui.SameLine(); ImGui.DragFloat("##offy" + i + k, ref el.offY, 0.02f, float.MinValue, float.MaxValue); ImGui.SameLine(); ImGui.Text("Z:"); ImGui.SameLine(); ImGui.DragFloat("##offz" + i + k, ref el.offZ, 0.02f, float.MinValue, float.MaxValue); ImGui.SameLine(); if (ImGui.Button("Set to my position##off" + i + k)) { el.offX = p._pi.ClientState.LocalPlayer.Position.X; el.offY = p._pi.ClientState.LocalPlayer.Position.Y; el.offZ = p._pi.ClientState.LocalPlayer.Position.Z; } ImGui.SameLine(); if (ImGui.Button("Set to 0 0 0##off" + i + k)) { el.offX = 0; el.offY = 0; el.offZ = 0; } //ImGui.SameLine(); //ImGui.Checkbox("Actor relative##rota"+i+k, ref el.includeRotation); ImGuiEx.SizedText("Line thickness:", WidthElement); ImGui.SameLine(); ImGui.DragFloat("##thicc" + i + k, ref el.thicc, 0.1f, 0f, float.MaxValue); ImGui.PopItemWidth(); if (el.thicc > 0) { ImGui.SameLine(); var v4 = ImGui.ColorConvertU32ToFloat4(el.color); if (ImGui.ColorEdit4("##colorbutton" + i + k, ref v4, ImGuiColorEditFlags.NoInputs)) { el.color = ImGui.ColorConvertFloat4ToU32(v4); } ImGui.PopItemWidth(); } else { ImGui.SameLine(); ImGui.Text("Thickness is set to 0: only text overlay will be drawn."); } if (el.thicc > 0) { ImGuiEx.SizedText("Radius:", WidthElement); ImGui.SameLine(); ImGui.SetNextItemWidth(60f); ImGui.DragFloat("##radius" + i + k, ref el.radius, 0.01f, 0, float.MaxValue); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Leave at 0 to draw single dot"); } if (el.type == 1) { if (el.refActorType != 1) { ImGui.SameLine(); ImGui.Checkbox("+target hitbox##" + i + k, ref el.includeHitbox); } ImGui.SameLine(); ImGui.Checkbox("+your hitbox##" + i + k, ref el.includeOwnHitbox); ImGui.SameLine(); ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("When the game tells you that ability A has distance D,\n" + "in fact it means that you are allowed to execute\n" + "ability A if distance between edge of your hitbox\n" + "and enemy's hitbox is less or equal than distance D,\n" + "that is for targeted abilities.\n" + "If an ability is AoE, such check is performed between\n" + "middle point of your character and edge of enemy's hitbox.\n\n" + "Summary: if you are trying to make targeted ability indicator -\n" + "enable both \"+your hitbox\" and \"+target hitbox\".\n" + "If you are trying to make AoE ability indicator - \n" + "enable only \"+target hitbox\" to make indicators valid.\n" + "And if it's healing AoE ability, enable only \"+your hitbox\"."); } } } ImGuiEx.SizedText("Overlay text:", WidthElement); ImGui.SameLine(); ImGui.SetNextItemWidth(150f); ImGui.InputTextWithHint("##overlaytext" + i + k, "Text to display as overlay", ref el.overlayText, 30); if (el.overlayText.Length > 0) { ImGui.SameLine(); ImGui.Text("Vertical offset:"); ImGui.SameLine(); ImGui.SetNextItemWidth(60f); ImGui.DragFloat("##vtextadj" + i + k, ref el.overlayVOffset, 0.02f); ImGui.SameLine(); ImGui.Text("BG color:"); ImGui.SameLine(); var v4b = ImGui.ColorConvertU32ToFloat4(el.overlayBGColor); if (ImGui.ColorEdit4("##colorbuttonbg" + i + k, ref v4b, ImGuiColorEditFlags.NoInputs)) { el.overlayBGColor = ImGui.ColorConvertFloat4ToU32(v4b); } ImGui.PopItemWidth(); ImGui.SameLine(); ImGui.Text("Text color:"); ImGui.SameLine(); var v4t = ImGui.ColorConvertU32ToFloat4(el.overlayTextColor); if (ImGui.ColorEdit4("##colorbuttonfg" + i + k, ref v4t, ImGuiColorEditFlags.NoInputs)) { el.overlayTextColor = ImGui.ColorConvertFloat4ToU32(v4t); } ImGui.PopItemWidth(); } } } if (elcolored) { ImGui.PopStyleColor(); elcolored = false; } } } } if (colored) { ImGui.PopStyleColor(); colored = false; } } if (!open) { curEdit = null; } ImGui.EndChild(); } ImGui.PopStyleVar(); }
//displays selected entity info internal override void Display() { ImGui.SetNextWindowSize(new Vector2(150, 200), ImGuiCond.Once); if (ImGui.Begin("Actions", _flags)) { //check if ANY entity has been clicked //if true, display all possible toolbar menu icons for it if (_uiState.LastClickedEntity != null) { //Gets the last clicked entity var _entityState = _uiState.LastClickedEntity; ToolbuttonData btn; void NewButton(Type T, string PictureString, string TooltipText, List <ToolbuttonData> ButtonList) { //Creates a buttton if it is usuable in this situation if (EntityUIWindows.checkIfCanOpenWindow(T, _entityState)) { btn = new ToolbuttonData() { Picture = _uiState.SDLImageDictionary[PictureString], TooltipText = TooltipText, ClickType = T //Opens up the componet design menu }; ButtonList.Add(btn); } } void NewCondtionalButton(Type T, string PictureString, string TooltipText) { NewButton(T, PictureString, TooltipText, CondtionalButtons); } void NewStandardButton(Type T, string PictureString, string TooltipText) { NewButton(T, PictureString, TooltipText, StandardButtons); } //Populates Buttons NewStandardButton(typeof(SelectPrimaryBlankMenuHelper), "Select", "Selects the entity"); NewStandardButton(typeof(PinCameraBlankMenuHelper), "Pin", "Focuses camera"); NewStandardButton(typeof(RenameWindow), "Rename", "Renames the entity"); NewCondtionalButton(typeof(PowerGen), "Power", "Shows power stats"); NewCondtionalButton(typeof(CargoTransfer), "Cargo", "Shows cargo"); NewCondtionalButton(typeof(ColonyPanel), "Industry", "Opens Industry menu"); NewCondtionalButton(typeof(FireControl), "Firecon", "Opens firecontrol menu"); //Displays all buttons in a list void PrintButtonList(ref List <ToolbuttonData> PrintButtons) { uint iterations = 0; uint unclickedcolor; uint clickedcolour; ImGuiCol buttonidx = ImGuiCol.Button; unsafe { Vector4 *unclickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.Button); Vector4 *clickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.ButtonActive); unclickedcolor = ImGui.ColorConvertFloat4ToU32(*unclickedcolorv); clickedcolour = ImGui.ColorConvertFloat4ToU32(*clickedcolorv); } foreach (var button in PrintButtons) { ImGui.SameLine(); ImGui.PushID(iterations.ToString()); if (EntityUIWindows.checkopenUIWindow(button.ClickType, _entityState, _uiState)) //If the window is open { ImGui.PushStyleColor(buttonidx, clickedcolour); //Have the button be "pressed" } else//If closed { ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally } if (ImGui.ImageButton(button.Picture, BtnSizes)) { EntityUIWindows.openUIWindow(button.ClickType, _entityState, _uiState); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(button.TooltipText); } ImGui.PopID(); iterations++; } ImGui.NewLine(); ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally PrintButtons = new List <ToolbuttonData>(); } //Prints both button lists PrintButtonList(ref StandardButtons); PrintButtonList(ref CondtionalButtons); void ActionButton(Type T) { //Makes a small button if it is usable in this situation if (EntityUIWindows.checkIfCanOpenWindow(T, _entityState)) { bool buttonresult = ImGui.SmallButton(GlobalUIState.namesForMenus[T]); EntityUIWindows.openUIWindow(T, _entityState, _uiState, buttonresult); if (ImGui.IsItemHovered()) { ImGui.SetTooltip(GlobalUIState.namesForMenus[T]); } } } //Makes all small buttons ActionButton(typeof(PlanetaryWindow)); ActionButton(typeof(GotoSystemBlankMenuHelper)); ActionButton(typeof(WarpOrderWindow)); ActionButton(typeof(ChangeCurrentOrbitWindow)); } ImGui.End(); } }
public unsafe bool CustomTreeNode(string label) { var style = ImGui.GetStyle(); var storage = ImGui.GetStateStorage(); uint id = ImGui.GetID(label); int opened = storage.GetInt(id, 0); float x = ImGui.GetCursorPosX(); ImGui.BeginGroup(); if (ImGui.InvisibleButton(label, new Vector2(-1, ImGui.GetFontSize() + style.FramePadding.Y * 2))) { opened = storage.GetInt(id, 0); // opened = p_opened == p_opened; } bool hovered = ImGui.IsItemHovered(); bool active = ImGui.IsItemActive(); if (hovered || active) { var col = ImGui.GetStyle().Colors[(int)(active ? ImGuiCol.HeaderActive : ImGuiCol.HeaderHovered)]; ImGui.GetWindowDrawList().AddRectFilled(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ImGui.ColorConvertFloat4ToU32(col)); } ImGui.SameLine(); ImGui.ColorButton("color_btn", opened == 1 ? new Vector4(1, 1, 1, 1) : new Vector4(1, 0, 0, 1)); ImGui.SameLine(); ImGui.Text(label); ImGui.EndGroup(); if (opened == 1) { ImGui.TreePush(label); } return(opened != 0); }
internal override void Display() { // if (!IsActive || _selectedEntitySate == null) { return; } ImGui.SetNextWindowSize(new Vector2(1500, 800)); if (ImGui.Begin("Sensor Display", ref IsActive)) { if (_selectedEntity.HasDataBlob <SensorAbilityDB>()) { if (_selectedReceverAtb == null || ImGui.Button("refresh")) { SetSensorData(); } ImGui.Columns(2); ImGui.SetColumnWidth(0, 300); if (ImGui.Combo("Targets", ref _targetIndex, _potentialTargetNames, _potentialTargetNames.Length)) { _targetEntity = _potentialTargetEntities[_targetIndex]; SetTargetData(); } ImGui.Text("lowest_x: " + lowestWave); ImGui.Text("highest_x: " + highestWave); ImGui.Text("lowest_y: " + lowestMag); ImGui.Text("highest_y: " + highestMag); if (_targetSensorProfile != null) { ImGui.Text("target cross section: " + _targetSensorProfile.TargetCrossSection_msq); } uint borderColour = ImGui.ColorConvertFloat4ToU32(new Vector4(0.5f, 0.5f, 0.5f, 1.0f)); uint receverColour = ImGui.ColorConvertFloat4ToU32(new Vector4(0.25f, 1.0f, 0.5f, 1.0f)); uint receverFill = ImGui.ColorConvertFloat4ToU32(new Vector4(0.25f, 1.0f, 0.5f, 0.75f)); uint reflectedColour = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.5f, 1.0f)); uint reflectedFill = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.5f, 0.75f)); uint emittedColour = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.25f, 1.0f)); uint emittedFill = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.25f, 0.5f)); uint detectedColour = ImGui.ColorConvertFloat4ToU32(new Vector4(0.0f, 0.0f, 1.0f, 0.75f)); ImGui.BeginChild("stuff"); BorderGroup.Begin("Recevers:", borderColour); DisplayWavInfo(_receverDat); BorderGroup.End(); if (_reflectDat != null) { BorderGroup.Begin("Reflectors:", borderColour); DisplayWavInfo(_reflectDat); BorderGroup.End(); } if (_emmittrDat != null) { BorderGroup.Begin("Emmiters:", borderColour); DisplayWavInfo(_emmittrDat); BorderGroup.End(); } if (_detectedDat != null) { BorderGroup.Begin("Detected:", borderColour); DisplayWavInfo(_detectedDat); BorderGroup.End(); } ImGui.EndChild(); ImGui.NextColumn(); // ImDrawList API uses screen coordinates! Vector2 canvas_pos = ImGui.GetCursorScreenPos(); Vector2 canvas_size = ImGui.GetContentRegionAvail(); Vector2 canvas_endPos = canvas_pos + canvas_size; Vector2 waveBounds = new Vector2((float)(highestWave - lowestWave), (float)(highestMag - lowestMag)); _scalingFactor.X = 1 / (waveBounds.X / canvas_size.X); _scalingFactor.Y = 1 / (waveBounds.Y / canvas_size.Y); _translation.X = (float)(canvas_pos.X - lowestWave * _scalingFactor.X); _translation.Y = (float)(canvas_pos.Y - lowestMag * _scalingFactor.Y); _draw_list.AddRect(canvas_pos, canvas_endPos, borderColour); ImGui.Text("Scale:"); ImGui.Text("X: " + _scalingFactor.X + " Y: " + _scalingFactor.Y); Vector2 p0 = _translation + new Vector2((float)lowestWave, (float)lowestMag) * _scalingFactor; Vector2 p1 = _translation + new Vector2((float)highestWave, (float)highestMag) * _scalingFactor; ImGui.Text("Box From: " + p0); ImGui.Text("Box To: " + p1); DrawWav(_receverDat, receverFill); if (_reflectDat != null) { DrawWav(_reflectDat, reflectedFill); } if (_emmittrDat != null) { DrawWav(_emmittrDat, emittedFill); } if (_detectedDat != null) { DrawWav(_detectedDat, detectedColour); } } } void DrawWav(WaveDrawData wavesArry, uint colour) { for (int i = 0; i < wavesArry.Count; i++) { Vector2 p0 = _translation + wavesArry.Points[i].p0 * _scalingFactor; Vector2 p1 = _translation + wavesArry.Points[i].p1 * _scalingFactor; Vector2 p2 = _translation + wavesArry.Points[i].p2 * _scalingFactor; if (wavesArry.IsWaveDrawn[i].drawSrc) { //_draw_list.AddLine(p0, p1, colour); //_draw_list.AddLine(p1, p2, colour); _draw_list.AddTriangleFilled(p0, p1, p2, colour); } if (wavesArry.HasAtn && wavesArry.IsWaveDrawn[i].drawAtn) { Vector2 p3 = _translation + wavesArry.Points[i].p3 * _scalingFactor; _draw_list.AddTriangleFilled(p0, p3, p2, colour); } } } void DisplayWavInfo(WaveDrawData wavesArry) { for (int i = 0; i < wavesArry.Count; i++) { if (ImGui.Checkbox("Show Wave##drawbool" + i, ref wavesArry.IsWaveDrawn[i].drawSrc)) { ResetBounds(); } if (wavesArry.HasAtn) { ImGui.SameLine(); if (ImGui.Checkbox("Show Attenuated Wave##drawbool" + i, ref wavesArry.IsWaveDrawn[i].drawAtn)) { ResetBounds(); } } ImGui.Text("MinWav: " + Stringify.DistanceSmall(wavesArry.Points[i].p0.X)); ImGui.SameLine(); ImGui.Text("Magnitude: " + Stringify.Power(wavesArry.Points[i].p0.Y)); ImGui.Text("AvgWav: " + Stringify.DistanceSmall(wavesArry.Points[i].p1.X)); if (wavesArry.HasAtn) { ImGui.SameLine(); ImGui.Text(" Magnitude peak/attenuated:"); ImGui.Text(" " + Stringify.Power(wavesArry.Points[i].p1.Y) + "/" + Stringify.Power(wavesArry.Points[i].p3.Y)); } else { ImGui.SameLine(); ImGui.Text(" Magnitude peak:"); ImGui.Text(" " + Stringify.Power(wavesArry.Points[i].p1.Y)); } ImGui.Text("MaxWav: " + Stringify.DistanceSmall(wavesArry.Points[i].p2.X)); ImGui.SameLine(); ImGui.Text("Magnitude: " + Stringify.Power(wavesArry.Points[i].p2.Y)); } } void ResetBounds() { lowestWave = float.PositiveInfinity; lowestMag = float.PositiveInfinity; highestMag = float.NegativeInfinity; highestWave = float.NegativeInfinity; var dat = _receverDat; for (int i = 0; i < dat.Count; i++) { if (dat.IsWaveDrawn[i].drawSrc) { float low = dat.Points[i].p0.X; float high = dat.Points[i].p2.X; float mag1 = dat.Points[i].p0.Y; //recever highest value float mag2 = dat.Points[i].p1.Y; //recever lowest value if (low < lowestWave) { lowestWave = low; } if (high > highestWave) { highestWave = high; } if (mag1 > highestMag) { highestMag = mag1; } if (mag2 < lowestMag) { lowestMag = mag2; } } } if (_reflectDat != null) { ResetTargetBounds(_reflectDat); } if (_emmittrDat != null) { ResetTargetBounds(_emmittrDat); } if (_detectedDat != null) { ResetTargetBounds(_detectedDat); } } void ResetTargetBounds(WaveDrawData dat) { for (int i = 0; i < dat.Count; i++) { if (dat.IsWaveDrawn[i].drawSrc || dat.IsWaveDrawn[i].drawAtn) { float low = dat.Points[i].p0.X; float high = dat.Points[i].p2.X; float mag1 = dat.Points[i].p0.Y; //xmit lowest value prob 0 float mag2 = dat.Points[i].p1.Y; //xmit highest value float mag3 = dat.Points[i].p3.Y; //xmit 2nd highest value if (low < lowestWave) { lowestWave = low; } if (high > highestWave) { highestWave = high; } if (mag1 < lowestMag) //will likely be 0 { lowestMag = mag1; } if (dat.IsWaveDrawn[i].drawSrc) { if (mag2 > highestMag) { highestMag = mag2; } } if (dat.IsWaveDrawn[i].drawAtn) { if (mag3 > highestMag) { highestMag = mag3; } } } } } void SetSensorData() { if (_selectedEntity.GetDataBlob <ComponentInstancesDB>().TryGetComponentsByAttribute <SensorReceverAtbDB>(out var recevers)) { _receverDat = new WaveDrawData(); _receverDat.HasAtn = false; var points = _receverDat.Points = new (Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)[recevers.Count]; _receverDat.IsWaveDrawn = new (bool drawSrc, bool drawAtn)[recevers.Count]; _selectedReceverAtb = new SensorReceverAtbDB[recevers.Count]; _selectedReceverInstanceAbility = new SensorReceverAbility[recevers.Count]; int i = 0; foreach (var recever in recevers) { _selectedReceverAtb[i] = recever.Design.GetAttribute <SensorReceverAtbDB>(); _selectedReceverInstanceAbility[i] = recever.GetAbilityState <SensorReceverAbility>(); float low = (float)_selectedReceverAtb[i].RecevingWaveformCapabilty.WavelengthMin_nm; float mid = (float)_selectedReceverAtb[i].RecevingWaveformCapabilty.WavelengthAverage_nm; float high = (float)_selectedReceverAtb[i].RecevingWaveformCapabilty.WavelengthMax_nm; float mag1 = (float)_selectedReceverAtb[i].WorstSensitivity_kW; float mag2 = (float)_selectedReceverAtb[i].BestSensitivity_kW; points[i].p0 = new Vector2(low, mag1); points[i].p1 = new Vector2(mid, mag2); points[i].p2 = new Vector2(high, mag1); i++; } var tgts = _selectedStarSys.GetAllEntitiesWithDataBlob <SensorProfileDB>(); _potentialTargetNames = new string[tgts.Count]; _potentialTargetEntities = tgts.ToArray(); i = 0; foreach (var target in tgts) { string name = target.GetDataBlob <NameDB>().GetName(_uiState.Faction); _potentialTargetNames[i] = name; i++; } for (int j = 0; j < _selectedReceverInstanceAbility.Length; j++) { //SetTargetData(); //var foo = _selectedReceverInstanceAbility[i].CurrentContacts; //foreach (SensorProcessorTools.SensorReturnValues val in foo.Values) //{ //val.SignalStrength_kW //} } }
public void DrawChannelAddEditWindow() { if (!ChannelEditWindowVisible) { return; } ImGui.SetNextWindowSize(new Vector2(400, 600), ImGuiCond.Always); if (ImGui.Begin("Add/Edit Channel Configuration", ref this.channelEditWindowVisible, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) { ImGui.TextWrapped($"Please select what type of XIVChat you'd like to relay and where it should go."); ImGui.Spacing(); // ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X * 0.4f); /* * var currentitem = currentEntry.ChatType; * PluginLog.Information($"Current XivChatType: {currentitem}"); * if (ImGui.BeginCombo("##XivChatTypeSelector", $"Select a Chat Type")) * { * foreach (var availableChatType in XivChatTypeExtensions.TypeInfoDict) * { * bool isSelected = (currentitem == availableChatType.Key); * if(ImGui.Selectable($"{availableChatType.Key.GetFancyName()} ({(int)availableChatType.Key})", isSelected)) * { * // set the channel type to this * PluginLog.Information($"Inside the Selectable() right now for {availableChatType.Key}"); * } * if (isSelected) * { * currentEntry.ChatType = availableChatType.Key; * ImGui.SetItemDefaultFocus(); * } * * } * ImGui.EndCombo(); * } */ XivChatType currentChatTypeSelected = selectedChannelConfig.ChatType; string[] list = XivChatTypeExtensions.TypeInfoDict.Select(x => x.Key.GetFancyName()).ToArray(); int currentListIndex = Array.IndexOf(list, selectedChannelConfig.ChatType.GetFancyName()); if (ImGui.Combo("##XivChatTypeSelector", ref currentListIndex, list, list.Length)) { selectedChannelConfig.ChatType = XivChatTypeExtensions.GetByFancyName(list[currentListIndex]); // PluginLog.Information($"Set ChatType to {selectedChannelConfig.ChatType}"); } string[] channel_types = { Configuration.ChannelType.Guild.ToString(), Configuration.ChannelType.User.ToString() }; int channelTypeSelection = (int)selectedChannelConfig.Channel.Type; if (ImGui.Combo("##XivChannelTypeSelector", ref channelTypeSelection, channel_types, 2)) { selectedChannelConfig.Channel.Type = (Configuration.ChannelType)channelTypeSelection; // PluginLog.Information($"Set ChannelType to {selectedChannelConfig.Channel.Type}"); } ImGui.Text($"Server ID"); string serverIDInput = selectedChannelConfig.Channel.GuildId.ToString(); if (ImGui.InputTextWithHint($"##ServerID", $"Put your Server ID here", ref serverIDInput, 30)) { selectedChannelConfig.Channel.GuildId = ulong.Parse(serverIDInput); } ImGui.Text($"Channel ID"); string channelIDInput = selectedChannelConfig.Channel.ChannelId.ToString(); if (ImGui.InputTextWithHint($"##ChannelID", $"Put your Server ID here", ref channelIDInput, 30)) { selectedChannelConfig.Channel.ChannelId = ulong.Parse(channelIDInput); } ImGui.Spacing(); // ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X * 0.4f); byte[] values = BitConverter.GetBytes(selectedChannelConfig.Color); //Vector4 embedColor = ImGui.ColorConvertU32ToFloat4(selectedChannelConfig.Color); Vector4 embedColor = new Vector4(values[2] / 255.0f, values[1] / 255.0f, values[0] / 255.0f, 1.0f); if (ImGui.ColorPicker4($"EmbedColor", ref embedColor)) { selectedChannelConfig.Color = ImGui.ColorConvertFloat4ToU32(embedColor); } ImGui.Spacing(); if (ImGui.Button("Apply")) { // this.bot.Dispose(); int red = (byte)(embedColor.X * 255); int green = (byte)(embedColor.Y * 255); int blue = (byte)(embedColor.Z * 255); int rgb = red; rgb = (rgb << 8) + green; rgb = (rgb << 8) + blue; selectedChannelConfig.Color = (uint)rgb; this.plugin.RestartBot(); selectedChannelConfig = null; Save(); Visible = false; Visible = true; ChannelEditWindowVisible = false; } ImGui.SameLine(); if (ImGui.Button("Cancel")) { Visible = false; Visible = true; ChannelEditWindowVisible = false; } } ImGui.End(); }
public static unsafe void DrawText(string text, float scale, Vector2 position, Vector4 color, bool isVertical, bool isFlipped) { var uColor = ImGui.ColorConvertFloat4ToU32(color); var font = ImGui.GetFont(); var textSize = CalcTextSize(text, scale); Vector2 textPos; if (isVertical) { textPos = isFlipped ? position : new Vector2(position.X, position.Y + textSize.X); } else { textPos = isFlipped ? position + textSize : position; } var currentTextPos = textPos; var charsUsed = 0; var drawList = ImGui.GetWindowDrawList(); drawList.PrimReserve(6 * text.Length, 4 * text.Length); foreach (var c in text) { switch (c) { case '\n': { if (isVertical) { currentTextPos = isFlipped ? new Vector2(currentTextPos.X - font.FontSize * scale, textPos.Y) : new Vector2(currentTextPos.X + font.FontSize * scale, textPos.Y); } else { currentTextPos = isFlipped ? new Vector2(textPos.X, currentTextPos.Y - font.FontSize * scale) : new Vector2(textPos.X, currentTextPos.Y + font.FontSize * scale); } continue; } case '\r': continue; } var glyph = (FontGlyph *)font.FindGlyph(c).NativePtr; if (glyph == null) { continue; } if (isVertical) { // Vertical text if (isFlipped) { drawList.PrimQuadUV( currentTextPos + new Vector2(-glyph->Y1, glyph->X1) * scale, currentTextPos + new Vector2(-glyph->Y1, glyph->X0) * scale, currentTextPos + new Vector2(-glyph->Y0, glyph->X0) * scale, currentTextPos + new Vector2(-glyph->Y0, glyph->X1) * scale, new Vector2(glyph->U1, glyph->V1), new Vector2(glyph->U0, glyph->V1), new Vector2(glyph->U0, glyph->V0), new Vector2(glyph->U1, glyph->V0), uColor ); } else { drawList.PrimQuadUV( currentTextPos + new Vector2(glyph->Y0, -glyph->X0) * scale, currentTextPos + new Vector2(glyph->Y0, -glyph->X1) * scale, currentTextPos + new Vector2(glyph->Y1, -glyph->X1) * scale, currentTextPos + new Vector2(glyph->Y1, -glyph->X0) * scale, new Vector2(glyph->U0, glyph->V0), new Vector2(glyph->U1, glyph->V0), new Vector2(glyph->U1, glyph->V1), new Vector2(glyph->U0, glyph->V1), uColor ); } } else { if (isFlipped) // Upside-down text { drawList.PrimQuadUV( currentTextPos + new Vector2(-glyph->X1, -glyph->Y1) * scale, currentTextPos + new Vector2(-glyph->X0, -glyph->Y1) * scale, currentTextPos + new Vector2(-glyph->X0, -glyph->Y0) * scale, currentTextPos + new Vector2(-glyph->X1, -glyph->Y0) * scale, new Vector2(glyph->U1, glyph->V1), new Vector2(glyph->U0, glyph->V1), new Vector2(glyph->U0, glyph->V0), new Vector2(glyph->U1, glyph->V0), uColor ); } else // Normal text { drawList.PrimQuadUV( currentTextPos + new Vector2(glyph->X0, glyph->Y0) * scale, currentTextPos + new Vector2(glyph->X1, glyph->Y0) * scale, currentTextPos + new Vector2(glyph->X1, glyph->Y1) * scale, currentTextPos + new Vector2(glyph->X0, glyph->Y1) * scale, new Vector2(glyph->U0, glyph->V0), new Vector2(glyph->U1, glyph->V0), new Vector2(glyph->U1, glyph->V1), new Vector2(glyph->U0, glyph->V1), uColor ); } } if (isVertical) { if (isFlipped) { currentTextPos.Y += glyph->AdvanceX * scale; } else { currentTextPos.Y -= glyph->AdvanceX * scale; } } else { if (isFlipped) { currentTextPos.X -= glyph->AdvanceX * scale; } else { currentTextPos.X += glyph->AdvanceX * scale; } } charsUsed++; } drawList.PrimUnreserve(6 * (text.Length - charsUsed), 4 * (text.Length - charsUsed)); // Return unused primitves }