Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加随机主页预设 #5432

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion Plain Craft Launcher 2/Pages/PageLaunch/PageLaunchRight.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,17 @@ Download:
Exit Sub
End If
Case 3
Select Case Setup.Get("UiCustomPreset")
Static RandomFlag As Boolean
Static PresetIndex As Integer
Dim Preset = Setup.Get("UiCustomPreset")
If Preset <> 12 Then '非随机预设
PresetIndex = Preset
ElseIf RandomFlag = False Then '确保每次启动只生成一次随机数
Log("[Page] 主页预设:随机预设")
PresetIndex = New Random().Next(0, 12) '生成0-11的随机数
RandomFlag = True
Copy link

@shimoranla shimoranla Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

随机数注释部分,中文和数字之间需要加个空格

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

注释中中文与数字间需要空格为 PCL 社区规范

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段没什么用,只需要重新选择一次随机预设就会被重置为 Nothing,你应该加一个设置项来存储这个东西

根据我本地的调试日志 此处的静态变量 重新选择预设不会被重置,一旦选择随机预设,flag赋值后将保持true值,除非重启程序。此后即如果选择其他预设方案然后再切回随机预设,由于flag为true,导致index不会被重新赋值,使之保持为选择随机预设之前到预设,确保了一次运行只随机一次

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

随机数注释部分,中文和数字之间需要加个空格

这点我确实不知道,今天第一次翻PCL源码,找到关键文件后就没看其他的了

End If
Select Case PresetIndex
Case 0
Log("[Page] 主页预设:你知道吗")
Content = "
Expand Down
1 change: 1 addition & 0 deletions Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
<local:MyComboBoxItem Content="PCL 新功能说明书(作者:WForst-Breeze)" />
<local:MyComboBoxItem Content="OpenMCIM 仪表盘(作者:SALTWOOD)" />
<local:MyComboBoxItem Content="杂志主页(作者:CreeperIsASpy)" />
<local:MyComboBoxItem Content="随机预设(每次启动随机选择一个预设)" />
</local:MyComboBox>
</Grid>
</StackPanel>
Expand Down