示例#1
0
        public Layout(int id, int padRotation = 0, int drcRotation = 0, int buttonsRotation = 0)
        {
            if (id <= 0)
            {
                throw new ArgumentException("ID must be greater than zero.");
            }

            PadRotation     = padRotation;
            DRCRotation     = drcRotation;
            ButtonsRotation = buttonsRotation;

            NameID        = "VCM_LAYOUT_" + id.ToString() + "_NAME";
            DescriptionID = "VCM_LAYOUT_" + id.ToString() + "_EXPLANATION";

            Name        = StringLanguages.Empty;
            Description = StringLanguages.Empty;
        }
示例#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;
        }