/
MainMenuScreen.vb
1852 lines (1550 loc) · 80.5 KB
/
MainMenuScreen.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports System.Net
Imports System.Net.Cache
Imports System.Threading.Tasks
Public Class MainMenuScreen
Inherits Screen
Dim mainmenuIndex As Integer = 0
Dim loadMenuIndex(3) As Integer
Dim languageMenuIndex(3) As Integer
Dim packsMenuIndex(3) As Integer
Dim gameModeMenuIndex(3) As Integer
Dim packInfoIndex As Integer = 0
Dim deleteIndex As Integer = 0
Public menuIndex As Integer = 0
Dim loadGameJoltIndex As Integer = 0
Dim currentLevel As Integer = -1
Dim levelChangeDelay As Integer = 0
Dim mainTexture As Texture2D
Dim Saves As New List(Of String)
Dim SaveNames As New List(Of String)
Dim Languages As New List(Of String)
Dim LanguageNames As New List(Of String)
Dim currentLanguage As String = "en"
Dim PackNames As New List(Of String)
Dim EnabledPackNames As New List(Of String)
Dim ModeNames As New List(Of String)
Dim tempLoadDisplay As String = ""
Public Overrides Function GetScreenStatus() As String
Dim s As String = "MenuIndex=" & Me.menuIndex & vbNewLine &
"CurrentLevel=" & Me.currentLevel & vbNewLine &
"LevelChangeDelay=" & Me.levelChangeDelay.ToString()
Return s
End Function
Public Sub New()
GameModeManager.SetGameModePointer("Kolben")
Me.Identification = Identifications.MainMenuScreen
Me.CanBePaused = False
Me.MouseVisible = True
Me.CanChat = False
Me.currentLanguage = Localization.LanguageSuffix
Screen.TextBox.Showing = False
Screen.PokemonImageView.Showing = False
Screen.ChooseBox.Showing = False
Effect = New BasicEffect(Core.GraphicsDevice)
Effect.FogEnabled = True
SkyDome = New SkyDome()
Camera = New MainMenuCamera()
' renderTarget = New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height, False, Core.GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24)
' blurEffect = Core.Content.Load(Of Effect)("Effects\BlurEffect")
Core.Player.Skin = "Hilbert"
Level = New Level()
ChangeLevel()
mainTexture = TextureManager.GetTexture("GUI\Menus\Menu")
Screen.Level.World.Initialize(Screen.Level.EnvironmentType, Screen.Level.WeatherType)
If System.IO.Directory.Exists(GameController.GamePath & "\Save\") = False Then
System.IO.Directory.CreateDirectory(GameController.GamePath & "\Save\")
End If
GetSaves()
GetLanguages()
GetPacks()
GameJolt.Emblem.ClearOnlineSpriteCache()
Screen.Level.World.Initialize(Screen.Level.EnvironmentType, Screen.Level.WeatherType)
UpdateCheck()
End Sub
Private Sub UpdateCheck()
Try
If Not GameController.UpdateChecked Then
Logger.Debug("---Check Version---")
If Not Core.GameOptions.UpdateDisabled AndAlso My.Computer.Network.IsAvailable Then
WaitForUpdaterAsync()
End If
End If
Catch ex As Exception
End Try
End Sub
Private Async Function WaitForUpdaterAsync() As Task
Dim Updater As New Process
Updater.EnableRaisingEvents = True
Updater.StartInfo = New ProcessStartInfo("Updater.exe")
Updater.Start()
AddHandler Updater.Exited, Sub()
Select Case Updater.ExitCode
Case 0
GameController.UpdateChecked = True
Case 1
Core.GameInstance.Exit()
Case 2
Core.GameOptions.UpdateDisabled = True
Core.GameOptions.SaveOptions()
GameController.UpdateChecked = True
Case 3
Core.GameOptions.UpdateDisabled = True
Core.GameOptions.SaveOptions()
Core.GameInstance.Exit()
End Select
End Sub
Await Task.Delay(20000)
If Not Updater.HasExited Then
Updater.Kill()
GameController.UpdateChecked = True
End If
End Function
Private Sub GetPacks(Optional ByVal reload As Boolean = False)
PackNames.Clear()
If reload = False Then
EnabledPackNames.Clear()
EnabledPackNames.AddRange(Core.GameOptions.ContentPackNames)
End If
PackNames.AddRange(EnabledPackNames)
If System.IO.Directory.Exists(GameController.GamePath & "\ContentPacks\") = True Then
For Each ContentPackFolder As String In System.IO.Directory.GetDirectories(GameController.GamePath & "\ContentPacks\")
Dim newContentPack As String = ContentPackFolder.Remove(0, (GameController.GamePath & "\ContentPacks\").Length)
If PackNames.Contains(newContentPack) = False Then
PackNames.Add(newContentPack)
End If
Next
End If
End Sub
Private Sub GetLanguages()
Languages.Clear()
LanguageNames.Clear()
For Each file As String In System.IO.Directory.GetFiles(GameController.GamePath & "\Content\Localization\")
If file.EndsWith(".dat") = True Then
Dim content() As String = System.IO.File.ReadAllLines(file)
file = System.IO.Path.GetFileNameWithoutExtension(file)
If file.StartsWith("Tokens_") = True Then
Dim TokenName As String = file.Remove(0, 7)
Dim LanguageName As String = ""
For Each line As String In content
If line.StartsWith("language_name,") = True Then
LanguageName = content(0).GetSplit(1)
Languages.Add(TokenName)
LanguageNames.Add(LanguageName)
Exit For
End If
Next
End If
End If
Next
End Sub
Private Sub GetSaves()
If System.IO.File.Exists(GameController.GamePath & "\Save\lastSession.id") = True Then
Dim idData As String = System.IO.File.ReadAllText(GameController.GamePath & "\Save\lastSession.id")
If System.IO.Directory.Exists(GameController.GamePath & "\Save\" & idData) = False Then
System.IO.File.Delete(GameController.GamePath & "\Save\lastSession.id")
End If
End If
Saves.Clear()
SaveNames.Clear()
For Each Folder As String In System.IO.Directory.GetDirectories(GameController.GamePath & "\Save")
If Player.IsSaveGameFolder(Folder) = True Then
Saves.Add(Folder)
End If
Next
For i = 0 To Saves.Count - 1
If i <= Saves.Count - 1 Then
Dim entry As String = Saves(i)
Dim Data() As String = System.IO.File.ReadAllText(entry & "\Player.dat").SplitAtNewline()
Dim Name As String = "Missingno."
Dim Autosave As Boolean = False
For Each Line As String In Data
If Line.StartsWith("Name|") = True Then
Name = Line.GetSplit(1, "|")
End If
If Line.StartsWith("AutoSave|") = True Then
Autosave = True
End If
Next
If Autosave = True Then
Saves.RemoveAt(i)
i -= 1
Else
SaveNames.Add(Name)
End If
End If
Next
End Sub
Private Sub GetGameModes()
ModeNames.Clear()
For Each folder As String In System.IO.Directory.GetDirectories(GameController.GamePath & "\GameModes\")
If System.IO.File.Exists(folder & "\GameMode.dat") = True Then
Dim directory As String = folder
If directory.EndsWith("\") = True Then
directory = directory.Remove(directory.Length - 1, 1)
End If
directory = directory.Remove(0, directory.LastIndexOf("\") + 1)
ModeNames.Add(directory)
End If
Next
End Sub
Private Sub ChangeLevel()
Dim levelCount As Integer = 0
For Each levelPath As String In System.IO.Directory.GetFiles(GameController.GamePath & "\maps\mainmenu\")
Dim levelFile As String = System.IO.Path.GetFileName(levelPath)
If levelFile.StartsWith("mainmenu") = True And levelFile.EndsWith(".dat") = True Then
levelCount += 1
End If
Next
Dim levelID As Integer = Core.Random.Next(0, levelCount)
If levelCount > 1 Then
While levelID = currentLevel
levelID = Core.Random.Next(0, levelCount)
End While
End If
Select Case levelID
Case 0
Camera.Position = New Vector3(13, 2, 14)
Case 1
Camera.Position = New Vector3(23, 2, 10)
Case 2
Camera.Position = New Vector3(23, 2, 12)
Case 3
Camera.Position = New Vector3(24, 2, 14)
End Select
If Me.currentLevel <> levelID Then
Me.currentLevel = levelID
Level.Load("mainmenu\mainmenu" & levelID & ".dat")
End If
levelChangeDelay = 1000
End Sub
Public Overrides Sub Update()
Lighting.UpdateLighting(Screen.Effect)
Camera.Update()
Level.Update()
SkyDome.Update()
If Core.GameInstance.IsActive = True Then
Select Case Me.menuIndex
Case 0
UpdateMainMenu()
Case 1
UpdateLoadMenu()
Case 2
UpdateDeleteMenu()
Case 3
UpdateLanguageMenu()
Case 4
UpdatePacksMenu()
Case 5
UpdatePackInformationMenu()
Case 6
UpdateNewGameMenu()
Case 7
UpdateLoadGameJoltSaveMenu()
End Select
End If
If Me.levelChangeDelay <= 0 Then
If Core.Random.Next(0, 1000) = 0 Then
ChangeLevel()
End If
Else
Me.levelChangeDelay -= 1
End If
End Sub
Dim renderTarget As RenderTarget2D
Dim blurEffect As Effect
#Region "MainMenu"
Public Overrides Sub Draw()
'Core.GraphicsDevice.SetRenderTarget(renderTarget)
'Core.GraphicsDevice.Clear(Core.BackgroundColor)
SkyDome.Draw(45.0F)
Level.Draw()
World.DrawWeather(Screen.Level.World.CurrentMapWeather)
'Core.GraphicsDevice.SetRenderTarget(Nothing)
'Core.SpriteBatch.EndBatch()
'blurEffect.CurrentTechnique = blurEffect.Techniques("GaussianBlur")
'blurEffect.Parameters("TextureWidth").SetValue(Core.windowSize.Width)
'Core.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise, blurEffect)
'Core.SpriteBatch.Draw(renderTarget, New Vector2(0, 0), Color.White)
'Core.SpriteBatch.End()
'Core.SpriteBatch.BeginBatch()
Select Case Me.menuIndex
Case 0
DrawMainMenu()
Case 1
DrawLoadMenu()
Case 2
DrawDeleteMenu()
Case 3
DrawLanguageMenu()
Case 4
DrawPacksMenu()
Case 5
DrawPackInformationMenu()
Case 6
DrawNewGameMenu()
Case 7
DrawLoadGameJoltSaveMenu()
End Select
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, GameController.DEVELOPER_NAME, New Vector2(7, Core.ScreenSize.Height - FontManager.InGameFont.MeasureString(GameController.DEVELOPER_NAME).Y - 1), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, GameController.DEVELOPER_NAME, New Vector2(4, Core.ScreenSize.Height - FontManager.InGameFont.MeasureString(GameController.DEVELOPER_NAME).Y - 4), Color.White)
Core.SpriteBatch.DrawInterface(TextureManager.GetTexture("GUI\Logos\P3D"), New Rectangle(CInt(Core.ScreenSize.Width / 2) - 260, 40, 500, 110), Color.White)
If Core.GameOptions.ShowDebug = 0 Then
Dim s As String = GameController.GAMENAME & " " & GameController.GAMEDEVELOPMENTSTAGE & " " & GameController.GAMEVERSION
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, s, New Vector2(7, 7), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, s, New Vector2(5, 5), Color.White)
End If
End Sub
Private Sub DrawMainMenu()
Dim CanvasTexture As Texture2D
For i = 0 To 7
Dim Text As String = ""
Select Case i
Case 0
Text = Localization.GetString("main_menu_continue")
Case 1
Text = Localization.GetString("main_menu_load_game")
Case 2
Text = Localization.GetString("main_menu_new_game")
Case 3
Text = Localization.GetString("main_menu_quit_game")
Case 7
Text = "Play online"
End Select
If i = mainmenuIndex Then
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 48, 48, 48), "")
Else
If i < 2 And Saves.Count = 0 Or i = 0 And System.IO.Directory.Exists(GameController.GamePath & "\Save\autosave") = False Then
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(48, 0, 48, 48), "")
Else
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "")
End If
End If
If i = 4 Then
If i = mainmenuIndex Then
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 64, 0, 64, 64), New Rectangle(96, 80, 16, 16), Color.White)
Else
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 64, 0, 64, 64), New Rectangle(96, 64, 16, 16), Color.White)
End If
ElseIf i = 5 Then
If i = mainmenuIndex Then
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 64, 64, 64, 64), New Rectangle(112, 80, 16, 16), Color.White)
Else
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 64, 64, 64, 64), New Rectangle(112, 64, 16, 16), Color.White)
End If
ElseIf i = 6 Then
If Security.FileValidation.IsValid(False) = True And GameController.Hacker = False Then
If GameJolt.API.LoggedIn = True Then
If i = mainmenuIndex Then
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 196, Core.ScreenSize.Height - 60, 192, 56), New Rectangle(160, 96, 96, 28), Color.White)
Else
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 196, Core.ScreenSize.Height - 60, 192, 56), New Rectangle(160, 65, 96, 28), Color.White)
End If
Core.SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "Logged in as", New Vector2(Core.ScreenSize.Width - 148, Core.ScreenSize.Height - 54), Color.White)
Core.SpriteBatch.DrawInterfaceString(FontManager.MiniFont, GameJolt.API.username, New Vector2(Core.ScreenSize.Width - 148, Core.ScreenSize.Height - 34), New Color(204, 255, 0))
Else
If i = mainmenuIndex Then
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 60, Core.ScreenSize.Height - 60, 56, 56), New Rectangle(129, 96, 28, 28), Color.White)
Else
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(Core.ScreenSize.Width - 60, Core.ScreenSize.Height - 60, 56, 56), New Rectangle(129, 65, 28, 28), Color.White)
End If
End If
Else
Core.SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "File Validation failed. Download a new copy of the game to fix this.", New Vector2(220, Core.ScreenSize.Height - 30), Color.White)
End If
ElseIf i = 7 Then
If GameJolt.API.LoggedIn = True And Security.FileValidation.IsValid(False) = True And GameController.Hacker = False Then
Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2), 160 + 128, 320, 64), True)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Text, New Vector2(CInt(Core.ScreenSize.Width / 2) - (FontManager.InGameFont.MeasureString(Text).X / 2) + 160 + 20, 196 + 128), Color.Black)
End If
ElseIf i = 1 And GameJolt.API.LoggedIn = True Then
Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180 - 160 - 20, 160 + i * 128, 320, 64), True)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Text, New Vector2(CInt(Core.ScreenSize.Width / 2) - (FontManager.InGameFont.MeasureString(Text).X / 2) - 10 - 160 - 20, 196 + i * 128), Color.Black)
Else
Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180, 160 + i * 128, 320, 64), True)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Text, New Vector2(CInt(Core.ScreenSize.Width / 2) - (FontManager.InGameFont.MeasureString(Text).X / 2) - 10, 196 + i * 128), Color.Black)
End If
Next
Dim d As New Dictionary(Of Buttons, String)
d.Add(Buttons.A, "Accept")
If GameJolt.API.LoggedIn = True Then
DrawGamePadControls(d, New Vector2(Core.ScreenSize.Width - 170, Core.ScreenSize.Height - 100))
Else
DrawGamePadControls(d, New Vector2(Core.ScreenSize.Width - 234, Core.ScreenSize.Height - 40))
End If
End Sub
Private Sub UpdateMainMenu()
If Controls.Up(True, True) = True Then
Me.mainmenuIndex -= 1
End If
If Controls.Down(True, True) = True Then
Me.mainmenuIndex += 1
End If
If Core.GameInstance.IsMouseVisible = True Then
For i = 0 To 7
If i = 4 Then
If Core.ScaleScreenRec(New Rectangle(Core.ScreenSize.Width - 64, 0, 64, 64)).Contains(MouseHandler.MousePosition) = True Then
Me.mainmenuIndex = 4
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
LanguageButton()
End If
End If
ElseIf i = 5 Then
If Core.ScaleScreenRec(New Rectangle(Core.ScreenSize.Width - 64, 64, 64, 64)).Contains(MouseHandler.MousePosition) = True Then
Me.mainmenuIndex = 5
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
PacksButton()
End If
End If
ElseIf i = 6 Then
Dim r As Rectangle = Core.ScaleScreenRec(New Rectangle(Core.ScreenSize.Width - 196, Core.ScreenSize.Height - 60, 192, 56))
If GameJolt.API.LoggedIn = False Then
r = Core.ScaleScreenRec(New Rectangle(Core.ScreenSize.Width - 64, Core.ScreenSize.Height - 64, 64, 64))
End If
If r.Contains(MouseHandler.MousePosition) = True Then
Me.mainmenuIndex = 6
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
GameJoltButton()
End If
End If
ElseIf i = 1 And GameJolt.API.LoggedIn = True Then
If Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180 - 160 - 20, 160 + i * 128, 320 + 32, 64 + 32)).Contains(MouseHandler.MousePosition) = True Then
Me.mainmenuIndex = i
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
LoadGameButton()
End If
End If
ElseIf i = 7 And GameJolt.API.LoggedIn = True Then
If Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2), 160 + 128, 320 + 32, 64 + 32)).Contains(MouseHandler.MousePosition) = True Then
Me.mainmenuIndex = i
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
LoadGameJoltButton()
End If
End If
Else
If Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180, 160 + i * 128, 320 + 32, 64 + 32)).Contains(MouseHandler.MousePosition) = True Then
Me.mainmenuIndex = i
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
Select Case Me.mainmenuIndex
Case 0
ContinueButton()
Case 1
LoadGameButton()
Case 2
NewGameButton()
Case 3
CloseGameButton()
End Select
End If
End If
End If
Next
End If
If Security.FileValidation.IsValid(False) = True And GameController.Hacker = False Then
If GameJolt.API.LoggedIn = True Then
mainmenuIndex = CInt(MathHelper.Clamp(mainmenuIndex, 0, 7))
Else
mainmenuIndex = CInt(MathHelper.Clamp(mainmenuIndex, 0, 6))
End If
Else
mainmenuIndex = mainmenuIndex.Clamp(0, 5)
End If
If Controls.Accept(False, True) = True Then
Select Case Me.mainmenuIndex
Case 0
ContinueButton()
Case 1
LoadGameButton()
Case 2
NewGameButton()
Case 3
CloseGameButton()
Case 4
LanguageButton()
Case 5
PacksButton()
Case 6
GameJoltButton()
Case 7
LoadGameJoltButton()
End Select
End If
End Sub
Private Sub PacksButton()
GetPacks()
packsMenuIndex(0) = 0
packsMenuIndex(2) = 0
Me.menuIndex = 4
End Sub
Private Sub LanguageButton()
GetLanguages()
If Languages.Contains(currentLanguage) = True Then
languageMenuIndex(0) = Languages.IndexOf(currentLanguage)
End If
Me.menuIndex = 3
End Sub
Private Sub ContinueButton()
If Saves.Count > 0 And Player.IsSaveGameFolder(GameController.GamePath & "\Save\autosave") = True Then
Core.Player.IsGameJoltSave = False
Core.Player.LoadGame("autosave")
Core.SetScreen(New JoinServerScreen(Me))
End If
End Sub
Private Sub LoadGameButton()
GetSaves()
If Saves.Count > 0 Then
Me.menuIndex = 1
End If
End Sub
Private Sub LoadGameJoltButton()
If Security.FileValidation.IsValid(False) = True And GameController.Hacker = False Then
If GameJolt.API.LoggedIn = True Then
Core.GameJoltSave.DownloadSave(GameJolt.LogInScreen.LoadedGameJoltID, True)
End If
Me.menuIndex = 7
End If
End Sub
Private Sub CloseGameButton()
Core.GameOptions.SaveOptions()
Core.GameInstance.Exit()
End Sub
Private Sub GameJoltButton()
If Security.FileValidation.IsValid(False) = True And GameController.Hacker = False Then
Core.SetScreen(New GameJolt.LogInScreen(Me))
End If
End Sub
#End Region
#Region "LoadMenu"
Private Sub DrawLoadMenu()
Dim CanvasTexture As Texture2D
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "")
For i = 0 To 3
Dim c As Color = Color.White
If i + loadMenuIndex(2) = loadMenuIndex(0) Then
c = New Color(101, 142, 255)
End If
Canvas.DrawRectangle(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 258, 180 + i * 50, 480, 48), c, True)
Next
Canvas.DrawScrollBar(New Vector2(CInt(Core.ScreenSize.Width / 2) + 250, 180), Saves.Count, 4, loadMenuIndex(2), New Size(4, 200), False, New Color(190, 190, 190), New Color(63, 63, 63), True)
Dim x As Integer = Saves.Count - 1
x = CInt(MathHelper.Clamp(x, 0, 3))
For i = 0 To x
Dim Name As String = SaveNames(i + loadMenuIndex(2))
If i + loadMenuIndex(2) = loadMenuIndex(0) Then
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Name, New Vector2(CInt(Core.ScreenSize.Width / 2) - 245, 191 + i * 50), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Name, New Vector2(CInt(Core.ScreenSize.Width / 2) - 248, 188 + i * 50), Color.White)
Else
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Name, New Vector2(CInt(Core.ScreenSize.Width / 2) - 248, 188 + i * 50), Color.Black)
End If
Next
Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 272, 388, 512, 128), True)
If tempLoadDisplay = "" Then
Dim dispName As String = "(Unknown)"
Dim dispBadges As String = "(Unknown)"
Dim dispPlayTime As String = "(Unknown)"
Dim dispLocation As String = "(Unknown)"
Dim dispGameMode As String = "Kolben"
Dim Data() As String = System.IO.File.ReadAllText(Saves(loadMenuIndex(0)) & "\Player.dat").SplitAtNewline()
For Each Line As String In Data
If Line.Contains("|") = True Then
Dim ID As String = Line.Remove(Line.IndexOf("|"))
Dim Value As String = Line.Remove(0, Line.IndexOf("|") + 1)
Select Case ID
Case "Name"
dispName = Value
Case "Badges"
Dim bCount As Integer = 0
If Value = "0" Then
bCount = 0
Else
If Value.Contains(",") = False Then
bCount = 1
Else
Dim s() As String = Value.Split(CChar(","))
bCount = s.Length
End If
End If
dispBadges = bCount.ToString()
Case "PlayTime"
Dim dd() As String = Value.Split(CChar(","))
Dim tSpan As TimeSpan = Nothing
If dd.Count = 3 Then
tSpan = New TimeSpan(CInt(dd(0)), CInt(dd(1)), CInt(dd(2)))
ElseIf dd.Count = 4 Then
tSpan = New TimeSpan(CInt(dd(3)), CInt(dd(0)), CInt(dd(1)), CInt(dd(2)))
End If
dispPlayTime = TimeHelpers.GetDisplayTime(tSpan, True)
Case "location"
dispLocation = Value
Case "GameMode"
dispGameMode = Value
End Select
End If
Next
Me.tempLoadDisplay = Localization.GetString("load_menu_name") & ": " & dispName & vbNewLine &
Localization.GetString("load_menu_gamemode") & ": " & dispGameMode & vbNewLine &
Localization.GetString("load_menu_badges") & ": " & dispBadges & vbNewLine &
Localization.GetString("load_menu_location") & ": " & Localization.GetString("Places_" & dispLocation) & vbNewLine &
Localization.GetString("load_menu_time") & ": " & dispPlayTime
End If
Core.SpriteBatch.DrawInterfaceString(FontManager.MiniFont, tempLoadDisplay, New Vector2(CInt(Core.ScreenSize.Width / 2) - 252, 416), Color.Black)
For i = 0 To 2
Dim Text As String = ""
Select Case i
Case 0
Text = Localization.GetString("load_menu_load")
Case 1
Text = Localization.GetString("load_menu_delete")
Case 2
Text = Localization.GetString("load_menu_back")
End Select
If i = loadMenuIndex(1) Then
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 48, 48, 48), "")
Else
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "")
End If
Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 272 + i * 192, 550, 128, 64), True)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Text, New Vector2(CInt(Core.ScreenSize.Width / 2) - 254 + i * 192, 582), Color.Black)
Next
Dim d As New Dictionary(Of Buttons, String)
d.Add(Buttons.A, "Accept")
d.Add(Buttons.B, "Back")
DrawGamePadControls(d)
End Sub
Private Sub UpdateLoadMenu()
If Controls.Up(True, True, True) = True Then
loadMenuIndex(0) -= 1
If loadMenuIndex(0) - loadMenuIndex(2) < 0 Then
loadMenuIndex(2) -= 1
End If
tempLoadDisplay = ""
End If
If Controls.Down(True, True, True) = True Then
loadMenuIndex(0) += 1
If loadMenuIndex(0) + loadMenuIndex(2) > 3 Then
loadMenuIndex(2) += 1
End If
tempLoadDisplay = ""
End If
If Core.GameInstance.IsMouseVisible = True Then
For i = 0 To 2
If Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 272 + i * 192, 550, 128 + 32, 64 + 32)).Contains(MouseHandler.MousePosition) = True Then
Me.loadMenuIndex(1) = i
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
Select Case loadMenuIndex(1)
Case 0
Core.Player.IsGameJoltSave = False
Core.Player.LoadGame(System.IO.Path.GetFileName(Saves(loadMenuIndex(0))))
Core.SetScreen(New JoinServerScreen(Me))
Case 1
Me.menuIndex = 2
Case 2
Me.menuIndex = 0
tempLoadDisplay = ""
End Select
End If
End If
Next
End If
For i = 0 To 3
If Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 258, 180 + i * 50, 480, 48)).Contains(MouseHandler.MousePosition) = True Then
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.LeftButton) = True Then
Me.loadMenuIndex(0) = i + loadMenuIndex(2)
tempLoadDisplay = ""
End If
End If
Next
loadMenuIndex(0) = CInt(MathHelper.Clamp(loadMenuIndex(0), 0, Saves.Count - 1))
loadMenuIndex(2) = CInt(MathHelper.Clamp(loadMenuIndex(2), 0, Saves.Count - 4))
If Controls.Right(True, True, False) = True Then
loadMenuIndex(1) += 1
End If
If Controls.Left(True, True, False) = True Then
loadMenuIndex(1) -= 1
End If
loadMenuIndex(1) = CInt(MathHelper.Clamp(loadMenuIndex(1), 0, 2))
If Controls.Accept(False, True) = True Then
Select Case loadMenuIndex(1)
Case 0
Core.Player.IsGameJoltSave = False
Core.Player.LoadGame(System.IO.Path.GetFileName(Saves(loadMenuIndex(0))))
Core.SetScreen(New JoinServerScreen(Me))
Case 1
Me.menuIndex = 2
Case 2
Me.menuIndex = 0
tempLoadDisplay = ""
End Select
End If
If Controls.Dismiss() = True Then
Me.menuIndex = 0
End If
End Sub
#End Region
#Region "LoadGameJoltSaveMenu"
Private Sub DrawLoadGameJoltSaveMenu()
If Core.GameJoltSave.DownloadFailed = False Then
Dim downloaded As Boolean = Core.GameJoltSave.DownloadFinished
If downloaded = True Then
Dim r As New Rectangle(CInt(Core.ScreenSize.Width / 2) - 256, 300, 512, 128)
If Core.ScaleScreenRec(r).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Or Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 0 Then
Canvas.DrawRectangle(Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 264, 292, 528, 144)), New Color(255, 255, 255, 150))
End If
If GameJolt.LogInScreen.UserBanned(Core.GameJoltSave.GameJoltID) = True Then
Dim reason As String = GameJolt.LogInScreen.GetBanReasonByID(GameJolt.LogInScreen.BanReasonIDForUser(Core.GameJoltSave.GameJoltID))
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, reason, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(reason).X / 2) + 2, 260 + 2), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, reason, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(reason).X / 2), 260), Color.Red)
End If
GameJolt.Emblem.Draw(GameJolt.API.username, Core.GameJoltSave.GameJoltID, Core.GameJoltSave.Points, Core.GameJoltSave.Gender, Core.GameJoltSave.Emblem, Core.ScaleScreenVec(New Vector2(CSng(Core.ScreenSize.Width / 2) - 256, 300)), CSng(4 * Core.SpriteBatch.InterfaceScale), Core.GameJoltSave.DownloadedSprite)
Dim y As Integer = 0
If Core.ScaleScreenRec(New Rectangle(r.X + 32 + r.Width, r.Y, 32, 32)).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Or Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 1 Then
y = 16
Core.SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "Change to male.", New Vector2(r.X + 64 + 4 + r.Width, r.Y + 4), Color.White)
End If
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(r.X + 32 + r.Width, r.Y, 32, 32), New Rectangle(144, 32 + y, 16, 16), Color.White)
y = 0
If Core.ScaleScreenRec(New Rectangle(r.X + 32 + r.Width, r.Y + 48, 32, 32)).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Or Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 2 Then
y = 16
Core.SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "Change to female.", New Vector2(r.X + 64 + 4 + r.Width, r.Y + 4 + 48), Color.White)
End If
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(r.X + 32 + r.Width, r.Y + 48, 32, 32), New Rectangle(160, 32 + y, 16, 16), Color.White)
y = 0
If Core.ScaleScreenRec(New Rectangle(r.X + 32 + r.Width, r.Y + 48 + 48, 32, 32)).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Or Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 3 Then
y = 16
Core.SpriteBatch.DrawInterfaceString(FontManager.MiniFont, "Reset save.", New Vector2(r.X + 64 + 4 + r.Width, r.Y + 4 + 48 + 48), Color.White)
End If
Core.SpriteBatch.DrawInterface(mainTexture, New Rectangle(r.X + 32 + r.Width, r.Y + 48 + 48, 32, 32), New Rectangle(176, 32 + y, 16, 16), Color.White)
Else
Dim downloadProgress As Integer = Core.GameJoltSave.DownloadProgress
Dim total As Integer = Core.GameJoltSave.TotalDownloadItems
Dim downloadtext As String = "Downloading profile..."
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, downloadtext & LoadingDots.Dots, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(downloadtext).X / 2) + 2, 322), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, downloadtext & LoadingDots.Dots, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(downloadtext).X / 2), 320), Color.White)
Canvas.DrawScrollBar(New Vector2(CInt(Core.ScreenSize.Width / 2) - 256, 400), total, downloadProgress, 0, New Size(512, 8), True, Color.Black, Color.White, True)
End If
Else
Dim failText As String = "The download failed! Please try again."
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, failText, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(failText).X / 2) + 2, 322), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, failText, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(failText).X / 2), 320), Color.DarkRed)
End If
If ControllerHandler.IsConnected() = False Then
Dim text As String = "Right-Click to quit to the main menu."
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, text, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(text).X / 2) + 2, 502), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.MainFont, text, New Vector2(CSng(Core.ScreenSize.Width / 2 - FontManager.MainFont.MeasureString(text).X / 2), 500), Color.White)
End If
Dim d As New Dictionary(Of Buttons, String)
d.Add(Buttons.A, "Select")
d.Add(Buttons.B, "Back")
Me.DrawGamePadControls(d)
End Sub
Private Sub UpdateLoadGameJoltSaveMenu()
Dim downloaded As Boolean = Core.GameJoltSave.DownloadFinished
If downloaded = True Then
If Controls.Down(True, True, False, True, True) = True Or Controls.Right(True, True, False, True, True) = True Then
loadGameJoltIndex += 1
End If
If Controls.Up(True, True, False, True, True) = True Or Controls.Left(True, True, False, True, True) = True Then
loadGameJoltIndex -= 1
End If
loadGameJoltIndex = loadGameJoltIndex.Clamp(0, 3)
If Controls.Accept(True, True) = True Then
If Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 0 Or Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 256, 300, 512, 128)).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Then
Core.Player.IsGameJoltSave = True
Core.Player.LoadGame("GAMEJOLTSAVE")
Core.SetScreen(New JoinServerScreen(Me))
End If
Dim r As Rectangle = Core.ScaleScreenRec(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 256, 300, 512, 128))
If Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 1 Or Core.ScaleScreenRec(New Rectangle(r.X + 32 + r.Width, r.Y, 32, 32)).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Then
ButtonChangeMale()
End If
If Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 2 Or Core.ScaleScreenRec(New Rectangle(r.X + 32 + r.Width, r.Y + 48, 32, 32)).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Then
ButtonChangeFemale()
End If
If Core.GameInstance.IsMouseVisible = False And loadGameJoltIndex = 3 Or Core.ScaleScreenRec(New Rectangle(r.X + 32 + r.Width, r.Y + 48 + 48, 32, 32)).Contains(MouseHandler.MousePosition) = True And Core.GameInstance.IsMouseVisible = True Then
ButtonResetSave()
End If
End If
End If
If Controls.Dismiss(True, True) = True Then
Me.menuIndex = 0
End If
End Sub
Private Sub ButtonChangeMale()
Core.GameJoltSave.Gender = "0"
Core.Player.Skin = GameJolt.Emblem.GetPlayerSpriteFile(GameJolt.Emblem.GetPlayerLevel(Core.GameJoltSave.Points), Core.GameJoltSave.GameJoltID, Core.GameJoltSave.Gender)
Select Case Core.GameJoltSave.Gender
Case "0"
Core.Player.Male = True
Case "1"
Core.Player.Male = False
Case Else
Core.Player.Male = True
End Select
End Sub
Private Sub ButtonChangeFemale()
Core.GameJoltSave.Gender = "1"
Core.Player.Skin = GameJolt.Emblem.GetPlayerSpriteFile(GameJolt.Emblem.GetPlayerLevel(Core.GameJoltSave.Points), Core.GameJoltSave.GameJoltID, Core.GameJoltSave.Gender)
Select Case Core.GameJoltSave.Gender
Case "0"
Core.Player.Male = True
Case "1"
Core.Player.Male = False
Case Else
Core.Player.Male = True
End Select
End Sub
Private Sub ButtonResetSave()
Core.GameJoltSave.ResetSave()
End Sub
#End Region
#Region "LanguageMenu"
Private Sub DrawLanguageMenu()
Dim CanvasTexture As Texture2D
For i = 0 To 3
Dim c As Color = Color.White
If i + languageMenuIndex(2) = languageMenuIndex(0) Then
c = New Color(101, 142, 255)
End If
Canvas.DrawRectangle(New Rectangle(CInt(Core.ScreenSize.Width / 2) - 258, 180 + i * 50, 480, 48), c, True)
Next
Canvas.DrawScrollBar(New Vector2(CInt(Core.ScreenSize.Width / 2) + 250, 180), Languages.Count, 4, languageMenuIndex(2), New Size(4, 200), False, New Color(190, 190, 190), New Color(63, 63, 63), True)
Dim x As Integer = Languages.Count - 1
x = CInt(MathHelper.Clamp(x, 0, 3))
For i = 0 To x
Dim Name As String = LanguageNames(i + languageMenuIndex(2))
If i + languageMenuIndex(2) = languageMenuIndex(0) Then
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Name, New Vector2(CInt(Core.ScreenSize.Width / 2) - 245, 191 + i * 50), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Name, New Vector2(CInt(Core.ScreenSize.Width / 2) - 248, 188 + i * 50), Color.White)
Else
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Name, New Vector2(CInt(Core.ScreenSize.Width / 2) - 248, 188 + i * 50), Color.Black)
End If
Next
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "")
For i = 0 To 1
Dim Text As String = ""
Select Case i
Case 0
Text = Localization.GetString("language_menu_apply")
Case 1
Text = Localization.GetString("language_menu_back")
End Select