static Core() { Command.CommandManager.Changed += new EventHandler(CommandManager_Changed); FullPath = string.Empty; option = LoadOption(); // 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(); CommandScripts = new Script.ScriptCollection <Script.CommandScript>(); SelectedScripts = new Script.ScriptCollection <Script.SelectedScript>(); ExportScripts = new Script.ScriptCollection <Script.ExportScript>(); ImportScripts = new Script.ScriptCollection <Script.ImportScript>(); }
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 Language.English: Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); break; case Language.Japanese: Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja-JP"); break; } New(); if (!DoExecuteWithMLBundle()) { InitializeScripts(entryDirectory); } }
static Core() { Command.CommandManager.Changed += new EventHandler(CommandManager_Changed); FullPath = string.Empty; option = LoadOption(); Language = Option.GuiLanguage; // 読み込んだ設定により Core の言語を設定する // 設定された言語によりカルチャーを切り替えます 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(); CommandScripts = new Script.ScriptCollection <Script.CommandScript>(); SelectedScripts = new Script.ScriptCollection <Script.SelectedScript>(); ExportScripts = new Script.ScriptCollection <Script.ExportScript>(); ImportScripts = new Script.ScriptCollection <Script.ImportScript>(); }
/// <summary> /// Load option parameters from config.option.xml /// If it failed, return default values. /// </summary> /// <param name="defaultLanguage"></param> /// <returns></returns> static public Data.OptionValues LoadOption(Language?defaultLanguage) { Data.OptionValues res = new Data.OptionValues(); postEffect = new Data.PostEffectValues(); var path = System.IO.Path.Combine(GetEntryDirectory(), OptionFilePath); if (!System.IO.File.Exists(path)) { if (defaultLanguage != null) { res.GuiLanguage.SetValueDirectly((Language)defaultLanguage.Value); } return(res); } var doc = new System.Xml.XmlDocument(); doc.Load(path); if (doc.ChildNodes.Count != 2) { return(res); } if (doc.ChildNodes[1].Name != "EffekseerProject") { return(res); } var optionElement = doc["EffekseerProject"]["Option"]; if (optionElement != null) { var o = res as object; Data.IO.LoadObjectFromElement(optionElement as System.Xml.XmlElement, ref o, false); } var postEffectElement = doc["EffekseerProject"]["PostEffect"]; if (postEffectElement != null) { var o = postEffect as object; Data.IO.LoadObjectFromElement(postEffectElement as System.Xml.XmlElement, ref o, false); } var recordingElement = doc["EffekseerProject"]["Recording"]; if (recordingElement != null) { var o = recording as object; Data.IO.LoadObjectFromElement(recordingElement as System.Xml.XmlElement, ref o, false); } IsChanged = false; return(res); }
// config.option.xml から読み込み // 読み込み失敗したら、OptionValues のデフォ設定を返します static public Data.OptionValues LoadOption() { Data.OptionValues res = new Data.OptionValues(); var path = System.IO.Path.Combine(GetEntryDirectory(), OptionFilePath); if (!System.IO.File.Exists(path)) { return(res); } var doc = new System.Xml.XmlDocument(); doc.Load(path); if (doc.ChildNodes.Count != 2) { return(res); } if (doc.ChildNodes[1].Name != "EffekseerProject") { return(res); } var optionElement = doc["EffekseerProject"]["Option"]; if (optionElement != null) { var o = res as object; Data.IO.LoadObjectFromElement(optionElement as System.Xml.XmlElement, ref o, false); } IsChanged = false; return(res); }
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); } } } } } }