Exemple #1
0
        public static void Initialize()
        {
            var entryDirectory = GetEntryDirectory() + "\\";

            // スクリプト読み込み
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/import");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/export");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/command");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/selected");

            Script.Compiler.Initialize();

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/command", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.CommandScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.CommandScript>(file, out script, out error))
                        {
                            CommandScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/selected", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.SelectedScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.SelectedScript>(file, out script, out error))
                        {
                            SelectedScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/export", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.ExportScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.ExportScript>(file, out script, out error))
                        {
                            ExportScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/import", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.ImportScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.ImportScript>(file, out script, out error))
                        {
                            ImportScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            LoadOption();
        }
Exemple #2
0
        static void Exec(bool gui, string input, string output, string export, string format, float magnification, bool materialCache)
        {
            // Register UI
            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.LanguageSelector), () => { return(new GUI.Component.LanguageSelector()); });

            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.ProcedualModelReference), () => {
                return(new GUI.Component.ObjectReference <Data.ProcedualModelParameter>(Core.ProcedualModel.ProcedualModels));
            });

            // Debug
            bool isDebugMode = false;

#if DEBUG
            isDebugMode = true;
#endif
            if (System.IO.File.Exists(Path.Combine(EntryDirectory, "debug.txt")) || isDebugMode)
            {
                swig.Native.SetFileLogger(Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.log.txt"));
                Utils.Logger.LogPath = Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.Managed.log.txt");
            }

            LanguageTable.LoadTable(Path.Combine(EntryDirectory, "resources/languages/languages.txt"));

            var    systemLanguage = EfkN.GetSystemLanguage();
            string language       = null;

            if (systemLanguage != swig.SystemLanguage.Unknown)
            {
                if (systemLanguage == swig.SystemLanguage.Japanese)
                {
                    language = "ja";
                }
                else if (systemLanguage == swig.SystemLanguage.English)
                {
                    language = "en";
                }
            }
            else
            {
                language = "en";
            }

            Core.OnOutputMessage += new Action <string>(Core_OnOutputMessage);
            Core.Initialize(language);

            if (gui)
            {
                ChangeLanguage();
                LanguageTable.OnLanguageChanged += (o, e) => { ChangeLanguage(); };

                // Failed to compile script
                if (Core.ExportScripts.Count == 0)
                {
                    Script.ExportScript efkpkgExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportEfkPkg.UniqueName,
                        Plugin.ExportEfkPkg.Author,
                        Plugin.ExportEfkPkg.Title,
                        Plugin.ExportEfkPkg.Description,
                        Plugin.ExportEfkPkg.Filter,
                        Plugin.ExportEfkPkg.Call);
                    Core.ExportScripts.Add(efkpkgExporter);

                    Script.ExportScript defaultExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportDefault.UniqueName,
                        Plugin.ExportDefault.Author,
                        Plugin.ExportDefault.Title,
                        Plugin.ExportDefault.Description,
                        Plugin.ExportDefault.Filter,
                        Plugin.ExportDefault.Call);
                    Core.ExportScripts.Add(defaultExporter);

                    Script.ImportScript efkpkgImporter = new Script.ImportScript(
                        Script.ScriptPosition.External,
                        Plugin.ImportEfkPkg.UniqueName,
                        Plugin.ImportEfkPkg.Author,
                        Plugin.ImportEfkPkg.Title,
                        Plugin.ImportEfkPkg.Description,
                        Plugin.ImportEfkPkg.Filter,
                        Plugin.ImportEfkPkg.Call);
                    Core.ImportScripts.Add(efkpkgImporter);
                }

                System.OperatingSystem os         = System.Environment.OSVersion;
                swig.DeviceType        deviceType = swig.DeviceType.DirectX11;

                if (!(os.Platform == PlatformID.Win32NT ||
                      os.Platform == PlatformID.Win32S ||
                      os.Platform == PlatformID.Win32Windows ||
                      os.Platform == PlatformID.WinCE))
                {
                    deviceType = swig.DeviceType.OpenGL;
                }

                if (!GUI.Manager.Initialize(960, 540, deviceType))
                {
                    return;
                }
            }

            try
            {
                if (input != string.Empty)
                {
                    Core.LoadFrom(input);
                }

                if (output != string.Empty)
                {
                    Core.SaveTo(output);
                }

                if (export != string.Empty)
                {
                    if (magnification == 0.0f)
                    {
                        magnification = Core.Option.Magnification;
                    }

                    if (format == "gltf")
                    {
                        var option = new Effekseer.Exporter.glTFExporterOption();
                        option.Scale = magnification;
                        var exporter = new Effekseer.Exporter.glTFExporter();
                        exporter.Export(export, option);
                    }
                    else if (format == "glb")
                    {
                        var option = new Effekseer.Exporter.glTFExporterOption();
                        option.Scale  = magnification;
                        option.Format = Exporter.glTFExporterFormat.glb;
                        var exporter = new Effekseer.Exporter.glTFExporter();
                        exporter.Export(export, option);
                    }
                    else
                    {
                        var binaryExporter = new Binary.Exporter();
                        var binary         = binaryExporter.Export(Core.Root, magnification);
                        System.IO.File.WriteAllBytes(export, binary);
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.Message);
            }

            try
            {
                if (materialCache)
                {
                    IO.MaterialCacheGenerator.GenerateMaterialCaches();
                }
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.Message);
            }

            if (gui)
            {
                while (GUI.Manager.NativeManager.DoEvents())
                {
                    GUI.Manager.Update();
                }

                GUI.Manager.Terminate();
                Process.MaterialEditor.Terminate();
            }

            Core.Dispose();
        }
Exemple #3
0
        public bool Initialize(bool gui)
        {
            // Setup Special Paths
            {
                try
                {
                    StartDirectory = System.IO.Directory.GetCurrentDirectory();
                    EntryDirectory = GUI.Manager.GetEntryDirectory();
                }
                catch (Exception e)
                {
                    ExportError(e);
                    return(false);
                }

                Name = Path.GetFileNameWithoutExtension(System.AppDomain.CurrentDomain.FriendlyName);
            }



            // Register UI
            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.LanguageSelector), () => { return(new GUI.Component.LanguageSelector()); });

            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.ProceduralModelReference), () => {
                return(new GUI.Component.ObjectReference <Data.ProceduralModelParameter>(Core.ProceduralModel.ProceduralModels));
            });

            // Debug
            bool isDebugMode = false;

#if DEBUG
            isDebugMode = true;
#endif
            if (System.IO.File.Exists(Path.Combine(EntryDirectory, "debug.txt")) || isDebugMode)
            {
                swig.Native.SetFileLogger(Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.log.txt"));
                Utils.Logger.LogPath = Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.Managed.log.txt");
            }

            LanguageTable.CreateTableFromDirectory(EntryDirectory);

            var    systemLanguage = EfkN.GetSystemLanguage();
            string language       = null;

            if (systemLanguage != swig.SystemLanguage.Unknown)
            {
                if (systemLanguage == swig.SystemLanguage.Japanese)
                {
                    language = "ja";
                }
                else if (systemLanguage == swig.SystemLanguage.English)
                {
                    language = "en";
                }
            }
            else
            {
                language = "en";
            }

            Core.OnOutputMessage += new Action <string>(Core_OnOutputMessage);
            Core.Initialize(language);

            if (gui)
            {
                ChangeLanguage();
                LanguageTable.OnLanguageChanged += (o, e) => { ChangeLanguage(); };

                // Failed to compile script
                if (Core.ExportScripts.Count == 0)
                {
                    Script.ExportScript efkpkgExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportEfkPkg.UniqueName,
                        Plugin.ExportEfkPkg.Author,
                        Plugin.ExportEfkPkg.Title,
                        Plugin.ExportEfkPkg.Description,
                        Plugin.ExportEfkPkg.Filter,
                        Plugin.ExportEfkPkg.Call);
                    Core.ExportScripts.Add(efkpkgExporter);

                    Script.ExportScript defaultExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportDefault.UniqueName,
                        Plugin.ExportDefault.Author,
                        Plugin.ExportDefault.Title,
                        Plugin.ExportDefault.Description,
                        Plugin.ExportDefault.Filter,
                        Plugin.ExportDefault.Call);
                    Core.ExportScripts.Add(defaultExporter);

                    Script.ImportScript efkpkgImporter = new Script.ImportScript(
                        Script.ScriptPosition.External,
                        Plugin.ImportEfkPkg.UniqueName,
                        Plugin.ImportEfkPkg.Author,
                        Plugin.ImportEfkPkg.Title,
                        Plugin.ImportEfkPkg.Description,
                        Plugin.ImportEfkPkg.Filter,
                        Plugin.ImportEfkPkg.Call);
                    Core.ImportScripts.Add(efkpkgImporter);
                }

                OnInitialize();
            }

            return(true);
        }
Exemple #4
0
        static void InitializeScripts(string entryDirectory)
        {
#if SCRIPT_ENABLED
            // Load scripts
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/import");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/export");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/command");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/selected");

            Script.Compiler.Initialize();

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/command", "*.*", System.IO.SearchOption.AllDirectories);

                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.CommandScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.CommandScript>(file, out script, out error))
                        {
                            CommandScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/selected", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.SelectedScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.SelectedScript>(file, out script, out error))
                        {
                            SelectedScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/export", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.ExportScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.ExportScript>(file, out script, out error))
                        {
                            ExportScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }

                        Console.WriteLine(error);
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/import", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.ImportScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.ImportScript>(file, out script, out error))
                        {
                            ImportScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }
#endif
        }
Exemple #5
0
        public static void Initialize(Language?language = null)
        {
            var entryDirectory = GetEntryDirectory() + "/";

            Command.CommandManager.Changed += new EventHandler(CommandManager_Changed);
            FullPath = string.Empty;

            option = LoadOption(language);

            // Switch the language according to the loaded settings
            Language = Option.GuiLanguage;

            // Switch the culture according to the set language
            switch (Language)
            {
            case Effekseer.Language.English:
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
                break;

            case Effekseer.Language.Japanese:
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja-JP");
                break;
            }

            New();

            // Load scripts
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/import");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/export");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/command");
            System.IO.Directory.CreateDirectory(entryDirectory + "scripts/selected");

            Script.Compiler.Initialize();

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/command", "*.*", System.IO.SearchOption.AllDirectories);

                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.CommandScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.CommandScript>(file, out script, out error))
                        {
                            CommandScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/selected", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.SelectedScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.SelectedScript>(file, out script, out error))
                        {
                            SelectedScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/export", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.ExportScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.ExportScript>(file, out script, out error))
                        {
                            ExportScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }

                        Console.WriteLine(error);
                    }
                }
            }

            {
                var files = System.IO.Directory.GetFiles(entryDirectory + "scripts/import", "*.*", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    var ext = System.IO.Path.GetExtension(file);
                    if (ext == ".cs" || ext == ".py")
                    {
                        Script.ImportScript script = null;
                        string error = string.Empty;

                        if (Script.Compiler.CompileScript <Script.ImportScript>(file, out script, out error))
                        {
                            ImportScripts.Add(script);
                        }
                        else
                        {
                            if (OnOutputMessage != null)
                            {
                                OnOutputMessage(error);
                            }
                        }
                    }
                }
            }
        }