forked from Courseplay/courseplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hud.lua
2427 lines (2176 loc) · 120 KB
/
hud.lua
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
---@class courseplay.hud
courseplay.hud = {};
local abs, ceil, floor, max = math.abs, math.ceil, math.floor, math.max;
local function round(num)
return floor(num + 0.5);
end
courseplay.hud.sizeRatio = 1;
courseplay.hud.uiScale = g_gameSettings:getValue("uiScale");
-- px are in targetSize for 1920x1080
function courseplay.hud:pxToNormal(px, dimension, fullPixel)
local ret;
if dimension == 'x' then
ret = (px / 1920) * courseplay.hud.sizeRatio * courseplay.hud.uiScale * g_aspectScaleX;
else
ret = (px / 1080) * courseplay.hud.sizeRatio * courseplay.hud.uiScale * g_aspectScaleY;
end;
if fullPixel == nil or fullPixel then
ret = self:getFullPx(ret, dimension);
end;
return ret;
end;
function courseplay.hud:getFullPx(n, dimension)
if dimension == 'x' then
return round(n * g_screenWidth) / g_screenWidth;
else
return round(n * g_screenHeight) / g_screenHeight;
end;
end;
function courseplay.hud:getPxToNormalConstant(widthPx, heightPx)
return widthPx/g_screenWidth, heightPx/g_screenHeight;
end;
-- 800x600: g_cM vehicleHudPosX=0.826458, vehicleHudPosY=0.020833, vehicleBaseHudHeight=0.027708, vehicleHudScale=0.700000
-- 1024x768: g_cM vehicleHudPosX=0.826458, vehicleHudPosY=0.020833, vehicleBaseHudHeight=0.027708, vehicleHudScale=0.700000
-- 1280x800: g_cM vehicleHudPosX=0.826458, vehicleHudPosY=0.025000, vehicleBaseHudHeight=0.033250, vehicleHudScale=0.700000
-- 1680x1050: g_cM vehicleHudPosX=0.826458, vehicleHudPosY=0.025000, vehicleBaseHudHeight=0.033250, vehicleHudScale=0.700000
-- 1920x1080: g_cM vehicleHudPosX=0.826458, vehicleHudPosY=0.027778, vehicleBaseHudHeight=0.036944, vehicleHudScale=0.700000
-- ####################################################################################################
-- SETUP
courseplay.hud.basePosX = 0.5 - courseplay.hud:pxToNormal(630 / 2, 'x'); -- Center Screen - half hud width
courseplay.hud.basePosY = courseplay.hud:pxToNormal(32, 'y');
function courseplay.hud:setup()
-- self = courseplay.hud
print('## Courseplay: setting up hud');
self.PAGE_COMBINE_CONTROLS = 0;
self.PAGE_CP_CONTROL = 1;
self.PAGE_MANAGE_COURSES = 2;
self.PAGE_COMBI_MODE = 3;
self.PAGE_MANAGE_COMBINES = 4;
self.PAGE_SPEEDS = 5;
self.PAGE_GENERAL_SETTINGS = 6;
self.PAGE_DRIVING_SETTINGS = 7;
self.PAGE_COURSE_GENERATION = 8;
self.PAGE_SHOVEL_POSITIONS = 9;
self.PAGE_BUNKERSILO_SETTINGS = 10;
self.basePosX = courseplay.hud.basePosX;
self.basePosY = courseplay.hud.basePosY;
self.baseWidth = self:pxToNormal(630, 'x');
self.baseHeight = self:pxToNormal(347, 'y');
self.baseCenterPosX = self.basePosX + self.baseWidth * 0.5;
self.baseUVsPx = { 10,357, 640,10 };
self.baseWithModeButtonsUVsPx = {10,724, 640,377 };
self.baseTextureSize = {
x = 1024;
y = 1024;
};
-- COLORS NOTE:
-- Because Giants fucked up big time, overlay colors that don't use full values are displayed way brighter than they should.
-- Until Giants fixes this, we're gonna have to use fake color values that effectively produce our desired colors
self.colors = {
white = courseplay.utils:rgbToNormal(255, 255, 255, 1.00),
whiteInactive = courseplay.utils:rgbToNormal(255, 255, 255, 0.75),
whiteDisabled = courseplay.utils:rgbToNormal(255, 255, 255, 0.15),
hover = courseplay.utils:rgbToNormal( 4, 98, 180, 1.00), -- IS FAKE COLOR! ORIG COLOR: 32/168/219/1
activeGreen = courseplay.utils:rgbToNormal( 43, 205, 10, 1.00), -- IS FAKE COLOR! ORIG COLOR: 110/235/56/1
activeRed = courseplay.utils:rgbToNormal(153, 22, 19, 1.00), -- IS FAKE COLOR! ORIG COLOR: 206/83/77/1
closeRed = courseplay.utils:rgbToNormal(116, 0, 0, 1.00), -- IS FAKE COLOR! ORIG COLOR: 180/0/0/1
warningRed = courseplay.utils:rgbToNormal(222, 2, 3, 1.00), -- IS FAKE COLOR! ORIG COLOR: 240/25/25/1
shadow = courseplay.utils:rgbToNormal( 4, 4, 4, 1.00), -- IS FAKE COLOR! ORIG COLOR: 35/35/35/1
textDark = courseplay.utils:rgbToNormal( 1, 1, 1, 1.00) -- IS FAKE COLOR! ORIG COLOR: 15/15/15/1
};
self.visibleArea = {};
self.visibleArea.width = self:pxToNormal(600, 'x');
self.visibleArea.x1 = self.basePosX + self:pxToNormal(15, 'x');
self.visibleArea.x2 = self.visibleArea.x1 + self.visibleArea.width;
self.visibleArea.height = self:pxToNormal(326, 'y');
self.visibleArea.y1 = self.basePosY + self:pxToNormal(8, 'y');
self.visibleArea.y2 = self.visibleArea.y1 + self.visibleArea.height;
--print(string.format("\t\tposX=%f,posY=%f, visX1=%f,visX2=%f, visY1=%f,visY2=%f, visCenter=%f", self.basePosX, self.basePosY, self.visibleArea.x1, self.visibleArea.x2, self.visibleArea.y1, self.visibleArea.y2, self.baseCenterPosX));
-- LINES AND TEXT
self.fontSizes = {
seedUsageCalculator = self:pxToNormal(16, 'y');
pageTitle = self:pxToNormal(22, 'y');
contentTitle = self:pxToNormal(17, 'y');
contentValue = self:pxToNormal(15, 'y');
bottomInfo = self:pxToNormal(16, 'y');
bottomInfoSmall = self:pxToNormal(13, 'y');
version = self:pxToNormal(11, 'y');
infoText = self:pxToNormal(16, 'y');
};
self.numPages = 10;
self.numLines = 8;
self.lineHeight = self:pxToNormal(23, 'y');
self.linesPosY = {};
self.linesButtonPosY = {};
for l=1,self.numLines do
if l == 1 then
self.linesPosY[l] = self.basePosY + self:pxToNormal(229 + 23*0.5 - 17*0.5 + 2, 'y'); -- gfx line bottom y + lineHeight/2 - fontSize/2 plus some magic 2px for good measure
self.linesButtonPosY[l] = self.basePosY + self:pxToNormal(229 + 23*0.5 - 16*0.5, 'y'); -- gfx line bottom y + lineHeight/2 - buttonSize/2
else
self.linesPosY[l] = self.linesPosY[1] - ((l-1) * self.lineHeight);
self.linesButtonPosY[l] = self.linesButtonPosY[1] - ((l-1) * self.lineHeight);
end;
end;
self.contentMinX = self.visibleArea.x1 + self:pxToNormal(10, 'x');
self.contentMaxX = self.visibleArea.x2 - self:pxToNormal(10, 'x');
self.contentMaxWidth = self.contentMaxX - self.contentMinX;
self.col1posX = self.contentMinX;
self.col2posX = {
[self.PAGE_COMBINE_CONTROLS] = self.basePosX + self:pxToNormal(368, 'x'),
[self.PAGE_CP_CONTROL] = self.basePosX + self:pxToNormal(368, 'x'),
[self.PAGE_MANAGE_COURSES] = self.basePosX + self:pxToNormal(234, 'x'),
[self.PAGE_COMBI_MODE] = self.basePosX + self:pxToNormal(368, 'x'),
[self.PAGE_MANAGE_COMBINES] = self.basePosX + self:pxToNormal(234, 'x'),
[self.PAGE_SPEEDS] = self.basePosX + self:pxToNormal(234, 'x'),
[self.PAGE_GENERAL_SETTINGS] = self.basePosX + self:pxToNormal(350, 'x'),
[self.PAGE_DRIVING_SETTINGS] = self.basePosX + self:pxToNormal(368, 'x'),
[self.PAGE_COURSE_GENERATION] = self.basePosX + self:pxToNormal(368, 'x'),
[self.PAGE_SHOVEL_POSITIONS] = self.basePosX + self:pxToNormal(390, 'x'),
[self.PAGE_BUNKERSILO_SETTINGS] = self.basePosX + self:pxToNormal(390, 'x'),
};
self.col2posXforce = {
--[[[self.PAGE_COMBINE_CONTROLS] = {
[4] = self.basePosX + self:pxToNormal(407, 'x');
[5] = self.basePosX + self:pxToNormal(407, 'x');
[7] = self.basePosX + self:pxToNormal(407, 'x');
};
[self.PAGE_GENERAL_SETTINGS] = {
[4] = self.basePosX + self:pxToNormal(240, 'x');
};
[self.PAGE_DRIVING_SETTINGS] = {
[7] = self.basePosX + self:pxToNormal(202, 'x');
[8] = self.basePosX + self:pxToNormal(202, 'x');
};]]
};
self.col3posX = {
[self.PAGE_COURSE_GENERATION] = self.basePosX + self:pxToNormal(450, 'x'),
};
self.versionPosY = self.visibleArea.y1 + self:pxToNormal(16, 'y');
-- PAGE TITLES
self.pageTitles = {
[self.PAGE_COMBINE_CONTROLS] = courseplay:loc("COURSEPLAY_PAGE_TITLE_COMBINE_CONTROLS"), -- combine controls
[self.PAGE_CP_CONTROL] = courseplay:loc("COURSEPLAY_PAGE_TITLE_CP_CONTROL"), -- courseplay control
[self.PAGE_MANAGE_COURSES] = { courseplay:loc("COURSEPLAY_PAGE_TITLE_MANAGE_COURSES"), courseplay:loc("COURSEPLAY_PAGE_TITLE_CHOOSE_FOLDER"), courseplay:loc("COURSEPLAY_COURSES_FILTER_TITLE") }, -- courses & filter
[self.PAGE_COMBI_MODE] = courseplay:loc("COURSEPLAY_PAGE_TITLE_COMBI_MODE"), -- combi mode settings
[self.PAGE_MANAGE_COMBINES] = courseplay:loc("COURSEPLAY_PAGE_TITLE_MANAGE_COMBINES"), -- manage combines
[self.PAGE_SPEEDS] = courseplay:loc("COURSEPLAY_PAGE_TITLE_SPEEDS"), -- speeds
[self.PAGE_GENERAL_SETTINGS] = courseplay:loc("COURSEPLAY_PAGE_TITLE_GENERAL_SETTINGS"), -- general settings
[self.PAGE_DRIVING_SETTINGS] = courseplay:loc("COURSEPLAY_PAGE_TITLE_DRIVING_SETTINGS"), -- Driving settings
[self.PAGE_COURSE_GENERATION] = courseplay:loc("COURSEPLAY_MODESPECIFIC_SETTINGS"), -- course generation
[self.PAGE_SHOVEL_POSITIONS] = courseplay:loc("COURSEPLAY_SHOVEL_POSITIONS"), -- shovel
[self.PAGE_BUNKERSILO_SETTINGS] = courseplay:loc("COURSEPLAY_MODE10_SETTINGS") -- compacter
};
self.pageTitlePosX = self.visibleArea.x1 + self:pxToNormal(55, 'x');
self.pageTitlePosY = self.visibleArea.y1 + self:pxToNormal(249 + 34*0.5 - 23*0.5 + 5, 'y'); -- title line bottom y + title line height/2 - fontSize/2 plus some magic 5px for good measure
-- BUTTON SIZES AND POSITIONS
self.buttonSize = {
big = {
w = self:pxToNormal(32, 'x');
h = self:pxToNormal(32, 'y');
margin = self:pxToNormal(10, 'x');
};
middle = {
w = self:pxToNormal(24, 'x');
h = self:pxToNormal(24, 'y');
margin = self:pxToNormal(8, 'x');
};
small = {
w = self:pxToNormal(16, 'x');
h = self:pxToNormal(16, 'y');
margin = self:pxToNormal(8, 'x');
};
};
self.indent = self.buttonSize.small.w * 1.25;
self.topIconsY = self.basePosY + self:pxToNormal(263, 'y');
self.buttonPosX = {};
for i=1,7 do
self.buttonPosX[i] = self.contentMaxX + self.buttonSize.small.margin - i * (self.buttonSize.small.w + self.buttonSize.small.margin);
end;
self.buttonCoursesPosX = {};
self.buttonCoursesPosX[0] = self.contentMinX;
for i=1,5 do
self.buttonCoursesPosX[i] = self.buttonPosX[i] - self.buttonSize.middle.w - self.buttonSize.middle.margin;
end;
-- ICON SPRITE
self.iconSpritePath = Utils.getFilename('img/iconSprite.png', courseplay.path);
self.iconSpriteSize = {
x = 256;
y = 512;
};
self.modeButtonsUVsPx = {
[courseplay.MODE_GRAIN_TRANSPORT] = { 112, 72, 144,40 };
[courseplay.MODE_COMBI] = { 148, 72, 180,40 };
[courseplay.MODE_OVERLOADER] = { 184, 72, 216,40 };
[courseplay.MODE_SEED_FERTILIZE] = { 220, 72, 252,40 };
[courseplay.MODE_TRANSPORT] = { 4,108, 36,76 };
[courseplay.MODE_FIELDWORK] = { 40,108, 72,76 };
[courseplay.MODE_BALE_COLLECTOR] = { 76,108, 108,76 };
[courseplay.MODE_FIELD_SUPPLY] = { 112,108, 144,76 };
[courseplay.MODE_SHOVEL_FILL_AND_EMPTY] = { 148,108, 180,76 };
[courseplay.MODE_BUNKERSILO_COMPACTER] = { 219,431, 251,399 };
};
self.pageButtonsUVsPx = {
[self.PAGE_COMBINE_CONTROLS] = { 4,36, 36, 4 };
[self.PAGE_CP_CONTROL] = { 40,36, 72, 4 };
[self.PAGE_MANAGE_COURSES] = { 76,36, 108, 4 };
[self.PAGE_COMBI_MODE] = { 112,36, 144, 4 };
[self.PAGE_MANAGE_COMBINES] = { 148,36, 180, 4 };
[self.PAGE_SPEEDS] = { 184,36, 216, 4 };
[self.PAGE_GENERAL_SETTINGS] = { 220,36, 252, 4 };
[self.PAGE_DRIVING_SETTINGS] = { 4,72, 36,40 };
[self.PAGE_COURSE_GENERATION] = { 40,72, 72,40 };
[self.PAGE_SHOVEL_POSITIONS] = { 76,72, 108,40 };
[self.PAGE_BUNKERSILO_SETTINGS] = { 219,431, 251,399 }; --{ 220,396, 252,365 };
};
self.buttonUVsPx = {
calculator = { 76,288, 108,256 };
cancel = { 40,288, 72,256 };
close = { 148,216, 180,184 };
copy = { 184,180, 216,148 };
courseAdd = { 40,252, 72,220 };
courseLoadAppend = { 4,252, 36,220 };
courseClear = { 184,360, 216,328 };
eye = { 148,180, 180,148 };
delete = { 184,216, 216,184 };
folderNew = { 220,216, 252,184 };
folderParentFrom = { 76,252, 108,220 };
folderParentTo = { 112,252, 144,220 };
headlandDirCW = { 4,324, 36,292 };
headlandDirCCW = { 40,324, 72,292 };
headlandOrdBef = { 112,288, 176,256 };
headlandOrdAft = { 184,288, 248,256 };
generateCourse = { 40, 72, 72, 40 };
courseGenSettings = { 220, 36, 252, 4 }; -- same as settings cogwheel for now
navUp = { 76,216, 108,184 };
navDown = { 112,216, 144,184 };
navLeft = { 4,216, 36,184 };
navRight = { 40,216, 72,184 };
navPlus = { 148,252, 180,220 };
navMinus = { 184,252, 216,220 };
recordingAddSplit = { 220,360, 252,328 };
recordingCross = { 76,180, 108,148 };
recordingDelete = { 148,360, 180,328 };
recordingPause = { 40,360, 72,328 };
recordingPlay = { 220,324, 252,292 };
recordingReverse = { 112,360, 144,328 };
recordingStop = { 76,360, 108,328 };
recordingTurn = { 4,360, 36,328 };
recordingWait = { 40,180, 72,148 };
recordingUnload = { 4,431, 36,399 };
refresh = { 220,252, 252,220 };
save = { 220,180, 252,148 };
search = { 4,288, 36,256 };
shovelLoading = { 76,324, 108,292 };
shovelUnloading = { 112,324, 144,292 };
shovelPreUnload = { 148,324, 180,292 };
shovelTransport = { 184,324, 216,292 };
waypointSignsAll = { 76,396, 144,364 };
waypointSignsEnd = { 148,396, 216,364 };
waypointSignsStart = { 4,396, 72,364 };
};
-- bottom info
self.bottomInfo = {};
self.bottomInfo.iconWidth = self.buttonSize.middle.w;
self.bottomInfo.iconHeight = self.buttonSize.middle.h;
self.bottomInfo.textPosY = self.basePosY + self:pxToNormal(36 + 16*0.5 + 1, 'y');
self.bottomInfo.textSmallPosY = self.bottomInfo.textPosY; -- + self:pxToNormal(1, 'y');
self.bottomInfo.iconPosY = self.basePosY + self:pxToNormal(36 + 30*0.5 - 24*0.5, 'y');
self.bottomInfo.modeIconX = self.col1posX;
self.bottomInfo.courseNameX = self.bottomInfo.modeIconX + self.bottomInfo.iconWidth * 1.25;
self.bottomInfo.crossingPointsIconX = self.contentMaxX - self.bottomInfo.iconWidth * 2;
self.bottomInfo.crossingPointsTextX = self.bottomInfo.crossingPointsIconX + self.bottomInfo.iconWidth * 1.5; -- rendered with center alignment
self.bottomInfo.waitPointsIconX = self.bottomInfo.crossingPointsIconX - self.buttonSize.middle.margin - self.bottomInfo.iconWidth * 2;
self.bottomInfo.waitPointsTextX = self.bottomInfo.waitPointsIconX + self.bottomInfo.iconWidth * 1.5; -- rendered with center alignment
self.bottomInfo.waypointIconX = self.bottomInfo.waitPointsIconX - self.buttonSize.middle.margin - self.bottomInfo.iconWidth * 4;
self.bottomInfo.waypointTextX = self.bottomInfo.waypointIconX + self.bottomInfo.iconWidth * 1.25;
self.bottomInfo.additionalContentX = self.bottomInfo.waypointIconX - self.bottomInfo.iconWidth
self.bottomInfo.modeUVsPx = {
[courseplay.MODE_GRAIN_TRANSPORT] = { 184,108, 216, 76 };
[courseplay.MODE_COMBI] = { 220,108, 252, 76 };
[courseplay.MODE_OVERLOADER] = { 4,144, 36,112 };
[courseplay.MODE_SEED_FERTILIZE] = { 40,144, 72,112 };
[courseplay.MODE_TRANSPORT] = { 76,144, 108,112 };
[courseplay.MODE_FIELDWORK] = { 112,144, 144,112 };
[courseplay.MODE_BALE_COLLECTOR] = { 148,144, 180,112 };
[courseplay.MODE_FIELD_SUPPLY] = { 184,144, 216,112 };
[courseplay.MODE_SHOVEL_FILL_AND_EMPTY] = { 220,144, 252,112 };
[courseplay.MODE_BUNKERSILO_COMPACTER] = { 219,394, 251,362 };
};
-- TOOLTIP
self.toolTipIconWidth = self:pxToNormal(20, 'x');
self.toolTipIconHeight = self:pxToNormal(20, 'y');
self.toolTipIconPosX = self.col1posX;
self.toolTipIconPosY = self.basePosY + self:pxToNormal(11, 'y');
self.toolTipTextPosX = self.toolTipIconPosX + self.toolTipIconWidth * 1.25;
self.toolTipTextPosY = self.basePosY + self:pxToNormal(16, 'y');
-- INFO TEXT
self.infoTextPosX = self.col1posX;
self.infoTextPosY = self.toolTipTextPosY;
-- DIRECTION ARROW
self.directionArrowWidth = self:pxToNormal(128, 'x');
self.directionArrowHeight = self:pxToNormal(128, 'y');
self.directionArrowPosX = self.baseCenterPosX - self.directionArrowWidth * 0.5;
self.directionArrowPosY = self.linesPosY[8]; -- self.basePosY + self:pxToNormal(118, 'y');
-- INGAME MAP ICONS
self.ingameMapIconsUVs = {
[courseplay.MODE_GRAIN_TRANSPORT] = courseplay.utils:rgbToNormal(255, 113, 16, 1), -- Orange
[courseplay.MODE_COMBI] = courseplay.utils:rgbToNormal(255, 203, 24, 1), -- Yellow
[courseplay.MODE_OVERLOADER] = courseplay.utils:rgbToNormal(129, 204, 52, 1), -- Green
[courseplay.MODE_SEED_FERTILIZE] = courseplay.utils:rgbToNormal( 30, 255, 156, 1), -- Light Green
[courseplay.MODE_TRANSPORT] = courseplay.utils:rgbToNormal( 21, 198, 255, 1), -- Blue
[courseplay.MODE_FIELDWORK] = courseplay.utils:rgbToNormal( 49, 52, 140, 1), -- Dark Blue
[courseplay.MODE_BALE_COLLECTOR] = courseplay.utils:rgbToNormal(159, 29, 250, 1), -- Purple
[courseplay.MODE_FIELD_SUPPLY] = courseplay.utils:rgbToNormal(255, 27, 231, 1), -- Pink
[courseplay.MODE_SHOVEL_FILL_AND_EMPTY] = courseplay.utils:rgbToNormal(231, 19, 19, 1), -- Red
[courseplay.MODE_BUNKERSILO_COMPACTER] = courseplay.utils:rgbToNormal(231, 19, 19, 1), -- Red
};
self.pagesWithSaveCourseIcon = { [1]=true;
[2]=true;
}
-- SOUND
self.clickSound = createSample('clickSound');
loadSample(self.clickSound, Utils.getFilename('sounds/cpClickSound.ogg', courseplay.path), false);
local debugToolTips = courseplay.globalSettings.debugChannels:getToolTips()
local numDebugChannels = courseplay.globalSettings.debugChannels:getNumberOfChannels()
--- Setup debug hud buttons
self.debugChannelData = {}
--- Number of channels per line.
self.debugChannelData.buttonsPerLine = 12
--- Number of debug channel lines.
self.debugChannelData.lines = math.ceil(numDebugChannels / self.debugChannelData.buttonsPerLine)
--- Current selected debug channel line
self.debugChannelData.lineSelected = 1
--- First channel of the line.
self.debugChannelData.lineFirstChannel = 1
--- Last channel of the line.
self.debugChannelData.lineLastChannel = self.debugChannelData.buttonsPerLine
self.debugChannelData.btnPosData = {}
self.debugChannelData.toolTips = debugToolTips
local dbgW = self:pxToNormal(22, 'x')
local dbgH = self:pxToNormal(22, 'y')
local dbgMarginX = dbgW * 0.075
local dbgMaxX = self.contentMaxX - (2 * (self.buttonSize.small.w + self.buttonSize.small.margin))
local dbgMinX = dbgMaxX - (self.debugChannelData.buttonsPerLine * dbgW) - ((self.debugChannelData.buttonsPerLine - 1) * dbgMarginX)
local dbgBtnPosY = self.linesPosY[8] - self:pxToNormal(5, 'y')
for i = 1, self.debugChannelData.buttonsPerLine do
local data = {}
data.width = dbgW
data.height = dbgH
data.posX = dbgMinX + ((i - 1) * (dbgW + dbgMarginX))
data.posY = dbgBtnPosY
data.textPosX = data.posX + (dbgW * 0.5)
data.textPosY = self.linesPosY[8]
self.debugChannelData.btnPosData[i] = data
end
end;
---Getter functions
function courseplay.hud:getModeUvs()
return self.modeButtonsUVsPx
end
function courseplay.hud:getIconSpriteSize()
return self.iconSpriteSize
end
function courseplay.hud:getIconSpritePath()
return self.iconSpritePath
end
-- ####################################################################################################
-- set the content cyclic
function courseplay.hud:setContent(vehicle)
-- self = courseplay.hud
-- course name
if vehicle.cp.currentCourseName ~= nil then
vehicle.cp.hud.content.bottomInfo.courseNameText = vehicle.cp.currentCourseName;
elseif vehicle.Waypoints[1] ~= nil then
vehicle.cp.hud.content.bottomInfo.courseNameText = courseplay:loc('COURSEPLAY_TEMP_COURSE');
else
vehicle.cp.hud.content.bottomInfo.courseNameText = courseplay:loc('COURSEPLAY_NO_COURSE_LOADED');
end;
if vehicle.Waypoints[vehicle.cp.waypointIndex] ~= nil or vehicle.cp.isRecording or vehicle.cp.recordingIsPaused or g_server == nil then
-- waypoints
if not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused and vehicle.cp.waypointIndex then
local str = ('%d/%d'):format(vehicle.cp.waypointIndex, vehicle.cp.numWaypoints);
if str:len() > 7 then
vehicle.cp.hud.content.bottomInfo.waypointTextSmall = str;
vehicle.cp.hud.content.bottomInfo.waypointText = nil;
else
vehicle.cp.hud.content.bottomInfo.waypointText = str;
end;
else
vehicle.cp.hud.content.bottomInfo.waypointText = tostring(vehicle.cp.waypointIndex);
end;
-- waitPoints
vehicle.cp.hud.content.bottomInfo.waitPointsText = tostring(vehicle.cp.numWaitPoints);
-- crossingPoints
vehicle.cp.hud.content.bottomInfo.crossingPointsText = tostring(vehicle.cp.numCrossingPoints);
else
vehicle.cp.hud.content.bottomInfo.waypointText = nil;
vehicle.cp.hud.content.bottomInfo.waypointTextSmall = nil;
vehicle.cp.hud.content.bottomInfo.waitPointsText = nil;
vehicle.cp.hud.content.bottomInfo.crossingPointsText = nil;
end;
--setup bottomInfo texts
local timeRemaining = vehicle.cp.driver.getRemainingTime and vehicle.cp.driver:getRemainingTime()
if timeRemaining ~= nil then
timeRemaining = courseplay:sekToTimeFormat(timeRemaining)
vehicle.cp.hud.content.bottomInfo.timeRemainingText = ('%02.f:%02.f:%02.f'):format(timeRemaining.nHours,timeRemaining.nMins,timeRemaining.nSecs)
else
vehicle.cp.hud.content.bottomInfo.timeRemainingText = nil
end
if vehicle.cp.settings.convoyActive:is(true) then
local distance = vehicle.cp.driver.convoyCurrentDistance or 0
local pos = vehicle.cp.driver.convoyCurrentPosition or 0
local total = vehicle.cp.driver.convoyTotalMembers or 0
vehicle.cp.hud.content.bottomInfo.convoyText = string.format("<--%s--> %d/%d",(distance == 0 and "--" or string.format("%d%s",distance,courseplay:loc('COURSEPLAY_UNIT_METER'))),pos,total)
else
vehicle.cp.hud.content.bottomInfo.convoyText = nil
end
------------------------------------------------------------------
-- AUTOMATIC PAGE RELOAD BASED ON VARIABLE STATE
-- ALL PAGES
if vehicle.cp.hud.reloadPage[-1] then
for page=0,self.numPages do
self:setReloadPageOrder(vehicle, page, true);
end;
self:setReloadPageOrder(vehicle, -1, false);
end;
-- RELOAD PAGE
if vehicle.cp.hud.reloadPage[vehicle.cp.hud.currentPage] then
for line=1,self.numLines do
for column=1,3 do
vehicle.cp.hud.content.pages[vehicle.cp.hud.currentPage][line][column].text = nil;
end;
end;
self:showRecordingButtons(vehicle,false)
self:showCpModeButtons(vehicle, false)
vehicle.cp.hud.saveCourseButton:setShow(false)
vehicle.cp.hud.clearCurrentCourseButton:setShow(false)
vehicle.cp.hud.copyCourseButton:setShow(false)
self:deleteAllTexts(vehicle,vehicle.cp.hud.currentPage)
self:updatePageContent(vehicle, vehicle.cp.hud.currentPage);
self:updateDebugChannelButtons(vehicle)
end;
end; --END setHudContent()
function courseplay.hud:deleteAllTexts(vehicle,page)
for line=1,self.numLines do
for column=1,3 do
vehicle.cp.hud.content.pages[page][line][column].text = nil;
end;
end;
end
function courseplay.hud:renderHud(vehicle)
-- self = courseplay.hud
-- BASE HUD
if vehicle.cp.hud.currentPage == self.PAGE_CP_CONTROL and vehicle.cp.canSwitchMode and not vehicle.cp.distanceCheck then
vehicle.cp.hud.bgWithModeButtons:render();
else
vehicle.cp.hud.bg:render();
end;
-- BUTTONS
courseplay.buttons:renderButtons(vehicle, vehicle.cp.hud.currentPage);
if vehicle.cp.hud.mouseWheel.render then
vehicle.cp.hud.mouseWheel.icon:render();
end;
-- VERSION INFO
if courseplay.versionDisplayStr ~= nil then
courseplay:setFontSettings('white', false, 'right');
renderText(self.contentMaxX, self.versionPosY, self.fontSizes.version, courseplay.versionDisplayStr);
end;
-- HUD TITLES
courseplay:setFontSettings('white', true, 'left');
local hudPageTitle = self.pageTitles[vehicle.cp.hud.currentPage];
if vehicle.cp.hud.currentPage == 2 then
if not vehicle.cp.hud.choose_parent and vehicle.cp.hud.filter == '' then
hudPageTitle = self.pageTitles[vehicle.cp.hud.currentPage][1];
elseif vehicle.cp.hud.choose_parent then
hudPageTitle = self.pageTitles[vehicle.cp.hud.currentPage][2];
elseif vehicle.cp.hud.filter ~= '' then
hudPageTitle = string.format(self.pageTitles[vehicle.cp.hud.currentPage][3], vehicle.cp.hud.filter);
end;
end;
renderText(self.pageTitlePosX, self.pageTitlePosY, self.fontSizes.pageTitle, hudPageTitle);
--MAIN CONTENT
courseplay:setFontSettings('white', false);
local page = vehicle.cp.hud.currentPage;
for line,columns in pairs(vehicle.cp.hud.content.pages[page]) do
for column,entry in pairs(columns) do
if column == 1 and entry.text ~= nil and entry.text ~= '' then
if entry.isClicked then
courseplay:setFontSettings('activeRed', false);
elseif entry.isHovered then
courseplay:setFontSettings('hover', false);
end;
renderText(self.col1posX + entry.indention, self.linesPosY[line], self.fontSizes.contentTitle, entry.text);
courseplay:setFontSettings('white', false);
elseif column >= 2 and entry.text ~= nil and entry.text ~= "" then
renderText(vehicle.cp.hud.content.pages[page][line][column].posX, self.linesPosY[line], self.fontSizes.contentValue, entry.text);
end;
end;
end;
if page == 6 then -- debug channels text
courseplay:setFontSettings('textDark', true, 'center');
local channelNum;
for i,data in ipairs(self.debugChannelData.btnPosData) do
channelNum = self.debugChannelData.lineFirstChannel + (i - 1);
renderText(data.textPosX, data.textPosY, self.fontSizes.contentValue, tostring(channelNum));
end
courseplay:setFontSettings('white', false, 'left');
end;
-- BOTTOM GLOBAL INFO
if vehicle.cp.hud.content.bottomInfo.waitPointsText ~= nil and vehicle.cp.hud.content.bottomInfo.crossingPointsText ~= nil and vehicle.cp.hud.content.bottomInfo.timeRemainingText == nil then
courseplay:setFontSettings('white', false, 'center');
renderText(self.bottomInfo.waitPointsTextX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.waitPointsText);
vehicle.cp.hud.waitPointsIcon:render();
renderText(self.bottomInfo.crossingPointsTextX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.crossingPointsText);
vehicle.cp.hud.crossingPointsIcon:render();
end;
-- 2D/DEBUG LINE BUTTON MODE
local courseDrawModeSetting = vehicle.cp.settings.courseDrawMode
if not courseDrawModeSetting:isDeactivated() then
local txt = courseDrawModeSetting:getText()
courseplay:setFontSettings('white', true);
renderText(vehicle.cp.hud.changeDrawCourseModeButton.x + vehicle.cp.hud.changeDrawCourseModeButton.width * 0.5, self.topIconsY + self.fontSizes.version * 1.25, self.fontSizes.version, txt);
courseplay:setFontSettings('white', false);
end;
--- Displays a custom field path, if it was generated.
local setting = vehicle.cp.courseGeneratorSettings.fieldEdgePath
if vehicle:getIsActive() and setting:isUnsavedCustomFieldPathVisible() then
setting:showCustomFieldEdgePath()
end
end;
function courseplay.hud:renderHudBottomInfo(vehicle)
courseplay:setFontSettings('white', false, 'left');
vehicle.cp.hud.currentModeIcon:render();
if vehicle.cp.hud.content.bottomInfo.courseNameText ~= nil then
renderText(self.bottomInfo.courseNameX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.courseNameText);
end;
if vehicle.cp.hud.content.bottomInfo.waypointText ~= nil then
renderText(self.bottomInfo.waypointTextX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.waypointText);
vehicle.cp.hud.currentWaypointIcon:render();
elseif vehicle.cp.hud.content.bottomInfo.waypointTextSmall ~= nil then
renderText(self.bottomInfo.waypointTextX, self.bottomInfo.textSmallPosY, self.fontSizes.bottomInfoSmall, vehicle.cp.hud.content.bottomInfo.waypointTextSmall);
vehicle.cp.hud.currentWaypointIcon:render();
end;
if vehicle.cp.hud.content.bottomInfo.timeRemainingText ~= nil then
courseplay:setFontSettings('white', false, 'right');
--renderText(self.bottomInfo.additionalContentX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.timeRemainingText);
renderText(self.bottomInfo.crossingPointsTextX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.timeRemainingText);
end
if vehicle.cp.hud.content.bottomInfo.convoyText ~= nil then
courseplay:setFontSettings('white', false, 'right');
renderText(self.bottomInfo.additionalContentX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.convoyText);
end
end
-- set the content on demand
function courseplay.hud:updatePageContent(vehicle, page)
-- self = courseplay.hud
-- this is an ugly hack to enable two different settings occupy the same row, like toggleReturnToFirstPoint and
-- setCustomSingleFieldEdge on page 1. They are mutually exclusive and when enabled, will disable the other. If
-- there is a change, they set forceUpdate to force the update of the HUD page, otherwise there's only an empty
-- row shown until the page is reselected
local forceUpdate = false
courseplay:debug(string.format('%s: loadPage(..., %d), set content', nameNum(vehicle), page), courseplay.DBG_HUD);
--go through all the HUD stuff and update the content
for line,columns in pairs(vehicle.cp.hud.content.pages[page]) do
for column,entry in pairs(columns) do
if entry.functionToCall ~= nil then
if entry.functionToCall == 'startStop' then
if vehicle.cp.canDrive then
self:enableButtonWithFunction(vehicle,page, 'startStop')
if not vehicle:getIsCourseplayDriving() then
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_START_COURSE')
else
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_STOP_COURSE')
end
self:enableButtonsOnThisPage(vehicle,page)
else
self:disableButtonWithFunction(vehicle,page, 'startStop')
end
self:showCpModeButtons(vehicle, not vehicle:getIsCourseplayDriving())
elseif entry.functionToCall == 'start_record' then
if not vehicle.cp.canDrive then
if (not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused) then
self:enableButtonWithFunction(vehicle,page, 'start_record')
if vehicle.cp.numWaypoints == 0 then
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_RECORDING_START');
end;
else
self:disableButtonsOnThisPage(vehicle,page)
self:showRecordingButtons(vehicle, true)
end
end
elseif entry.functionToCall == 'startingPoint:next' then
--StartingPointSetting
local setting = vehicle.cp.settings.startingPoint
if not setting:isDisabled() then
self:enableButtonWithFunction(vehicle,page, 'next',setting)
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
else
self:disableButtonWithFunction(vehicle,page, 'next',setting)
end
elseif entry.functionToCall == 'autoDriveMode:changeByX' then
--autoDriveModeSetting
if not vehicle.cp.settings.autoDriveMode:isDisabled() then
self:enableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.autoDriveMode)
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.autoDriveMode:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.autoDriveMode:getText()
else
self:disableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.autoDriveMode)
end
elseif entry.functionToCall == 'stopAtEnd:toggle' then
--StopAtEndSetting
if not vehicle.cp.settings.stopAtEnd:isDisabled() then
self:enableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.stopAtEnd)
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.stopAtEnd:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.stopAtEnd:getText()
else
self:disableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.stopAtEnd)
end
elseif entry.functionToCall == 'returnToFirstPoint:changeByX' then
--ReturnToFirstPointSetting
if not vehicle.cp.settings.returnToFirstPoint:isDisabled() then
self:enableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.returnToFirstPoint)
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.returnToFirstPoint:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.returnToFirstPoint:getText()
else
self:disableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.returnToFirstPoint)
forceUpdate = true -- force reload of this page if functionToCall changed
courseplay.hud:setReloadPageOrder(vehicle, page, true);
end
elseif entry.functionToCall == 'automaticCoverHandling:toggle' then
--AutomaticCoverHandlingSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.automaticCoverHandling:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.automaticCoverHandling:getText()
elseif string.find(entry.functionToCall, "siloSelectedFillType") then
--SiloSelectedFillTypeSetting
if string.find(entry.functionToCall, "GrainTransportDriver") then
self:updateSiloSelectedFillTypeList(vehicle,page,3,7,"GrainTransportDriver",line)
elseif string.find(entry.functionToCall, "FillableFieldWorkDriver") then
self:updateSiloSelectedFillTypeList(vehicle,page,6,7,"FillableFieldWorkDriver",line)
elseif string.find(entry.functionToCall, "FieldSupplyDriver") then --FieldSupplyDriver
self:updateSiloSelectedFillTypeList(vehicle,page,3,4,"FieldSupplyDriver",line)
elseif string.find(entry.functionToCall, "ShovelModeDriver") then --ShovelModeDriver
self:updateSiloSelectedFillTypeList(vehicle,page,6,8,"ShovelModeDriver",line)
elseif string.find(entry.functionToCall, "MixerWagonAIDriver") then --MixerWagonAIDriver
self:updateSiloSelectedFillTypeList(vehicle,page,2,8,"MixerWagonAIDriver",line)
end
elseif entry.functionToCall == 'switchDriverCopy' then
if not vehicle.cp.canDrive and not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused then
self:enableButtonWithFunction(vehicle,page, 'switchDriverCopy')
vehicle.cp.hud.copyCourseButton:setShow(true)
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_COPY_COURSE');
if vehicle.cp.copyCourseFromDriver ~= nil then
local printString = ''
local driverName = vehicle.cp.copyCourseFromDriver:getName() or courseplay:loc('COURSEPLAY_VEHICLE');
local dist = courseplay:distanceToObject(vehicle, vehicle.cp.copyCourseFromDriver);
if dist >= 1000 then
printString = printString..('%s %s (%.1f%s)'):format(courseplay:loc('COURSEPLAY_COPY_COURSE'),driverName, dist * 0.001, courseplay:getMeasuringUnit());
else
printString = printString..('%s %s (%d%s)'):format(courseplay:loc('COURSEPLAY_COPY_COURSE'),driverName, dist, courseplay:loc('COURSEPLAY_UNIT_METER'));
end;
printString = printString..' (' .. (vehicle.cp.copyCourseFromDriver.cp.currentCourseName or courseplay:loc('COURSEPLAY_TEMP_COURSE')) .. ')';
vehicle.cp.hud.content.pages[page][line][1].text = printString
else
vehicle.cp.hud.content.pages[page][line][2].text = courseplay:loc('COURSEPLAY_NONE');
end;
else
self:disableButtonWithFunction(vehicle,page, 'switchDriverCopy')
end
elseif entry.functionToCall == 'openAdvancedCourseGeneratorSettings' then
if not vehicle:getIsCourseplayDriving() and not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused then
self:enableButtonWithFunction(vehicle,page, 'openAdvancedCourseGeneratorSettings')
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_PAGE_TITLE_COURSE_GENERATION').."...";
else
self:disableButtonWithFunction(vehicle,page, 'openAdvancedCourseGeneratorSettings')
end
elseif entry.functionToCall == 'turnSpeed:changeByX' then
--TurnSpeedSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.turnSpeed:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.turnSpeed:getText()
elseif entry.functionToCall == 'fieldSpeed:changeByX' then
--FieldSpeedSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.fieldSpeed:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.fieldSpeed:getText()
elseif entry.functionToCall == 'reverseSpeed:changeByX' then
--ReverseSpeedSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.reverseSpeed:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.reverseSpeed:getText()
elseif entry.functionToCall == 'streetSpeed:changeByX' then
--StreetSpeedSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.streetSpeed:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.streetSpeed:getText()
elseif entry.functionToCall == 'useRecordingSpeed:toggle' then
--UseRecordingSpeedSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.useRecordingSpeed:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.useRecordingSpeed:getText()
elseif entry.functionToCall == 'warningLightsMode:next' then
--WarningLightsModeSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.warningLightsMode:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.warningLightsMode:getText()
elseif entry.functionToCall == 'openAdvancedSettingsDialog' then
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_OPEN_ADVANCED_SETTINGS');
elseif entry.functionToCall == 'foldImplementAtEnd:toggle' then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.foldImplementAtEnd:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.foldImplementAtEnd:getText()
elseif entry.functionToCall == 'saveFuelOption:toggle' then
--SaveFuelOptionSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.saveFuelOption:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.saveFuelOption:getText()
elseif entry.functionToCall == 'alwaysSearchFuel:toggle' then
--AlwaysSearchFuelSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.alwaysSearchFuel:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.alwaysSearchFuel:getText()
elseif entry.functionToCall == 'loadUnloadOffsetX:changeByX' then
--- LoadUnloadOffsetXSetting
local setting = vehicle.cp.settings.loadUnloadOffsetX
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
elseif entry.functionToCall == 'loadUnloadOffsetZ:changeByX' then
--- LoadUnloadOffsetZSetting
local setting = vehicle.cp.settings.loadUnloadOffsetZ
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
elseif entry.functionToCall == 'useRealisticDriving:toggle' then
--RealisticDrivingSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.useRealisticDriving:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.useRealisticDriving:getText()
elseif entry.functionToCall == 'turnDiameter:changeByX' then
local setting = vehicle.cp.settings.turnDiameter
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
elseif entry.functionToCall == 'workWidth:changeByX' then
local setting = vehicle.cp.courseGeneratorSettings.workWidth
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
elseif entry.functionToCall == 'multiTools:changeLaneNumber' then
local setting = vehicle.cp.courseGeneratorSettings.multiTools
vehicle.cp.hud.content.pages[page][line][1].text = setting.laneNumber:getLabel()
if setting:get() > 1 then
self:enableButtonWithFunction(vehicle,page, 'changeLaneNumber',setting)
vehicle.cp.hud.content.pages[page][line][2].text = setting.laneNumber:getText()
else
self:disableButtonWithFunction(vehicle,page, 'changeLaneNumber',setting)
end
elseif entry.functionToCall == 'turnOnField:toggle' then
--TurnOnFieldSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.turnOnField:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.turnOnField:getText()
elseif entry.functionToCall == 'fieldEdgePath:changeByX' then
--- Updates the custom field edge buttons and the texts.
self:updateFieldEdgePathTextsAndButtons(vehicle,page,line)
elseif entry.functionToCall == 'symmetricLaneChange:toggle' then
--SymmetricLaneChangeSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.symmetricLaneChange:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.symmetricLaneChange:getText()
elseif entry.functionToCall == 'changeToolOffsetX' then
--Tool horizontal offset
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.toolOffsetX:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.toolOffsetX:getText()
elseif entry.functionToCall == 'changeToolOffsetZ' then
--Tool vertical offset
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.toolOffsetZ:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.toolOffsetZ:getText()
elseif entry.functionToCall == 'waitTime:changeByX' then
--- WaitTimeSetting
local setting = vehicle.cp.settings.waitTime
if not setting:isDisabled() then
self:enableButtonWithFunction(vehicle,page, 'changeByX',setting)
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
else
self:disableButtonWithFunction(vehicle,page, 'changeByX',setting)
end
elseif entry.functionToCall == 'convoyActive:toggle' then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.convoyActive:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.convoyActive:getText()
elseif entry.functionToCall == 'convoyMinDistance:changeByX' then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.convoyMinDistance:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.convoyMinDistance:getText()
elseif entry.functionToCall == 'convoyMaxDistance:changeByX' then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.convoyMaxDistance:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.convoyMaxDistance:getText()
elseif entry.functionToCall == 'driveOnAtFillLevel:changeByX' then
--DriveOnAtFillLevelSetting
if not vehicle.cp.settings.separateFillTypeLoading:isActive() then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.driveOnAtFillLevel:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.driveOnAtFillLevel:getText()
self:enableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.driveOnAtFillLevel)
else
self:disableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.driveOnAtFillLevel)
end
elseif entry.functionToCall == 'moveOnAtFillLevel:changeByX' then
--DriveOnAtFillLevelSetting
if not vehicle.cp.settings.separateFillTypeLoading:isActive() then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.moveOnAtFillLevel:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.moveOnAtFillLevel:getText()
self:enableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.moveOnAtFillLevel)
else
self:disableButtonWithFunction(vehicle,page, 'changeByX',vehicle.cp.settings.moveOnAtFillLevel)
end
--TODO: setDriveNow should be AIDriver function!
elseif entry.functionToCall == 'setDriveNow' then
if not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused then
if vehicle.cp.driver and vehicle.cp.driver.getCanShowDriveOnButton then
if vehicle:getIsCourseplayDriving() and vehicle.cp.driver:getCanShowDriveOnButton() then
self:enableButtonWithFunction(vehicle,page, 'setDriveNow')
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.driveUnloadNow:getLabel()
else
self:disableButtonWithFunction(vehicle,page, 'setDriveNow')
end
end
end
elseif entry.functionToCall == 'requestUnloader:toggle' then
--requestUnloaderSetting
if not g_combineUnloadManager:getHasUnloaders(vehicle) then
self:enableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.requestUnloader)
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.requestUnloader:getText()
else
local unloader = g_combineUnloadManager:getUnloaderByNumber(1, vehicle)
self:disableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.requestUnloader)
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.requestUnloader:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = unloader.name;
end
elseif entry.functionToCall == 'startStopUnloader' then
if g_combineUnloadManager:getHasUnloaders(vehicle) then
self:enableButtonWithFunction(vehicle,page, 'startStopUnloader')
local courseplayer = g_combineUnloadManager:getUnloaderByNumber(1, vehicle)
vehicle.cp.hud.content.pages[page][line][1].text = courseplayer.cp.settings.forcedToStop:getText()
else
self:disableButtonWithFunction(vehicle,page, 'startStopUnloader')
end
elseif entry.functionToCall == 'sendUnloaderHome' then
print("g_combineUnloadManager:getHasUnloaders(vehicle):"..tostring(g_combineUnloadManager:getHasUnloaders(vehicle)))
if g_combineUnloadManager:getHasUnloaders(vehicle) then
self:enableButtonWithFunction(vehicle,page, 'sendUnloaderHome')
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_UNLOADING_DRIVER_SEND_HOME');
else
self:disableButtonWithFunction(vehicle,page, 'sendUnloaderHome')
end
elseif entry.functionToCall == 'driverPriorityUseFillLevel:toggle' then
--DriverPriorityUseFillLevelSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.driverPriorityUseFillLevel:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.driverPriorityUseFillLevel:getText()
elseif entry.functionToCall == 'stopForUnload:toggle' then
--StopForUnloadSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.stopForUnload:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.stopForUnload:getText()
elseif entry.functionToCall == 'combineOffsetX:changeByX' then
--- CombineOffsetXSetting
local setting = vehicle.cp.settings.combineOffsetX
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
elseif entry.functionToCall == 'combineOffsetZ:changeByX' then
--- CombineOffsetZSetting
local setting = vehicle.cp.settings.combineOffsetZ
vehicle.cp.hud.content.pages[page][line][1].text = setting:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = setting:getText()
elseif entry.functionToCall == 'followAtFillLevel:changeByX' then
--FollowAtFillLevelSetting
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.followAtFillLevel:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.settings.followAtFillLevel:getText()
--[[elseif entry.functionToCall == 'toggleSearchCombineMode' then --automatic or manual
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_COMBINE_SEARCH_MODE'); --always
vehicle.cp.hud.content.pages[page][line][2].text = vehicle.cp.searchCombineAutomatically and courseplay:loc('COURSEPLAY_AUTOMATIC_SEARCH') or courseplay:loc('COURSEPLAY_MANUAL_SEARCH');
elseif entry.functionToCall == 'selectAssignedCombine' then -- if manual toggle through combines to select one
--Line 2: select combine manually
if not vehicle.cp.searchCombineAutomatically then
self:enableButtonWithFunction(vehicle,page, 'selectAssignedCombine')
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_CHOOSE_COMBINE'); --only if manual
if vehicle.cp.settings.selectedCombineToUnload:get() ~= nil then
local name = vehicle.cp.settings.selectedCombineToUnload:get().name
local dist = courseplay:distanceToObject(vehicle, vehicle.cp.settings.selectedCombineToUnload:get());
if dist >= 1000 then
vehicle.cp.hud.content.pages[page][line][2].text = ('%s (%.1f%s)'):format(name, dist * 0.001, courseplay:getMeasuringUnit());
else
vehicle.cp.hud.content.pages[page][line][2].text = ('%s (%d%s)'):format(name, dist, courseplay:loc('COURSEPLAY_UNIT_METER'));
end;
else
vehicle.cp.hud.content.pages[page][line][2].text = courseplay:loc('COURSEPLAY_NONE');
end;
else
self:disableButtonWithFunction(vehicle,page, 'selectAssignedCombine')
end;
]]
elseif entry.functionToCall == 'searchCombineOnField:changeByX' then
--SearchCombineOnFieldSetting
--Line 3: choose field for automatic search --only if automatic
if vehicle.cp.searchCombineAutomatically and courseplay.fields.numAvailableFields > 0 then
vehicle.cp.settings.searchCombineOnField:refresh()
self:enableButtonWithFunction(vehicle,page, 'searchCombineOnField:changeByX')
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.searchCombineOnField:getLabel():format(vehicle.cp.settings.searchCombineOnField:getText())
else
self:disableButtonWithFunction(vehicle,page, 'searchCombineOnField:changeByX')