PageSetupSystem.xaml.vb 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. Class PageSetupSystem
  2. #Region "语言"
  3. 'Private Sub PageSetupUI_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
  4. ' AniControlEnabled -= 1
  5. ' '读取设置
  6. ' Select Case Lang
  7. ' Case "zh_CN"
  8. ' ComboLang.SelectedIndex = 0
  9. ' Case "zh_HK"
  10. ' ComboLang.SelectedIndex = 1
  11. ' Case "en_US"
  12. ' ComboLang.SelectedIndex = 2
  13. ' End Select
  14. ' CheckDebug.Checked = ReadReg("SystemDebugMode", "False")
  15. ' AniControlEnabled += 1
  16. 'End Sub
  17. 'Private Sub RefreshLang() Handles ComboLang.SelectionChanged
  18. ' If IsLoaded Then
  19. ' If Not ComboLang.IsLoaded Then Exit Sub
  20. ' Lang = CType(ComboLang.SelectedItem, MyComboBoxItem).Tag
  21. ' Application.Current.Resources.MergedDictionaries(1) = New ResourceDictionary With {.Source = New Url("Languages\" & Lang & ".xaml", UrlKind.Relative)}
  22. ' WriteReg("Lang", Lang)
  23. ' End If
  24. 'End Sub
  25. #End Region
  26. Private Shadows IsLoaded As Boolean = False
  27. Private Sub PageSetupSystem_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
  28. '重复加载部分
  29. PanBack.ScrollToHome()
  30. #If Not BETA Then
  31. ItemSystemUpdateDownload.Content = "在有新版本时自动下载(更新快照版可能需要更新密钥)"
  32. #End If
  33. '非重复加载部分
  34. If IsLoaded Then Exit Sub
  35. IsLoaded = True
  36. AniControlEnabled += 1
  37. Reload()
  38. SliderLoad()
  39. AniControlEnabled -= 1
  40. End Sub
  41. Public Sub Reload()
  42. '下载
  43. SliderDownloadThread.Value = Setup.Get("ToolDownloadThread")
  44. SliderDownloadSpeed.Value = Setup.Get("ToolDownloadSpeed")
  45. ComboDownloadVersion.SelectedIndex = Setup.Get("ToolDownloadVersion")
  46. ComboDownloadTranslate.SelectedIndex = Setup.Get("ToolDownloadTranslate")
  47. CheckDownloadKeepModpack.Checked = Setup.Get("ToolDownloadKeepModpack")
  48. CheckDownloadIgnoreQuilt.Checked = Setup.Get("ToolDownloadIgnoreQuilt")
  49. CheckDownloadCert.Checked = Setup.Get("ToolDownloadCert")
  50. 'Minecraft 更新提示
  51. CheckUpdateRelease.Checked = Setup.Get("ToolUpdateRelease")
  52. CheckUpdateSnapshot.Checked = Setup.Get("ToolUpdateSnapshot")
  53. '辅助设置
  54. CheckHelpChinese.Checked = Setup.Get("ToolHelpChinese")
  55. '系统设置
  56. ComboSystemUpdate.SelectedIndex = Setup.Get("SystemSystemUpdate")
  57. ComboSystemActivity.SelectedIndex = Setup.Get("SystemSystemActivity")
  58. TextSystemCache.Text = Setup.Get("SystemSystemCache")
  59. '调试选项
  60. CheckDebugMode.Checked = Setup.Get("SystemDebugMode")
  61. SliderDebugAnim.Value = Setup.Get("SystemDebugAnim")
  62. CheckDebugDelay.Checked = Setup.Get("SystemDebugDelay")
  63. CheckDebugSkipCopy.Checked = Setup.Get("SystemDebugSkipCopy")
  64. End Sub
  65. '初始化
  66. Public Sub Reset()
  67. Try
  68. Setup.Reset("ToolDownloadThread")
  69. Setup.Reset("ToolDownloadSpeed")
  70. Setup.Reset("ToolDownloadVersion")
  71. Setup.Reset("ToolDownloadTranslate")
  72. Setup.Reset("ToolDownloadKeepModpack")
  73. Setup.Reset("ToolDownloadIgnoreQuilt")
  74. Setup.Reset("ToolDownloadCert")
  75. Setup.Reset("ToolUpdateRelease")
  76. Setup.Reset("ToolUpdateSnapshot")
  77. Setup.Reset("ToolHelpChinese")
  78. Setup.Reset("SystemDebugMode")
  79. Setup.Reset("SystemDebugAnim")
  80. Setup.Reset("SystemDebugDelay")
  81. Setup.Reset("SystemDebugSkipCopy")
  82. Setup.Reset("SystemSystemCache")
  83. Setup.Reset("SystemSystemUpdate")
  84. Setup.Reset("SystemSystemActivity")
  85. Log("[Setup] 已初始化启动器页设置")
  86. Hint("已初始化启动器页设置!", HintType.Finish, False)
  87. Catch ex As Exception
  88. Log(ex, "初始化启动器页设置失败", LogLevel.Msgbox)
  89. End Try
  90. Reload()
  91. End Sub
  92. '将控件改变路由到设置改变
  93. Private Shared Sub CheckBoxChange(sender As MyCheckBox, e As Object) Handles CheckDebugMode.Change, CheckDebugDelay.Change, CheckDebugSkipCopy.Change, CheckUpdateRelease.Change, CheckUpdateSnapshot.Change, CheckHelpChinese.Change, CheckDownloadKeepModpack.Change, CheckDownloadIgnoreQuilt.Change, CheckDownloadCert.Change
  94. If AniControlEnabled = 0 Then Setup.Set(sender.Tag, sender.Checked)
  95. End Sub
  96. Private Shared Sub SliderChange(sender As MySlider, e As Object) Handles SliderDebugAnim.Change, SliderDownloadThread.Change, SliderDownloadSpeed.Change
  97. If AniControlEnabled = 0 Then Setup.Set(sender.Tag, sender.Value)
  98. End Sub
  99. Private Shared Sub ComboChange(sender As MyComboBox, e As Object) Handles ComboDownloadVersion.SelectionChanged, ComboDownloadTranslate.SelectionChanged, ComboSystemUpdate.SelectionChanged, ComboSystemActivity.SelectionChanged
  100. If AniControlEnabled = 0 Then Setup.Set(sender.Tag, sender.SelectedIndex)
  101. End Sub
  102. Private Shared Sub TextBoxChange(sender As MyTextBox, e As Object) Handles TextSystemCache.ValidatedTextChanged
  103. If AniControlEnabled = 0 Then Setup.Set(sender.Tag, sender.Text)
  104. End Sub
  105. '滑动条
  106. Private Sub SliderLoad()
  107. SliderDownloadThread.GetHintText = Function(Value As Integer)
  108. Return Value + 1
  109. End Function
  110. SliderDownloadSpeed.GetHintText = Function(Value As Integer)
  111. If Value <= 14 Then
  112. Return (Value + 1) * 0.1 & " M/s"
  113. ElseIf Value <= 31 Then
  114. Return (Value - 11) * 0.5 & " M/s"
  115. ElseIf Value <= 41 Then
  116. Return (Value - 21) & " M/s"
  117. Else
  118. Return "无限制"
  119. End If
  120. End Function
  121. SliderDebugAnim.GetHintText = Function(Value As Integer)
  122. Return If(Value > 29, "关闭", (Value / 10 + 0.1) & "x")
  123. End Function
  124. End Sub
  125. Private Sub SliderDownloadThread_PreviewChange(sender As Object, e As RouteEventArgs) Handles SliderDownloadThread.PreviewChange
  126. If SliderDownloadThread.Value < 100 Then Exit Sub
  127. If Not Setup.Get("HintDownloadThread") Then
  128. Setup.Set("HintDownloadThread", True)
  129. MyMsgBox("如果设置过多的下载线程,可能会导致下载时出现非常严重的卡顿。" & vbCrLf &
  130. "一般设置 64 线程即可满足大多数下载需求,除非你知道你在干什么,否则不建议设置更多的线程数!", "警告", "我知道了", IsWarn:=True)
  131. End If
  132. End Sub
  133. '识别码/解锁码替代入口
  134. Private Sub BtnSystemIdentify_Click(sender As Object, e As MouseButtonEventArgs) Handles BtnSystemIdentify.Click
  135. PageOtherAbout.CopyUniqueAddress()
  136. End Sub
  137. Private Sub BtnSystemUnlock_Click(sender As Object, e As MouseButtonEventArgs) Handles BtnSystemUnlock.Click
  138. PageOtherAbout.DonateCodeInput()
  139. End Sub
  140. '调试模式
  141. Private Sub CheckDebugMode_Change() Handles CheckDebugMode.Change
  142. If AniControlEnabled = 0 Then Hint("部分调试信息将在刷新或启动器重启后切换显示!",, False)
  143. End Sub
  144. '自动更新
  145. Private Sub ComboSystemActivity_SizeChanged(sender As Object, e As SelectionChangedEventArgs) Handles ComboSystemActivity.SelectionChanged
  146. If AniControlEnabled <> 0 Then Exit Sub
  147. If ComboSystemActivity.SelectedIndex = 2 Then
  148. If MyMsgBox("若选择此项,即使在将来出现严重问题时,你也无法获取相关通知。" & vbCrLf &
  149. "例如,如果发现某个版本游戏存在严重 Bug,你可能就会因为无法得到通知而导致无法预知的后果。" & vbCrLf & vbCrLf &
  150. "一般选择 仅在有重要通知时显示公告 就可以让你尽量不受打扰了。" & vbCrLf &
  151. "除非你在制作服务器整合包,或时常手动更新启动器,否则极度不推荐选择此项!", "警告", "我知道我在做什么", "取消", IsWarn:=True) = 2 Then
  152. ComboSystemActivity.SelectedItem = e.RemovedItems(0)
  153. End If
  154. End If
  155. End Sub
  156. Private Sub ComboSystemUpdate_SizeChanged(sender As Object, e As SelectionChangedEventArgs) Handles ComboSystemUpdate.SelectionChanged
  157. If AniControlEnabled <> 0 Then Exit Sub
  158. If ComboSystemUpdate.SelectedIndex = 3 Then
  159. If MyMsgBox("若选择此项,即使在启动器将来出现严重问题时,你也无法获取更新并获得修复。" & vbCrLf &
  160. "例如,如果官方修改了登录方式,从而导致现有启动器无法登录,你可能就会因为无法更新而无法开始游戏。" & vbCrLf & vbCrLf &
  161. "一般选择 仅在有重大漏洞更新时显示提示 就可以让你尽量不受打扰了。" & vbCrLf &
  162. "除非你在制作服务器整合包,或时常手动更新启动器,否则极度不推荐选择此项!", "警告", "我知道我在做什么", "取消", IsWarn:=True) = 2 Then
  163. ComboSystemUpdate.SelectedItem = e.RemovedItems(0)
  164. End If
  165. End If
  166. End Sub
  167. Private Sub BtnSystemUpdate_Click(sender As Object, e As EventArgs) Handles BtnSystemUpdate.Click
  168. UpdateCheckByButton()
  169. End Sub
  170. ''' <summary>
  171. ''' 启动器是否已经是最新版?
  172. ''' 若返回 Nothing,则代表无更新缓存文件或出错。
  173. ''' </summary>
  174. Public Shared Function IsLauncherNewest() As Boolean?
  175. Try
  176. '确认服务器公告是否正常
  177. Dim ServerContent As String = ReadFile(PathTemp & "Cache\Notice.cfg")
  178. If ServerContent.Split("|").Count < 3 Then Return Nothing
  179. '确认是否为最新
  180. #If BETA Then
  181. Dim NewVersionCode As Integer = ServerContent.Split("|")(2)
  182. #Else
  183. Dim NewVersionCode As Integer = ServerContent.Split("|")(1)
  184. #End If
  185. Return NewVersionCode <= VersionCode
  186. Catch ex As Exception
  187. Log(ex, "确认启动器更新失败", LogLevel.Feedback)
  188. Return Nothing
  189. End Try
  190. End Function
  191. End Class