Beispiel #1
0
        public static void RenderNodes()
        {
            ImGui.Checkbox("Show grid", ref grid);

            filter.Draw("Filter");
            ImGui.Checkbox("Hide filtred", ref hideFiltred);
            ImGui.Separator();

            RenderMenu();

            ImNode first      = null;
            var    sawFocused = false;

            foreach (var p in ImNodes.Nodes)
            {
                var node = p.Value;
                var name = node.GetName();

                if (!filter.PassFilter(name))
                {
                    continue;
                }

                if (first == null)
                {
                    first = node;
                }

                if (ImNode.Focused == node)
                {
                    node.ForceFocus = true;
                    sawFocused      = true;
                }

                if (ImGui.Selectable($"#{node.Id} {name}", ImNode.Focused == node))
                {
                    ImNode.Focused  = node;
                    node.ForceFocus = true;
                    sawFocused      = true;

                    target =
                        -node.RealPosition + new Vector2((Engine.Instance.GetScreenWidth() - node.Size.X) / 2,
                                                         (Engine.Instance.GetScreenHeight() - node.Size.Y) / 2);
                }

                if (ImGui.OpenPopupOnItemClick("node_menu", 1))
                {
                    CurrentMenu = node;
                }
            }

            if (!sawFocused)
            {
                ImNode.Focused = first;
            }

            ImGui.End();
        }
        public override void Render()
        {
            ImGui.Text($"Entity Save ({total} entities)");
            filter.Draw();

            foreach (var pair in Datas)
            {
                if (filter.PassFilter(pair.Key))
                {
                    ImGui.BulletText($"{pair.Key} x{pair.Value.Count}");
                }
            }
        }
Beispiel #3
0
        public override void Render()
        {
            ImGui.Text($"Global Save ({Values.Count} entries)");
            filter.Draw();

            foreach (var pair in Values)
            {
                if (filter.PassFilter(pair.Key))
                {
                    ImGui.BulletText(pair.Key);
                    ImGui.SameLine();
                    ImGui.Text(pair.Value);
                }
            }
        }
Beispiel #4
0
        public static void Render()
        {
            if (!WindowManager.PoolEditor)
            {
                return;
            }

            ImGui.SetNextWindowSize(size, ImGuiCond.Once);

            if (!ImGui.Begin("Pool Editor##re"))
            {
                ImGui.End();
                return;
            }

            ImGui.Combo("Pool##pe", ref Pool, ItemPool.Names, ItemPool.Count);

            ImGui.Separator();

            filter.Draw("");
            ImGui.SameLine();
            ImGui.Text($"{count}");

            if (ImGui.Button("Add##pe"))
            {
                ImGui.OpenPopup("Add Item##pe");
            }

            if (ImGui.BeginPopupModal("Add Item##pe"))
            {
                ImGui.SetWindowSize(popupSize);

                popupFilter.Draw("");
                ImGui.BeginChild("ScrollinegionUses##reee", new System.Numerics.Vector2(0, -ImGui.GetStyle().ItemSpacing.Y - ImGui.GetFrameHeightWithSpacing() - 4),
                                 false, ImGuiWindowFlags.HorizontalScrollbar);

                ImGui.Separator();

                foreach (var i in Items.Datas)
                {
                    ImGui.PushID($"{id}__itm");

                    if (!BitHelper.IsBitSet(i.Value.Pools, Pool) && popupFilter.PassFilter(i.Key) && ImGui.Selectable($"{i.Key}##d", selectedItem == i.Key))
                    {
                        selectedItem = i.Key;
                    }

                    ImGui.PopID();
                    id++;
                }

                id = 0;

                ImGui.EndChild();
                ImGui.Separator();

                if (selectedItem != null && (ImGui.Button("Add") || Input.Keyboard.WasPressed(Keys.Enter, true)))
                {
                    ItemEditor.Selected   = Items.Datas[selectedItem];
                    ItemEditor.ForceFocus = true;

                    ItemEditor.Selected.Pools = BitHelper.SetBit(ItemEditor.Selected.Pools, Pool, true);
                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();

                if (ImGui.Button("Cancel") || Input.Keyboard.WasPressed(Keys.Escape, true))
                {
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            if (ItemEditor.Selected != null)
            {
                ImGui.SameLine();

                if (ImGui.Button("Remove##pe"))
                {
                    ItemEditor.Selected.Pools = BitHelper.SetBit(ItemEditor.Selected.Pools, Pool, false);
                    ItemEditor.Selected       = null;
                }
            }

            count = 0;

            ImGui.Separator();

            var height = ImGui.GetStyle().ItemSpacing.Y;

            ImGui.BeginChild("rollingRegionItems##Pe", new System.Numerics.Vector2(0, -height),
                             false, ImGuiWindowFlags.HorizontalScrollbar);

            foreach (var i in Items.Datas.Values)
            {
                ImGui.PushID($"{id}___m");

                if (filter.PassFilter(i.Id))
                {
                    if (!BitHelper.IsBitSet(i.Pools, Pool))
                    {
                        continue;
                    }

                    count++;

                    if (ImGui.Selectable($"{i.Id}##ped", i == ItemEditor.Selected))
                    {
                        if (i != ItemEditor.Selected)
                        {
                            ItemEditor.Selected      = i;
                            ItemEditor.ForceFocus    = true;
                            WindowManager.ItemEditor = true;
                        }
                    }
                }

                ImGui.PopID();
                id++;
            }

            id = 0;

            ImGui.EndChild();
            ImGui.End();
        }
        public static void Render()
        {
            if (!WindowManager.LocaleEditor)
            {
                return;
            }

            ImGui.SetNextWindowSize(size, ImGuiCond.Once);

            if (!ImGui.Begin("Locale editor"))
            {
                ImGui.End();
                return;
            }

            if (ImGui.Combo("##locale", ref locale, aviableLocales, aviableLocales.Length))
            {
                Locale.Load(aviableLocales[locale]);
            }

            ImGui.SameLine();

            if (ImGui.Button("Save"))
            {
                Locale.Save();
            }

            ImGui.SameLine();

            if (ImGui.Button("New"))
            {
                ImGui.OpenPopup("New locale");
            }

            if (ImGui.BeginPopupModal("New locale"))
            {
                ImGui.SetItemDefaultFocus();
                var input  = ImGui.InputText("Name", ref newLocaleName, 3, ImGuiInputTextFlags.EnterReturnsTrue);
                var button = ImGui.Button("Create");

                ImGui.SameLine();

                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                    newLocaleName = "";
                }
                else
                {
                    if (input || button)
                    {
                        Locale.Current = newLocaleName;
                        Locale.Map     = new Dictionary <string, string>();
                        Locale.Loaded[newLocaleName] = Locale.Map;

                        var list = aviableLocales.ToList();
                        list.Add(newLocaleName);
                        aviableLocales = list.ToArray();
                        locale         = list.Count - 1;

                        newLocaleName = "";
                        ImGui.CloseCurrentPopup();
                    }
                }

                ImGui.EndPopup();
            }

            var notEng = aviableLocales[locale] != "en";

            if (notEng)
            {
                if (ImGui.Button("Clear"))
                {
                    Locale.Map.Clear();
                }

                ImGui.SameLine();

                if (ImGui.Button("Delete"))
                {
                    ImGui.OpenPopup("Delete?");
                }

                if (ImGui.BeginPopupModal("Delete?"))
                {
                    ImGui.Text("This operation can't be undone!");
                    ImGui.Text("Are you sure?");

                    if (ImGui.Button("Yes"))
                    {
                        ImGui.CloseCurrentPopup();
                        var list = aviableLocales.ToList();
                        list.Remove(Locale.Current);
                        aviableLocales = list.ToArray();
                        locale         = 0;
                        Locale.Delete();
                    }

                    ImGui.SameLine();
                    ImGui.SetItemDefaultFocus();

                    if (ImGui.Button("No"))
                    {
                        ImGui.CloseCurrentPopup();
                    }

                    ImGui.EndPopup();
                }
            }

            if (notEng)
            {
                ImGui.SameLine();

                if (ImGui.Button("Add en"))
                {
                    foreach (var t in Locale.Fallback)
                    {
                        if (!Locale.Map.ContainsKey(t.Key))
                        {
                            Locale.Map[t.Key] = t.Value;
                        }
                    }
                }
            }

            ImGui.Text(notEng ? $"{Locale.Map.Count} entries (en has {Locale.Fallback.Count})" : $"{Locale.Map.Count} entries");

            if (notEng)
            {
                ImGui.Checkbox("Show english", ref showEnglish);
            }

            ImGui.Separator();

            filter.Draw("");
            ImGui.SameLine();
            ImGui.Checkbox("By key", ref filterByKey);

            ImGui.Separator();
            var height = ImGui.GetStyle().ItemSpacing.Y + ImGui.GetFrameHeightWithSpacing() + 4;

            ImGui.BeginChild("ScrollingRegionLocale", new System.Numerics.Vector2(0, -height),
                             false);
            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, spacer);

            var    i      = 0;
            string remove = null;

            foreach (var t in Locale.Map)
            {
                if (filter.PassFilter(filterByKey ? t.Key : t.Value))
                {
                    var key   = t.Key;
                    var value = t.Value;

                    ImGui.PushItemWidth(100);
                    ImGui.PushID($"{i}__key");

                    if (notEng && showEnglish && Locale.Fallback.TryGetValue(t.Key, out var en))
                    {
                        ImGui.InputText("", ref en, 64);
                    }
                    else
                    {
                        ImGui.InputText("", ref key, 64);
                    }

                    ImGui.PopID();
                    ImGui.PopItemWidth();
                    ImGui.SameLine();
                    ImGui.PushID($"{i}__value");
                    ImGui.InputText("", ref value, 256);

                    if (created == t.Key)
                    {
                        ImGui.SetKeyboardFocusHere(-1);
                        ImGui.SetScrollHereY(-1);
                        created = null;
                    }

                    if (key != t.Key || value != t.Value)
                    {
                        modified.Add(new ModifiedInfo {
                            OldKey     = t.Key,
                            OldValue   = t.Value,
                            Key        = key,
                            Value      = value,
                            KeyChanged = key != t.Key
                        });
                    }

                    ImGui.SameLine();

                    if (ImGui.SmallButton("-"))
                    {
                        remove = t.Key;
                    }
                }

                i++;
            }

            if (remove != null)
            {
                Locale.Map.Remove(remove);
            }

            ImGui.PopStyleVar();
            ImGui.EndChild();
            ImGui.Separator();

            var enter = ImGui.InputText("##newkey", ref newKey, 128, ImGuiInputTextFlags.EnterReturnsTrue);

            ImGui.SameLine();

            if ((enter || ImGui.Button("Add")) && newKey.Length > 0)
            {
                modified.Add(new ModifiedInfo {
                    Key   = newKey,
                    Value = newKey
                });

                created = newKey;
                newKey  = "";
            }

            if (modified.Count > 0)
            {
                foreach (var t in modified)
                {
                    if (t.OldKey != null)
                    {
                        Locale.Map.Remove(t.KeyChanged ? t.OldKey : Locale.Map.FirstOrDefault(m => m.Value == t.OldValue).Key);
                    }

                    if (t.Key.Length > 0)
                    {
                        Locale.Map[t.Key] = t.Value;
                    }
                }

                modified.Clear();
            }

            ImGui.End();
        }
Beispiel #6
0
        /// <summary>Draws this instance.</summary>
        public override void Draw()
        {
            if (!isOpen)
            {
                eventHandler?.Invoke(this, EventType.CloseConsole);
                return;
            }

            if (ImGui.Begin("Console", ref isOpen))
            {
                if (ImGui.Button(Icon.TRASH + " Clean"))
                {
                    Clear();
                    return;
                }

                ImGui.SameLine();

                filter.Draw(Icon.SEARCH + "", -100.0f);

                ImGui.SameLine();

                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, itemSpace);

                ImGui.PushStyleColor(ImGuiCol.Button, filterLogs ? buttonPressed : buttonDefault);
                if (ImGui.Button(Icon.COMMENT + ""))
                {
                    filterLogs = !filterLogs;
                }

                ImGui.PopStyleColor(1);

                ImGui.SameLine();

                ImGui.PushStyleColor(ImGuiCol.Button, filterWarnings ? buttonPressed : buttonDefault);

                if (log.Find(i => i.Contains("Warning")) != null)
                {
                    ImGui.PushStyleColor(ImGuiCol.Text, yellowColor);
                }

                if (ImGui.Button(Icon.EXCLAMATIONCIRCLE + ""))
                {
                    filterWarnings = !filterWarnings;
                }
                ImGui.PopStyleColor();
                if (log.Find(i => i.Contains("Warning")) != null)
                {
                    ImGui.PopStyleColor();
                }

                ImGui.SameLine();

                ImGui.PushStyleColor(ImGuiCol.Button, filterErrors ? buttonPressed : buttonDefault);

                if (log.Find(i => i.Contains("Error")) != null)
                {
                    ImGui.PushStyleColor(ImGuiCol.Text, redColor);
                }

                if (ImGui.Button(Icon.EXCLAMATIONTRIANGLE + ""))
                {
                    filterErrors = !filterErrors;
                }

                ImGui.PopStyleColor();
                if (log.Find(i => i.Contains("Error")) != null)
                {
                    ImGui.PopStyleColor();
                }

                ImGui.PopStyleVar(1);

                ImGui.Separator();

                if (ImGui.BeginChild("scrolling", new System.Numerics.Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar))
                {
                    ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new System.Numerics.Vector2(0, 0));

                    for (int i = 0; i < log.Count; i++)
                    {
                        if (filter.IsActive())
                        {
                            if (filter.PassFilter(log[i]))
                            {
                                Print(log[i]);
                            }
                        }
                        else
                        {
                            Print(log[i]);
                        }
                    }

                    ImGui.PopStyleVar();

                    if (ImGui.GetScrollY() >= ImGui.GetScrollMaxY())
                    {
                        ImGui.SetScrollHereY(1.0f);
                    }
                }

                ImGui.EndChild();
            }

            ImGui.End();
        }
Beispiel #7
0
        public static void RenderDebug()
        {
            if (!WindowManager.Save)
            {
                return;
            }

            ImGui.SetNextWindowSize(size, ImGuiCond.Once);

            if (!ImGui.Begin("Save Debug"))
            {
                ImGui.End();
                return;
            }

            filter.Draw("Search##sd");
            ImGui.Checkbox("Global", ref global);
            ImGui.Separator();

            var height = ImGui.GetStyle().ItemSpacing.Y;

            ImGui.BeginChild("ScrollingRegionItems", new System.Numerics.Vector2(0, -height),
                             false, ImGuiWindowFlags.HorizontalScrollbar);

            var k = (global ? GlobalSave.Values : GameSave.Values).Keys;

            foreach (var i in k)
            {
                ImGui.PushID(i);

                if (filter.PassFilter(i))
                {
                    var s       = i;
                    var changed = false;

                    ImGui.PushItemWidth(100);
                    if (ImGui.InputText($"##{i}", ref s, 128))
                    {
                        changed = true;
                    }

                    ImGui.PopItemWidth();

                    var v = (global ? GlobalSave.Values : GameSave.Values)[i];

                    if (v == null)
                    {
                        continue;
                    }

                    ImGui.SameLine();

                    if (ImGui.InputText($"##v_v{i}", ref v, 128) || changed)
                    {
                        if (global)
                        {
                            GlobalSave.Values.Remove(i);
                            GlobalSave.Put(s, v);
                        }
                        else
                        {
                            GameSave.Values.Remove(i);
                            GameSave.Put(s, v);
                        }
                    }
                }

                ImGui.PopID();
            }

            ImGui.EndChild();
            ImGui.End();
        }
Beispiel #8
0
        /// <summary>Draw this instance.</summary>
        public override void Draw()
        {
            if (ImGui.Begin(Name, ref isOpen))
            {
                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new System.Numerics.Vector2(1.0f, 3.0f));
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 0f);


                if (Project.Current != null)
                {
                    foreach (string folderButton in GetNameDir(currentDirRight))
                    {
                        if (ImGui.Button(folderButton))
                        {
                            MoveToDir(folderButton);
                        }
                        ImGui.SameLine();

                        ImGui.Text("/");

                        ImGui.SameLine();
                    }
                }

                ImGui.PopStyleVar(2);
                ImGui.PopStyleColor();


                filter.Draw(Icon.SEARCH + string.Empty, ImGui.GetContentRegionAvail().X - 20.0f);

                if (filter.IsActive())
                {
                    templist.Clear();
                    foreach (string file in Directory.GetFiles(Project.Current.AssetsPath, "*", SearchOption.AllDirectories))
                    {
                        if (filter.PassFilter(Path.GetFileName(file)))
                        {
                            templist.Add(file);
                        }
                    }
                }

                ImGui.Separator();

                if (ImGui.BeginChild("Assets-Child-Master"))
                {
                    if (ImGui.BeginChild("Assets-Child-Left", new Vector2((ImGui.GetWindowWidth() <= ImGui.GetWindowHeight()) ? ImGui.GetContentRegionAvail().X : ImGui.GetContentRegionAvail().X / 3, ImGui.GetContentRegionAvail().Y), true))
                    {
                        if (Project.Current != null)
                        {
                            ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 0, 0, 0));
                            ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 0f);

                            if (!filter.IsActive())
                            {
                                if (Project.Current != null)
                                {
                                    ShowTree(Project.Current.AssetsPath);
                                }
                            }
                            else
                            {
                                foreach (string file in templist)
                                {
                                    ShowFile(file);
                                }
                            }

                            ImGui.PopStyleVar();
                            ImGui.PopStyleColor();
                        }
                    }

                    ImGui.EndChild();



                    ImGui.SameLine();

                    if (ImGui.GetWindowWidth() > ImGui.GetWindowHeight())
                    {
                        if (ImGui.BeginChild("Assets-Child-Right", new System.Numerics.Vector2(ImGui.GetContentRegionAvail().X, ImGui.GetContentRegionAvail().Y), true, ImGuiWindowFlags.AlwaysAutoResize))
                        {
                            ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 0, 0, 0));
                            ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 0f);
                            if (Project.Current != null)
                            {
                                if (!filter.IsActive())
                                {
                                    foreach (string directory in Directory.GetDirectories(currentDirRight))
                                    {
                                        ImGui.PushStyleVar(ImGuiStyleVar.ButtonTextAlign, new Vector2(0f, 0.5f));

                                        if (ImGui.Button(Icon.FOLDERO + " " + Path.GetFileName(Path.GetDirectoryName(directory + "/t.txt")), new Vector2(ImGui.GetContentRegionAvail().X, 25.0f)))
                                        {
                                            ChangeDir(directory);
                                        }

                                        ImGui.PopStyleVar();
                                    }


                                    ShowFiles(currentDirRight);
                                }
                                else
                                {
                                    foreach (string file in templist)
                                    {
                                        ShowFile(file);
                                    }
                                }
                            }

                            ImGui.PopStyleVar();
                            ImGui.PopStyleColor();
                        }

                        ImGui.EndChild();
                    }
                }

                ImGui.EndChild();
            }

            ImGui.End();
        }
Beispiel #9
0
        public static void RenderDebug(JsonValue root)
        {
            root.InputFloat("Chance", "chance");

            root.InputInt("Min", "min");
            root.InputInt("Max", "max");

            if (!root["items"].IsJsonArray)
            {
                root["items"] = new JsonArray();
            }

            var toRemove = -1;
            var items    = root["items"].AsJsonArray;

            for (var i = 0; i < items.Count; i++)
            {
                if (ImGui.SmallButton($"{items[i]}##s"))
                {
                    WindowManager.ItemEditor = true;
                    ItemEditor.Selected      = assets.items.Items.Datas[items[i]];
                }

                ImGui.SameLine();

                if (ImGui.SmallButton("-"))
                {
                    toRemove = i;
                }
            }

            if (toRemove != -1)
            {
                items.Remove(toRemove);
            }

            if (ImGui.Button("Add"))
            {
                ImGui.OpenPopup("Add Item##p");
            }

            ImGui.Separator();

            if (ImGui.BeginPopupModal("Add Item##p"))
            {
                ImGui.SetWindowSize(popupSize);

                popupFilter.Draw("");
                ImGui.BeginChild("ScrollinegionUses##reee", new System.Numerics.Vector2(0, -ImGui.GetStyle().ItemSpacing.Y - ImGui.GetFrameHeightWithSpacing() - 4),
                                 false, ImGuiWindowFlags.HorizontalScrollbar);

                ImGui.Separator();

                foreach (var i in assets.items.Items.Datas)
                {
                    ImGui.PushID($"{id}__itm");

                    if (popupFilter.PassFilter(i.Key) && !items.Contains(i.Key) && ImGui.Selectable($"{i.Key}##dd", selectedItem == i.Key))
                    {
                        selectedItem = i.Key;
                    }

                    ImGui.PopID();
                    id++;
                }

                id = 0;

                ImGui.EndChild();
                ImGui.Separator();

                if (selectedItem != null && (ImGui.Button("Add") || Input.Keyboard.WasPressed(Keys.Enter, true)))
                {
                    items.Add(selectedItem);
                    selectedItem = null;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();

                if (ImGui.Button("Cancel") || Input.Keyboard.WasPressed(Keys.Escape, true))
                {
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }
        }
Beispiel #10
0
        public static void DisplayUse(JsonValue parent, JsonValue root, string useId = null)
        {
            if (root == JsonValue.Null)
            {
                return;
            }

            ImGui.PushID(ud);
            ud++;

            if (!root.IsJsonArray && parent != JsonValue.Null)
            {
                if (ImGui.Button("-"))
                {
                    if (parent.IsJsonArray)
                    {
                        toRemove = parent.AsJsonArray.IndexOf(root);
                    }
                    else if (root.IsJsonObject)
                    {
                        root.AsJsonObject.Clear();
                    }

                    return;
                }

                ImGui.SameLine();
            }

            if (root.IsString)
            {
                if (ImGui.TreeNode(root.AsString))
                {
                    ImGui.TreePop();
                }
            }
            else if (root.IsJsonObject && root["id"] != JsonValue.Null)
            {
                var id = root["id"].AsString;

                if (ImGui.TreeNode(id))
                {
                    root.Checkbox("Single Use", "single", false);
                    ImGui.Separator();

                    if (UseRegistry.Renderers.TryGetValue(id, out var renderer))
                    {
                        renderer(root);
                    }
                    else
                    {
                        ImGui.Text($"No renderer found for use '{id}'");
                    }

                    ImGui.TreePop();
                }
            }
            else if (root.IsJsonArray)
            {
                foreach (var u in root.AsJsonArray)
                {
                    DisplayUse(root, u);
                }

                if (toRemove > -1)
                {
                    root.AsJsonArray.Remove(toRemove);
                    toRemove = -1;
                }

                if (useId != null)
                {
                    if (ImGui.Button("Add"))
                    {
                        root.AsJsonArray.Add(new JsonObject {
                            ["id"] = useId
                        });
                    }
                }
                else
                {
                    if (ImGui.Button("Add use"))
                    {
                        toAdd = root;
                        ImGui.OpenPopup("Add item use");
                    }
                }

                if (ImGui.BeginPopupModal("Add item use"))
                {
                    id = 0;

                    ImGui.SetWindowSize(popupSize);
                    popupFilter.Draw("");
                    ImGui.BeginChild("ScrollingRegionUses", new System.Numerics.Vector2(0, -ImGui.GetStyle().ItemSpacing.Y - ImGui.GetFrameHeightWithSpacing() - 4),
                                     false, ImGuiWindowFlags.HorizontalScrollbar);

                    foreach (var i in UseRegistry.Uses)
                    {
                        ImGui.PushID(id);

                        if (popupFilter.PassFilter(i.Key) && ImGui.Selectable(i.Key, selectedUse == i.Key))
                        {
                            selectedUse = i.Key;
                        }

                        ImGui.PopID();
                        id++;
                    }

                    ImGui.EndChild();
                    ImGui.Separator();

                    if (ImGui.Button("Add") || Input.Keyboard.WasPressed(Keys.Enter, true))
                    {
                        toAdd.AsJsonArray.Add(new JsonObject {
                            ["id"] = selectedUse
                        });

                        ImGui.CloseCurrentPopup();
                    }

                    ImGui.SameLine();

                    if (ImGui.Button("Cancel") || Input.Keyboard.WasPressed(Keys.Escape, true))
                    {
                        ImGui.CloseCurrentPopup();
                    }

                    ImGui.EndPopup();
                }
            }
            else
            {
                if (ImGui.TreeNode(root.ToString()))
                {
                    ImGui.TreePop();
                }
            }

            ImGui.PopID();
        }
Beispiel #11
0
        public static void Render()
        {
            if (!WindowManager.ItemEditor)
            {
                return;
            }

            if (toSort)
            {
                toSort = false;
                Sort();
            }

            RenderWindow();

            ImGui.SetNextWindowSize(size, ImGuiCond.Once);

            if (!ImGui.Begin("Item explorer"))
            {
                ImGui.End();
                return;
            }

            id = 0;
            ud = 0;

            if (ImGui.Button("New"))
            {
                ImGui.OpenPopup("New item");
                fromCurrent = false;
            }

            if (Selected != null)
            {
                ImGui.SameLine();

                if (ImGui.Button("New from current"))
                {
                    ImGui.OpenPopup("New item");
                    fromCurrent = true;
                }
            }

            ImGui.SameLine();

            if (ImGui.Button("Save") || (Input.Keyboard.IsDown(Keys.LeftControl, true) && Input.Keyboard.WasPressed(Keys.S)))
            {
                Log.Info("Saving items");
                Items.Save();
            }

            ImGui.SameLine();

            if (ImGui.Button("Spawn All (super laggy!)"))
            {
                var player = LocalPlayer.Locate(Engine.Instance.State.Area);

                foreach (var id in Items.Datas.Keys)
                {
                    Items.CreateAndAdd(id, Engine.Instance.State.Area, false).Center = player.Center;
                }
            }

            ImGui.SameLine();

            if (ImGui.Button("Unlock All"))
            {
                foreach (var data in Items.Datas.Values)
                {
                    if (!data.Unlocked)
                    {
                        Items.Unlock(data.Id);
                    }
                }
            }

            if (ImGui.BeginPopupModal("New item"))
            {
                ImGui.PushItemWidth(300);
                ImGui.InputText("Id", ref itemName, 64);
                ImGui.PopItemWidth();

                if (ImGui.Button("Create") || Input.Keyboard.WasPressed(Keys.Enter, true))
                {
                    var data = new ItemData();

                    if (fromCurrent && Selected != null)
                    {
                        data.Type        = Selected.Type;
                        data.Quality     = Selected.Quality;
                        data.Animation   = Selected.Animation;
                        data.Pools       = Selected.Pools;
                        data.Root        = JsonValue.Parse(Selected.Root.ToString());
                        data.Renderer    = data.Root["renderer"];
                        data.Uses        = data.Root["uses"];
                        data.SingleUse   = Selected.SingleUse;
                        data.UseTime     = Selected.UseTime;
                        data.Lockable    = Selected.Lockable;
                        data.UnlockPrice = Selected.UnlockPrice;
                        data.Single      = Selected.Single;

                        var c = Selected.Chance;
                        data.Chance = new Chance(c.Any, c.Melee, c.Magic, c.Range);
                    }
                    else
                    {
                        data.Chance   = Chance.All();
                        data.Uses     = new JsonArray();
                        data.Renderer = new JsonObject();

                        data.Root = new JsonObject {
                            ["uses"]     = data.Uses,
                            ["renderer"] = data.Renderer
                        };
                    }

                    data.Id = itemName;
                    Items.Datas[data.Id] = data;
                    Selected             = data;
                    itemName             = "";

                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();

                if (ImGui.Button("Cancel") || Input.Keyboard.WasPressed(Keys.Escape, true))
                {
                    itemName = "";
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            ImGui.Separator();

            filter.Draw("Search");

            ImGui.SameLine();
            ImGui.Text($"{count}");

            count = 0;
            ImGui.Combo("Filter by", ref sortBy, sortTypes, sortTypes.Length);

            if (sortBy > 0)
            {
                if (sortBy == 1)
                {
                    ImGui.Combo("Type", ref sortType, Types, Types.Length);
                }
                else if (sortBy == 2)
                {
                    ImGui.Checkbox("Lockable", ref locked);
                }
                else if (sortBy == 3)
                {
                    if (ImGui.TreeNode("Spawns in"))
                    {
                        ImGui.Checkbox("Does not spawn", ref invertSpawn);
                        ImGui.Separator();

                        var i = 0;

                        foreach (var p in ItemPool.ById)
                        {
                            var val = p.Contains(pools);

                            if (ImGui.Checkbox(p.Name, ref val))
                            {
                                pools = p.Apply(pools, val);
                            }

                            i++;

                            if (i == ItemPool.Count)
                            {
                                break;
                            }
                        }

                        ImGui.TreePop();
                    }
                }
                else if (sortBy == 4)
                {
                    ImGui.Checkbox("Single?", ref single);
                }
                else if (sortBy == 5)
                {
                    ImGui.Combo("Quality", ref quality, Quality, Quality.Length);
                }
                else if (sortBy == 6)
                {
                    var v = (int)weaponTypeSort;

                    if (ImGui.Combo("Weapon Type", ref v, WeaponTypes, WeaponTypes.Length))
                    {
                        weaponTypeSort = (WeaponType)v;
                    }
                }
            }

            ImGui.Separator();

            var height = ImGui.GetStyle().ItemSpacing.Y;

            ImGui.BeginChild("ScrollingRegionItems", new System.Numerics.Vector2(0, -height),
                             false, ImGuiWindowFlags.HorizontalScrollbar);

            foreach (var i in Items.Datas.Values)
            {
                ImGui.PushID(id);

                if (ForceFocus && i == Selected)
                {
                    ImGui.SetScrollHereY();
                    ForceFocus = false;
                }

                if (filter.PassFilter(i.Id))
                {
                    if (sortBy > 0)
                    {
                        if (sortBy == 1)
                        {
                            if (i.Type != (ItemType)sortType)
                            {
                                continue;
                            }
                        }
                        else if (sortBy == 2)
                        {
                            if (i.Lockable != locked)
                            {
                                continue;
                            }
                        }
                        else if (sortBy == 3)
                        {
                            var found = false;

                            for (var j = 0; j < 32; j++)
                            {
                                if (BitHelper.IsBitSet(pools, j) && BitHelper.IsBitSet(i.Pools, j))
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (invertSpawn == found)
                            {
                                continue;
                            }
                        }
                        else if (sortBy == 4)
                        {
                            if (i.Single != single)
                            {
                                continue;
                            }
                        }
                        else if (sortBy == 5)
                        {
                            if (i.Quality != (ItemQuality)quality)
                            {
                                continue;
                            }
                        }
                        else if (sortBy == 6)
                        {
                            if (i.Type != ItemType.Weapon || i.WeaponType != weaponTypeSort)
                            {
                                continue;
                            }
                        }
                    }

                    count++;

                    if (ImGui.Selectable(i.Id, i == Selected))
                    {
                        Selected = i;

                        if (ImGui.IsMouseDown(1))
                        {
                            if (ImGui.Button("Give"))
                            {
                                LocalPlayer.Locate(Engine.Instance.State.Area)
                                ?.GetComponent <InventoryComponent>()
                                .Pickup(Items.CreateAndAdd(
                                            Selected.Id, Engine.Instance.State.Area
                                            ));
                            }
                        }
                    }
                }

                ImGui.PopID();
                id++;
            }

            ImGui.EndChild();
            ImGui.End();
        }
Beispiel #12
0
        public static void Render()
        {
            ImGui.SetNextWindowSize(size, ImGuiCond.Once);

            if (!ImGui.Begin("Entity placer"))
            {
                ImGui.End();
                open = false;
                return;
            }

            open = true;

            var down    = !ImGui.GetIO().WantCaptureMouse&& Input.Mouse.CheckLeftButton;
            var clicked = !ImGui.GetIO().WantCaptureMouse&& MouseData.HadClick;

            if (Input.Keyboard.IsDown(Keys.LeftControl, true))
            {
                if (entity != null)
                {
                    if (Input.Keyboard.WasPressed(Keys.C, true))
                    {
                        copy = entity.GetType();
                    }

                    if (copy != null && Input.Keyboard.WasPressed(Keys.V, true))
                    {
                        var od = currentType;
                        currentType = copy;
                        CreateEntity(false);
                        currentType = od;
                    }

                    if (Input.Keyboard.WasPressed(Keys.D, true))
                    {
                        entity.Done = true;
                        entity      = null;
                    }
                }
            }

            ImGui.Checkbox("Move", ref move);            /*) {
                                                          * if (entityMode != 0) {
                                                          * RemoveEntity();
                                                          * }
                                                          * }*/

            if (!move && entity != null)
            {
                var mouse = Input.Mouse.GamePosition;

                if (SnapToGrid)
                {
                    mouse.X = (float)Math.Floor(mouse.X / 16) * 16;
                    mouse.Y = (float)Math.Floor(mouse.Y / 16) * 16;
                }

                mouse += new Vector2(8 - entity.Width / 2f, 8 - entity.Height / 2f);

                if (Center)
                {
                    entity.Center = mouse;
                }
                else
                {
                    entity.Position = mouse;
                }

                if (clicked)
                {
                    CreateEntity(false);
                }
            }
            else if (move)
            {
                var    mouse    = Input.Mouse.GamePosition;
                Entity selected = null;

                foreach (var e in Editor.Area.Entities.Entities)
                {
                    if (e.OnScreen && AreaDebug.PassFilter(e) && !(e is Firefly || e is WindFx || e is Lock))
                    {
                        if (e.Contains(mouse))
                        {
                            selected = e;
                        }
                    }
                }

                HoveredEntity = selected;

                if (clicked)
                {
                    entity = selected;

                    if (selected != null)
                    {
                        AreaDebug.ToFocus = entity;
                        offset            = entity.Position - mouse;
                    }
                }
                else if (entity != null && (down && entity.Contains(mouse) || Input.Keyboard.IsDown(Keys.LeftAlt, true)))
                {
                    mouse += offset;

                    if (SnapToGrid)
                    {
                        mouse.X = (float)Math.Round(mouse.X / 16) * 16;
                        mouse.Y = (float)Math.Round(mouse.Y / 16) * 16;
                    }

                    mouse += new Vector2(8 - entity.Width / 2f, 8 - entity.Height / 2f);

                    if (Center)
                    {
                        entity.Center = mouse;
                    }
                    else
                    {
                        entity.Position = mouse;
                    }
                }
            }

            ImGui.Checkbox("Snap to grid", ref SnapToGrid);
            ImGui.SameLine();
            ImGui.Checkbox("Center", ref Center);

            if (entity != null)
            {
                ImGui.Separator();
                ImGui.Text(entity.GetType().Name);

                if (ImGui.Button("Open debug"))
                {
                    AreaDebug.ToFocus = entity;
                }

                ImGui.Separator();
            }

            filter.Draw("");
            var i = 0;

            ImGui.Separator();
            var h = ImGui.GetStyle().ItemSpacing.Y;

            ImGui.BeginChild("ScrollingRegionConsole", new System.Numerics.Vector2(0, -h),
                             false, ImGuiWindowFlags.HorizontalScrollbar);

            foreach (var t in Types)
            {
                if (filter.PassFilter(t.Name))
                {
                    if (ImGui.Selectable(t.Name, selected == i))
                    {
                        selected = i;

                        currentType = t.Type;
                        CreateEntity();
                    }
                }

                i++;
            }

            ImGui.EndChild();
            ImGui.End();
        }
		public static void Render() {
			if (!WindowManager.LootTable) {
				return;
			}
			
			ImGui.SetNextWindowSize(size, ImGuiCond.Once);

			if (!ImGui.Begin("Loot Table Editor")) {
				ImGui.End();
				return;
			}

			if (ImGui.Button("Save")) {
				LootTables.Save();
			}

			ImGui.SameLine();
			
			if (ImGui.Button("New##pe")) {
				ImGui.OpenPopup("Add Item##pe");	
			}

			if (selectedTable != null) {
				ImGui.SameLine();
				
				if (ImGui.Button("Delete")) {
					LootTables.Defined.Remove(selectedTable);
					LootTables.Data.Remove(selectedTable);
					
					selectedTable = null;
				}
			}
			
			filter.Draw("");
			ImGui.SameLine();
			ImGui.Text($"{count}");

			if (ImGui.BeginPopupModal("Add Item##pe")) {
				ImGui.PushItemWidth(300);
				ImGui.InputText("Id", ref poolName, 64);
				ImGui.PopItemWidth();
				
				if (ImGui.Button("Add") || Input.Keyboard.WasPressed(Keys.Enter, true)) {
					selectedTable = poolName;
					LootTables.Defined[poolName] = new AnyDrop();
					LootTables.Data[poolName] = new JsonObject {
						["type"] = "any"
					};
					
					poolName = "";
					ImGui.CloseCurrentPopup();
				}

				ImGui.SameLine();
				
				if (ImGui.Button("Cancel") || Input.Keyboard.WasPressed(Keys.Escape, true)) {
					poolName = "";
					ImGui.CloseCurrentPopup();
				}

				ImGui.EndPopup();
			}
			
			if (selectedTable != null) {
				ImGui.SameLine();

				if (ImGui.Button("Remove##pe")) {
					LootTables.Defined.Remove(selectedTable);
					selectedTable = null;
				}
			}

			count = 0;
			
			ImGui.Separator();
			
			var height = ImGui.GetStyle().ItemSpacing.Y;
			ImGui.BeginChild("rolingRegionItems##Pe", new System.Numerics.Vector2(0, -height), 
				false, ImGuiWindowFlags.HorizontalScrollbar);

			foreach (var i in LootTables.Defined) {
				ImGui.PushID($"{id}___m");

				if (filter.PassFilter(i.Key)) {
					count++;

					if (ImGui.Selectable($"{i.Key}##ped", i.Key  == selectedTable)) {
						selectedTable = i.Key;
					}
				}

				ImGui.PopID();
				id++;
			}

			id = 0;

			ImGui.EndChild();
			ImGui.End();

			if (selectedTable == null) {
				return;
			}

			var show = true;
			ImGui.SetNextWindowSize(size, ImGuiCond.Once);

			if (!ImGui.Begin("Loot Table", ref show)) {
				ImGui.End();
				return;
			}

			if (!show) {
				selectedTable = null;
				ImGui.End();
				return;
			}
			
			LootTables.RenderDrop(LootTables.Data[selectedTable]);
			ImGui.End();
		}
Beispiel #14
0
        public static void Render(Area area)
        {
            if (!WindowManager.Entities)
            {
                return;
            }

            RenderWindow();

            ImGui.SetNextWindowSize(defaultSize, ImGuiCond.Once);

            if (!ImGui.Begin("Entities"))
            {
                ImGui.End();
                return;
            }

            ImGui.Text($"Total {area.Entities.Entities.Count} entities");
            filter.Draw();

            ImGui.Checkbox("Hide level helpers", ref hideLevel);
            ImGui.Checkbox("Show only on screen", ref onlyOnScreen);

            var sel = ImGui.Button("Jump to selected");

            if (sel)
            {
                WindowManager.Entities = true;
            }

            ImGui.Text($"Showing {id} entities");

            ImGui.Separator();

            var height = ImGui.GetStyle().ItemSpacing.Y + ImGui.GetFrameHeightWithSpacing() + 4;

            ImGui.BeginChild("ScrollingRegionConsole", new Vector2(0, -height),
                             false, ImGuiWindowFlags.HorizontalScrollbar);

            id = 0;

            foreach (var e in (hasTag ? area.Tagged[BitTag.Tags[currentTag]] : area.Entities.Entities))
            {
                if (filter.PassFilter(e.GetType().FullName) && (!onlyOnScreen || e.OnScreen) && (!hideLevel || PassFilter(e)))
                {
                    var s = selected == e;

                    if (s && (sel || toFocus == e))
                    {
                        ImGui.SetScrollHereY();
                        toFocus = null;
                    }

                    if (ImGui.Selectable($"{e.GetType().Name}##{id}", s))
                    {
                        selected = e;
                    }

                    id++;
                }
            }

            ImGui.EndChild();
            ImGui.Separator();

            ImGui.Checkbox("Must have tag", ref hasTag);

            if (hasTag)
            {
                ImGui.SameLine();
                ImGui.Combo("Tag", ref currentTag, Tags.AllTags, Tags.AllTags.Length);
            }

            ImGui.End();
        }