MainWindow.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using Gtk;
  3. public partial class MainWindow: Gtk.Window
  4. {
  5. //--------------------------------------------------------------------------------
  6. enum Platform
  7. {
  8. Linux32 = 0,
  9. Linux64,
  10. Windows32,
  11. Windows64,
  12. Android
  13. }
  14. //--------------------------------------------------------------------------------
  15. enum BuildMode
  16. {
  17. Debug = 0,
  18. Development,
  19. Release
  20. }
  21. public string project_name = null;
  22. public string source_path = null;
  23. public string destination_path = null;
  24. //--------------------------------------------------------------------------------
  25. public MainWindow () : base (Gtk.WindowType.Toplevel)
  26. {
  27. Build ();
  28. }
  29. //--------------------------------------------------------------------------------
  30. protected void OnDeleteEvent (object sender, DeleteEventArgs a)
  31. {
  32. Application.Quit ();
  33. a.RetVal = true;
  34. }
  35. //--------------------------------------------------------------------------------
  36. protected void OnProjectButtonClicked (object sender, EventArgs e)
  37. {
  38. starter.ProjectDialog pd = new starter.ProjectDialog (this);
  39. pd.Run ();
  40. pd.Destroy ();
  41. project_entry.Text = project_name;
  42. }
  43. //--------------------------------------------------------------------------------
  44. protected void OnRunButtonClicked (object sender, EventArgs e)
  45. {
  46. Platform platform = (Platform) platform_combobox.Active;
  47. BuildMode build = (BuildMode) build_combobox.Active;
  48. // Do not use MD for compiling because it cannot retrieve env value even though is specified in target environment.
  49. // Use 'xbuild' command instead.
  50. string path = Environment.GetEnvironmentVariable("CROWN_INSTALL_DIR") + "/";
  51. string executable = "";
  52. switch (platform)
  53. {
  54. case Platform.Linux32:
  55. {
  56. path += "bin/linux32/";
  57. switch (build)
  58. {
  59. case BuildMode.Debug: executable = "crown-debug-32"; break;
  60. case BuildMode.Development: executable = "crown-development-32"; break;
  61. case BuildMode.Release: executable = "crown-release-32"; break;
  62. }
  63. break;
  64. }
  65. case Platform.Linux64:
  66. {
  67. path += "bin/linux64/";
  68. switch (build)
  69. {
  70. case BuildMode.Debug: executable = "crown-debug-64"; break;
  71. case BuildMode.Development: executable = "crown-development-64"; break;
  72. case BuildMode.Release: executable = "crown-release-64"; break;
  73. }
  74. break;
  75. }
  76. case Platform.Windows32:
  77. {
  78. path += "bin\\windows32\\";
  79. switch (build)
  80. {
  81. case BuildMode.Debug: executable = "crown-debug-32"; break;
  82. case BuildMode.Development: executable = "crown-development-32"; break;
  83. case BuildMode.Release: executable = "crown-release-32"; break;
  84. }
  85. break;
  86. }
  87. case Platform.Windows64:
  88. {
  89. path += "bin\\windows64\\";
  90. switch (build)
  91. {
  92. case BuildMode.Debug: executable = "crown-debug-64"; break;
  93. case BuildMode.Development: executable = "crown-development-64"; break;
  94. case BuildMode.Release: executable = "crown-release-64"; break;
  95. }
  96. break;
  97. }
  98. }
  99. string args = " --source-dir " + source_path;
  100. args += " --bundle-dir " + destination_path;
  101. args += " --compile --continue";
  102. System.IO.Directory.SetCurrentDirectory (path);
  103. System.Diagnostics.Process.Start (executable, args);
  104. }
  105. }