Esempio n. 1
0
    void RebuildToolList()
    {
        toollist.DeleteChildren(true);

        foreach (var entry in Library.GetAllAttributes <BaseTool>())
        {
            if (entry.Title == "BaseTool")
            {
                continue;
            }

            var button = toollist.Add.Button(entry.Title);
            button.SetClass("active", entry.Name == ConsoleSystem.GetValue("tool_current"));

            button.AddEventListener("onclick", () =>
            {
                ConsoleSystem.Run("tool_current", entry.Name);
                ConsoleSystem.Run("inventory_current", "weapon_tool");

                foreach (var child in toollist.Children)
                {
                    child.SetClass("active", child == button);
                }
            });
        }
    }
Esempio n. 2
0
    public SpawnMenu()
    {
        Instance = this;

        StyleSheet.Load("/ui/SpawnMenu.scss");

        var left = Add.Panel("left");
        {
            var tabs = left.AddChild <ButtonGroup>();
            tabs.AddClass("tabs");

            var body = left.Add.Panel("body");

            {
                var props = body.AddChild <SpawnList>();
                tabs.SelectedButton = tabs.AddButtonActive("Props", (b) => props.SetClass("active", b));

                var ents = body.AddChild <EntityList>();
                tabs.AddButtonActive("Entities", (b) => ents.SetClass("active", b));
            }
        }

        var right = Add.Panel("right");
        {
            var tabs = right.Add.Panel("tabs");
            {
                tabs.Add.Button("Tools").AddClass("active");
                tabs.Add.Button("Utility");
            }
            var body = right.Add.Panel("body");
            {
                var list = body.Add.Panel("toollist");
                {
                    foreach (var entry in Library.GetAllAttributes <Sandbox.Tools.BaseTool>())
                    {
                        if (entry.Title == "Sandbox.Tools.BaseTool")
                        {
                            continue;
                        }

                        var button = list.Add.Button(entry.Title);
                        button.SetClass("active", entry.Name == ConsoleSystem.GetValue("tool_current"));

                        button.AddEvent("onclick", () =>
                        {
                            ConsoleSystem.Run("tool_current", entry.Name);
                            ConsoleSystem.Run("inventory_current", "weapon_tool");

                            foreach (var child in list.Children)
                            {
                                child.SetClass("active", child == button);
                            }
                        });
                    }
                }
                body.Add.Panel("inspector");
            }
        }
    }
Esempio n. 3
0
    void UpdateActiveTool()
    {
        var toolCurrent = ConsoleSystem.GetValue("tool_current");
        var tool        = string.IsNullOrWhiteSpace(toolCurrent) ? null : Library.GetAttribute(toolCurrent);

        foreach (var child in toollist.Children)
        {
            if (child is Button button)
            {
                child.SetClass("active", tool != null && button.Text == tool.Title);
            }
        }
    }
Esempio n. 4
0
 public void UpdateServerInfo()
 {
     ServerMapName = Global.MapName;
     ServerPlayersLabel.UpdateTranslation(new TranslationData("SCOREBOARD.HEADER.PLAYERAMOUNT", Client.All.Count, ConsoleSystem.GetValue("maxplayers").ToInt(0)));
 }