PageSetupSystem.xaml.vb 9.7 KB

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