2026-08-08 14:07:56 +08:00
|
|
|
|
using System;
|
2026-08-09 21:32:55 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Text;
|
2026-08-08 14:07:56 +08:00
|
|
|
|
using System.Windows;
|
2026-08-09 21:32:55 +08:00
|
|
|
|
using MRCC.Launcher;
|
2026-08-08 14:07:56 +08:00
|
|
|
|
|
2026-08-09 21:32:55 +08:00
|
|
|
|
internal static class Program
|
2026-08-08 14:07:56 +08:00
|
|
|
|
{
|
2026-08-09 21:32:55 +08:00
|
|
|
|
public static bool IsDevMode;
|
|
|
|
|
|
private static readonly object _logLock = new();
|
|
|
|
|
|
private static readonly string LogPath = "redcircuit.log";
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
|
private static extern bool AllocConsole();
|
|
|
|
|
|
|
2026-08-08 14:07:56 +08:00
|
|
|
|
[STAThread]
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2026-08-09 21:32:55 +08:00
|
|
|
|
IsDevMode = args.Any(a => string.Equals(a, "dev", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
|
|
if (IsDevMode)
|
2026-08-08 14:07:56 +08:00
|
|
|
|
{
|
2026-08-09 21:32:55 +08:00
|
|
|
|
AllocConsole();
|
|
|
|
|
|
Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true });
|
|
|
|
|
|
Log("=== RedCircuit 开发模式 ===");
|
|
|
|
|
|
Log($"工作目录: {Environment.CurrentDirectory}");
|
|
|
|
|
|
Log($"EXE目录: {AppContext.BaseDirectory}");
|
|
|
|
|
|
Log("HTML5 世界直接运行于 WebView2 内,控制台用于查看日志。");
|
|
|
|
|
|
}
|
2026-08-08 14:07:56 +08:00
|
|
|
|
|
2026-08-09 21:32:55 +08:00
|
|
|
|
// 启动器 UI:WebView2 加载 HTML5 世界
|
|
|
|
|
|
var app = new App();
|
|
|
|
|
|
app.Run(new MainWindow());
|
|
|
|
|
|
}
|
2026-08-08 14:07:56 +08:00
|
|
|
|
|
2026-08-09 21:32:55 +08:00
|
|
|
|
public static void Log(string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
var line = $"[{DateTime.Now:HH:mm:ss.fff}] {message}";
|
|
|
|
|
|
lock (_logLock)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsDevMode) Console.WriteLine(line);
|
|
|
|
|
|
Debug.WriteLine(line);
|
|
|
|
|
|
try { File.AppendAllText(LogPath, line + Environment.NewLine, Encoding.UTF8); } catch { }
|
|
|
|
|
|
}
|
2026-08-08 14:07:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|