Ejemplo n.º 1
0
 public override string CallFunction(Compiler.File function)
 {
     return("function " + Compiler.Project + "/" + function.name);
 }
Ejemplo n.º 2
0
        public void ExportFiles(string path)
        {
            List <Compiler.File> files = new List <Compiler.File>();

            foreach (string f in code.Keys)
            {
                files.Add(new Compiler.File(f, code[f].Replace('\t' + "", "")));
            }
            string rpdir = Path.GetDirectoryName(projectPath) + "/resourcespack";

            if (Directory.Exists(rpdir))
            {
                foreach (var file in Directory.GetFiles(rpdir, "*.bps", SearchOption.AllDirectories))
                {
                    var f = new Compiler.File(file, File.ReadAllText(file).Replace('\t' + "", ""));
                    f.resourcespack = true;
                    files.Add(f);
                }
            }

            List <Compiler.File> resourcesfiles = new List <Compiler.File>();

            foreach (string f in resources.Keys)
            {
                resourcesfiles.Add(new Compiler.File(f, resources[f].Replace('\t' + "", "")));
            }

            CompilerCore core;

            if (project.compilationSetting.CompilerCoreName == "java")
            {
                core = new CompilerCoreJava();
            }
            else if (project.compilationSetting.CompilerCoreName == "bedrock")
            {
                core = new CompilerCoreBedrock();
            }
            else
            {
                throw new Exception("Unknown Compiler Core");
            }

            List <Compiler.File> cFiles = Compiler.compile(core, project.projectName, files, resourcesfiles,
                                                           Debug, project.compilationSetting, project.version,
                                                           Path.GetDirectoryName(projectPath));

            foreach (Compiler.File f in cFiles)
            {
                string fileName;
                if (f.type == "json" && f.name.Contains("json"))
                {
                    fileName = path + "/data/" + project.projectName.ToLower() + "/" + f.name;
                }
                else if (f.type == "json" && !f.name.Contains("json"))
                {
                    fileName = path + "/data/" + project.projectName.ToLower() + "/" + f.name + ".json";
                }
                else
                {
                    fileName = path + "/data/" + project.projectName.ToLower() + "/functions/" + f.name + ".mcfunction";
                }
                try
                {
                    SafeWriteFile(fileName, f.content);
                }
                catch (Exception e)
                {
                    throw new Exception(fileName + " " + e.ToString());
                }
            }

            if (Directory.Exists(rpdir))
            {
                string rpPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/tmp_rp";
                if (Directory.Exists(rpPath))
                {
                    Directory.Delete(rpPath, true);
                    Directory.CreateDirectory(rpPath);
                }
                else
                {
                    Directory.CreateDirectory(rpPath);
                }

                foreach (Compiler.File f in Compiler.resourcespackFiles)
                {
                    string fileName = rpPath + "/" + f.name + ".json";
                    try
                    {
                        SafeWriteFile(fileName, f.content);
                    }
                    catch (Exception e)
                    {
                        throw new Exception(fileName + " " + e.ToString());
                    }
                }
                foreach (var file in Directory.GetFiles(path + "imported_rp", "*.*", SearchOption.AllDirectories))
                {
                    if (!file.EndsWith(".bps"))
                    {
                        string fileName = file.Replace(path.Replace("\\", "/") + "imported_rp/", rpPath);
                        SafeCopy(file, fileName);
                    }
                }
                foreach (var file in Directory.GetFiles(rpdir, "*.*", SearchOption.AllDirectories))
                {
                    if (!file.EndsWith(".bps"))
                    {
                        string fileName = file.Replace(rpdir, rpPath);
                        SafeCopy(file, fileName);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public abstract string CallFunction(Compiler.File function);