Exemplo n.º 1
0
 public void BoolCheckbox(ref JSONStorableBool output, string name, bool start,
                          JSONStorableBool.SetBoolCallback callback = null, bool right = false)
 {
     output = new JSONStorableBool(name, start, callback);
     script.RegisterBool(output);
     script.CreateToggle(output, right);
 }
    public static UIDynamic CreateToggle(this MVRScript script, JSONStorableBool jsb, string label, bool rightSide = true)
    {
        var control = script.CreateToggle(jsb, rightSide);

        control.label = label;
        return(control);
    }
Exemplo n.º 3
0
    protected void CreateControls()
    {
        DestroyControls();

        /*
         * var debugJson = new JSONStorableString("Debug", Id);
         * RegisterStorable(debugJson);
         * var debugTextField = Script.CreateTextField(debugJson, true);
         * debugTextField.height = 80f;
         * var debugTextInputField = debugTextField.gameObject.AddComponent<UnityEngine.UI.InputField>();
         * debugTextInputField.textComponent = debugTextField.UItext;
         * debugJson.inputField = debugTextInputField;
         * RegisterControl(debugTextField);
         */

        if (IsDuplicate)
        {
            var jss = RegisterStorable(new JSONStorableString("Duplicate", "This item has duplicates and cannot be edited."));
            RegisterControl(Script.CreateTextField(jss));
        }
        else
        {
            _modifiedJson = new JSONStorableBool("This item has been modified", false);
            _modifiedJson.valNoCallback       = Modified;
            _modifiedJson.setCallbackFunction = (bool val) =>
            {
                if (val)
                {
                    // You cannot just enable the Modified flag without actually modifying anything
                    _modifiedJson.valNoCallback = false;
                    return;
                }

                ResetToInitial();
            };
            var resetUi = Script.CreateToggle(_modifiedJson, true);
            RegisterControl(resetUi);

            if (Mirror != null)
            {
                var goToMirrorButton = Script.CreateButton("Go to mirror", true);
                goToMirrorButton.button.onClick.AddListener(() =>
                {
                    Script.SendMessage("SelectEditable", Mirror);
                });
                RegisterControl(goToMirrorButton);
            }

            CreateControlsInternal();
        }
    }
Exemplo n.º 4
0
        public ActionSelector(
            MVRScript plug,
            CallbackAction call = null, string name = "action",
            string startAtom    = null,
            AtomStorableSelector _storableSelected = null) : base(call)
        {
            try
            {
                actionButton = plug.CreateButton(null, true);
                actionButton.button.onClick.AddListener(CallAction);
                //actionButton.button.gameObject.SetActive(false);
                actionButton.button.enabled = false;

                skipSaveRestore = new JSONStorableBool("skip saverestore", false);
                plug.RegisterBool(skipSaveRestore);
                if (_storableSelected == null)
                {
                    storableSelected = new AtomStorableSelector(plug, SyncStorable, startAtom);
                }
                else
                {
                    SuperController.LogMessage("...");
                    storableSelected = _storableSelected;
                    storableSelected.Add(SyncStorable);
                }

                actionChooser = new JSONStorableStringChooser(name,
                                                              null, null, name, SyncActionTarget);
                plug.RegisterStringChooser(actionChooser);
                UIDynamicPopup dp = plug.CreateScrollablePopup(actionChooser);
                dp.popupPanelHeight = 820f;

                plug.CreateToggle(skipSaveRestore).toggle.onValueChanged.AddListener(
                    b => {
                    if (storableSelected.storable != null && storableSelected.storable.name != "None")
                    {
                        SyncStorable(storableSelected.storable.name);
                    }
                });
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Exemplo n.º 5
0
 public UIDynamicToggle CreateToggle(JSONStorableBool jsb, bool rightSide = false)
 {
     return(_toggles.AddAndReturn(_plugin.CreateToggle(jsb, rightSide)));
 }