Beispiel #1
0
    public override VisualElement CreatePropertyGUI(SerializedProperty property)
    {
        string styleSheetPath = this.GetAssetPath() + STYLE_SHEET_NAME;
        string treePath       = this.GetAssetPath() + TREE_NAME;
        var    container      = ROJOEditor.LoadAssetTree(treePath);

        container.LoadStyleSheet(styleSheetPath);
        var eventsContainer    = container.Q <VisualElement>(name: "Events");
        var animationContainer = container.Q <VisualElement>(name: "Animations");

        eventsContainer.AddProperty(property.FindPropertyRelative("OnStart"));
        eventsContainer.AddProperty(property.FindPropertyRelative("OnComplete"));

        animationContainer.AddProperty(property.FindPropertyRelative("move"));
        animationContainer.AddProperty(property.FindPropertyRelative("scale"));
        animationContainer.AddProperty(property.FindPropertyRelative("rotate"));
        animationContainer.AddProperty(property.FindPropertyRelative("animatedProperty"));
        animationContainer.AddProperty(property.FindPropertyRelative("animatedProperty2"));
        animationContainer.AddProperty(property.FindPropertyRelative("animatedProperty3"));


        ToggleView toggleView = container.Q <ToggleView>(name: "toggleView");

        toggleView.Init();
        return(container);
    }
Beispiel #2
0
        public GetSingleToggleTagsTests()
        {
            _mediator   = Substitute.For <IMediator>();
            _controller = new ToggleTagsController(_mediator);

            _validLocator   = ToggleLocator.Create("i exist");
            _invalidLocator = ToggleLocator.Create("i dont exist");

            var toggleView = new ToggleView
            {
                ID          = ToggleID.CreateNew(),
                Name        = "toggle-1",
                Description = "the first toggle",
                Tags        = { "first", "dev" }
            };

            var response = new GetToggleResponse
            {
                Toggle = toggleView
            };

            _mediator
            .Send(Arg.Any <GetToggleRequest>())
            .Returns(new GetToggleResponse());
            _mediator
            .Send(Arg.Is <GetToggleRequest>(req => req.Locator == _validLocator))
            .Returns(response);
        }
Beispiel #3
0
        /// <summary>
        /// 执行绑定过程
        /// </summary>
        protected override void Awake()
        {
            toggleView = GetComponent <ToggleView>();

            //实例化DataEntity
            this.DataEntity = new TabItemEntity();

            //在父类的Awake函数中执行绑定过程
            base.Awake();
        }
Beispiel #4
0
 private void ViewLetterButtons()
 {
     for (int index = 0; index < DataUtil.Length(model.letterButtonTexts); index++)
     {
         string letter     = model.letterButtonTexts[index];
         var    letterView = view.letterButtonTexts[index];
         TextView.SetText(letterView, letter);
         SceneNodeView.SetVisible(view.letterButtons[index], model.empty != letter);
         ToggleView.SetIsOn(view.letterButtons[index], model.isLetterSelects[index]);
     }
 }
 private void AssertLetterSelected(SpellingController controller, int index, int length)
 {
     Assert.AreEqual(true,
                     SceneNodeView.GetVisible(
                         controller.view.selected.answers[length]));
     Assert.AreEqual(controller.model.letterButtonTexts[index],
                     TextView.GetText(
                         controller.view.selected.answerTexts[length]));
     Assert.AreEqual(true,
                     ToggleView.IsOn(
                         controller.view.letterButtons[index]));
 }
Beispiel #6
0
        /// <summary>
        /// Called by the sample trigger feature page to get the HTML for a list of checkboxes to use a trigger options
        /// <para>
        /// {{list=plugin_function 'HomeSeerSamplePlugin' 'GetTriggerOptionsHtml' [2]}}
        /// </para>
        /// </summary>
        /// <param name="numTriggerOptions">The number of checkboxes to generate</param>
        /// <returns>
        /// A List of HTML strings representing checkbox input elements
        /// </returns>
        public List <string> GetTriggerOptionsHtml(int numTriggerOptions)
        {
            var triggerOptions = new List <string>();

            for (var i = 1; i <= numTriggerOptions; i++)
            {
                var cbTrigOpt = new ToggleView($"checkbox-triggeroption{i}", $"Trigger Option {i}")
                {
                    ToggleType = EToggleType.Checkbox
                };
                triggerOptions.Add(cbTrigOpt.ToHtml());
            }

            return(triggerOptions);
        }
Beispiel #7
0
        public void UpdateToggle(ObjectId id, TogglePutRequest toggle)
        {
            var updatedToggle = new ToggleView
            {
                Id        = id,
                Name      = toggle.Name,
                Value     = toggle.Value,
                OnlyAdmin = toggle.OnlyAdmin
            };

            var result = Query <ToggleView> .EQ(t => t.Id, id);

            var operation = Update <ToggleView> .Replace(updatedToggle);

            _collection.Update(result, operation);
        }
Beispiel #8
0
        public List <ToggleView> GetToggles()
        {
            var result = new List <ToggleView>();
            var data   = _collection.FindAll();

            foreach (var r in data)
            {
                var item = new ToggleView();
                item.Id        = r.Id;
                item.Name      = r.Name;
                item.Value     = r.Value;
                item.OnlyAdmin = r.OnlyAdmin;

                result.Add(item);
            }

            return(result);
        }
Beispiel #9
0
    public override VisualElement CreatePropertyGUI(SerializedProperty property)
    {
        string path = this.GetAssetPath() + TREE_NAME;

        _container = ROJOEditor.LoadAssetTree(path);
        string stylePath = this.GetAssetPath() + STYLE_NAME;

        _container.LoadStyleSheet(stylePath);
        var enabledToggle = _container.Q <Toggle>(name: "enabledToggle");

        enabledToggle.RegisterValueChangedCallback(OnToggleEnabled);
        enabledToggle.BindProperty(property.FindPropertyRelative("Enabled"));

        _behaviourName      = _container.Q <TextElement>(name: "behaviourName");
        _behaviourName.text = property.name;
        _mainContainer      = _container.Q <VisualElement>(name: "mainContainer");
        _animationContainer = _container.Q <VisualElement>(name: "Animations");
        _eventsContainer    = _container.Q <VisualElement>(name: "Events");

        ToggleView toggleView = _container.Q <ToggleView>(name: "toggleView");

        toggleView.Init();



        var moveProperty       = property.FindPropertyRelative("move");
        var scaleProperty      = property.FindPropertyRelative("scale");
        var rotateProperty     = property.FindPropertyRelative("rotate");
        var propertiesProperty = property.FindPropertyRelative("animatedProperty");

        var onStartProperty = property.FindPropertyRelative("OnStart");
        var onEndProperty   = property.FindPropertyRelative("OnComplete");

        _animationContainer.Add(new PropertyField(moveProperty));
        _animationContainer.Add(new PropertyField(scaleProperty));
        _animationContainer.Add(new PropertyField(rotateProperty));
        _animationContainer.Add(new PropertyField(propertiesProperty));

        _eventsContainer.Add(new PropertyField(onStartProperty));
        _eventsContainer.Add(new PropertyField(onEndProperty));

        SetEnable(enabledToggle.value);
        return(_container);
    }
Beispiel #10
0
        public static IView View()
        {
            var bodySelector = new ListSelectView<CelestialBody>("Planet", () => FlightGlobals.fetch == null ? null : FlightGlobals.fetch.bodies, null, Extensions.CbToString);
            bodySelector.CurrentlySelected = FlightGlobals.fetch == null ? null : FlightGlobals.ActiveVessel == null ? Planetarium.fetch.Home : FlightGlobals.ActiveVessel.mainBody;
            var lat = new TextBoxView<double>("Lat", "Latitude of landing coordinates", 0.001d, myTryParse);
            var lon = new TextBoxView<double>("Lon", "Longitude of landing coordinates", 0.001d, myTryParse);
            var alt = new TextBoxView<double>("Alt", "Altitude of landing coordinates", 20, Model.SiSuffix.TryParse);
            var setRot = new ToggleView("Set rotation",
                "If set, rotates the vessel such that up on the vessel is up when landing. Otherwise, the same orientation is kept as before teleporting, relative to the planet",
                false);
            Func<bool> isValid = () => lat.Valid && lon.Valid && alt.Valid;
            Action<double, double, CelestialBody> load = (latVal, lonVal, body) =>
            {
                lat.Object = latVal;
                lon.Object = lonVal;
                bodySelector.CurrentlySelected = body;
            };

            return new VerticalView(new IView[]
                {
                    lat,
                    lon,
                    alt,
                    bodySelector,
                    setRot,
                    new ConditionalView(() => FlightGlobals.fetch != null && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.mainBody != bodySelector.CurrentlySelected,
                        new LabelView("Landing on a body other than the current one is not recommended.",
                            "This causes lots of explosions, it's advisable to teleport to an orbit above the planet, then land on it directly")),
                    new ConditionalView(() => lat.Valid && (lat.Object < -89.9 || lat.Object > 89.9),
                        new LabelView("Setting latitude to -90 or 90 degrees (or near it) is dangerous, try 89.9 degrees",
                            "(This warning also appears when latitude is past 90 degrees)")),
                    new DynamicToggleView("Landing", "Land the ship (or stop landing)", Model.DoLander.IsLanding,
                        isValid, b => Model.DoLander.ToggleLanding(lat.Object, lon.Object, alt.Object, bodySelector.CurrentlySelected, setRot.Value, load)),
                    new ConditionalView(() => Model.DoLander.IsLanding(), new LabelView(HelpString(), "Moves the landing vessel's coordinates slightly")),
                    new ConditionalView(() => !Model.DoLander.IsLanding(), new ButtonView("Land here", "Stops the vessel and slowly lowers it to the ground (without teleporting)", () => Model.DoLander.LandHere(load))),
                    new ConditionalView(isValid, new ButtonView("Save", "Save the entered location", () => Model.DoLander.AddSavedCoords(lat.Object, lon.Object, bodySelector.CurrentlySelected))),
                    new ButtonView("Load", "Load a previously-saved location", () => Model.DoLander.Load(load)),
                    new ButtonView("Delete", "Delete a previously-saved location", Model.DoLander.Delete),
                    new ButtonView("Set to current", "Set lat/lon to the current position", () => Model.DoLander.SetToCurrent(load)),
                    new ListSelectView<Vessel>("Set lat/lon to", Model.DoLander.LandedVessels, select => Model.DoLander.SetToLanded(load, select), Extensions.VesselToString),
                });
        }
        public void UpdateButtonTogglesLettersAfter()
        {
            var controller = AssertButtonSelectedToggles();
            var buttons    = controller.view.letterButtons;

            controller.buttons.view.Down(buttons[3]);
            controller.Update();
            AssertLetterSelected(controller, 3, 0);
            controller.buttons.view.Down(buttons[2]);
            controller.Update();
            AssertLetterSelected(controller, 2, 1);
            controller.buttons.view.Down(buttons[1]);
            controller.Update();
            AssertLetterSelected(controller, 1, 2);
            controller.buttons.view.Down(buttons[2]);
            controller.Update();
            Assert.AreEqual(false,
                            SceneNodeView.GetVisible(
                                controller.view.selected.answers[2]));
            Assert.AreEqual(false,
                            SceneNodeView.GetVisible(
                                controller.view.selected.answers[1]));
            Assert.AreEqual(false,
                            ToggleView.IsOn(
                                controller.view.letterButtons[1]));
            AssertLetterSelected(controller, 3, 0);
            controller.buttons.view.Down(buttons[3]);
            controller.Update();
            Assert.AreEqual(false,
                            SceneNodeView.GetVisible(
                                controller.view.selected.answers[0]));
            controller.buttons.view.Down(buttons[1]);
            controller.Update();
            AssertLetterSelected(controller, 1, 0);
            controller.buttons.view.Down(buttons[1]);
            controller.Update();
            Assert.AreEqual(false,
                            SceneNodeView.GetVisible(
                                controller.view.selected.answers[0]));
        }
Beispiel #12
0
 public ToggleViewTests()
 {
     _view   = new ToggleView();
     _editor = EditorID.Parse("editor");
     _id     = ToggleID.CreateNew();
 }
Beispiel #13
0
        void ReleaseDesignerOutlets()
        {
            if (ClassCount != null)
            {
                ClassCount.Dispose();
                ClassCount = null;
            }

            if (ClassCountHeight != null)
            {
                ClassCountHeight.Dispose();
                ClassCountHeight = null;
            }

            if (CloseBtnHeight != null)
            {
                CloseBtnHeight.Dispose();
                CloseBtnHeight = null;
            }

            if (DataVisualizerBtn != null)
            {
                DataVisualizerBtn.Dispose();
                DataVisualizerBtn = null;
            }

            if (DefaultHeight != null)
            {
                DefaultHeight.Dispose();
                DefaultHeight = null;
            }

            if (ObjectBtn != null)
            {
                ObjectBtn.Dispose();
                ObjectBtn = null;
            }

            if (SaveBtn != null)
            {
                SaveBtn.Dispose();
                SaveBtn = null;
            }

            if (SearchView != null)
            {
                SearchView.Dispose();
                SearchView = null;
            }

            if (SelectedClass != null)
            {
                SelectedClass.Dispose();
                SelectedClass = null;
            }

            if (SelectedClassHeight != null)
            {
                SelectedClassHeight.Dispose();
                SelectedClassHeight = null;
            }

            if (SettingBtn != null)
            {
                SettingBtn.Dispose();
                SettingBtn = null;
            }

            if (ShareBtn != null)
            {
                ShareBtn.Dispose();
                ShareBtn = null;
            }

            if (Sidebar != null)
            {
                Sidebar.Dispose();
                Sidebar = null;
            }

            if (SidebarClose != null)
            {
                SidebarClose.Dispose();
                SidebarClose = null;
            }

            if (SideBarToggle != null)
            {
                SideBarToggle.Dispose();
                SideBarToggle = null;
            }

            if (SidebarView != null)
            {
                SidebarView.Dispose();
                SidebarView = null;
            }

            if (SidebarWidth != null)
            {
                SidebarWidth.Dispose();
                SidebarWidth = null;
            }

            if (SidebarXOffset != null)
            {
                SidebarXOffset.Dispose();
                SidebarXOffset = null;
            }

            if (sidebarYOffset != null)
            {
                sidebarYOffset.Dispose();
                sidebarYOffset = null;
            }

            if (TextviewTopPadding != null)
            {
                TextviewTopPadding.Dispose();
                TextviewTopPadding = null;
            }

            if (ToggleHeight != null)
            {
                ToggleHeight.Dispose();
                ToggleHeight = null;
            }

            if (ToggleView != null)
            {
                ToggleView.Dispose();
                ToggleView = null;
            }

            if (ToolBar != null)
            {
                ToolBar.Dispose();
                ToolBar = null;
            }
        }
        public static IView View()
        {
            CelestialBody body = null;

            var geeAsl = new TextBoxView<double>("Gravity multiplier", "1.0 is kerbin, 0.5 is half of kerbin's gravity, etc.", 1, Model.SiSuffix.TryParse);
            var ocean = new ToggleView("Has ocean", "Does weird things to the ocean if off", false);
            var atmosphere = new ToggleView("Has atmosphere", "Toggles if the planet has atmosphere or not", false);
            var atmosphereContainsOxygen = new ToggleView("Atmosphere contains oxygen", "Whether jet engines work or not", false);
            var atmosphereDepth = new TextBoxView<double>("Atmosphere depth", "Theoretically atmosphere height. In reality, doesn't work too well.", 1, Model.SiSuffix.TryParse);
            var atmosphereTemperatureSeaLevel = new TextBoxView<double>("atmosphereTemperatureSeaLevel", "New 1.0 field. Unknown what this does.", 1, Model.SiSuffix.TryParse);
            var atmospherePressureSeaLevel = new TextBoxView<double>("atmospherePressureSeaLevel", "New 1.0 field. Unknown what this does.", 1, Model.SiSuffix.TryParse);
            var atmosphereMolarMass = new TextBoxView<double>("atmosphereMolarMass", "New 1.0 field. Unknown what this does.", 1, Model.SiSuffix.TryParse);
            var atmosphereAdiabaticIndex = new TextBoxView<double>("atmosphereAdiabaticIndex", "New 1.0 field. Unknown what this does.", 1, Model.SiSuffix.TryParse);
            var rotates = new ToggleView("Rotates", "If the planet rotates.", false);
            var rotationPeriod = new TextBoxView<double>("Rotation period", "Rotation period of the planet, in seconds.", 1, Model.SiSuffix.TryParse);
            var initialRotation = new TextBoxView<double>("Initial rotation", "Absolute rotation in degrees of the planet at time=0", 1, Model.SiSuffix.TryParse);
            var tidallyLocked = new ToggleView("Tidally locked", "If the planet is tidally locked. Overrides Rotation Period.", false);

            Action<CelestialBody> onSelect = cb =>
            {
                body = cb;
                geeAsl.Object = body.GeeASL;
                ocean.Value = body.ocean;
                atmosphere.Value = body.atmosphere;
                atmosphereContainsOxygen.Value = body.atmosphereContainsOxygen;
                atmosphereDepth.Object = body.atmosphereDepth;
                atmosphereTemperatureSeaLevel.Object = body.atmosphereTemperatureSeaLevel;
                atmospherePressureSeaLevel.Object = body.atmospherePressureSeaLevel;
                atmosphereMolarMass.Object = body.atmosphereMolarMass;
                atmosphereAdiabaticIndex.Object = body.atmosphereAdiabaticIndex;
                rotates.Value = body.rotates;
                rotationPeriod.Object = body.rotationPeriod;
                initialRotation.Object = body.initialRotation;
                tidallyLocked.Value = body.tidallyLocked;
            };

            var selectBody = new ConditionalView(() => FlightGlobals.fetch != null && FlightGlobals.Bodies != null,
                                 new ListSelectView<CelestialBody>("Selected body", () => FlightGlobals.Bodies, onSelect, Extensions.CbToString));

            var apply = new ConditionalView(() =>
                            geeAsl.Valid &&
                            atmosphereDepth.Valid &&
                            atmosphereTemperatureSeaLevel.Valid &&
                            atmospherePressureSeaLevel.Valid &&
                            atmosphereMolarMass.Valid &&
                            atmosphereAdiabaticIndex.Valid &&
                            rotationPeriod.Valid &&
                            initialRotation.Valid,
                            new ButtonView("Apply", "Applies the changes to the body", () =>
                    {
                        new Model.PlanetEditor.PlanetSettings(
                            geeAsl.Object,
                            ocean.Value,
                            atmosphere.Value,
                            atmosphereContainsOxygen.Value,
                            atmosphereDepth.Object,
                            atmosphereTemperatureSeaLevel.Object,
                            atmospherePressureSeaLevel.Object,
                            atmosphereMolarMass.Object,
                            atmosphereAdiabaticIndex.Object,
                            rotates.Value,
                            rotationPeriod.Object,
                            initialRotation.Object,
                            tidallyLocked.Value,
                            body.orbit).CopyTo(body, false);
                    }));

            var editFields = new ConditionalView(() => body != null, new VerticalView(new IView[]
                    {
                        geeAsl,
                        ocean,
                        atmosphere,
                        atmosphereContainsOxygen,
                        atmosphereDepth,
                        atmosphereTemperatureSeaLevel,
                        atmospherePressureSeaLevel,
                        atmosphereMolarMass,
                        atmosphereAdiabaticIndex,
                        rotates,
                        rotationPeriod,
                        initialRotation,
                        tidallyLocked,
                        apply,
                    }));

            var resetToDefault = new ConditionalView(() => body != null,
                                     new ButtonView("Reset to defaults", "Reset the selected planet to defaults",
                                         () => { Model.PlanetEditor.ResetToDefault(body); onSelect(body); }));

            var copyToKerbin = new ConditionalView(() => body != null && body != Model.PlanetEditor.Kerbin,
                                   new ButtonView("Copy to kerbin", "Copies the selected planet's settings to kerbin",
                                       () => new Model.PlanetEditor.PlanetSettings(body).CopyTo(Model.PlanetEditor.Kerbin, false)));

            var savePlanet = new ConditionalView(() => body != null,
                                 new ButtonView("Save planet to config file", "Saves the current configuration of the planet to a file, so it stays edited even after a restart. Delete the file named the planet's name in " + IoExt.GetPath(null) + " to undo.",
                                     () => Model.PlanetEditor.SavePlanet(body)));

            var reloadDefaults = new ConditionalView(() => FlightGlobals.fetch != null && FlightGlobals.Bodies != null,
                                     new ButtonView("Reload config files", "Reloads the planet .cfg files in " + IoExt.GetPath(null),
                                         Model.PlanetEditor.ApplyFileDefaults));

            return new VerticalView(new IView[]
                {
                    selectBody,
                    editFields,
                    resetToDefault,
                    copyToKerbin,
                    savePlanet,
                    reloadDefaults
                });
        }
Beispiel #15
0
 /// <inheritdoc />
 protected override bool OnDeviceConfigChange(Page deviceConfigPage, int deviceRef)
 {
     foreach (AbstractView view in deviceConfigPage.Views)
     {
         if (view.Id == Constants.Devices.DeviceConfigSampleToggleId)
         {
             ToggleView v = view as ToggleView;
             if (v != null)
             {
                 SetExtraData(deviceRef, Constants.Devices.DeviceConfigSampleToggleId, v.IsEnabled.ToString());
             }
         }
         else if (view.Id == Constants.Devices.DeviceConfigSampleCheckBoxId)
         {
             ToggleView v = view as ToggleView;
             if (v != null)
             {
                 SetExtraData(deviceRef, Constants.Devices.DeviceConfigSampleCheckBoxId, v.IsEnabled.ToString());
             }
         }
         else if (view.Id == Constants.Devices.DeviceConfigSelectListId)
         {
             SelectListView v = view as SelectListView;
             if (v != null)
             {
                 SetExtraData(deviceRef, Constants.Devices.DeviceConfigSelectListId, v.Selection.ToString());
             }
         }
         else if (view.Id == Constants.Devices.DeviceConfigRadioSlId)
         {
             SelectListView v = view as SelectListView;
             if (v != null)
             {
                 SetExtraData(deviceRef, Constants.Devices.DeviceConfigRadioSlId, v.Selection.ToString());
             }
         }
         else if (view.Id == Constants.Devices.DeviceConfigInputId)
         {
             InputView v = view as InputView;
             if (v != null)
             {
                 SetExtraData(deviceRef, Constants.Devices.DeviceConfigInputId, v.Value);
             }
         }
         else if (view.Id == Constants.Devices.DeviceConfigTextAreaId)
         {
             TextAreaView v = view as TextAreaView;
             if (v != null)
             {
                 SetExtraData(deviceRef, Constants.Devices.DeviceConfigTextAreaId, v.Value);
             }
         }
         else if (view.Id == Constants.Devices.DeviceConfigTimeSpanId)
         {
             TimeSpanView v = view as TimeSpanView;
             if (v != null)
             {
                 SetExtraData(deviceRef, Constants.Devices.DeviceConfigTimeSpanId, v.GetStringValue());
             }
         }
     }
     return(true);
 }
Beispiel #16
0
 private void ApplyToggleView(ToggleView toggleview)
 {
     if (!this.toggleView.HasFlag(toggleview))
     {
         this.toggleView |= toggleview;
     }
     else
     {
         this.toggleView &= ~toggleview;
     }
 }