Exemple #1
0
        /// <summary>
        /// Create a new project with given settings.
        /// </summary>
        /// <param name="options">Project creation option</param>
        /// <param name="environment">Creating environment</param>
        /// <returns>Whether if the creation is succeed</returns>
        public static bool CreateProject(CreationOptions options, EnvironmentSetting environment)
        {
            if (!_SanityCheck(options, environment))
            {
                return(false);
            }

            CreationContext ctx = new CreationContext();

            ctx.InitializeGeneratingValues();

            CreationVariables variables = new CreationVariables(options, ctx);
            FilterProcessor   filter    = new FilterProcessor(variables);

            TemplateList templateListData = TemplateList.ReadFile(Path.Combine(environment.templatePath, "Template.txt"), filter);

            if (templateListData == null)
            {
                Console.Error.WriteLine("  [E] Cannot read template index data.");
                return(false);
            }

            if (!_DoCopyWorks(templateListData, filter, options, environment))
            {
                Console.Error.WriteLine("  [E] Copy process failed!!");
                return(false);
            }

            return(true);
        }
Exemple #2
0
        private static bool _SanityCheck(CreationOptions options, EnvironmentSetting environment)
        {
            if (options == null || environment == null)
            {
                return(false);
            }

            return(true);
        }
        private void _InitializeVariables(CreationOptions options, CreationContext ctx)
        {
            m_variableTable = new Dictionary <string, string>();

            // Token
            m_variableTable.Add("${{", "${{");

            m_variableTable.Add("ProgramName".ToUpper(), options.programName);
            m_variableTable.Add("ProgramName-Lower".ToUpper(), options.programName.ToLower());
            m_variableTable.Add("ProgramName-Upper".ToUpper(), options.programName.ToUpper());

            m_variableTable.Add("GameTitle".ToUpper(), options.gameTitle);

            m_variableTable.Add("AppIdentifier".ToUpper(), options.appIdentifier);

            switch (options.appOrientation)
            {
            case CreationOptions.AppOrientationType.kLandscape:
            {
                m_variableTable.Add("Orientation-IsLandscapeCppBool".ToUpper(), "true");
                m_variableTable.Add("Orientation-Android".ToUpper(), "userLandscape");
                m_variableTable.Add("Orientation-iOS".ToUpper(), "\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\r\n\t\t<string>UIInterfaceOrientationLandscapeRight</string>");
                m_variableTable.Add("Resolution-WinPC".ToUpper(), "\t\tscreenWidth = 1280;\r\n\t\tscreenHeight = 720;");
            }
            break;

            case CreationOptions.AppOrientationType.kPortrait:
            {
                m_variableTable.Add("Orientation-IsLandscapeCppBool".ToUpper(), "false");
                m_variableTable.Add("Orientation-Android".ToUpper(), "userPortrait");
                m_variableTable.Add("Orientation-iOS".ToUpper(), "\t\t<string>UIInterfaceOrientationPortrait</string>\r\n\t\t<string>UIInterfaceOrientationPortraitUpsideDown</string>");
                m_variableTable.Add("Resolution-WinPC".ToUpper(), "\t\tscreenWidth = 540;\r\n\t\tscreenHeight = 960;");
            }
            break;
            }

            m_variableTable.Add("GUID-Solution".ToUpper(), ctx.guid_solution);
            m_variableTable.Add("GUID-GameProject".ToUpper(), ctx.guid_gameProject);
            m_variableTable.Add("GUID-AppAndroid".ToUpper(), ctx.guid_appAndroid);
            m_variableTable.Add("GUID-AppWinPC".ToUpper(), ctx.guid_appWinPC);
        }
 internal CreationVariables(CreationOptions options, CreationContext ctx)
 {
     _InitializeVariables(options, ctx);
 }
Exemple #5
0
        private static bool _DoCopyWorks(TemplateList templateListData, FilterProcessor filter, CreationOptions options, EnvironmentSetting environment)
        {
            // Create Project Directory
            string projectRoot = Path.Combine(environment.engineRootPath, options.projectDirctoryName);

            try
            {
                Directory.CreateDirectory(projectRoot);
            }
            catch
            {
                Console.Error.WriteLine("  [E] Cannot create project directory.");
                return(false);
            }

            string templateProjectPath = Path.Combine(environment.templatePath, "Project");

            if (!Directory.Exists(templateProjectPath))
            {
                Console.Error.WriteLine("  [E] Template project data not exists.");
            }

            templateListData.mainWorkSet.DoCopyWorks(templateProjectPath, projectRoot, filter);

            switch (options.creatingScene)
            {
            case CreationOptions.SceneGenerationType.kNone:
            {
                const string kNoneSceneGameSectionName = "None";
                if (templateListData.conditionalWorkSets.ContainsKey(kNoneSceneGameSectionName))
                {
                    templateListData.conditionalWorkSets[kNoneSceneGameSectionName].DoCopyWorks(templateProjectPath, projectRoot, filter);
                }
            }
            break;

            case CreationOptions.SceneGenerationType.kEmptyScene:
            {
                const string kEmptySceneGameSectionName = "EmptyScene";
                if (templateListData.conditionalWorkSets.ContainsKey(kEmptySceneGameSectionName))
                {
                    templateListData.conditionalWorkSets[kEmptySceneGameSectionName].DoCopyWorks(templateProjectPath, projectRoot, filter);
                }
            }
            break;

            case CreationOptions.SceneGenerationType.kUIBaseScene:
            {
                const string kUIBaseSceneGameSectionName = "UIBaseScene";
                if (templateListData.conditionalWorkSets.ContainsKey(kUIBaseSceneGameSectionName))
                {
                    templateListData.conditionalWorkSets[kUIBaseSceneGameSectionName].DoCopyWorks(templateProjectPath, projectRoot, filter);
                }
            }
            break;
            }

            return(true);
        }