Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 1 addition & 45 deletions Plain Craft Launcher 2/Application.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@
Environment.Exit((int)ModBase.ProcessReturnValues.Fail);
}
}
/* TODO ERROR: Skipped IfDirectiveTrivia
#If DEBUGRESERVED Then
*/ /* TODO ERROR: Skipped DisabledTextTrivia
'制作更新包
ElseIf args(0) = "--edit1" Then
ExeEdit(args(1), True)
Environment.Exit(ProcessReturnValues.TaskDone)
ElseIf args(0) = "--edit2" Then
ExeEdit(args(1), False)
Environment.Exit(ProcessReturnValues.TaskDone)
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
}

// 初始化文件结构
Expand All @@ -75,30 +62,7 @@
Directory.CreateDirectory(ModBase.PathTemp + "Cache");
Directory.CreateDirectory(ModBase.PathTemp + "Download");
Directory.CreateDirectory(ModBase.PathAppdata);
/* TODO ERROR: Skipped IfDirectiveTrivia
#If False Then
*/ /* TODO ERROR: Skipped DisabledTextTrivia
'检测单例
Dim ShouldWaitForExit As Boolean = args.Length > 0 AndAlso args(0) = "--wait" '要求等待已有的 PCL 退出
Dim WaitRetryCount As Integer = 0
WaitRetry:
Dim WindowHwnd As IntPtr = FindWindow(Nothing, "Plain Craft Launcher Community Edition ")
If WindowHwnd = IntPtr.Zero Then FindWindow(Nothing, "Plain Craft Launcher 2 Community Edition ")
If WindowHwnd <> IntPtr.Zero Then
If ShouldWaitForExit AndAlso WaitRetryCount < 20 Then '至多等待 10 秒
WaitRetryCount += 1
Thread.Sleep(500)
GoTo WaitRetry
End If
'将已有的 PCL 窗口拖出来
ShowWindowToTop(WindowHwnd)
'播放提示音并退出
Beep()
Environment.[Exit](ProcessReturnValues.Cancel)
End If
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/ // 设置 ToolTipService 默认值
// 设置 ToolTipService 默认值
ToolTipService.InitialShowDelayProperty.OverrideMetadata(typeof(DependencyObject),
new FrameworkPropertyMetadata(300));
ToolTipService.BetweenShowDelayProperty.OverrideMetadata(typeof(DependencyObject),
Expand Down Expand Up @@ -159,14 +123,6 @@
// 计时
ModBase.Log("[Start] 第一阶段加载用时:" + (TimeUtils.GetTimeTick() - ModBase.ApplicationStartTick) + " ms");
ModBase.ApplicationStartTick = TimeUtils.GetTimeTick();
// 执行测试
/* TODO ERROR: Skipped IfDirectiveTrivia
#If DEBUGRESERVED Then
*/ /* TODO ERROR: Skipped DisabledTextTrivia
Test()
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
ModAnimation.AniControlEnabled += 1;
}
catch (Exception ex)
Expand Down Expand Up @@ -239,12 +195,12 @@
// 自定义监听器类
public class BindingErrorTraceListener : TraceListener
{
public override void Write(string message)

Check warning on line 198 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, ARM64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 198 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, x64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).
{
ModBase.Log($"警告,检测到 Binding 失败:{message}");
}

public override void WriteLine(string message)

Check warning on line 203 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, ARM64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 203 in Plain Craft Launcher 2/Application.xaml.cs

View workflow job for this annotation

GitHub Actions / build (CI, x64) / Build

Nullability of type of parameter 'message' doesn't match overridden member (possibly because of nullability attributes).
{
ModBase.Log($"警告,检测到 Binding 失败:{message}");
}
Expand Down
6 changes: 0 additions & 6 deletions Plain Craft Launcher 2/Modules/Base/ModBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3649,9 +3649,6 @@ public static void Log(string Text, LogLevel Level = LogLevel.Normal, string Tit
ModMain.Hint("[调试模式] " + Text, ModMain.HintType.Info, false);
break;
}
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
case LogLevel.Hint:
{
ModMain.Hint(Text, ModMain.HintType.Critical, false);
Expand Down Expand Up @@ -3756,9 +3753,6 @@ public static void Log(Exception Ex, string Desc, LogLevel Level = LogLevel.Debu
ModMain.Hint("[调试模式] " + ExLine, ModMain.HintType.Info, false);
break;
}
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
case LogLevel.Hint:
{
var ExLine = Desc + ":" + Ex;
Expand Down
130 changes: 0 additions & 130 deletions Plain Craft Launcher 2/Modules/ModWebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,134 +343,4 @@ public static void StartNaidAuthorize(Action? completeCallback = null)
}

#endregion

#region 旧的 HTTP 服务端实现

/* TODO ERROR: Skipped IfDirectiveTrivia
#If False
*/ /* TODO ERROR: Skipped DisabledTextTrivia
Private Server As HttpListener
Public Class HttpServer
Public Sub New()
Server = New HttpListener()
Server.Prefixes.Add("http://127.0.0.1:29992/")
Server.Start()
Task.Run(
Async Function()
While True
Try
Dim Context As HttpListenerContext = Await Server.GetContextAsync()
ApiRoute(Context)
Catch ex As Exception
Log(ex, "[Server] 处理响应时发生错误")
End Try
End While
End Function)
End Sub

Private CurrentStatus As New OAuthCompleteStatus()

Public Sub ApiRoute(Context As HttpListenerContext)


Dim RequestUrl As String = Context.Request.Url.AbsolutePath
Dim OAuthCode As String = Nothing

' 多斜杠处理
While RequestUrl.Contains("//")
RequestUrl = RequestUrl.Replace("//", "/")
End While

Select Case RequestUrl
Case "/api/naid/oauth20/callback"

Dim Query = Context.Request.Url.Query
If Query.StartsWith("?") Then Query = Query.Substring(1)

'在 URL 参数中寻找授权码
For Each Param As String In Query.Split("&"c)
If Param.StartsWithF("code=") Then
OAuthCode = Param.Substring(5)
End If
Next

'设置状态信息
If OAuthCode IsNot Nothing Then
Dim result = NatayarkProfileManager.GetNaidDataSync(OAuthCode)
If result Then
CurrentStatus.success = True
CurrentStatus.username = NatayarkProfileManager.NaidProfile.Username
Else
CurrentStatus.success = False
CurrentStatus.message = $"获取用户信息失败,请尝试重新登录"
CurrentStatus.stacktrace = NatayarkProfileManager.Exception.ToString()
End If
Else
CurrentStatus.success = False
CurrentStatus.message = $"回调参数无效: {Query}"
End If

'重定向至结束页
Context.Response.StatusCode = HttpStatusCode.Redirect
Context.Response.AddHeader("location", "/complete")
Context.Response.Close()
Case "/complete"
Try
Dim Data = GetResourceStream("Resources/oauth-complete.html")
If Data Is Nothing Then GoTo NotFound
Context.Response.StatusCode = HttpStatusCode.OK
Context.Response.AddHeader("Content-Type", "text/html, charset=utf-8")
Data.CopyTo(Context.Response.OutputStream)
Context.Response.OutputStream.Dispose()
Context.Response.Close()
Catch ex As Exception
GoTo NotFound
End Try
Case "/assets/background"
SyncLock ChangeLock
If PicAddress Is Nothing OrElse String.IsNullOrWhiteSpace(PicAddress) Then GoTo NotFound
Using FileReadStream As New FileStream(PicAddress, FileMode.Open, FileAccess.Read, FileShare.None, 16384, True)
Context.Response.StatusCode = HttpStatusCode.OK
Context.Response.AddHeader("Content-Type", "application/octet-stream")
FileReadStream.CopyTo(Context.Response.OutputStream)
Context.Response.OutputStream.Dispose()
Context.Response.Close()
End Using
End SyncLock
Case "/assets/icon.ico"
Try
Dim Data = GetResourceStream("Images/icon.ico")
If Data Is Nothing Then GoTo NotFound
Context.Response.StatusCode = HttpStatusCode.OK
Context.Response.AddHeader("Content-Type", "application/octet-stream")
Data.CopyTo(Context.Response.OutputStream)
Context.Response.OutputStream.Dispose()
Context.Response.Close()
Catch ex As Exception
GoTo NotFound
End Try
Case "/api/naid/oauth20/status"
Try
Dim status = JsonConvert.SerializeObject(CurrentStatus)
Dim buffer = Encoding.UTF8.GetBytes(status)
Context.Response.StatusCode = HttpStatusCode.OK
Context.Response.AddHeader("Content-Type", "application/json, charset=utf-8")
Context.Response.OutputStream.Write(buffer, 0, buffer.Length)
Context.Response.OutputStream.Dispose()
Context.Response.Close()
Catch ex As Exception
GoTo NotFound
End Try
Case Else
NotFound:
Context.Response.StatusCode = HttpStatusCode.NotFound
Context.Response.Close()
End Select
End Sub
End Class
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,8 @@ private void StartExport(object sender, MouseButtonEventArgs e)
var Loaders = new List<ModLoader.LoaderBase>();

#region 准备 PCL 文件

/* TODO ERROR: Skipped IfDirectiveTrivia
#If Not RELEASE Then
*/

#if !RELEASE
if (IncludePCL)
Loaders.Add(new ModLoader.LoaderTask<int, int>("下载 PCL 正式版", Loader =>
{
Expand All @@ -749,9 +747,7 @@ private void StartExport(object sender, MouseButtonEventArgs e)
ProgressWeight = 0.5d,
Block = false
});
/* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/
#endif

#endregion

Expand Down Expand Up @@ -840,14 +836,11 @@ private void StartExport(object sender, MouseButtonEventArgs e)
Loader.Progress = 0.97d;
// 复制 PCL 实例设置
ModBase.CopyDirectory(McInstance.PathInstance + @"PCL\", OverridesFolder + @"PCL\");
/* TODO ERROR: Skipped IfDirectiveTrivia
#If RELEASE Then
*/ /* TODO ERROR: Skipped DisabledTextTrivia
#if RELEASE
'复制 PCL 本体
If IncludePCL Then CopyFile(ExePathWithName, CacheFolder & "Plain Craft Launcher.exe")
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
#End If
*/ // 复制 PCL 个性化内容
#endif
// 复制 PCL 个性化内容
if (IncludePCLCustom)
{
if (Directory.Exists(ModBase.ExePath + @"PCL\Pictures\"))
Expand Down
Loading