public Plugin() { Instance = this; Config = new Configuration(Configuration.SettingXmlFilePath); PythonExecutor = new PythonExecutor(); try { Config.Load(); InitIronPython(); } catch (Exception e) { using (StreamWriter sw = new StreamWriter("lastest.log", false, Encoding.UTF8)) { try { sw.WriteLine(PythonExecutor.FormatException(e)); } catch { } sw.WriteLine(e); } } var assembly = Assembly.GetExecutingAssembly(); var stream = assembly.GetManifestResourceStream("CurtainFireMakerPlugin.Resources.icon.ico"); Image = Image.FromStream(stream); }
private void RunScript(string path, ProgressForm form, Action finalize) { var world = new World(this, Path.GetFileNameWithoutExtension(Config.ScriptPath)); world.InitPre(); bool dropFlag = false; try { long time = Environment.TickCount; PythonExecutor.SetGlobalVariable(new Dictionary <string, object> { { "WORLD", world } }); PythonExecutor.ExecuteScriptOnNewScope(path); form.Progress.Minimum = 0; form.Progress.Maximum = world.MaxFrame; form.Progress.Step = 1; world.InitPost(); for (int i = 0; i < world.MaxFrame; i++) { world.Frame(); form.Progress.PerformStep(); if (form.DialogResult == DialogResult.Cancel) { break; } } if (form.DialogResult != DialogResult.Cancel) { world.Export(); dropFlag = true; } Console.WriteLine($"{Environment.TickCount - time}ms"); } catch (Exception e) { try { Console.WriteLine(PythonExecutor.FormatException(e)); } catch { } Console.WriteLine(e); } finally { finalize(); } if (dropFlag) { try { world.DropFileToMMM(); } catch { } } }