-
Notifications
You must be signed in to change notification settings - Fork 0
/
agaw-client.bmx
1187 lines (1077 loc) · 43.5 KB
/
agaw-client.bmx
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
Strict
Import "imports/Toolbox.bmx"
Import "imports/sfTCP.bmx"
Import "imports/clientChatDisplay.bmx"
Import "imports/RequestText.bmx"
Import "imports/INI_Interface.bmx"
Incbin "version.txt"
Incbin "OCRAEXT.TTF"
Incbin "art/BottomLeftPanel.png"
Incbin "art/menubutton.png"
Incbin "art/menubutton_down.png"
Incbin "art/topBar.png"
Incbin "art/windowbackground.png"
Global version:String = LoadText("incbin::version.txt")
Global mainChat:sChatHandler = New sChatHandler
Global attacheUpdates:sChatHandler = New sChatHandler
Global settingsIni:INI_File = OpenINI("client-settings.ini")
''' Setup the INI settings that don't have a default value and start saving it.
If FileType("client-settings.ini") = 0 Then
Notify( "Setting resolution to 1280x720. Modify your settings by opening 'client-settings.ini'!" )
Local serverName:String = RequestText("Set Server", "Please input the server IP or server domain.", "127.0.0.1")
if not serverName or serverName = "" Then RuntimeError( "Client needs a server to connect to." )
settingsIni.set("screen_width", 1280, "graphics")
settingsIni.set("screen_height", 720, "graphics")
settingsIni.set("server_ip", serverName, "network")
settingsIni.set("server_port", DEFAULTPORT, "network")
settingsIni.save("client-settings.ini")
EndIf
scnx = settingsIni.GetInteger( "screen_width", "graphics" )
scny = settingsIni.GetInteger( "screen_height", "graphics" )
mainChat.NewVariable("server_ip", settingsIni.GetString( "server_ip", "network" ))
mainChat.NewVariable("port", settingsIni.GetString( "server_port", "network" ))
Local screenMode:int = 0
If settingsIni.ItemExists("fullscreen", "graphics") Then
screenMode = settingsIni.GetInteger( "fullscreen", "graphics" ) * 32
Else
settingsIni.set("fullscreen", screenMode / 32, "graphics")
EndIf
Local screenHertz:int = 60
If settingsIni.ItemExists("hertz", "graphics") Then
screenHertz = settingsIni.GetInteger( "hertz", "graphics" )
Else
settingsIni.set("hertz", screenHertz, "graphics")
EndIf
AppTitle = "A Galaxy At War: Empires ::: " + version + " ::: Client"
Graphics(scnx, scny, screenMode)
SetBlend ALPHABLEND
mainChat.enabled = False
Global stdFont:TImageFont = LoadImageFont("incbin::OCRAEXT.TTF", 12)
Global medFont:TImageFont = LoadImageFont("incbin::OCRAEXT.TTF", 24)
Global lrgFont:TImageFont = LoadImageFont("incbin::OCRAEXT.TTF", 32)
SetImageFont stdFont
'''' Login Stuffs
Global usernameCH:sTextBox = New sTextBox
Global passwordCH:sTextBox = New sTextBox
usernameCH.Prompttxt = "Username: "
usernameCH.currentString = ""
If settingsIni.ItemExists("user_name", "game") Then
usernameCH.currentString = settingsIni.GetString( "user_name", "game" )
EndIf
If usernameCH.currentString Then
passwordCH.enabled = True
Else
usernameCH.enabled = True
End If
passwordCH.Prompttxt = "Password: "
passwordCH.isPassword = True
Global menuBars:TImage[] = [LoadImage("incbin::art/topBar.png"), LoadImage("incbin::art/menubutton.png"), LoadImage("incbin::art/menubutton_down.png"), LoadImage("incbin::art/windowbackground.png")]
Global mouseDragging = False
Global selectedSystem:TSystem = Null, targetSystem:TSystem = Null, selectedShips:Int = 0, selectedFleet:TFleet = Null, totalships = 0
Global bottomLeftWindow:Int = 0, topLeftChat:Int = 0
Global wasConnected = False, justConnected = False, justFinishedFirstSync = False, hasFinishedFirstSync = False
If Not Connect(mainChat.GetVariable("server_ip".tolower())._var, Int(mainChat.GetVariable("port")._var)) Then
client = Null
EndIf
Global midDrag = False, dragX:Int = 0, dragY:Int = 0
Global lastConnectTry:Int = MilliSecs() ' lastConnectTry = MilliSecs()
TerritorySquare.CreateGrid(50, 4)
Global tgEnabled = True
Global currentScreen:Int = 0
DoMain
If client Then
If client.Connected() Then client.SendPacket(Packet.ID_MESSAGESELF, "logs off")
client.Close()
End If
settingsIni.save("client-settings.ini")
End '''''''''''''''''''''```````````'`'`'`'`'`''`'`''`''`'`''`'`'`''`````'`'`'`'`'`''`'`''`''`'`''`'`'`''`````'`'`'`'`'`''`'`''`''`'`''`'`'`''`
Function DoMain()
While Not AppTerminate() And Not KeyHit(KEY_ESCAPE)
UpdateInput()
If client Then
UpdateClient()
Else
If wasConnected Then
mainChat.add("[ERROR] You have been disconnected for some reason!", 1)
wasConnected = False
End If
End If
Select currentScreen
Case 0 '' Login Screen
DoLoginScreen
If client Then
If client.auth Then
If client.totalSystems = curGame.systems.Count()
currentScreen = 1
ProcessChatCommand("help", "")
Else
currentScreen = 2
hasFinishedFirstSync = False
End If
EndIf
If Not client.Connected() Then client.Close() ; client = Null ; lastConnectTry = MilliSecs()
Else
If lastConnectTry - MilliSecs() < - 5000 Then If Not Connect(mainChat.GetVariable("server_ip".tolower())._var, ..
Int(mainChat.GetVariable("port")._var)) Then
client = Null
lastConnectTry = MilliSecs()
EndIf
EndIf
Case 1 '' Game Screen
DrawGameScreen()
UpdateGameScreen()
If Not client Then
currentScreen = 0
Else
If Not client.auth Then currentScreen = 0
If Not client.Connected() Then
client.Close()
client = Null
currentScreen = 0
lastConnectTry = MilliSecs()
selectedShips = 0
selectedSystem = Null
selectedFleet = Null
EndIf
EndIf
Case 2 '' Sync Screen
DoSyncScreen()
If Not client Then
currentScreen = 0
Else
If Not client.auth Then currentScreen = 0
If Not client.Connected() Then client.Close() ; client = Null ; currentScreen = 0;lastConnectTry = MilliSecs()
If curGame.systems.Count() = client.totalSystems And curGame.fleets.Count() = client.totalFleets And curGame.players.Count() = client.totalPlayers Then
currentScreen = 1
Else
If Not client.IsSyncingTGame Then
client.SendPacket(Packet.ID_UPDATEALL, "plz")
End If
EndIf
EndIf
End Select
''' Ping/Sync Info
DrawImage(menuBars[(client <> Null) + 1], scnx - 80, -8)
DrawPing(scnx - 56, 6)
DrawSync(scnx - 56 - 16, 6)
If tb.PointIn.MouseInRect(scnx - 80, 0, 80, 24) And client Then
If client.IsSyncingTGame Then
DrawText "Syncing now...", scnx - 128, 32
Else
DrawText "Last Sync:" + Int((MilliSecs() - client.lastSync) / 1000) + "s", scnx - 128, 32
End If
EndIf
Flip;Cls
Wend
End Function
Function UpdateClient()
wasConnected = True
justFinishedFirstSync = False
client.finishedSyncingThisFrame = False
client.Update()
If client.finishedSyncingThisFrame Then
If tgEnabled Then TerritorySquare.UpdateAll() ; TerritoryMesh.UpdateAll()
If Not hasFinishedFirstSync Then hasFinishedFirstSync = True ; justFinishedFirstSync = True ; currentScreen = 1
End If
If client.recievedMessages.Count() > 0
Local tmpStr:String = String(client.recievedMessages.RemoveFirst())
If tmpStr.Contains("`") Then
mainChat.add(tmpStr.Split("`")[0], Int(tmpStr.Split("`")[1]))
Else
mainChat.add(tmpStr)
EndIf
EndIf
If client.attacheUpdates.Count() > 0 Then
Local tmpStr:String = String(client.attacheUpdates.RemoveFirst())
If tmpStr.Contains("`") Then
attacheUpdates.add(tmpStr.Split("`")[0], Int(tmpStr.Split("`")[1]))
Else
attacheUpdates.add(tmpStr)
EndIf
End If
If MilliSecs() - client.lastPingRecv > 60 * 1000 And MilliSecs() - client.lastPingSent > 4 * 1000 Then
mainChat.add("[ERROR] Server Timeout! Haven't heard from the server in the last 60 seconds...", 1)
client.Close()
client = Null
wasConnected = False
ElseIf MilliSecs() - client.lastPingRecv > 5 * 1000 And MilliSecs() - client.lastPingSent > 4 * 1000 Then
client.SendPing()
EndIf
End Function
Function DoLoginScreen()
Local tmpX = scnx / 2 - 240
Local tmpY = scny / 2
usernameCH.SetPosition(tmpX + 16, tmpY + 24)
passwordCH.SetPosition(tmpX + 16, tmpY + 64)
If KeyHit(KEY_ENTER) And client Then
If usernameCH.currentString = "" Then
usernameCH.enabled = True
passwordCH.enabled = False
ElseIf passwordCH.currentString = "" Then
passwordCH.enabled = True
usernameCH.enabled = False
End If
If usernameCH.currentString <> "" And passwordCH.currentString <> "" Then
client.SendLogin(usernameCH.currentString, passwordCH.currentString)
settingsIni.set("user_name", usernameCH.currentString, "game")
passwordCH.currentString = ""
usernameCH.enabled = False
passwordCH.enabled = False
End If
End If
If KeyHit(KEY_TAB)
If usernameCH.enabled Then
passwordCH.enabled = True
usernameCH.enabled = False
ElseIf passwordCH.enabled
passwordCH.enabled = False
usernameCH.enabled = True
End If
End If
SetImageFont medFont
Local usernameSelected:Int = usernameCH.CheckInput()
Local passwordSelected:Int = passwordCH.CheckInput()
If usernameCH.enabled = False And passwordCH.enabled = False Then GetChar()
SetImageFont stdFont
If usernameSelected
usernameCH.enabled = True
passwordCH.enabled = False
ElseIf passwordSelected
usernameCH.enabled = False
passwordCH.enabled = True
Else
If msh[1] Then
usernameCH.enabled = False
passwordCH.enabled = False
End If
End If
SetLineWidth 32
SetAlpha 0.1
SetColor 96, 96, 128
tb.Draw.Circle(scnx / 2, scny / 2, scny / 3, scny / 8)
tb.Draw.Circle(scnx / 2, scny / 2, ((Sin((MilliSecs() * 0.2)) Mod 360) * (8 * (1 + (client <> Null)))) + (scny / 3), scny / 8)
SetColor 255, 255, 255
SetLineWidth 1
SetAlpha 0.05
mainChat.DrawList(0, 0, 1)
SetAlpha 0.9
SetImageFont lrgFont
tb.Draw.CenteredText("A Galaxy At War: Empires", scnx / 2, scny / 2 - 128)
tb.Draw.CenteredText(version, scnx / 2, scny / 2 - 128 + 32)
'DrawRect tmpX, tmpY, 320, 128
DrawImageRect(menuBars[3], tmpX - 4, tmpY - 4, 480 + 8, 128 + 8)
SetColor 96, 96, 128
DrawImageRect(menuBars[3], tmpX, tmpY, 480, 128)
SetColor 255, 255, 255
SetAlpha 1.0
SetImageFont medFont
usernameCH.Draw()
passwordCH.Draw()
SetImageFont stdFont
If client
SetColor 97, 255, 97
tb.Draw.CenteredText "Connected to " + mainChat.GetVariable("server_ip".tolower())._var + ":" + Int(mainChat.GetVariable("port")._var), scnx / 2, tmpY - 32
Else
SetColor 255, 97, 97
tb.Draw.CenteredText "Connecting to " + mainChat.GetVariable("server_ip".tolower())._var + ":" + Int(mainChat.GetVariable("port")._var), scnx / 2, tmpY - 32
End If
SetColor 255, 255, 255
End Function
Function DoSyncScreen()
Local tmpX = scnx / 2
Local tmpY = scny / 2
SetLineWidth 32
SetAlpha 0.1
SetColor 96, 96, 128
tb.Draw.Circle(tmpX, tmpY, scny / 3, scny / 8)
tb.Draw.Circle(tmpX, tmpY, ((Sin((MilliSecs() * 0.2)) Mod 360) * (24 * (1 + (client <> Null)))) + (scny / 3), scny / 8)
SetColor 255, 255, 255
SetLineWidth 1
SetAlpha 0.05
mainChat.DrawList(0, 0, 1)
SetAlpha 0.9
SetImageFont lrgFont
tb.Draw.CenteredText("A Galaxy At War: Empires", scnx / 2, scny / 2 - 128)
tb.Draw.CenteredText(version, scnx / 2, scny / 2 - 128 + 32)
SetColor 255, 255, 255
SetAlpha 1.0
SetImageFont medFont
tb.Draw.CenteredText("Syncing With Server...", tmpX, tmpY)
If client Then
If client.totalSystems > - 1 Then
Local tmpPercent:Float = Float(curgame.systems.Count() + curGame.players.Count()) / (Float(client.totalSystems) + Float(client.totalPlayers))
tb.Draw.CenteredText(Int(tmpPercent * 100) + "%", tmpX, tmpY + 32)
SetImageFont stdFont
tb.Draw.CenteredText("Systems: " + curGame.systems.Count() + " / " + client.totalSystems, tmpX, tmpY + 48 + (16 * 2))
' tb.Draw.CenteredText("Fleets: " + curGame.fleets.Count() + " / " + client.totalFleets, tmpX, tmpY + 48 + (16 * 2))
tb.Draw.CenteredText("Players: " + curGame.players.Count() + " / " + client.totalPlayers, tmpX, tmpY + 48 + (16 * 3))
End If
End If
SetImageFont stdFont
If client
SetColor 97, 255, 97
tb.Draw.CenteredText "Connected to " + mainChat.GetVariable("server_ip".tolower())._var + ":" + Int(mainChat.GetVariable("port")._var), tmpX, tmpY - 32
End If
SetColor 255, 255, 255
End Function
Function UpdateGameScreen()
If UpdateTopLeft()
GetChar
If KeyHit(KEY_ENTER) Then mainChat.enabled = True
If KeyHit(KEY_SLASH) Then mainChat.enabled = True; mainChat.currentString = "/"
Local tmp:Int = MouseZSpeed()
If tmp = 0 Then tmp = KeyHit(KEY_2) - KeyHit(KEY_1)
If tmp = 0 Then tmp = KeyHit(KEY_EQUALS) - KeyHit(KEY_MINUS)
If tmp < 0 Then
If Not (MAP_SCALE = 4) Then
currentXPan:/2
currentYPan:/2
End If
If MAP_SCALE = 8 Then MAP_SCALE = 4
If MAP_SCALE = 16 Then MAP_SCALE = 8
If MAP_SCALE = 32 Then MAP_SCALE = 16
If MAP_SCALE = 64 Then MAP_SCALE = 32
ElseIf tmp > 0 Then
If Not (MAP_SCALE = 64) Then
currentXPan:*2
currentYPan:*2
End If
If MAP_SCALE = 32 Then MAP_SCALE = 64
If MAP_SCALE = 16 Then MAP_SCALE = 32
If MAP_SCALE = 8 Then MAP_SCALE = 16
If MAP_SCALE = 4 Then MAP_SCALE = 8
If MAP_SCALE = 2 Then MAP_SCALE = 4
EndIf
If KeyHit(KEY_F3) Then
currentXPan = 0
currentYPan = 0
MAP_SCALE = 2
End If
' If client Then
currentYPan:+(KeyDown(KEY_DOWN) - KeyDown(KEY_UP)) * (MAP_SCALE / 4) * (tb.KeysDown(KEY_RSHIFT, KEY_LSHIFT) * 2 + 1)
currentXPan:+(KeyDown(KEY_RIGHT) - KeyDown(KEY_LEFT)) * (MAP_SCALE / 4) * (tb.KeysDown(KEY_RSHIFT, KEY_LSHIFT) * 2 + 1)
' currentYPan:+(KeyDown(KEY_S) - KeyDown(KEY_W)) * (MAP_SCALE / 4) * (tb.KeysDown(KEY_RSHIFT, KEY_LSHIFT) * 2 + 1)
' currentXPan:+(KeyDown(KEY_D) - KeyDown(KEY_A)) * (MAP_SCALE / 4) * (tb.KeysDown(KEY_RSHIFT, KEY_LSHIFT) * 2 + 1)
If KeyHit(KEY_HOME) Or KeyHit(KEY_SPACE) Then If client Then If client.ply Then
If Not client.ply.homeSystem Then client.ply.homeSystem = curGame.FindSystemID(client.ply.homeSystemID)
currentXPan = client.ply.homeSystem.x * MAP_SCALE
currentYPan = client.ply.homeSystem.Y * MAP_SCALE
'currentXPan = 0 ; currentYPan = 0
EndIf
If justFinishedFirstSync Then If client Then If client.ply Then
If Not client.ply.homeSystem Then client.ply.homeSystem = curGame.FindSystemID(client.ply.homeSystemID)
currentXPan = client.ply.homeSystem.x * MAP_SCALE
currentYPan = client.ply.homeSystem.Y * MAP_SCALE
EndIf
If KeyHit(KEY_F)
Local result:String = RequestText("Find System", "Enter System ID #")
If result <> "" Then
selectedSystem = curGame.FindSystemID(Int(result))
currentXPan = selectedSystem.x * MAP_SCALE
currentYPan = selectedSystem.Y * MAP_SCALE
selectedFleet = Null
targetSystem = Null
selectedShips = 0
bottomLeftWindow = 0
End If
End If
' EndIf
End If
'''''''''''''''''''' Update drag stuff
If midDrag And Not msd[1] Then
midDrag = False
currentXPan:-(MouseX() - dragX)
currentYPan:-(MouseY() - dragY)
End If
If msh[1] Then
selectedShips = 0
selectedSystem = Null
selectedFleet = Null
If msd[1] Then
If Not midDrag Then
midDrag = True
dragX = MouseX()
dragY = MouseY()
End If
End If
EndIf
tb.FlushKeyHits()
End Function
Function DrawGameScreen()
Const TerritorySquareDepth:Float = 0.95
'''''''''''''''''
''' Draw Systems and Fleets
If KeyHit(KEY_F5) Then TerritorySquare.UpdateAll() ; TerritoryMesh.UpdateAll() ;tgEnabled = True
If KeyHit(KEY_F6) Then tgEnabled = False
DrawBottomLeftWindow()
Cls
If Not midDrag Then
SetOrigin Int((scnx / 2) - currentXPan), Int((scny / 2) - currentYPan)
Else
SetOrigin Int((scnx / 2) - currentXPan + (MouseX() - dragX)), Int((scny / 2) - currentYPan + (MouseY() - dragY))
EndIf
If tgEnabled Then
SetLineWidth(3)
TerritorySquare.DrawAll()
TerritoryMesh.DrawAll()
SetLineWidth(1)
EndIf
DrawGalaxyGrid
totalships = 0
DrawGalaxyMap
SetOrigin(0, 0)
' If client Then
If targetSystem And selectedSystem Then
If selectedShips > 0 Then
If tb.Draw.ClickableText("(S)end " + selectedShips + " ships", ..
(targetSystem.x * MAP_SCALE) + (scnx / 2) - currentXPan, ..
(targetSystem.y * MAP_SCALE) - (MAP_SCALE * 2.1) + (scny / 2) - currentYPan, ..
False, True, True) Or KeyHit(KEY_S) Then
msh[1] = 0
client.SendPacket(Packet.ID_CMDSENDFLEET, selectedSystem.netID + "`" + targetSystem.netID + "`" + selectedShips)
selectedShips = 0
targetSystem = Null
End If
EndIf
EndIf
' EndIf
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Draw GUI
SetAlpha 1.0
''' /System/ bars
SetColor 192, 192, 255
DrawImageRect(menuBars[0], 0, 0, scnx, menuBars[0].Height)
DrawImageRect(menuBars[0], 0, scny - menuBars[0].Height, scnx, menuBars[0].Height)
SetColor 255, 255, 255
''' Time '' (2900.0 + (curGame.CurrentTurn * 0.1))
DrawImage(menuBars[(client <> Null) + 1], scnx - 96 - 8, scny - menuBars[1].Height + 8)
DrawText "Year: " + curGame.GetYear(), scnx - 96, scny - menuBars[1].Height + 16
DrawTopLeft
''' sys/flt Counts
If Not client Then
tb.Draw.TextOutline("System Count: " + curGame.systems.Count(), (scnx - 216), 4)
tb.Draw.TextOutline("Fleet Count: " + curGame.fleets.Count(), (scnx - 216 - 128), 4)
Else
If client.ply Then
tb.Draw.TextOutline("Systems: " + curGame.CountOwnedSystems(client.ply.netID), (scnx - 216), 4)
tb.Draw.TextOutline("Fleets: " + curGame.CountOwnedFleets(client.ply.netID), (scnx - 216 - 100), 4)
If totalships > 0 Then tb.Draw.TextOutline("Ships: " + totalships, (scnx - 216 - 100 * 2), 4)
Else
tb.Draw.TextOutline("System Count: " + curGame.systems.Count(), (scnx - 216), 4)
tb.Draw.TextOutline("Fleet Count: " + curGame.fleets.Count(), (scnx - 216 - 128), 4)
EndIf
EndIf
DrawBottomLeftWindow()
''' Credits bar
If client Then If client.ply Then
'''' Research
If client.ply.researchAspect > - 1 And client.ply.untilNextDecimal > 0 Then
SetColor 0, 32, 0
DrawImage menuBars[1], (scnx / 2) - (menuBars[1].width / 2), 4
SetColor 0, 232, 0
tb.Draw.ImageProgress menuBars[1], (scnx / 2) - (menuBars[1].width / 2), 4, (Float(client.ply.currentResearchTurn) / Float(client.ply.untilNextDecimal))
SetColor 255, 255, 255
EndIf
SetColor 255, 255, 255
DrawImage menuBars[1], (scnx / 2) - (menuBars[1].width / 2), -4
SetColor 0, 0, 0
'tb.Draw.CenteredText("Credits: " + tb.Math.LimitDenom(client.ply.credits), (scnx / 2), 0)
'tb.Draw.CenteredText("Ship Cost:" + tb.Math.LimitDenom(10 + (5.0 * (client.ply.researchTopics[TPlayer.RES_FLEETSPEED])) + (15.0 * (client.ply.researchTopics[TPlayer.RES_FLEETWEAPONS]))), (scnx / 2), 16)
tb.Draw.CenteredText("Ship Build Time:", (scnx / 2), 0)
Local buildTurns:Int = Int(30.0 - (client.ply.researchTopics[TPlayer.RES_SHIPBUILDING]) - (client.ply.researchTopics[TPlayer.RES_RESEARCH] * 0.25))
If buildTurns < 5 Then buildTurns = 5
tb.Draw.CenteredText(tb.Math.LimitTime(buildTurns * (GAME_TICK_TIME * 0.001)) + " / " + tb.Math.LimitDecimal(buildTurns * 0.1) + " yr", (scnx / 2), 16)
'16 - Int(ply.researchTopics[TPlayer.RES_SHIPBUILDING])
SetColor 255, 255, 255
If client.ply.researchAspect > - 1 Then tb.Draw.CenteredText(client.ply.GetResearchTopicName(client.ply.researchAspect, False) + " " + Int((Float(client.ply.currentResearchTurn) / Float(client.ply.untilNextDecimal)) * 100) + "%", (scnx / 2), menuBars[1].Height - 8)
EndIf
End Function
Function Connect(ip:String, port:Int)
If client Then Return False
client = New TMasterClient.Create(TSocket.CreateTCP())
If client.Connect(HostIp(ip), port) Then
Print "Connected to Server!"
' client.SendText("Hello World!")
client.SendPacket(Packet.ID_UPDATEALL, "plz")
mainChat.add("[INFO] Connected to Server!", 2)
Else
'Notify "Failed to connect to server!"
mainChat.add("[ERROR] Failed to Connect to Server! Trying again in 5 seconds...", 1)
Return False
End If
currentXPan = 0
currentYPan = 0
Return True
End Function
Function ProcessChatCommand:Int(command:String, arguments:String)
Select command.ToLower()
Case "help"
If arguments.Length > 1 Then
'' The mainChat messages must be added in reverse order because that way they'll make the most sense
'' to the user.
Select Lower(arguments)
case "logout"
mainChat.add("[HELP] Description: Disconnects you from the game and returns you to the main menu.", 7)
mainChat.add("[HELP] Command: /"+arguments, 6)
case "setempirename"
mainChat.add("[HELP] Description: Changes the name of your empire to NAME.", 7)
mainChat.add("[HELP] Command: /setEmpireName NAME", 6)
case "sendships"
mainChat.add("[HELP] Description: Sends AMT_TO_SEND ships from ORIGIN's system ID to DEST's system ID.", 7)
mainChat.add("[HELP] Command: /sendShips ORIGIN_SYS_ID DEST_SYS_ID AMT_TO_SEND", 5)
case "toggleshipyard"
mainChat.add("[HELP] Description: Toggles whether the system's shipyards are actively building ships or not.", 7)
mainChat.add("[HELP] Command: /toggleShipyard SYSTEM_ID", 6)
case "join"
mainChat.add("[HELP] The player's homeworld begins with 50 + (CurrentTurn / 20) ships.", 7)
mainChat.add("[HELP] The player's homeworld is automatically a 10 quality.", 7)
mainChat.add("[HELP] The player's speciality is selected randomly.", 7)
mainChat.add("[HELP] Description: Joins the current game if a valid joinable system is found.", 7)
mainChat.add("[HELP] Command: /"+arguments, 6)
case "list"
mainChat.add("[HELP] Description: Lists the online players.", 7)
mainChat.add("[HELP] Command: /"+arguments, 6)
case "me"
mainChat.add("[HELP] Description: Sends a message in the 3rd person.", 7)
mainChat.add("[HELP] Command: /"+arguments, 6)
Default
arguments = "" ' Reset it so that it prints the generic help list below.
End Select
EndIf
If arguments.Length = 0 Then
Local cmds : String = ""
cmds = cmds + "logout" + ", "
cmds = cmds + "setEmpireName" + ", "
cmds = cmds + "sendShips" + ", "
cmds = cmds + "toggleShipyard" + ", "
cmds = cmds + "join" + ", "
cmds = cmds + "list" + ", "
cmds = cmds + "me"
mainChat.add("[HELP] Use '/help COMMAND_NAME' for additional information.", 7)
mainChat.add("[HELP] Supported commands: "+cmds, 6)
Endif
Case "login" '' TODO Players will never have to use this. Remove it?
If client Then
Local tmpstr:String[] = arguments.Replace("`", " ").split(" ")
If tmpstr.Length = 2 Then
client.SendLogin(tmpStr[0], tmpStr[1])
Else
mainChat.add("[ERROR] You need to provide both a username and a password.", 1)
End If
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "logout"
If client Then
client.SendPacket(Packet.ID_MESSAGESELF, "logs off")
client.Close()
client = Null
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "setempirename"
If client Then
client.SendPacket(Packet.ID_SETEMPIRENAME, arguments.Replace("`", ""))
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "sendships" '' TODO Players will never have to use this. Remove it?
If client Then
Local tmpstr:String[] = arguments.Replace("`", " ").split(" ")
If tmpStr.Length = 3 Then
client.SendPacket(Packet.ID_CMDSENDFLEET, Combine(tmpStr))
client.SendPacket(Packet.ID_UPDATEALL, "plz")
Else
mainChat.add("[ERROR] You need to provide a starting system, a destination system, and the amount of ships you want.", 1)
End If
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "toggleshipyard"
If client Then
client.SendPacket(Packet.ID_CMDBUILDSHIP, arguments.Replace("`", " "))
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "join"
If client Then
client.SendPacket(Packet.ID_JOINREQUEST, arguments.Replace("`", " "))
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "list"
If client Then
client.SendPacket(Packet.ID_USERLIST, "plz")
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "me"
If client Then
client.SendPacket(Packet.ID_MESSAGESELF, arguments.Replace("`", " "))
Else
mainChat.add("[ERROR] Cannot " + command + " because you aren't connected yet!", 1)
EndIf
Case "connect" '' TODO Players will never have to use this. Remove it?
If Not client Then
If arguments <> ""
Local tmpstr:String[] = arguments.Replace("`", " ").split(":")
If tmpstr.Length = 2 Then
Connect(tmpstr[0], Int(tmpstr[1]))
ElseIf tmpStr.Length = 1 Then
Connect(mainChat.GetVariable(arguments.tolower())._var, Int(mainChat.GetVariable("port")._var))
Else
mainChat.add("[ERROR] You need to provide a IP and/or a port!", 1)
End If
Else
mainChat.add("[ERROR] No IP/Port or variable name given!", 1)
End If
Else
mainChat.add("[ERROR] Cannot " + command + " because you are already connected!", 1)
EndIf
Default
mainChat.add("[ERROR] Command '" + command + "' is not recongized", 1)
End Select
Return 0
End Function
Function DrawPing(pbX = 0, pbY = 0)
Local pingDelta = 0
If client Then
pingDelta = client.pingDelta
'client.IsSyncingTGame
SetColor 0, 255, 0
Else
SetColor 128, 0, 0
EndIf
DrawText("" + pingDelta, pbX + 18, pbY)
SetLineWidth 3
pbX:+4
pbY:+1
SetAlpha 0.25 ; If pingDelta < 200 Then SetAlpha 0.9
DrawLine pbX, pbY, pbX, pbY + 12
pbX:+4
SetAlpha 0.25 ; If pingDelta < 400 Then SetAlpha 0.9
DrawLine pbX, pbY + 3, pbX, pbY + 12
pbX:+4
SetAlpha 0.25 ; If pingDelta < 600 Then SetAlpha 0.9
DrawLine pbX, pbY + 6, pbX, pbY + 12
pbX:+4
SetAlpha 0.25 ; If pingDelta < 800 Then SetAlpha 0.9
DrawLine pbX, pbY + 9, pbX, pbY + 12
SetLineWidth 1
SetAlpha 1.0
SetColor 255, 255, 255
End Function
Function DrawSync(xx:Int, yy:Int)
If client Then
SetColor 0, 255, 0
SetAlpha 0.75
'client.IsSyncingTGame
If client.IsSyncingTGame = True Then
DrawOval xx, yy, 8, 12
DrawOval xx + 4, yy, 8, 12
ElseIf client.IsSyncingTGame = False Then
DrawOval xx, yy, 12, 12
End If
Else
SetColor 128, 0, 0
SetLineWidth 3
DrawLine xx, yy, xx + 12, yy + 12
DrawLine xx + 12, yy, xx, yy + 12
EndIf
SetLineWidth 1
SetAlpha 1.0
SetColor 255, 255, 255
End Function
Function DrawBottomLeftWindow()
Local tmpX:Int = 16, tmpY = scny
Select bottomLeftWindow
Case 0
tmpX = 232 '209 '440
If selectedSystem Then '''''''''''''''''''''''''''''''''' SYSTEM
tmpY = 96 + 64 + 64'16
SetColor 255, 255, 255
DrawImageRect(menuBars[3], 0, scny - tmpY - 3, tmpX + 3, tmpY + 3)
SetColor 96, 96, 128
DrawImageRect(menuBars[3], 0, scny - tmpY, tmpX, tmpY + 32)
SetColor 255, 255, 255
tmpY = (tmpY - 12)
tb.Draw.TextOutline("Selected System ID:" + selectedSystem.netID, 16, scny - tmpY)
If curGame.FindPlayerID(selectedSystem.owner) Then
tb.Draw.TextOutline("Owner: " + curGame.FindPlayerID(selectedSystem.owner).empireName, 16, scny - tmpY + (16 * 1))
Else
tb.Draw.TextOutline("Owner: None", 16, scny - tmpY + (16 * 1))
End If
tb.Draw.TextOutline("Position: x[" + selectedSystem.x + "] y[" + selectedSystem.y + "]", 16, scny - tmpY + (16 * 2))
tb.Draw.TextOutline("Ships In Orbit: " + selectedSystem.ships, 16, scny - tmpY + (16 * 3))
tb.Draw.TextOutline("New Ship In: " + tb.Math.LimitDecimal((selectedSystem.CalculateNewShipTime() - selectedSystem.lastBuild) * 0.1) + " years", 16, scny - tmpY + (16 * 5))
If selectedSystem.isBuilding > 0 Then
If tb.Draw.ClickableText("(B)uilding/Researching: Building", 16, scny - tmpY + (16 * 6) + 4, False, False, True) Or KeyHit(KEY_B) Then
client.SendPacket(Packet.ID_CMDBUILDSHIP, selectedSystem.netID)
selectedSystem.isBuilding:*- 1
msh[1] = False
EndIf
ElseIf selectedSystem.isBuilding < 0 Then
If tb.Draw.ClickableText("(B)uilding/Researching: Researching", 16, scny - tmpY + (16 * 6) + 4, False, False, True) Or KeyHit(KEY_B) Then
client.SendPacket(Packet.ID_CMDBUILDSHIP, selectedSystem.netID)
selectedSystem.isBuilding:*- 1
msh[1] = False
EndIf
Else
tb.Draw.TextOutline("Building/Researching: n/a", 16, scny - tmpY + (16 * 6) + 4)
EndIf
tb.Draw.TextOutline("Planet Quailty: " + selectedSystem.quality, 16, scny - tmpY + (16 * 8))
ElseIf selectedFleet'''''''''''''''''''''''''''''''''' FLEET
tmpx:+16
tmpY = 96 + 32
If selectedFleet.homeID > - 1 And selectedFleet.destID > - 1 Then tmpY:+64'96
If client Then If client.ply Then If selectedFleet.owner = client.ply.netID Then tmpY:+32
SetColor 255, 255, 255
DrawImageRect(menuBars[3], 0, scny - tmpY - 3, tmpX + 3, tmpY + 3)
SetColor 96, 96, 128
DrawImageRect(menuBars[3], 0, scny - tmpY, tmpX, tmpY + 32)
SetColor 255, 255, 255
tmpY = (tmpY - 12)
' tb.Draw.TextOutline("x[" + selectedFleet.damageOutput + "] y[" + selectedFleet.damageTaken + "]", 16, scny - tmpY - (16 * 4))
tb.Draw.TextOutline("Selected Fleet ID:" + selectedFleet.netID, 16, scny - tmpY)
If selectedFleet.owner > 0 Then
tb.Draw.TextOutline("Owner: " + curGame.FindPlayerID(selectedFleet.owner).empireName, 16, scny - tmpY + (16 * 1))
Else
tb.Draw.TextOutline("Owner: None", 16 + 225, scny - tmpY + (16 * 1))
End If
tb.Draw.TextOutline("Position: x[" + tb.Math.LimitDecimal(selectedFleet.x) + "] y[" + tb.Math.LimitDecimal(selectedFleet.y) + "]", ..
16, scny - tmpY + (16 * 2))
tb.Draw.TextOutline("Ships In Fleet: " + selectedFleet.strength, 16, scny - tmpY + (16 * 3))
If selectedFleet.homeID > - 1 And selectedFleet.destID > - 1 Then
If Not selectedFleet.destSys Then selectedFleet.destSys = curGame.FindSystemID(selectedFleet.destID)
If Not selectedFleet.destSys Then
tb.Draw.TextOutline("Distance: ???", 16, scny - tmpY + (16 * 4))
Else
Local etaCalc:Float = tb.Math.GetDistance(selectedFleet.x, selectedFleet.y, selectedFleet.destSys.x, selectedFleet.destSys.y)
tb.Draw.TextOutline("Distance: " + tb.Math.LimitDecimal(etaCalc, 2) + "u", 16, scny - tmpY + (16 * 5))
If selectedFleet.destID > - 1 And selectedFleet.speed > 0.0
etaCalc:/(selectedFleet.speed * curGame.movementTimeScale)
tb.Draw.TextOutline("ETA: " + Int(etaCalc + 1.0) + " turns / " + tb.Math.LimitTime(etaCalc * (GAME_TICK_TIME * 0.001)), 16, scny - tmpY + (16 * 6))
End If
End If
tb.Draw.TextOutline("From ID:[" + selectedFleet.homeID + "] Dest ID:[" + selectedFleet.destID + "]", 16, scny - tmpY + (16 * 7))
If client Then If client.ply Then If selectedFleet.owner = client.ply.netID Then
If tb.Draw.ClickableText("(T)urn Fleet Around", 16, scny - tmpY + (16 * 8) + 4, False, False, True) Or KeyHit(KEY_T) Then
client.SendPacket(Packet.ID_CMDRETREATFLEET, selectedFleet.netID)
Local tsys:TSystem = selectedFleet.homeSys, tnetID:Int = selectedFleet.homeID
selectedFleet.homeSys = selectedFleet.destSys
selectedFleet.homeID = selectedFleet.destID
selectedFleet.destSys = tsys
selectedFleet.destID = tnetID
msh[1] = False
End If
If selectedFleet.speed <= 0.5 Then
If tb.Draw.ClickableText("(C)ontinue", 16, scny - tmpY + (16 * 9) + 8, False, False, True) Or KeyHit(KEY_C) Then ..
client.SendPacket(Packet.ID_CMDSTARTFLEET, selectedFleet.netID)
Else
If tb.Draw.ClickableText("(S)top Fleet", 16, scny - tmpY + (16 * 9) + 8, False, False, True) Or KeyHit(KEY_S) Then ..
client.SendPacket(Packet.ID_CMDSTOPFLEET, selectedFleet.netID)
End If
End If
EndIf
End If
Case 1 '''''''''''''''''''''''''''''''''' RESEACH
SetColor 255, 255, 255
DrawImageRect(menuBars[3], 0, scny - 96 - 96 - 3, 440 + 3, 96 + 96 + 3)
SetColor 96, 96, 128
DrawImageRect(menuBars[3], 0, scny - 96 - 96, 440, 96 + 96 + 32)
SetColor 255, 255, 255
If client Then If client.ply Then
tb.Draw.TextOutline("Current Research Progress:", 16, scny - 84 - 96)
'if client.ply.prefered then drawtext
For Local ii:Int = 0 Until client.ply.researchTopics.Length - 1
If tb.Draw.ClickableText(client.ply.GetResearchTopicName(ii) + "", 16, scny - 84 - 96 + 24 + (16 * ii), False, False, True) Then
client.SendPacket(Packet.ID_RESEARCHSTART, ii)
client.ply.researchAspect = ii
client.ply.currentResearchTurn = 0
client.ply.untilNextDecimal = client.ply.researchTopics[client.ply.researchAspect] * (GAME_TICK_TIME * 0.001)
If client.ply.researchAspect = TPlayer.RES_FUELRANGE Then client.ply.untilNextDecimal:*(1 / 5.0)
If client.ply.researchAspect = TPlayer.RES_RADARRANGE Then client.ply.untilNextDecimal:*(1 / 5.0)
If client.ply.researchAspect = TPlayer.RES_FLEETSPEED Then client.ply.untilNextDecimal:*(1 / 2.0)
If client.ply.researchAspect = client.ply.preferedResearchAspect Then client.ply.untilNextDecimal:*(9 / 10.0)
EndIf
If ii = client.ply.researchAspect Then tb.Draw.TextOutline(">", 16 + 8 + 176, scny - 84 - 96 + 24 + (16 * ii))
tb.Draw.TextOutline(tb.Math.LimitDecimal(client.ply.researchTopics[ii]), 16 + 176 + 32, scny - 84 - 96 + 24 + (16 * ii))
If ii = client.ply.researchAspect And client.ply.untilNextDecimal > 0 Then
Local tmp:Int = (client.ply.untilNextDecimal - client.ply.currentResearchTurn)
' tb.Draw.CenteredText(tb.Math.LimitTime(buildTurns * (GAME_TICK_TIME * 0.001)) + " / " + tb.Math.LimitDecimal(buildTurns * 0.1) + " yr", (scnx / 2), 16)
tb.Draw.TextOutline(Int((Float(client.ply.currentResearchTurn) / Float(client.ply.untilNextDecimal)) * 100) + "% (Time Left: " + ..
tb.Math.LimitTime((GAME_TICK_TIME * 0.001) * tmp) + " / " + tb.Math.LimitDecimal(tmp * 0.1) + " yrs)", 16 + 225 + 32, scny - 84 - 96 + 24 + (16 * ii))
Local researchCost = (client.ply.untilNextDecimal - client.ply.currentResearchTurn) * 625
If client.ply.researchAspect = client.ply.preferedResearchAspect Then researchCost = Int(researchCost * (4 / 5.0))
If researchCost > client.ply.credits Then tb.Draw.SetRGB("red")
' If tb.Draw.ClickableText("Pay " + tb.Math.LimitDenom(researchCost) + " to Advance Right Away", 16 + 225 - 32, scny - 84 - 96, 0, 0, 1) Then ..
' client.SendPacket(Packet.ID_RESEARCHPAY, "plz")
tb.Draw.SetGrey(255)
DrawText ("Research Points: " + client.ply.credits, 16 + 225 - 32, scny - 84 - 96)
EndIf
Next
EndIf
Case 2''''''''''''''''''''''''''''''''''''''''''''''''' EMPIRES
tmpX = 340'440
tmpY = (curGame.players.Count() * 16) + 64
SetColor 255, 255, 255
DrawImageRect(menuBars[3], 0, scny - tmpY - 3, tmpX + 3, tmpY + 3)
SetColor 96, 96, 128
DrawImageRect(menuBars[3], 0, scny - tmpY, tmpX, tmpY + 32)
SetColor 255, 255, 255
tmpY = (tmpY - 12)
tb.Draw.TextOutline("Active Empires:", 16 + (56 * 0), scny - tmpY + (16 * 0))
tb.Draw.TextOutline("Systems:", 16 + 225, scny - tmpY + (16 * 0))
Local ii:Int = 0
''''
Local tmpPlayers:TList = curGame.players.copy()
Local tmpSorted:TList = CreateList()
While tmpPlayers.Count() > 0
Local highestTerritories = 0, highestplyr:TPlayer = TPlayer(tmpPlayers.First())
For Local tply:TPlayer = EachIn tmpPlayers
Local terrCount = curgame.CountOwnedSystems(tply.netID)
If terrcount > highestTerritories Then highestTerritories = terrcount; highestplyr = tply
Next
If highestplyr
tmpSorted.AddLast(highestplyr)
tmpPlayers.remove(highestplyr)
Else
Exit
EndIf
Wend
For Local tply:TPlayer = EachIn tmpSorted
ii:+1
If curGame.CountOwnedSystems(tply.netID) > 0 Then
SetAlpha 1.0
Else
SetAlpha 0.5
EndIf
tb.Draw.TextOutline(tply.empireName, 16 + (56 * 0), scny - tmpY + (16 * ii), False, "0,0,0", tply.rgb)
SetColor 255, 255, 255
tb.Draw.TextOutline(curGame.CountOwnedSystems(tply.netID), 16 + 225, scny - tmpY + (16 * ii))
tb.Draw.TextOutline(Int((Float(curGame.CountOwnedSystems(tply.netID)) / Float(curGame.systems.Count())) * 100) + "%", 16 + (56 * 4) + 40, scny - tmpY + (16 * ii))
SetAlpha 1.0
SetColor 255, 255, 255
Next
Default
'
End Select
If bottomLeftWindow = 0 Then
DrawImage(menuBars[1], -16, scny - menuBars[1].Height + 8)
tb.Draw.TextOutline("Selection", 16, scny - menuBars[1].Height + 16)', False, "0,0,0", "192,192,255")
Else
If tb.Draw.ClickableImage(menuBars[2], -16, scny - menuBars[1].Height + 8) Then bottomLeftWindow = 0
' DrawImage()
SetColor 0, 0, 0
DrawText "Selection", 16, scny - menuBars[1].Height + 16
SetColor 255, 255, 255
End If
If bottomLeftWindow = 1 Then
DrawImage(menuBars[1], (menuBars[1].width * 1) - 16, scny - menuBars[1].Height + 8)
tb.Draw.TextOutline("Research", (menuBars[1].width * 1) + 16, scny - menuBars[1].Height + 16)', False, "0,0,0", "192,192,255")
Else
If tb.Draw.ClickableImage(menuBars[2], (menuBars[1].width * 1) - 16, scny - menuBars[1].Height + 8) Then bottomLeftWindow = 1
' DrawImage(menuBars[2], (menuBars[1].width * 1) - 16, scny - menuBars[1].Height + 8)
SetColor 0, 0, 0
DrawText "Research", (menuBars[1].width * 1) + 16, scny - menuBars[1].Height + 16
SetColor 255, 255, 255
End If
If bottomLeftWindow = 2 Then
DrawImage(menuBars[1], (menuBars[1].width * 2) - 16, scny - menuBars[1].Height + 8)
tb.Draw.TextOutline("Empires", (menuBars[1].width * 2) + 16, scny - menuBars[1].Height + 16)', False, "0,0,0", "192,192,255")
Else
If tb.Draw.ClickableImage(menuBars[2], (menuBars[1].width * 2) - 16, scny - menuBars[1].Height + 8) Then bottomLeftWindow = 2
' DrawImage(menuBars[2], (menuBars[1].width * 1) - 16, scny - menuBars[1].Height + 8)
SetColor 0, 0, 0
DrawText "Empires", (menuBars[1].width * 2) + 16, scny - menuBars[1].Height + 16
SetColor 255, 255, 255
End If
End Function
Function DrawGalaxyGrid()
SetAlpha 0.2
DrawLine - 300 * MAP_SCALE, 0, 300 * MAP_SCALE, 0
DrawLine 0, -300 * MAP_SCALE, 0, 300 * MAP_SCALE
DrawText "25u", 25 * MAP_SCALE, 0
DrawText "50u", 50 * MAP_SCALE, 0
DrawText "75u", 75 * MAP_SCALE, 0
DrawText "100u", 100 * MAP_SCALE, 0
DrawText "150u", 150 * MAP_SCALE, 0
DrawText "200u", 200 * MAP_SCALE, 0