예제 #1
0
 public Cll.JSON.Value GetJSON()
 {
     Cll.JSON.Object jsonObj = new Cll.JSON.Object();
     jsonObj.AddMember("source", Source);
     jsonObj.AddMember("rotation", Rotation);
     jsonObj.AddMember("size", Size.Width.ToString() + " " + Size.Height.ToString());
     jsonObj.AddMember("target", Target);
     jsonObj.AddMember("position", Position.X.ToString() + " " + Position.Y.ToString());
     return(jsonObj);
 }
예제 #2
0
 public Cll.JSON.Value GetJSON(int index)
 {
     Cll.JSON.Object jsonObj = new Cll.JSON.Object();
     jsonObj.AddMember("position", Position.X.ToString() + " " + Position.Y.ToString());
     jsonObj.AddMember("rotation", Rotation);
     jsonObj.AddMember("resource", "//content_dir/assets/textures/" + Target + index.ToString("00") + ".png");
     jsonObj.AddMember("target", Target);
     jsonObj.AddMember("size", Size.Width.ToString() + " " + Size.Height.ToString());
     return(jsonObj);
 }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
0
        private static Cll.JSON.Object InjectFile(string inputFile, string outputPath)
        {
            string extension = Path.GetExtension(inputFile);

            Cll.JSON.Object fileJSON = new Cll.JSON.Object();

            if (extension == ".3gp" ||
                extension == ".avi" ||
                extension == ".flv" ||
                extension == ".m4v" ||
                extension == ".mkv" ||
                extension == ".mov" ||
                extension == ".mp4" ||
                extension == ".mpeg" ||
                extension == ".mpg" ||
                extension == ".ogv" ||
                extension == ".rm" ||
                extension == ".webm" ||
                extension == ".aac" ||
                extension == ".mp3" ||
                extension == ".m4a" ||
                extension == ".oga" ||
                extension == ".ogg" ||
                extension == ".wav" ||
                extension == ".wma")
            {
                Converter.EncoderResult result = Converter.Encoder(inputFile, outputPath);
                for (int i = 0; i < result.Name.Length; i++)
                {
                    fileJSON.AddMember("name", ValidName(result.Name[i]));
                    fileJSON.AddMember("filename", ValidName(ValidFilename(result.Name[i])));
                    fileJSON.AddMember("ext", result.Extension);
                    if (result.Extension == ".mp4")
                    {
                        fileJSON.AddMember("width", result.VideoInfo.Width);
                        fileJSON.AddMember("height", result.VideoInfo.Height);
                    }
                    else
                    {
                        fileJSON.AddMember("width", 0);
                        fileJSON.AddMember("height", 0);
                    }
                }
                Cll.Log.WriteLine("\"" + inputFile + "\" OK!");
            }
            else if (extension == ".jpg" ||
                     extension == ".png" ||
                     extension == ".bmp" ||
                     extension == ".gif")
            {
                string validFileName = ValidFilename(Path.GetFileNameWithoutExtension(inputFile));
                File.Copy(inputFile, Path.Combine(outputPath, validFileName + extension));
                fileJSON.AddMember("name", ValidName(Path.GetFileNameWithoutExtension(inputFile)));
                fileJSON.AddMember("filename", ValidName(validFileName));
                fileJSON.AddMember("ext", extension);
                Bitmap img = new Bitmap(inputFile);
                fileJSON.AddMember("width", img.Width);
                fileJSON.AddMember("height", img.Height);
                img.Dispose();
                Cll.Log.WriteLine("\"" + inputFile + "\" OK!");
            }
            else
            {
                Cll.Log.WriteLine("\"" + inputFile + "\" file is not supported.");
            }

            return(fileJSON);
        }
예제 #7
0
        public Cll.JSON.Value GetExtended()
        {
            Cll.JSON.Object jsonObj       = (Cll.JSON.Object)GetJSON();
            Cll.JSON.Object Strings       = new Cll.JSON.Object();
            Cll.JSON.Object Default       = new Cll.JSON.Object();
            Cll.JSON.Object Deutsch       = new Cll.JSON.Object();
            Cll.JSON.Object EnglishUSA    = new Cll.JSON.Object();
            Cll.JSON.Object EnglishEUR    = new Cll.JSON.Object();
            Cll.JSON.Object FrenchUSA     = new Cll.JSON.Object();
            Cll.JSON.Object FrenchEUR     = new Cll.JSON.Object();
            Cll.JSON.Object Italian       = new Cll.JSON.Object();
            Cll.JSON.Object Japanese      = new Cll.JSON.Object();
            Cll.JSON.Object Nederlands    = new Cll.JSON.Object();
            Cll.JSON.Object PortugueseUSA = new Cll.JSON.Object();
            Cll.JSON.Object PortugueseEUR = new Cll.JSON.Object();
            Cll.JSON.Object Russian       = new Cll.JSON.Object();
            Cll.JSON.Object SpanishUSA    = new Cll.JSON.Object();
            Cll.JSON.Object SpanishEUR    = new Cll.JSON.Object();

            foreach (Layout layout in Layouts)
            {
                Default.AddMember(layout.NameID, layout.Name.Default != null ? layout.Name.Default : "");
                Default.AddMember(layout.DescriptionID, layout.Description.Default != null ? layout.Description.Default : "");
                Deutsch.AddMember(layout.NameID, layout.Name.Deutsch != null ? layout.Name.Deutsch : "");
                Deutsch.AddMember(layout.DescriptionID, layout.Description.Deutsch != null ? layout.Description.Deutsch : "");
                EnglishUSA.AddMember(layout.NameID, layout.Name.EnglishUSA != null ? layout.Name.EnglishUSA : "");
                EnglishUSA.AddMember(layout.DescriptionID, layout.Description.EnglishUSA != null ? layout.Description.EnglishUSA : "");
                EnglishEUR.AddMember(layout.NameID, layout.Name.EnglishEUR != null ? layout.Name.EnglishEUR : "");
                EnglishEUR.AddMember(layout.DescriptionID, layout.Description.EnglishEUR != null ? layout.Description.EnglishEUR : "");
                FrenchUSA.AddMember(layout.NameID, layout.Name.FrenchUSA != null ? layout.Name.FrenchUSA : "");
                FrenchUSA.AddMember(layout.DescriptionID, layout.Description.FrenchUSA != null ? layout.Description.FrenchUSA : "");
                FrenchEUR.AddMember(layout.NameID, layout.Name.FrenchEUR != null ? layout.Name.FrenchEUR : "");
                FrenchEUR.AddMember(layout.DescriptionID, layout.Description.FrenchEUR != null ? layout.Description.FrenchEUR : "");
                Italian.AddMember(layout.NameID, layout.Name.Italian != null ? layout.Name.Italian : "");
                Italian.AddMember(layout.DescriptionID, layout.Description.Italian != null ? layout.Description.Italian : "");
                Japanese.AddMember(layout.NameID, layout.Name.Japanese != null ? layout.Name.Japanese : "");
                Japanese.AddMember(layout.DescriptionID, layout.Description.Japanese != null ? layout.Description.Japanese : "");
                Nederlands.AddMember(layout.NameID, layout.Name.Nederlands != null ? layout.Name.Nederlands : "");
                Nederlands.AddMember(layout.DescriptionID, layout.Description.Nederlands != null ? layout.Description.Nederlands : "");
                PortugueseUSA.AddMember(layout.NameID, layout.Name.PortugueseUSA != null ? layout.Name.PortugueseUSA : "");
                PortugueseUSA.AddMember(layout.DescriptionID, layout.Description.PortugueseUSA != null ? layout.Description.PortugueseUSA : "");
                PortugueseEUR.AddMember(layout.NameID, layout.Name.PortugueseEUR != null ? layout.Name.PortugueseEUR : "");
                PortugueseEUR.AddMember(layout.DescriptionID, layout.Description.PortugueseEUR != null ? layout.Description.PortugueseEUR : "");
                Russian.AddMember(layout.NameID, layout.Name.Russian != null ? layout.Name.Russian : "");
                Russian.AddMember(layout.DescriptionID, layout.Description.Russian != null ? layout.Description.Russian : "");
                SpanishUSA.AddMember(layout.NameID, layout.Name.SpanishUSA != null ? layout.Name.SpanishUSA : "");
                SpanishUSA.AddMember(layout.DescriptionID, layout.Description.SpanishUSA != null ? layout.Description.SpanishUSA : "");
                SpanishEUR.AddMember(layout.NameID, layout.Name.SpanishEUR != null ? layout.Name.SpanishEUR : "");
                SpanishEUR.AddMember(layout.DescriptionID, layout.Description.SpanishEUR != null ? layout.Description.SpanishEUR : "");
            }

            Strings.AddMember("Default", Default);
            Strings.AddMember("Deutsch", Deutsch);
            Strings.AddMember("EnglishUSA", EnglishUSA);
            Strings.AddMember("EnglishEUR", EnglishEUR);
            Strings.AddMember("FrenchUSA", FrenchUSA);
            Strings.AddMember("FrenchEUR", FrenchEUR);
            Strings.AddMember("Italian", Italian);
            Strings.AddMember("Japanese", Japanese);
            Strings.AddMember("Nederlands", Nederlands);
            Strings.AddMember("PortugueseUSA", PortugueseUSA);
            Strings.AddMember("PortugueseEUR", PortugueseEUR);
            Strings.AddMember("Russian", Russian);
            Strings.AddMember("SpanishUSA", SpanishUSA);
            Strings.AddMember("SpanishEUR", SpanishEUR);

            jsonObj.AddMember("strings", Strings);

            return(jsonObj);
        }