Exemplo n.º 1
0
        protected override void AddContentToWindow(ConsoleWindow window)
        {
            Helper.Log("AddContentToWindow");
            var screenSegmentStandard = window.Screen.CreateStandardSegment(InsertPosition.OnCursor);

            screenSegmentStandard.AddInterpretter(new SubjectiveDisplay <PopSimple>(_focus, M.m((PopSimple I) => message), null)
            {
                WrapText = wrapText,
                Justify  = TextAnchor.UpperLeft
            });
            window.Screen.CreateSpace(0);
            var seg = window.Screen.CreateTableSegment(buttons.Count, 1);

            seg.SqueezeTable = false;
            foreach (var button in buttons)
            {
                seg.AddInterpretter(SubjectiveButton <PopSimple> .Quick(
                                        _focus, button.label, button.toolTip, x =>
                {
                    button.action?.Invoke(this);
                    if (button.closeAfterClick)
                    {
                        x.Do();
                    }
                }));
            }
        }
Exemplo n.º 2
0
        protected override ConsoleWindow BuildInterface(string suggestedName = "")
        {
            var window = NewWindow("Mod Notifier", WindowSizing.GetCentralNarrowTall());
            var seg0   = window.Screen.CreateStandardSegment();

            seg0.AddInterpretter(SubjectiveButton <ModNotifierBlock> .Quick(_focus, "Refresh mod list", new ToolTip(""), x =>
            {
                _focus.Refresh();
                TriggerRebuild();
            }));

            foreach (var pair in _focus.mods)
            {
                var mod = pair.Value;
                window.Screen.CreateHeader(mod.name.ToString(), new ToolTip(pair.Key.ToString()));

                var seg1 = window.Screen.CreateStandardSegment();
                seg1.AddInterpretter(SubjectiveToggle <ModNotifierBlock.Mod> .Quick(mod,
                                                                                    "Is dependency",
                                                                                    new ToolTip("Do our construct depend on this mod?"),
                                                                                    (x, value) => x.enabled = value,
                                                                                    x => x.enabled));

                seg1.AddInterpretter(TextInput <ModNotifierBlock.Mod> .Quick(mod,
                                                                             M.m <ModNotifierBlock.Mod>(x => x.description),
                                                                             "Mod description",
                                                                             new ToolTip("You can include a description of the mod, why do we need this, what will not work if it's not installed, etc"),
                                                                             (x, value) => x.description = value));

                seg1.AddInterpretter(TextInput <ModNotifierBlock.Mod> .Quick(mod,
                                                                             M.m <ModNotifierBlock.Mod>(x => x.manifest),
                                                                             "modmanifest.json URI",
                                                                             new ToolTip("Leave blank if the mod doesn't use FtdModManager"),
                                                                             (x, value) => x.manifest = value));

                seg1.AddInterpretter(TextInput <ModNotifierBlock.Mod> .Quick(mod,
                                                                             M.m <ModNotifierBlock.Mod>(x => x.link),
                                                                             "External link",
                                                                             new ToolTip("An external link for the mod. Leave blank if you don't have one"),
                                                                             (x, value) => x.link = value));
            }
            return(window);
        }
Exemplo n.º 3
0
        public override void Build()
        {
            if (results == null)
            {
                results = _focus.SearchWithNewQuery("").ToArray();
            }

            var seg1 = CreateStandardSegment(InsertPosition.ZeroCursor);

            seg1.AddInterpretter(TextInput <BlockSearch> .Quick(_focus, M.m <BlockSearch>(x => x.query), "Search query", new ToolTip("Search query"),
                                                                (x, query) =>
            {
                if (query != x.query)
                {
                    if (query.Contains('`'))
                    {
                        deactivate();
                        return;
                    }
                    results = x.SearchWithNewQuery(query).ToArray();

                    Segments.Clear();
                    Build();
                }
            }));

            var seg2 = CreateStandardSegment();

            foreach (var item in results)
            {
                var button = SubjectiveButton <BlockSearch> .Quick(_focus, item.ComponentId.Name, item.GetToolTip(), x =>
                {
                    x.SelectItem(item);
                    deactivate();
                });

                button.Justify = TextAnchor.MiddleLeft;
                seg2.AddInterpretter(button);
            }
        }
Exemplo n.º 4
0
        protected override ConsoleWindow BuildInterface(string suggestedName = "")
        {
            var window = NewWindow(135317, "3D Hologram Projector", WindowSizing.GetSizeCentral(0.7f, 0.5f));

            window.DisplayTextPrompt = false;

            window.Screen.CreateHeader("File", new ToolTip("Configure loading options"));

            var seg1 = window.Screen.CreateStandardSegment();

            seg1.AddInterpretter(TextInput <Holo3D> .Quick(_focus, M.m <Holo3D>(x => x.Path), "Path",
                                                           new ToolTip("Type a local path into the box below to load an .obj file for the hologram"), (x, value) => x.Path = value));
            seg1.AddInterpretter(SubjectiveButton <Holo3D> .Quick(_focus, "Reload 3D Model",
                                                                  new ToolTip("Load the .obj and all related files and display the model as a hologram"), (x) => x.Reload()));

            var seg2 = window.Screen.CreateStandardHorizontalSegment();

            seg2.AddInterpretter(SubjectiveToggle <Holo3D> .Quick(_focus, "Enabled",
                                                                  new ToolTip("Should the hologram display?"), (x, value) => x.Enabled = value, x => x.Enabled));
            seg2.AddInterpretter(SubjectiveToggle <Holo3D> .Quick(_focus, "Display on start",
                                                                  new ToolTip("If turned off, the hologram will only load when you press the \"Reload\" button. " +
                                                                              "Otherwise, it will load immediately after the Construct is loaded (it may cause some serious lag)."),
                                                                  (x, value) => x.displayOnStart = value, x => x.displayOnStart));

            var items = Holo3D.shaders.Select(x => new DropDownMenuAltItem <Shader>
            {
                Name            = x.name,
                ObjectForAction = x,
                ToolTip         = "Shader to use\nPress \"Reload 3D Model\" button to apply"
            }).ToArray();
            var menu = new DropDownMenuAlt <Shader>();

            menu.SetItems(items);
            seg2.AddInterpretter(new DropDown <Holo3D, Shader>(_focus, menu, (x, shader) => x.shader == shader, (x, shader) => x.shader = shader));

            window.Screen.CreateHeader("Transform", new ToolTip("Configure position, rotation and scale"));

            var seg3 = window.Screen.CreateStandardSegment();

            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, -100, 100, 0.1f, 0,
                                                                                         M.m <Holo3D>(x => x.pos.z), "Forward/Back translation {0}m",
                                                                                         (x, value) => { x.pos.z = value; x.SetLocalTransform(); }, new ToolTip("Position.z")));
            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, -100, 100, 0.1f, 0,
                                                                                         M.m <Holo3D>(x => x.pos.x), "Left/Right translation {0}m",
                                                                                         (x, value) => { x.pos.x = value; x.SetLocalTransform(); }, new ToolTip("Position.x")));
            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, -100, 100, 0.1f, 0,
                                                                                         M.m <Holo3D>(x => x.pos.y), "Up/Down translation {0}m",
                                                                                         (x, value) => { x.pos.y = value; x.SetLocalTransform(); }, new ToolTip("Position.y")));

            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, -180, 180, 1, 0,
                                                                                         M.m <Holo3D>(x => x.rot.x), "Pitch {0}°",
                                                                                         (x, value) => { x.rot.x = value; x.SetLocalTransform(); }, new ToolTip("Rotation.x")));
            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, -180, 180, 1, 0,
                                                                                         M.m <Holo3D>(x => x.rot.z), "Roll {0}°",
                                                                                         (x, value) => { x.rot.z = value; x.SetLocalTransform(); }, new ToolTip("Rotation.z")));
            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, -180, 180, 1, 0,
                                                                                         M.m <Holo3D>(x => x.rot.y), "Yaw {0}°",
                                                                                         (x, value) => { x.rot.y = value; x.SetLocalTransform(); }, new ToolTip("Rotation.y")));

            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, 0.01f, 100, 0.01f, 1,
                                                                                         M.m <Holo3D>(x => x.scale.z), "Forward/Back scale {0}x",
                                                                                         (x, value) => { x.scale.z = value; x.SetLocalTransform(); }, new ToolTip("Scale.z")));
            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, 0.01f, 100, 0.01f, 1,
                                                                                         M.m <Holo3D>(x => x.scale.x), "Left/Right scale {0}x",
                                                                                         (x, value) => { x.scale.x = value; x.SetLocalTransform(); }, new ToolTip("Scale.x")));
            seg3.AddInterpretter(SubjectiveFloatClampedWithBarFromMiddle <Holo3D> .Quick(_focus, 0.01f, 100, 0.01f, 1,
                                                                                         M.m <Holo3D>(x => x.scale.y), "Up/Down scale {0}x",
                                                                                         (x, value) => { x.scale.y = value; x.SetLocalTransform(); }, new ToolTip("Scale.y")));

            return(window);
        }
Exemplo n.º 5
0
        protected override ConsoleWindow BuildInterface(string suggestedName = "")
        {
            var window1 = NewWindow("Mod List", WindowSizing.GetLhs());

            window1.DisplayTextPrompt = false;
            var seg1 = window1.Screen.CreateStandardSegment();

            foreach (var mod in _focus.mods)
            {
                var btn = seg1.AddInterpretter(SubjectiveButton <ModPreferences> .Quick(mod, mod.modName, new ToolTip(mod.basePath, 400), x =>
                {
                    selected = x;
                }));
                btn.Color = M.m <ModPreferences>(x => selected == x ? Color.green : Color.white);
            }


            var window2 = NewWindow("Mod Manager", WindowSizing.GetRhs());

            window2.DisplayTextPrompt = false;


            window2.Screen.CreateHeader("Mod Options", new ToolTip("Options for the selected mod"));
            var seg2 = window2.Screen.CreateStandardSegment();

            seg2.SetConditionalDisplay(() => selected != null);

            seg2.AddInterpretter(SubjectiveDisplay <Manager> .Quick(_focus, M.m <Manager>(
                                                                        x =>
            {
                if (selected.Managed)
                {
                    return("This mod is managed by FtdModManager");
                }
                else
                {
                    return("This mod is <b>not</b> managed by FtdModManager");
                }
            }
                                                                        ), "Information about this mod"));

            var items = Enum.GetNames(typeof(UpdateType)).Select(x => new DropDownMenuAltItem <UpdateType> {
                Name = x, ToolTip = x
            });
            var menu = new DropDownMenuAlt <UpdateType>();

            menu.SetItems(items.ToArray());

            seg2.AddInterpretter(new DropDown <Manager, UpdateType>(_focus, menu,
                                                                    (manager, x) => x == selected.updateType,
                                                                    (manager, x) => _focus.SetUpdateType(selected, x)));

            seg2.AddInterpretter(SubjectiveButton <Manager> .Quick(_focus, "Check update", new ToolTip("Check update"), x =>
            {
                x.CheckUpdate(selected);
            }));

            seg2.AddInterpretter(SubjectiveButton <Manager> .Quick(_focus, "Uninstall", new ToolTip("Uninstall mod"), x =>
            {
                _focus.DetectMods();
                TriggerRebuild();
            }));

            window2.Screen.CreateSpace();

            window2.Screen.CreateHeader("Mod Installation", new ToolTip("Install mod, etc."));
            var seg3 = window2.Screen.CreateStandardSegment();

            seg3.AddInterpretter(SubjectiveButton <Manager> .Quick(_focus, "Install new mod", new ToolTip("Install new mod"),
                                                                   x => preparingInstall = true))
            .SetConditionalDisplayFunction(() => !preparingInstall);

            seg3.AddInterpretter(TextInput <Manager> .Quick(_focus, M.m <Manager>(x => manifestUri), "Install URI",
                                                            new ToolTip("Paste the URI of the modmanifest.json here"), (manager, x) => manifestUri = x))
            .SetConditionalDisplayFunction(() => preparingInstall);

            seg3.AddInterpretter(TextInput <Manager> .Quick(_focus, M.m <Manager>(x => modDir), "Install path (Optional)",
                                                            new ToolTip("The installation directory of the new mod. Leave empty to use default value"), (manager, x) => modDir = x))
            .SetConditionalDisplayFunction(() => preparingInstall);

            var seg4 = window2.Screen.CreateStandardHorizontalSegment();

            seg4.AddInterpretter(SubjectiveButton <Manager> .Quick(_focus, "Install", new ToolTip("Install new mod!"), x =>
            {
                _focus.Install(manifestUri, modDir).ContinueWith(y =>
                {
                    isInstalling     = false;
                    preparingInstall = false;
                    manifestUri      = "";
                    modDir           = "";
                    _focus.DetectMods();
                    TriggerRebuild();
                });
            }))
            .SetConditionalDisplayFunction(() => preparingInstall && !isInstalling);

            seg4.AddInterpretter(SubjectiveButton <Manager> .Quick(_focus, "Cancel", new ToolTip("Cancel mod installation"),
                                                                   x => preparingInstall = false))
            .SetConditionalDisplayFunction(() => preparingInstall && !isInstalling);

            window2.Screen.CreateHeader("Miscellaneous", new ToolTip("Other useful operations"));
            var seg5 = window2.Screen.CreateStandardSegment();

            (seg5.AddInterpretter(SubjectiveButton <Manager> .Quick(_focus, "Restart FtD", new ToolTip("Restart FtD in order to reload mods"),
                                                                    x => _focus.RestartGame()))
             .SetConditionalDisplayFunction(() => !isInstalling) as SubjectiveButton <Manager>)
            .Color = M.m <Manager>(new Color(255 / 255f, 179 / 255f, 179 / 255f));

            //window.Screen.CreateSpace();
            return(window1);
        }