formMain.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Threading.Tasks;
  2. using System.Windows.Forms;
  3. using System;
  4. using NTERA.Console;
  5. using NTERA.Core;
  6. using NTERA.EmuEra;
  7. using NTERA.Engine;
  8. using NTERA.Engine.Runtime;
  9. namespace NTERA
  10. {
  11. public partial class formMain : Form
  12. {
  13. private readonly GameInstance instance = new GameInstance();
  14. public formMain()
  15. {
  16. InitializeComponent();
  17. //var scriptEngine = new EmuEraGameInstance();
  18. //var scriptEngine = new Engine();
  19. var eraFolder = Environment.GetEnvironmentVariable("ERA");
  20. if (eraFolder == null) {
  21. eraFolder = Environment.CurrentDirectory;
  22. }
  23. var scriptEngine = new EraRuntime(new JITCompiler(eraFolder));
  24. //Task.Factory.StartNew(() => instance.Run(new EraConsoleInstance(consoleControl1.Renderer, scriptEngine), scriptEngine));
  25. Task.Factory.StartNew(() => instance.Run(new EraConsoleInstance(consoleControl1.Renderer, scriptEngine), scriptEngine));
  26. }
  27. private void txtInput_KeyDown(object sender, KeyEventArgs e)
  28. {
  29. if (e.KeyCode == Keys.Enter)
  30. {
  31. instance.GiveInput(txtInput.Text);
  32. txtInput.Text = "";
  33. e.Handled = true;
  34. e.SuppressKeyPress = true;
  35. }
  36. }
  37. }
  38. }