Esempio n. 1
0
        public Cll.JSON.Value GetJSON(int index)
        {
            Cll.JSON.Object jsonObj          = new Cll.JSON.Object();
            Cll.JSON.Array  arrayScreens     = new Cll.JSON.Array();
            Cll.JSON.Array  arrayBackgrounds = new Cll.JSON.Array();

            if (ScreenUpperTV.Size.Width > 0 && ScreenUpperTV.Size.Height > 0)
            {
                arrayScreens.AddValue(ScreenUpperTV.GetJSON());
            }
            if (ScreenLowerTV.Size.Width > 0 && ScreenLowerTV.Size.Height > 0)
            {
                arrayScreens.AddValue(ScreenLowerTV.GetJSON());
            }
            if (ScreenUpperGamePad.Size.Width > 0 && ScreenUpperGamePad.Size.Height > 0)
            {
                arrayScreens.AddValue(ScreenUpperGamePad.GetJSON());
            }
            if (ScreenLowerGamePad.Size.Width > 0 && ScreenLowerGamePad.Size.Height > 0)
            {
                arrayScreens.AddValue(ScreenLowerGamePad.GetJSON());
            }

            if (arrayScreens.Count == 0)
            {
                throw new Exception("There must be at least one screen.");
            }

            arrayBackgrounds.AddValue(BackgroundTV.GetJSON(index));
            arrayBackgrounds.AddValue(BackgroundGamePad.GetJSON(index));

            jsonObj.AddMember("pad_rotation", PadRotation);
            jsonObj.AddMember("drc_rotation", DRCRotation);
            jsonObj.AddMember("screen", arrayScreens);
            jsonObj.AddMember("name_string_id", NameID);
            jsonObj.AddMember("background", arrayBackgrounds);
            jsonObj.AddMember("buttons_rotation", ButtonsRotation);
            jsonObj.AddMember("desc_string_id", DescriptionID);

            return(jsonObj);
        }
Esempio n. 2
0
        public static Cll.JSON.Object InjectFolder(string inputPath, string outputPath)
        {
            string[] folders = Directory.GetDirectories(inputPath);
            string[] files   = Directory.GetFiles(inputPath);

            string validFolderName = ValidFilename(Path.GetFileName(inputPath));
            string output          = Path.Combine(outputPath, validFolderName);

            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            NumericComparer numericComparer = new NumericComparer();

            Array.Sort(folders, numericComparer.Compare);
            Array.Sort(files, numericComparer.Compare);

            Cll.JSON.Object folderJSON = new Cll.JSON.Object();
            folderJSON.AddMember("name", ValidName(Path.GetFileName(inputPath)));
            folderJSON.AddMember("foldername", ValidName(validFolderName));

            Cll.JSON.Array foldersArray = new Cll.JSON.Array();
            foreach (string folder in folders)
            {
                foldersArray.AddValue(InjectFolder(folder, output));
            }

            Cll.JSON.Array filesArray = new Cll.JSON.Array();
            foreach (string file in files)
            {
                try
                {
                    Cll.JSON.Object fileJSON = InjectFile(file, output);
                    if (fileJSON.Count != 0)
                    {
                        filesArray.AddValue(fileJSON);
                    }
                }
                catch (Exception e)
                {
                    Cll.Log.WriteLine(e.ToString());
                }
            }

            folderJSON.AddMember("folders", foldersArray);
            folderJSON.AddMember("files", filesArray);

            return(folderJSON);
        }
Esempio n. 3
0
        public Cll.JSON.Value GetJSON()
        {
            Cll.JSON.Object jsonObj           = new Cll.JSON.Object();
            Cll.JSON.Object jsonConfiguration = new Cll.JSON.Object();
            Cll.JSON.Object jsonLayouts       = new Cll.JSON.Object();
            Cll.JSON.Array  arrayLayout       = new Cll.JSON.Array();
            Cll.JSON.Array  arrayGroups       = new Cll.JSON.Array();
            Cll.JSON.Object json3DRendering   = new Cll.JSON.Object();
            Cll.JSON.Object jsonDisplay       = new Cll.JSON.Object();
            Cll.JSON.Object jsonArguments     = new Cll.JSON.Object();

            for (int i = 0; i < Layouts.Length; i++)
            {
                arrayLayout.AddValue(Layouts[i].GetJSON(i + 1));
            }

            for (int i = 0; i < Groups.Length; i++)
            {
                arrayGroups.AddValue(Groups[i]);
            }

            jsonLayouts.AddMember("layout", arrayLayout);
            jsonLayouts.AddMember("groups", arrayGroups);
            json3DRendering.AddMember("Bilinear", Bilinear);
            json3DRendering.AddMember("RenderScale", RenderScale);
            jsonDisplay.AddMember("PixelArtUpscaler", PixelArtUpscaler);
            jsonDisplay.AddMember("Brightness", Brightness);
            jsonArguments.AddMember("fold_on_pause", FoldOnPause);
            jsonArguments.AddMember("fold_on_resume_fade_from_black_duration", FoldOnResumeFadeFromBlackDuration);
            jsonArguments.AddMember("fold_on_pause_timeout", FoldOnPauseTimeout);

            jsonConfiguration.AddMember("layouts", jsonLayouts);
            jsonConfiguration.AddMember("3DRendering", json3DRendering);
            jsonConfiguration.AddMember("Display", jsonDisplay);
            jsonConfiguration.AddMember("arguments", jsonArguments);

            jsonObj.AddMember("configuration", jsonConfiguration);

            return(jsonObj);
        }