Exemplo n.º 1
0
        //Functions for creation.
        public static WebPebbleProject CreateProject(string name, string authorName, string authorId, bool isWatchface, string sdk_version)
        {
            //First, generate an ID to use.
            var    collect = Program.database.GetCollection <WebPebbleProject>("projects");
            string id      = LibRpws.LibRpwsCore.GenerateRandomHexString(16);

            while (collect.Find(x => x.projectId == id).ToArray().Length != 0)
            {
                id = LibRpws.LibRpwsCore.GenerateRandomHexString(16);
            }
            //Now that we have a unique ID, create the files for it.
            PebbleProject.PebbleProject proj = PebbleProject.PebbleProject.CreateProjectFiles(id, name, authorName, isWatchface, sdk_version);
            //Now, create the object and save it to the database.
            WebPebbleProject wpp = new WebPebbleProject
            {
                authorId  = authorId,
                projectId = id,
                name      = name
            };

            wpp._id = collect.Insert(wpp);
            //Now, add the asset.
            wpp.AddAsset("main.c", AssetType.src, InnerAssetType.c, "main.c", File.ReadAllBytes(Program.config.media_dir + "Templates/main.c"));
            //Return the end product.
            return(wpp);
        }
Exemplo n.º 2
0
        /* CREATION FUNCTIONS */
        public static PebbleProject CreateProjectFiles(string id, string name, string author, bool isWatchface, string sdk_version)
        {
            //First, run the command to generate the files.
            LinuxInterface.ExecuteCommand("pebble new-project " + id, Program.config.user_project_dir);
            //Now, load the project from the files.
            PebbleProject proj = new PebbleProject(id);

            //Now, edit the package config file to apply the params offered.
            proj.package.name                      = name;
            proj.package.author                    = author;
            proj.package.pebble.companyName        = author;
            proj.package.pebble.shortName          = name;
            proj.package.pebble.displayName        = name;
            proj.package.pebble.longName           = name;
            proj.package.pebble.enableMultiJS      = true;
            proj.package.pebble.projectType        = "native";
            proj.package.pebble.watchapp.watchface = isWatchface;
            proj.package.pebble.sdkVersion         = sdk_version;
            proj.package.pebble.resources          = new Resources();
            proj.package.pebble.resources.media    = new List <Medium>();
            //Rename the main.c.
            try
            {
                File.Move(proj.pathnane + "src/c/" + id + ".c", proj.pathnane + "src/c/main.c");
            } catch
            {
            }
            //Save it
            proj.SavePackage();

            return(proj);
        }