ProgramInstance.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using System.Collections.Generic;
  2. using System.Drawing;
  3. using System.IO;
  4. using System.Windows.Forms;
  5. using NTERA.EmuEra.Game.EraEmu.Config;
  6. namespace NTERA.EmuEra
  7. {
  8. public static class Program
  9. {
  10. /*
  11. コードの開始地点。
  12. ここでMainWindowを作り、
  13. MainWindowがProcessを作り、
  14. ProcessがGameBase・ConstantData・Variableを作る。
  15. *.ERBの読み込み、実行、その他の処理をProcessが、
  16. 入出力をMainWindowが、
  17. 定数の保存をConstantDataが、
  18. 変数の管理をVariableが行う。
  19. と言う予定だったが改変するうちに境界が曖昧になってしまった。
  20. 後にEmueraConsoleを追加し、それに入出力を担当させることに。
  21. 1750 DebugConsole追加
  22. Debugを全て切り離すことはできないので一部EmueraConsoleにも担当させる
  23. TODO: 1819 MainWindow & Consoleの入力・表示組とProcess&Dataのデータ処理組だけでも分離したい
  24. */
  25. /// <summary>
  26. /// アプリケーションのメイン エントリ ポイントです。
  27. /// </summary>
  28. public static void CMain(string exeDir)
  29. {
  30. ExeDir = exeDir;// Directory.GetCurrentDirectory();
  31. #if DEBUG
  32. //debugMode = true;
  33. #endif
  34. CsvDir = ExeDir + "csv\\";
  35. ErbDir = ExeDir + "erb\\";
  36. DebugDir = ExeDir + "debug\\";
  37. DatDir = ExeDir + "dat\\";
  38. ContentDir = ExeDir + "resources\\";
  39. //エラー出力用
  40. //1815 .exeが東方板のNGワードに引っかかるそうなので除去
  41. ExeName = "NTERA";
  42. //Application.EnableVisualStyles();
  43. //Application.SetCompatibleTextRenderingDefault(false);
  44. ConfigData.Instance.LoadConfig();
  45. //二重起動の禁止かつ二重起動
  46. //if ((!Config.AllowMultipleInstances) && (Sys.PrevInstance()))
  47. //{
  48. // MessageBox.Show("多重起動を許可する場合、emuera.configを書き換えて下さい", "既に起動しています");
  49. // return;
  50. //}
  51. if (!Directory.Exists(CsvDir))
  52. {
  53. MessageBox.Show("csvフォルダが見つかりません", "フォルダなし");
  54. return;
  55. }
  56. if (!Directory.Exists(ErbDir))
  57. {
  58. MessageBox.Show("erbフォルダが見つかりません", "フォルダなし");
  59. return;
  60. }
  61. // int argsStart = 0;
  62. // if ((args.Length > 0)&&(args[0].Equals("-DEBUG", StringComparison.CurrentCultureIgnoreCase)))
  63. // {
  64. // argsStart = 1;//デバッグモードかつ解析モード時に最初の1っこ(-DEBUG)を飛ばす
  65. // debugMode = true;
  66. // }
  67. //if(debugMode)
  68. //{
  69. // ConfigData.Instance.LoadDebugConfig();
  70. // if (!Directory.Exists(DebugDir))
  71. // {
  72. // try
  73. // {
  74. // Directory.CreateDirectory(DebugDir);
  75. // }
  76. // catch
  77. // {
  78. // MessageBox.Show("debugフォルダの作成に失敗しました", "フォルダなし");
  79. // return;
  80. // }
  81. // }
  82. //}
  83. // if (args.Length > argsStart)
  84. // {
  85. // AnalysisFiles = new List<string>();
  86. // for (int i = argsStart; i < args.Length; i++)
  87. // {
  88. // if (!File.Exists(args[i]) && !Directory.Exists(args[i]))
  89. // {
  90. // MessageBox.Show("与えられたファイル・フォルダは存在しません");
  91. // return;
  92. // }
  93. // if ((File.GetAttributes(args[i]) & FileAttributes.Directory) == FileAttributes.Directory)
  94. // {
  95. // List<KeyValuePair<string, string>> fnames = Config.GetFiles(args[i] + "\\", "*.ERB");
  96. // for (int j = 0; j < fnames.Count; j++)
  97. // {
  98. // AnalysisFiles.Add(fnames[j].Value);
  99. // }
  100. // }
  101. // else
  102. // {
  103. // if (Path.GetExtension(args[i]).ToUpper() != ".ERB")
  104. // {
  105. // MessageBox.Show("ドロップ可能なファイルはERBファイルのみです");
  106. // return;
  107. // }
  108. // AnalysisFiles.Add(args[i]);
  109. // }
  110. // }
  111. // AnalysisMode = true;
  112. // }
  113. }
  114. /// <summary>
  115. /// 実行ファイルのディレクトリ。最後に\を付けたstring
  116. /// </summary>
  117. public static string ExeDir { get; private set; }
  118. public static string CsvDir { get; private set; }
  119. public static string ErbDir { get; private set; }
  120. public static string DebugDir { get; private set; }
  121. public static string DatDir { get; private set; }
  122. public static string ContentDir { get; private set; }
  123. public static string ExeName { get; private set; }
  124. public static bool Reboot;
  125. //public static int RebootClientX = 0;
  126. public static int RebootClientY;
  127. public static FormWindowState RebootWinState = FormWindowState.Normal;
  128. public static Point RebootLocation;
  129. public static bool AnalysisMode;
  130. public static List<string> AnalysisFiles;
  131. public static bool debugMode;
  132. public static bool DebugMode => debugMode;
  133. public static uint StartTime { get; private set; }
  134. }
  135. }