2
0

MainWindow.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 m_project_name = null;
  22. public string m_source_path = null;
  23. public string m_output_path = Environment.GetEnvironmentVariable("CROWN_OUTPUT_DIR") + "/";
  24. //--------------------------------------------------------------------------------
  25. public MainWindow () : base (Gtk.WindowType.Toplevel)
  26. {
  27. Build ();
  28. // Fill platform combobox
  29. Gtk.TreeIter platform_iter;
  30. PlatformID p_id = Environment.OSVersion.Platform;
  31. switch (p_id)
  32. {
  33. case PlatformID.Unix:
  34. platform_combobox.AppendText ("Linux32");
  35. platform_combobox.AppendText ("Linux64");
  36. break;
  37. case PlatformID.Win32NT:
  38. case PlatformID.Win32S:
  39. case PlatformID.Win32Windows:
  40. case PlatformID.WinCE:
  41. platform_combobox.AppendText ("Windows32");
  42. platform_combobox.AppendText ("Windows64");
  43. break;
  44. }
  45. platform_combobox.AppendText ("Android");
  46. platform_combobox.Model.IterNthChild (out platform_iter, 0);
  47. platform_combobox.SetActiveIter (platform_iter);
  48. // Fill debug combobox
  49. Gtk.TreeIter build_iter;
  50. build_combobox.AppendText ("Debug");
  51. build_combobox.AppendText ("Development");
  52. build_combobox.AppendText ("Release");
  53. build_combobox.Model.IterNthChild (out build_iter, 0);
  54. build_combobox.SetActiveIter (build_iter);
  55. }
  56. //--------------------------------------------------------------------------------
  57. protected void OnDeleteEvent (object sender, DeleteEventArgs a)
  58. {
  59. Application.Quit ();
  60. a.RetVal = true;
  61. }
  62. //--------------------------------------------------------------------------------
  63. protected void OnProjectButtonClicked (object sender, EventArgs e)
  64. {
  65. starter.ProjectDialog pd = new starter.ProjectDialog (this);
  66. pd.Run ();
  67. pd.Destroy ();
  68. project_entry.Text = m_project_name;
  69. }
  70. //--------------------------------------------------------------------------------
  71. protected void OnRunButtonClicked (object sender, EventArgs e)
  72. {
  73. Platform platform = (Platform) platform_combobox.Active;
  74. BuildMode build = (BuildMode) build_combobox.Active;
  75. // Do not use MonoDevelop for compiling because it cannot retrieve env value even though is specified in target environment.
  76. // Use 'xbuild' command instead.
  77. string path = Environment.GetEnvironmentVariable("CROWN_INSTALL_DIR") + "/";
  78. string output_path = m_output_path;
  79. string executable = "";
  80. switch (platform)
  81. {
  82. case Platform.Linux32:
  83. {
  84. path += "bin/linux32/";
  85. output_path += m_project_name + "-linux32";
  86. switch (build)
  87. {
  88. case BuildMode.Debug: executable = "crown-debug-32"; break;
  89. case BuildMode.Development: executable = "crown-development-32"; break;
  90. case BuildMode.Release: executable = "crown-release-32"; break;
  91. }
  92. break;
  93. }
  94. case Platform.Linux64:
  95. {
  96. path += "bin/linux64/";
  97. output_path += m_project_name + "-linux64";
  98. switch (build)
  99. {
  100. case BuildMode.Debug: executable = "crown-debug-64"; break;
  101. case BuildMode.Development: executable = "crown-development-64"; break;
  102. case BuildMode.Release: executable = "crown-release-64"; break;
  103. }
  104. break;
  105. }
  106. case Platform.Windows32:
  107. {
  108. path += "bin\\windows32\\";
  109. output_path += m_project_name + "-windows32";
  110. switch (build)
  111. {
  112. case BuildMode.Debug: executable = "crown-debug-32"; break;
  113. case BuildMode.Development: executable = "crown-development-32"; break;
  114. case BuildMode.Release: executable = "crown-release-32"; break;
  115. }
  116. break;
  117. }
  118. case Platform.Windows64:
  119. {
  120. path += "bin\\windows64\\";
  121. output_path += m_project_name + "-windows64";
  122. switch (build)
  123. {
  124. case BuildMode.Debug: executable = "crown-debug-64"; break;
  125. case BuildMode.Development: executable = "crown-development-64"; break;
  126. case BuildMode.Release: executable = "crown-release-64"; break;
  127. }
  128. break;
  129. }
  130. }
  131. string args = " --source-dir " + m_source_path;
  132. args += " --bundle-dir " + output_path;
  133. args += " --platform linux";
  134. args += " --compile --continue";
  135. System.IO.Directory.SetCurrentDirectory (path);
  136. System.Diagnostics.Process.Start (executable, args);
  137. }
  138. }