Example #1
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;
            }
        }