protected void SyncReceiverTarget(string receiverTargetName)
 {
     _receiverTargetName = receiverTargetName;
     receiverTarget      = null;
     if (receiver != null && receiverTargetName != null)
     {
         receiverTarget = receiver.GetFloatJSONParam(receiverTargetName);
         if (receiverTarget != null)
         {
             lowerValueJSON.min   = receiverTarget.min;
             lowerValueJSON.max   = receiverTarget.max;
             upperValueJSON.min   = receiverTarget.min;
             upperValueJSON.max   = receiverTarget.max;
             currentValueJSON.min = receiverTarget.min;
             currentValueJSON.max = receiverTarget.max;
             targetValueJSON.min  = receiverTarget.min;
             targetValueJSON.max  = receiverTarget.max;
             if (!insideRestore)
             {
                 lowerValueJSON.val   = receiverTarget.val;
                 upperValueJSON.val   = receiverTarget.max;
                 currentValueJSON.val = receiverTarget.val;
                 targetValueJSON.val  = receiverTarget.val;
             }
         }
     }
 }
            public Receiver(Breathe script, List <string> atoms, int index, bool rightSide)
            {
                this.index = index;

                script.CreateSpacer(rightSide);

                vartrigChooser = new JSONStorableStringChooser("receiver" + index, atoms, "", "Variable Trigger " + index);
                vartrigChooser.setCallbackFunction += (string atomId) => {
                    Atom         atom     = script.GetAtomById(atomId);
                    JSONStorable storable = (atom != null) ? storable = atom.GetStorableByID("Trigger") : null;
                    vartrig = (storable != null) ? storable.GetFloatJSONParam("value") : null;
                };
                script.CreateScrollablePopup(vartrigChooser, rightSide);
                script.RegisterStringChooser(vartrigChooser);

                List <string> modes = new List <string>()
                {
                    "Out+In", "OutHold", "InHold", "OutInSmooth", "OutSmooth", "InSmooth"
                };

                blendModeChooser = new JSONStorableStringChooser("mode" + index, modes, modes[blendMode], "Mode " + index);
                blendModeChooser.setCallbackFunction += (string modeName) => {
                    blendMode = modes.FindIndex((string entry) => { return(entry == modeName); });
                };
                script.CreateScrollablePopup(blendModeChooser, rightSide);
                script.RegisterStringChooser(blendModeChooser);

                offsetStart = script.SetupSlider("Time Offset Start " + index, 0.0f, -0.5f, 0.5f, rightSide);
                offsetEnd   = script.SetupSlider("Time Offset End " + index, 0.0f, -0.5f, 2.0f, rightSide);
                power       = script.SetupSlider("Power " + index, 1.0f, 0.0f, 1.0f, rightSide);
            }
Beispiel #3
0
        public void SetupDollControl(Atom atom)
        {
            meterTransform = containingAtom.GetComponentsInChildren <Transform>().ToList().First((s) => s.name == "O****m Meter");

            JSONStorable ometerStorable = atom.GetStorableByID(atom.GetStorableIDs().ToList().First((s) => s.Contains("OMeter")));

            intensityStorable = ometerStorable.GetFloatJSONParam("<3");
        }
Beispiel #4
0
        private void SaveStorable(JSONStorable aStorable, out JsonDict aDict)
        {
            aDict = new JsonDict();
            foreach (var param in aStorable.GetAllFloatAndColorParamNames())
            {
                var       type = aStorable.GetParamOrActionType(param);
                JSONClass json = new JSONClass();
                json["type"] = type.ToString();
                json["id"]   = param;
                JSONClass storableParams = new JSONClass();

                switch (type)
                {
                case JSONStorable.Type.Color:
                    aStorable.GetColorJSONParam(param)?.StoreJSON(storableParams);
                    break;

                case JSONStorable.Type.Float:
                    aStorable.GetFloatJSONParam(param)?.StoreJSON(storableParams);
                    break;

                case JSONStorable.Type.Bool:
                    aStorable.GetBoolJSONParam(param)?.StoreJSON(storableParams);
                    break;

                case JSONStorable.Type.String:
                    aStorable.GetStringJSONParam(param)?.StoreJSON(storableParams);
                    break;

                case JSONStorable.Type.StringChooser:
                    aStorable.GetStringChooserJSONParam(param)?.StoreJSON(storableParams);
                    break;

                default:
                    SuperController.LogError("Unhandled type: " + type.ToString());
                    break;
                }
                json["params"] = storableParams;

                aDict[param] = json;
            }
        }
Beispiel #5
0
        private void RestoreStorable(JSONStorable aStorable, JsonDict aDict, List <string> aRestoreList = null)
        {
            foreach (var kp in aDict)
            {
                JSONClass json  = kp.Value;
                string    param = kp.Key;
                if (aRestoreList != null && !aRestoreList.Contains(param))
                {
                    continue;
                }

                JSONStorable.Type type      = (JSONStorable.Type)Enum.Parse(typeof(JSONStorable.Type), json["type"].Value);
                JSONClass         paramJson = json["params"].AsObject;
                switch (type)
                {
                case JSONStorable.Type.Color:
                    aStorable.GetColorJSONParam(param)?.RestoreFromJSON(paramJson);
                    break;

                case JSONStorable.Type.Float:
                    aStorable.GetFloatJSONParam(param)?.RestoreFromJSON(paramJson);
                    break;

                case JSONStorable.Type.Bool:
                    aStorable.GetBoolJSONParam(param)?.RestoreFromJSON(paramJson);
                    break;

                case JSONStorable.Type.String:
                    aStorable.GetStringJSONParam(param)?.RestoreFromJSON(paramJson);
                    break;

                case JSONStorable.Type.StringChooser:
                    aStorable.GetStringChooserJSONParam(param)?.RestoreFromJSON(paramJson);
                    break;

                default:
                    SuperController.LogError("Unhandled type: " + type.ToString());
                    break;
                }
            }
        }