Exemple #1
0
        public Configuration(Cll.JSON.Element json)
        {
            Cll.JSON.Object config = (Cll.JSON.Object)json.Value.GetValue("configuration");
            Cll.JSON.Array  layout = (Cll.JSON.Array)config.GetValue("layouts").GetValue("layout");
            Cll.JSON.Array  groups = (Cll.JSON.Array)config.GetValue("layouts").GetValue("groups");

            Layouts          = new Layout[layout.Count];
            Groups           = new int[groups.Count];
            Bilinear         = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("3DRendering").GetValue("Bilinear")).Value);
            RenderScale      = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("3DRendering").GetValue("RenderScale")).Value);
            PixelArtUpscaler = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("Display").GetValue("PixelArtUpscaler")).Value);
            Brightness       = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("Display").GetValue("Brightness")).Value);

            if (config.Contains("arguments"))
            {
                FoldOnPause = ((Cll.JSON.Boolean)config.GetValue("arguments").GetValue("fold_on_pause")).Value;
                FoldOnResumeFadeFromBlackDuration = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("arguments").GetValue("fold_on_resume_fade_from_black_duration")).Value);
                FoldOnPauseTimeout = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("arguments").GetValue("fold_on_pause_timeout")).Value);
            }
            else
            {
                FoldOnPause = false;
                FoldOnResumeFadeFromBlackDuration = 1000;
                FoldOnPauseTimeout = 3000;
            }

            for (int i = 0; i < Layouts.Length; i++)
            {
                Layouts[i] = new Layout((Cll.JSON.Object)layout.GetValue(i));
            }

            for (int i = 0; i < Groups.Length; i++)
            {
                Groups[i] = Convert.ToInt32(((Cll.JSON.Number)groups.GetValue(i)).Value);
            }
        }
Exemple #2
0
        public Layout(Cll.JSON.Object layout)
        {
            Cll.JSON.Array screen     = (Cll.JSON.Array)layout.GetValue("screen");
            Cll.JSON.Array background = (Cll.JSON.Array)layout.GetValue("background");

            if (screen.Count < 1 || screen.Count > 4)
            {
                throw new Exception("Screens count must be greater than 0 and less than 5.");
            }

            if (background.Count != 2)
            {
                throw new Exception("Backgrounds count must be equal to 2.");
            }

            ScreenStruct[]     screens     = new ScreenStruct[screen.Count];
            BackgroundStruct[] backgrounds = new BackgroundStruct[background.Count];

            for (int i = 0; i < screens.Length; i++)
            {
                screens[i] = new ScreenStruct((Cll.JSON.Object)screen.GetValue(i));
            }

            if (screens[0].Source == "upper" && screens[0].Target == "tv")
            {
                ScreenUpperTV = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "upper" && screens[1].Target == "tv")
            {
                ScreenUpperTV = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "upper" && screens[2].Target == "tv")
            {
                ScreenUpperTV = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "upper" && screens[3].Target == "tv")
            {
                ScreenUpperTV = screens[3];
            }
            else
            {
                ScreenUpperTV = new ScreenStruct("upper", "tv", 0, 0, 0, 0);
            }

            if (screens[0].Source == "lower" && screens[0].Target == "tv")
            {
                ScreenLowerTV = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "lower" && screens[1].Target == "tv")
            {
                ScreenLowerTV = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "lower" && screens[2].Target == "tv")
            {
                ScreenLowerTV = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "lower" && screens[3].Target == "tv")
            {
                ScreenLowerTV = screens[3];
            }
            else
            {
                ScreenLowerTV = new ScreenStruct("lower", "tv", 0, 0, 0, 0);
            }

            if (screens[0].Source == "upper" && screens[0].Target == "drc")
            {
                ScreenUpperGamePad = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "upper" && screens[1].Target == "drc")
            {
                ScreenUpperGamePad = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "upper" && screens[2].Target == "drc")
            {
                ScreenUpperGamePad = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "upper" && screens[3].Target == "drc")
            {
                ScreenUpperGamePad = screens[3];
            }
            else
            {
                ScreenUpperGamePad = new ScreenStruct("upper", "drc", 0, 0, 0, 0);
            }

            if (screens[0].Source == "lower" && screens[0].Target == "drc")
            {
                ScreenLowerGamePad = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "lower" && screens[1].Target == "drc")
            {
                ScreenLowerGamePad = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "lower" && screens[2].Target == "drc")
            {
                ScreenLowerGamePad = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "lower" && screens[3].Target == "drc")
            {
                ScreenLowerGamePad = screens[3];
            }
            else
            {
                ScreenLowerGamePad = new ScreenStruct("lower", "drc", 0, 0, 0, 0);
            }

            backgrounds[0] = new BackgroundStruct((Cll.JSON.Object)background.GetValue(0));
            backgrounds[1] = new BackgroundStruct((Cll.JSON.Object)background.GetValue(1));

            if (backgrounds[0].Target == "tv")
            {
                BackgroundTV = backgrounds[0];
            }
            else if (backgrounds[1].Target == "tv")
            {
                BackgroundTV = backgrounds[1];
            }
            else
            {
                BackgroundTV = new BackgroundStruct("tv");
            }

            if (backgrounds[0].Target == "drc")
            {
                BackgroundGamePad = backgrounds[0];
            }
            else if (backgrounds[1].Target == "drc")
            {
                BackgroundGamePad = backgrounds[1];
            }
            else
            {
                BackgroundGamePad = new BackgroundStruct("drc");
            }

            if (layout.Contains("pad_rotation"))
            {
                PadRotation = Convert.ToInt32(((Cll.JSON.Number)layout.GetValue("pad_rotation")).Value);
            }
            else
            {
                PadRotation = 0;
            }
            if (layout.Contains("drc_rotation"))
            {
                DRCRotation = Convert.ToInt32(((Cll.JSON.Number)layout.GetValue("drc_rotation")).Value);
            }
            else
            {
                DRCRotation = 0;
            }
            if (layout.Contains("buttons_rotation"))
            {
                ButtonsRotation = Convert.ToInt32(((Cll.JSON.Number)layout.GetValue("buttons_rotation")).Value);
            }
            else
            {
                ButtonsRotation = 0;
            }

            if (layout.Contains("name_string_id"))
            {
                NameID = ((Cll.JSON.String)layout.GetValue("name_string_id")).Value;
            }
            else
            {
                NameID = "";
            }
            if (layout.Contains("desc_string_id"))
            {
                DescriptionID = ((Cll.JSON.String)layout.GetValue("desc_string_id")).Value;
            }
            else
            {
                DescriptionID = "";
            }

            Name        = StringLanguages.Empty;
            Description = StringLanguages.Empty;
        }