forked from Courseplay/courseplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hud.lua
1821 lines (1559 loc) · 104 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
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.pagesPerMode = { -- Pg 0 Pg 1 Pg 2 Pg 3 Pg 4 Pg 5 Pg 6 Pg 7 Pg 8 Pg 9 Pg10
[courseplay.MODE_GRAIN_TRANSPORT] = { [0] = true, [1] = true, [2] = true, [3] = true, [4] = false, [5] = true, [6] = true, [7] = true, [8] = false, [9] = false, [10] = false}; -- mode 1
[courseplay.MODE_COMBI] = { [0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = false, [9] = false, [10] = false }; -- mode 2
[courseplay.MODE_OVERLOADER] = { [0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = false, [9] = false, [10] = false }; -- mode 3
[courseplay.MODE_SEED_FERTILIZE] = { [0] = true, [1] = true, [2] = true, [3] = true, [4] = false, [5] = true, [6] = true, [7] = true, [8] = true, [9] = false, [10] = false }; -- mode 4
[courseplay.MODE_TRANSPORT] = { [0] = true, [1] = true, [2] = true, [3] = false, [4] = false, [5] = true, [6] = true, [7] = true, [8] = false, [9] = false, [10] = false }; -- mode 5
[courseplay.MODE_FIELDWORK] = { [0] = true, [1] = true, [2] = true, [3] = true, [4] = false, [5] = true, [6] = true, [7] = true, [8] = true, [9] = false, [10] = false }; -- mode 6
[courseplay.MODE_COMBINE_SELF_UNLOADING] = { [0] = false, [1] = true, [2] = true, [3] = true, [4] = false, [5] = true, [6] = true, [7] = true, [8] = false, [9] = false, [10] = false }; -- mode 7
[courseplay.MODE_LIQUIDMANURE_TRANSPORT] = { [0] = true, [1] = true, [2] = true, [3] = true, [4] = false, [5] = true, [6] = true, [7] = true, [8] = false, [9] = false, [10] = false }; -- mode 8
[courseplay.MODE_SHOVEL_FILL_AND_EMPTY] = { [0] = true, [1] = true, [2] = true, [3] = false, [4] = false, [5] = true, [6] = true, [7] = true, [8] = false, [9] = true, [10] = false }; -- mode 9
[courseplay.MODE_BUNKERSILO_COMPACTER] = { [0] = true, [1] = true, [2] = true, [3] = false, [4] = false, [5] = true, [6] = true, [7] = true, [8] = false, [9] = false, [10] = true }; -- mode 10
};
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;
-- SEEDUSAGECALCULATOR
self.suc = {};
self.suc.UVsPx = { 10,876, 476,744 };
self.suc.width = self:pxToNormal(466, 'x');
self.suc.height = self:pxToNormal(132, 'y');
self.suc.x1 = self.baseCenterPosX - self.suc.width * 0.5;
self.suc.x2 = self.baseCenterPosX + self.suc.width * 0.5;
self.suc.y1 = self.basePosY + self.baseHeight; -- + self:pxToNormal(5, 'y');
self.suc.y2 = self.suc.y1 + self.suc.height;
self.suc.visibleArea = {};
self.suc.visibleArea.width = self:pxToNormal(450, 'x');
self.suc.visibleArea.height = self:pxToNormal(116, 'y');
self.suc.visibleArea.x1 = self.baseCenterPosX - self.suc.visibleArea.width * 0.5;
self.suc.visibleArea.x2 = self.baseCenterPosX + self.suc.visibleArea.width * 0.5;
self.suc.visibleArea.y1 = self.suc.y1 + self:pxToNormal(8, 'y');
self.suc.visibleArea.y2 = self.suc.y2 - self:pxToNormal(8, 'y');
self.suc.visibleArea.hPadding = self:pxToNormal(10, 'x');
self.suc.visibleArea.vPadding = self:pxToNormal(10, 'y');
self.suc.visibleArea.overlayWidth = g_currentMission.hudTipperOverlay.width * 2.75;
self.suc.visibleArea.overlayHeight = self.suc.visibleArea.overlayWidth * g_screenAspectRatio;
self.suc.visibleArea.overlayPosX = self.suc.visibleArea.x2 - self.suc.visibleArea.overlayWidth - self.suc.visibleArea.hPadding;
self.suc.visibleArea.overlayPosY = self.suc.visibleArea.y1 + self.suc.visibleArea.vPadding;
--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(234, '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(234, '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(272, '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');
};
[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.PAGE_COURSE_GENERATION] = {
[6] = self.basePosX + self:pxToNormal(509, '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_PAGE_TITLE_COURSE_GENERATION"), -- 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,5 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_COMBINE_SELF_UNLOADING] = { 76,108, 108,76 };
[courseplay.MODE_LIQUIDMANURE_TRANSPORT] = { 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 };
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.timeRemainingX = 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_COMBINE_SELF_UNLOADING] = { 148,144, 180,112 };
[courseplay.MODE_LIQUIDMANURE_TRANSPORT] = { 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_COMBINE_SELF_UNLOADING] = courseplay.utils:rgbToNormal(159, 29, 250, 1), -- Purple
[courseplay.MODE_LIQUIDMANURE_TRANSPORT] = 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
};
-- SOUND
self.clickSound = createSample('clickSound');
loadSample(self.clickSound, Utils.getFilename('sounds/cpClickSound.wav', courseplay.path), false);
end;
-- ####################################################################################################
-- EXECUTION
function courseplay.hud:setContent(vehicle)
-- self = courseplay.hud
if vehicle.cp.hud.firstTimeSetContent then
--- Reset tools
-- This is to show the silo filltype line on first time opening the hud and the mode is Grain Transport.
if vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT then
courseplay:resetTools(vehicle);
end;
vehicle.cp.hud.firstTimeSetContent = false
end;
-- BOTTOM GLOBAL INFO
-- mode icon
vehicle.cp.hud.content.bottomInfo.showModeIcon = vehicle.cp.mode > 0 and vehicle.cp.mode <= courseplay.NUM_MODES;
-- 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 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;
if vehicle.cp.timeRemaining ~= nil then
local timeRemaining = courseplay:sekToTimeFormat(vehicle.cp.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
------------------------------------------------------------------
-- 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;
-- CURRENT PAGE
if vehicle.cp.hud.currentPage == 3 and vehicle:getIsCourseplayDriving() and (vehicle.cp.mode == 2 or vehicle.cp.mode == 3) then
for i,varName in pairs({ 'combineOffset', 'turnDiameter' }) do
if courseplay.utils:hasVarChanged(vehicle, varName) then
self:setReloadPageOrder(vehicle, 3, true);
break;
end;
end;
elseif vehicle.cp.hud.currentPage == 4 then
if vehicle.cp.savedCombine ~= nil then -- Force page 4 reload when combine distance is displayed
self:setReloadPageOrder(vehicle, 4, true);
end;
elseif vehicle.cp.hud.currentPage == 7 then
if vehicle.cp.copyCourseFromDriver ~= nil or courseplay.utils:hasVarChanged(vehicle, 'totalOffsetX') then -- Force page 7 reload when vehicle distance is displayed
self:setReloadPageOrder(vehicle, 7, true);
end;
end;
-- RELOAD PAGE
if vehicle.cp.hud.reloadPage[vehicle.cp.hud.currentPage] then
for line=1,self.numLines do
for column=1,2 do
vehicle.cp.hud.content.pages[vehicle.cp.hud.currentPage][line][column].text = nil;
end;
end;
self:loadPage(vehicle, vehicle.cp.hud.currentPage);
end;
end; --END setHudContent()
function courseplay.hud:renderHud(vehicle)
-- self = courseplay.hud
-- SEEDUSAGECALCULATOR
if vehicle.cp.suc.active then
vehicle.cp.hud.suc:render();
if vehicle.cp.suc.selectedFruit.overlay then
vehicle.cp.suc.selectedFruit.overlay:render();
end;
end;
-- 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;
-- BOTTOM GLOBAL INFO
courseplay:setFontSettings('white', false, 'left');
if vehicle.cp.hud.content.bottomInfo.showModeIcon then
vehicle.cp.hud.currentModeIcon:render();
end;
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.waitPointsText ~= nil and vehicle.cp.hud.content.bottomInfo.crossingPointsText ~= 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;
if vehicle.cp.hud.content.bottomInfo.timeRemainingText ~= nil then
courseplay:setFontSettings('white', false, 'right');
renderText(self.bottomInfo.timeRemainingX, self.bottomInfo.textPosY, self.fontSizes.bottomInfo, vehicle.cp.hud.content.bottomInfo.timeRemainingText);
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][2].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(courseplay.debugButtonPosData) do
channelNum = courseplay.debugChannelSectionStart + (i - 1);
renderText(data.textPosX, data.textPosY, self.fontSizes.contentValue, tostring(channelNum));
end;
courseplay:setFontSettings('white', false, 'left');
end;
-- SEED USAGE CALCULATOR
if vehicle.cp.suc.active then
local x = vehicle.cp.suc.textMinX;
local selectedField = courseplay.fields.fieldData[ vehicle.cp.fieldEdge.selectedField.fieldNum ];
local selectedFruit = vehicle.cp.suc.selectedFruit;
courseplay:setFontSettings('shadow', true);
renderText(x, vehicle.cp.suc.lines.title.posY - 0.001, vehicle.cp.suc.lines.title.fontSize, vehicle.cp.suc.lines.title.text);
courseplay:setFontSettings('white', true);
renderText(x, vehicle.cp.suc.lines.title.posY , vehicle.cp.suc.lines.title.fontSize, vehicle.cp.suc.lines.title.text);
courseplay:setFontSettings('white', false);
renderText(x, vehicle.cp.suc.lines.field.posY, vehicle.cp.suc.lines.field.fontSize, selectedField.fieldAreaText);
renderText(x, vehicle.cp.suc.lines.fruit.posY, vehicle.cp.suc.lines.fruit.fontSize, selectedFruit.sucText);
renderText(x, vehicle.cp.suc.lines.result.posY, vehicle.cp.suc.lines.result.fontSize, selectedField.seedDataText[selectedFruit.name]);
end;
-- 2D/DEBUG LINE BUTTON MODE
if CpManager.isDeveloper and vehicle.cp.drawCourseMode ~= courseplay.COURSE_2D_DISPLAY_OFF then
local txt;
if vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_2DONLY then
txt = '2D';
elseif vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_DBGONLY then
txt = '\nDBG';
else
txt = '2D\nDBG';
end;
courseplay:setFontSettings('white', true);
renderText(vehicle.cp.changeDrawCourseModeButton.x + vehicle.cp.changeDrawCourseModeButton.width * 0.5, self.topIconsY + self.fontSizes.version * 1.25, self.fontSizes.version, txt);
courseplay:setFontSettings('white', false);
end;
end;
function courseplay:setMinHudPage(vehicle)
vehicle.cp.minHudPage = courseplay.hud.PAGE_CP_CONTROL;
if vehicle.cp.isCombine or vehicle.cp.isChopper or vehicle.cp.isHarvesterSteerable or vehicle.cp.isSugarBeetLoader or vehicle.cp.attachedCombine ~= nil then
vehicle.cp.minHudPage = courseplay.hud.PAGE_COMBINE_CONTROLS;
end;
courseplay:setHudPage(vehicle, max(vehicle.cp.hud.currentPage, vehicle.cp.minHudPage));
courseplay:debug(('%s: setMinHudPage(): minHudPage=%d, currentPage=%d'):format(nameNum(vehicle), vehicle.cp.minHudPage, vehicle.cp.hud.currentPage), 18);
courseplay.buttons:setActiveEnabled(vehicle, 'pageNav');
end;
function courseplay.hud:loadPage(vehicle, page)
-- self = courseplay.hud
courseplay:debug(string.format('%s: loadPage(..., %d), set content', nameNum(vehicle), page), 18);
--PAGE 0: COMBINE SETTINGS
if page == self.PAGE_COMBINE_CONTROLS then
local combine = vehicle;
if vehicle.cp.attachedCombine ~= nil then
combine = vehicle.cp.attachedCombine;
end;
if not combine.cp.isChopper then
--Driver priority
vehicle.cp.hud.content.pages[0][4][1].text = courseplay:loc('COURSEPLAY_UNLOADING_DRIVER_PRIORITY');
vehicle.cp.hud.content.pages[0][4][2].text = combine.cp.driverPriorityUseFillLevel and courseplay:loc('COURSEPLAY_FILLEVEL') or courseplay:loc('COURSEPLAY_DISTANCE');
if vehicle.cp.mode == 6 then
vehicle.cp.hud.content.pages[0][5][1].text = courseplay:loc('COURSEPLAY_STOP_DURING_UNLOADING');
vehicle.cp.hud.content.pages[0][5][2].text = combine.cp.stopWhenUnloading and courseplay:loc('COURSEPLAY_ACTIVATED') or courseplay:loc('COURSEPLAY_DEACTIVATED');
end;
end;
-- no courseplayer!
if vehicle.cp.HUD0noCourseplayer then
if vehicle.cp.HUD0wantsCourseplayer then
vehicle.cp.hud.content.pages[0][1][1].text = courseplay:loc('COURSEPLAY_UNLOADING_DRIVER_REQUESTED');
else
vehicle.cp.hud.content.pages[0][1][1].text = courseplay:loc('COURSEPLAY_REQUEST_UNLOADING_DRIVER');
end
else
vehicle.cp.hud.content.pages[0][1][1].text = courseplay:loc('COURSEPLAY_DRIVER');
vehicle.cp.hud.content.pages[0][1][2].text = vehicle.cp.HUD0tractorName;
if vehicle.cp.HUD0tractorForcedToStop then
vehicle.cp.hud.content.pages[0][2][1].text = courseplay:loc('COURSEPLAY_UNLOADING_DRIVER_START');
else
vehicle.cp.hud.content.pages[0][2][1].text = courseplay:loc('COURSEPLAY_UNLOADING_DRIVER_STOP');
end
vehicle.cp.hud.content.pages[0][3][1].text = courseplay:loc('COURSEPLAY_UNLOADING_DRIVER_SEND_HOME');
--chopper
if combine.cp.isChopper then
if vehicle.cp.HUD0tractor then
vehicle.cp.hud.content.pages[0][4][1].text = courseplay:loc('COURSEPLAY_UNLOADING_SIDE');
if vehicle.cp.HUD0combineForcedSide == 'left' then
vehicle.cp.hud.content.pages[0][4][2].text = courseplay:loc('COURSEPLAY_LEFT');
elseif vehicle.cp.HUD0combineForcedSide == 'right' then
vehicle.cp.hud.content.pages[0][4][2].text = courseplay:loc('COURSEPLAY_RIGHT');
else
vehicle.cp.hud.content.pages[0][4][2].text = courseplay:loc('COURSEPLAY_UNLOADING_SIDE_NONE');
end;
--manual chopping: initiate/end turning maneuver
if vehicle.cp.HUD0isManual then
vehicle.cp.hud.content.pages[0][5][1].text = courseplay:loc('COURSEPLAY_TURN_MANEUVER');
if vehicle.cp.HUD0turnStage == 0 then
vehicle.cp.hud.content.pages[0][5][2].text = courseplay:loc('COURSEPLAY_START');
elseif vehicle.cp.HUD0turnStage == 1 then
vehicle.cp.hud.content.pages[0][5][2].text = courseplay:loc('COURSEPLAY_FINISH');
end;
end;
end;
end;
end;
--PAGE 1: COURSEPLAY CONTROL
elseif page == self.PAGE_CP_CONTROL then
if vehicle.cp.canDrive then
if not vehicle:getIsCourseplayDriving() then -- only 6 lines available, as the mode buttons are in lines 7 and 8!
vehicle.cp.hud.content.pages[1][1][1].text = courseplay:loc('COURSEPLAY_START_COURSE')
if vehicle.cp.mode ~= courseplay.MODE_SHOVEL_FILL_AND_EMPTY then
vehicle.cp.hud.content.pages[1][3][1].text = courseplay:loc('COURSEPLAY_START_AT_POINT');
if vehicle.cp.startAtPoint == courseplay.START_AT_NEAREST_POINT then
vehicle.cp.hud.content.pages[1][3][2].text = courseplay:loc('COURSEPLAY_NEAREST_POINT');
elseif vehicle.cp.startAtPoint == courseplay.START_AT_FIRST_POINT then
vehicle.cp.hud.content.pages[1][3][2].text = courseplay:loc('COURSEPLAY_FIRST_POINT');
elseif vehicle.cp.startAtPoint == courseplay.START_AT_CURRENT_POINT then
vehicle.cp.hud.content.pages[1][3][2].text = courseplay:loc('COURSEPLAY_CURRENT_POINT');
end;
end;
if vehicle.cp.hasAugerWagon and (vehicle.cp.mode == courseplay.MODE_OVERLOADER or vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT) then
vehicle.cp.hud.content.pages[1][4][1].text = courseplay:loc('COURSEPLAY_SAVE_PIPE_POSITION');
if vehicle.cp.pipeWorkToolIndex ~= nil then
vehicle.cp.hud.content.pages[1][4][2].text = 'OK';
else
vehicle.cp.hud.content.pages[1][4][2].text = courseplay:loc('UNKNOWN');
end
end
if vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT and #vehicle.cp.easyFillTypeList > 0 then
vehicle.cp.hud.content.pages[1][6][1].text = courseplay:loc('COURSEPLAY_FARM_SILO_FILL_TYPE');
vehicle.cp.hud.content.pages[1][6][2].text = FillUtil.fillTypeIndexToDesc[vehicle.cp.siloSelectedFillType].nameI18N;
end;
else
vehicle.cp.hud.content.pages[1][1][1].text = courseplay:loc('COURSEPLAY_STOP_COURSE')
if vehicle.cp.HUD1wait then
vehicle.cp.hud.content.pages[1][2][1].text = courseplay:loc('COURSEPLAY_CONTINUE')
end
if vehicle.cp.HUD1noWaitforFill then
vehicle.cp.hud.content.pages[1][3][1].text = courseplay:loc('COURSEPLAY_DRIVE_NOW')
end
vehicle.cp.hud.content.pages[1][4][1].text = courseplay:loc('COURSEPLAY_STOP_AT_LAST_POINT');
vehicle.cp.hud.content.pages[1][4][2].text = vehicle.cp.stopAtEnd and courseplay:loc('COURSEPLAY_ACTIVATED') or courseplay:loc('COURSEPLAY_DEACTIVATED');
if vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE and vehicle.cp.hasSowingMachine then
vehicle.cp.hud.content.pages[1][5][1].text = courseplay:loc('COURSEPLAY_RIDGEMARKERS');
vehicle.cp.hud.content.pages[1][5][2].text = vehicle.cp.ridgeMarkersAutomatic and courseplay:loc('COURSEPLAY_AUTOMATIC') or courseplay:loc('COURSEPLAY_DEACTIVATED');
elseif vehicle.cp.mode == courseplay.MODE_FIELDWORK and vehicle.cp.hasBaleLoader and not vehicle.cp.hasUnloadingRefillingCourse then
vehicle.cp.hud.content.pages[1][5][1].text = courseplay:loc('COURSEPLAY_UNLOADING_ON_FIELD');
vehicle.cp.hud.content.pages[1][5][2].text = vehicle.cp.automaticUnloadingOnField and courseplay:loc('COURSEPLAY_AUTOMATIC') or courseplay:loc('COURSEPLAY_MANUAL');
end;
if vehicle.cp.tipperHasCover and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_COMBI or vehicle.cp.mode == courseplay.MODE_TRANSPORT or vehicle.cp.mode == courseplay.MODE_FIELDWORK) then
vehicle.cp.hud.content.pages[1][6][1].text = courseplay:loc('COURSEPLAY_COVER_HANDLING');
vehicle.cp.hud.content.pages[1][6][2].text = vehicle.cp.automaticCoverHandling and courseplay:loc('COURSEPLAY_AUTOMATIC') or courseplay:loc('COURSEPLAY_DEACTIVATED');
end;
end
if (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and #vehicle.cp.easyFillTypeList > 0 then
vehicle.cp.hud.content.pages[1][5][1].text = courseplay:loc('COURSEPLAY_NUMBER_OF_RUNS');
vehicle.cp.hud.content.pages[1][5][2].text = vehicle.cp.runNumber < 11 and string.format("%d / %d",vehicle.cp.runCounter, vehicle.cp.runNumber) or courseplay:loc('COURSEPLAY_UNLIMITED');
end;
elseif not vehicle:getIsCourseplayDriving() then -- only 6 lines available, as the mode buttons are in lines 7 and 8!
if (not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused) and not vehicle.cp.canDrive then
if vehicle.cp.numWaypoints == 0 then
vehicle.cp.hud.content.pages[1][1][1].text = courseplay:loc('COURSEPLAY_RECORDING_START');
end;
--Custom field edge path
vehicle.cp.hud.content.pages[1][3][1].text = courseplay:loc('COURSEPLAY_SCAN_CURRENT_FIELD_EDGES');
if vehicle.cp.fieldEdge.customField.isCreated then
vehicle.cp.hud.content.pages[1][4][1].text = courseplay:loc('COURSEPLAY_CURRENT_FIELD_EDGE_PATH_NUMBER');
if vehicle.cp.fieldEdge.customField.fieldNum > 0 then
vehicle.cp.hud.content.pages[1][4][2].text = tostring(vehicle.cp.fieldEdge.customField.fieldNum);
if vehicle.cp.fieldEdge.customField.selectedFieldNumExists then
vehicle.cp.hud.content.pages[1][5][1].text = string.format(courseplay:loc('COURSEPLAY_OVERWRITE_CUSTOM_FIELD_EDGE_PATH_IN_LIST'), vehicle.cp.fieldEdge.customField.fieldNum);
else
vehicle.cp.hud.content.pages[1][5][1].text = string.format(courseplay:loc('COURSEPLAY_ADD_CUSTOM_FIELD_EDGE_PATH_TO_LIST'), vehicle.cp.fieldEdge.customField.fieldNum);
end;
else
vehicle.cp.hud.content.pages[1][4][2].text = '---';
end;
end;
end;
end;
--PAGE 2: COURSE LIST
elseif page == self.PAGE_MANAGE_COURSES then
-- update courses?
if vehicle.cp.reloadCourseItems then
courseplay.courses:reloadVehicleCourses(vehicle)
CourseplayEvent.sendEvent(vehicle,'self.cp.onMpSetCourses',true)
end
-- end update courses
local numCourses = #(vehicle.cp.hud.courses)
-- set line text
local courseName = ''
for line = 1, numCourses do
courseName = vehicle.cp.hud.courses[line].displayname
if courseName == nil or courseName == '' then
courseName = '-';
end;
vehicle.cp.hud.content.pages[2][line][1].text = courseName;
if vehicle.cp.hud.courses[line].type == 'course' then
vehicle.cp.hud.content.pages[2][line][1].indention = vehicle.cp.hud.courses[line].level * self.indent;
else
vehicle.cp.hud.content.pages[2][line][1].indention = (vehicle.cp.hud.courses[line].level + 1) * self.indent;
end
end;
for line = numCourses+1, self.numLines do
vehicle.cp.hud.content.pages[2][line][1].text = nil;
end
-- enable and disable buttons:
courseplay.buttons:setActiveEnabled(vehicle, 'page2');
--PAGE 3: MODE 2 SETTINGS
elseif page == self.PAGE_COMBI_MODE then
if vehicle.cp.mode == courseplay.MODE_COMBI or vehicle.cp.mode == courseplay.MODE_OVERLOADER then
vehicle.cp.hud.content.pages[3][1][1].text = courseplay:loc('COURSEPLAY_COMBINE_OFFSET_HORIZONTAL');
vehicle.cp.hud.content.pages[3][2][1].text = courseplay:loc('COURSEPLAY_COMBINE_OFFSET_VERTICAL');
if vehicle.cp.modeState ~= nil then
if vehicle.cp.combineOffset ~= 0 then
vehicle.cp.hud.content.pages[3][1][2].text = ('%s %.1fm'):format(vehicle.cp.combineOffsetAutoMode and '(auto)' or '(mnl)', vehicle.cp.combineOffset);
else
vehicle.cp.hud.content.pages[3][1][2].text = 'auto';
end;
else
vehicle.cp.hud.content.pages[3][1][2].text = '---';
end;
if vehicle.cp.tipperOffset ~= nil then
if vehicle.cp.tipperOffset ~= 0 then
vehicle.cp.hud.content.pages[3][2][2].text = ('auto%+.1fm'):format(vehicle.cp.tipperOffset);
else
vehicle.cp.hud.content.pages[3][2][2].text = 'auto';
end;
else
vehicle.cp.hud.content.pages[3][2][2].text = '---';
end;
elseif vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_FIELDWORK then
vehicle.cp.hud.content.pages[3][1][1].text = courseplay:loc('COURSEPLAY_TURN_ON_FIELD');
vehicle.cp.hud.content.pages[3][1][2].text = vehicle.cp.turnOnField and courseplay:loc('COURSEPLAY_ACTIVATED') or courseplay:loc('COURSEPLAY_DEACTIVATED');
vehicle.cp.hud.content.pages[3][2][1].text = courseplay:loc('COURSEPLAY_OPPOSITE_TURN_DIRECTION');
vehicle.cp.hud.content.pages[3][2][2].text = vehicle.cp.oppositeTurnMode and courseplay:loc('COURSEPLAY_OPPOSITE_TURN_WHEN_POSSIBLE') or courseplay:loc('COURSEPLAY_OPPOSITE_TURN_AT_END');
end;
vehicle.cp.hud.content.pages[3][3][1].text = courseplay:loc('COURSEPLAY_TURN_RADIUS');
if vehicle.cp.turnDiameterAuto ~= nil or vehicle.cp.turnDiameter ~= nil then
vehicle.cp.hud.content.pages[3][3][2].text = ('%s %d%s'):format(vehicle.cp.turnDiameterAutoMode and '(auto)' or '(mnl)', vehicle.cp.turnDiameter, courseplay:loc('COURSEPLAY_UNIT_METER'));
else
vehicle.cp.hud.content.pages[3][3][2].text = '---';
end;
vehicle.cp.hud.content.pages[3][4][1].text = courseplay:loc('COURSEPLAY_START_AT');
vehicle.cp.hud.content.pages[3][4][2].text = vehicle.cp.followAtFillLevel ~= nil and ('%d%%'):format(vehicle.cp.followAtFillLevel) or '---';
vehicle.cp.hud.content.pages[3][5][1].text = courseplay:loc('COURSEPLAY_DRIVE_ON_AT');
vehicle.cp.hud.content.pages[3][5][2].text = vehicle.cp.driveOnAtFillLevel ~= nil and ('%d%%'):format(vehicle.cp.driveOnAtFillLevel) or '---';
if vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT then
vehicle.cp.hud.content.pages[3][6][1].text = courseplay:loc('COURSEPLAY_REFILL_UNTIL_PCT');
vehicle.cp.hud.content.pages[3][6][2].text = ('%d%%'):format(vehicle.cp.refillUntilPct);
end;
if vehicle.cp.mode == courseplay.MODE_FIELDWORK and vehicle.cp.hasPlough then
vehicle.cp.hud.content.pages[3][7][1].text = courseplay:loc('COURSEPLAY_PLOUGH_FIELD_EDGE');
vehicle.cp.hud.content.pages[3][7][2].text = vehicle.cp.ploughFieldEdge and courseplay:loc('COURSEPLAY_ACTIVATED') or courseplay:loc('COURSEPLAY_DEACTIVATED');
end;
--PAGE 4: COMBINE ASSIGNMENT
elseif page == self.PAGE_MANAGE_COMBINES then
--Line 1: combine search mode (automatic vs manual)
vehicle.cp.hud.content.pages[4][1][1].text = courseplay:loc('COURSEPLAY_COMBINE_SEARCH_MODE'); --always
vehicle.cp.hud.content.pages[4][1][2].text = vehicle.cp.searchCombineAutomatically and courseplay:loc('COURSEPLAY_AUTOMATIC_SEARCH') or courseplay:loc('COURSEPLAY_MANUAL_SEARCH');
--Line 2: select combine manually
if not vehicle.cp.searchCombineAutomatically then
vehicle.cp.hud.content.pages[4][2][1].text = courseplay:loc('COURSEPLAY_CHOOSE_COMBINE'); --only if manual
if vehicle.cp.HUD4savedCombine then
if vehicle.cp.HUD4savedCombineName == nil then
vehicle:setCpVar('HUD4savedCombineName',courseplay:loc('COURSEPLAY_COMBINE'),courseplay.isClient);
end;
if vehicle.cp.savedCombine ~= nil then
local dist = courseplay:distanceToObject(vehicle, vehicle.cp.savedCombine);
if dist >= 1000 then
vehicle.cp.hud.content.pages[4][2][2].text = ('%s (%.1f%s)'):format(vehicle.cp.HUD4savedCombineName, dist * 0.001, courseplay:getMeasuringUnit());
else
vehicle.cp.hud.content.pages[4][2][2].text = ('%s (%d%s)'):format(vehicle.cp.HUD4savedCombineName, dist, courseplay:loc('COURSEPLAY_UNIT_METER'));
end;
end
else
vehicle.cp.hud.content.pages[4][2][2].text = courseplay:loc('COURSEPLAY_NONE');
end;
end;
--[[
--Line 3: choose field for automatic search --only if automatic
if vehicle.cp.searchCombineAutomatically and courseplay.fields.numAvailableFields > 0 then
vehicle.cp.hud.content.pages[4][3][1].text = courseplay:loc('COURSEPLAY_SEARCH_COMBINE_ON_FIELD'):format(vehicle.cp.searchCombineOnField > 0 and tostring(vehicle.cp.searchCombineOnField) or '---');
end;
--]]
--Line 4: current assigned combine
vehicle.cp.hud.content.pages[4][4][1].text = courseplay:loc('COURSEPLAY_CURRENT'); --always
vehicle.cp.hud.content.pages[4][4][2].text = vehicle.cp.HUD4hasActiveCombine and vehicle.cp.HUD4combineName or courseplay:loc('COURSEPLAY_NONE');
--Line 5: remove active combine from tractor
if vehicle.cp.activeCombine ~= nil then --only if activeCombine
vehicle.cp.hud.content.pages[4][5][1].text = courseplay:loc('COURSEPLAY_REMOVEACTIVECOMBINEFROMTRACTOR');
end;
--PAGE 5: SPEEDS
elseif page == self.PAGE_SPEEDS then
vehicle.cp.hud.content.pages[5][1][1].text = courseplay:loc('COURSEPLAY_SPEED_TURN');
vehicle.cp.hud.content.pages[5][2][1].text = courseplay:loc('COURSEPLAY_SPEED_FIELD');
vehicle.cp.hud.content.pages[5][3][1].text = courseplay:loc('COURSEPLAY_SPEED_MAX');
vehicle.cp.hud.content.pages[5][4][1].text = courseplay:loc('COURSEPLAY_SPEED_REVERSING');
vehicle.cp.hud.content.pages[5][5][1].text = courseplay:loc('COURSEPLAY_MAX_SPEED_MODE');
vehicle.cp.hud.content.pages[5][1][2].text = string.format('%d %s', g_i18n:getSpeed(vehicle.cp.speeds.turn), courseplay:getSpeedMeasuringUnit());
vehicle.cp.hud.content.pages[5][2][2].text = string.format('%d %s', g_i18n:getSpeed(vehicle.cp.speeds.field), courseplay:getSpeedMeasuringUnit());
vehicle.cp.hud.content.pages[5][4][2].text = string.format('%d %s', g_i18n:getSpeed(vehicle.cp.speeds.reverse), courseplay:getSpeedMeasuringUnit());
local streetSpeedStr = ('%d %s'):format(g_i18n:getSpeed(vehicle.cp.speeds.street), courseplay:getSpeedMeasuringUnit());
if vehicle.cp.speeds.useRecordingSpeed then
vehicle.cp.hud.content.pages[5][3][2].text = courseplay:loc('COURSEPLAY_MAX_SPEED_MODE_AUTOMATIC'):format(streetSpeedStr);
vehicle.cp.hud.content.pages[5][5][2].text = courseplay:loc('COURSEPLAY_MAX_SPEED_MODE_RECORDING');
else
vehicle.cp.hud.content.pages[5][3][2].text = streetSpeedStr;
vehicle.cp.hud.content.pages[5][5][2].text = courseplay:loc('COURSEPLAY_MAX_SPEED_MODE_MAX');
end;
-- Always use 4WD
if vehicle.cp.hasDriveControl and vehicle.cp.driveControl.hasFourWD then
vehicle.cp.hud.content.pages[5][7][1].text = courseplay:loc('COURSEPLAY_ALWAYS_USE_4WD');
vehicle.cp.hud.content.pages[5][7][2].text = vehicle.cp.driveControl.alwaysUseFourWD and courseplay:loc('COURSEPLAY_ACTIVATED') or courseplay:loc('COURSEPLAY_DEACTIVATED');
end;
--FuelSaveOption
vehicle.cp.hud.content.pages[5][8][1].text = courseplay:loc('COURSEPLAY_FUELSAVEOPTION');
vehicle.cp.hud.content.pages[5][8][2].text = vehicle.cp.saveFuelOptionActive and courseplay:loc('COURSEPLAY_ACTIVATED') or courseplay:loc('COURSEPLAY_DEACTIVATED');
--PAGE 6: GENERAL SETTINGS
elseif page == self.PAGE_GENERAL_SETTINGS then
-- pathfinding
vehicle.cp.hud.content.pages[6][1][1].text = nil;
vehicle.cp.hud.content.pages[6][1][2].text = nil;
if vehicle.cp.mode == courseplay.MODE_COMBI or vehicle.cp.mode == courseplay.MODE_OVERLOADER then
vehicle.cp.hud.content.pages[6][1][1].text = courseplay:loc('COURSEPLAY_PATHFINDING');
vehicle.cp.hud.content.pages[6][1][2].text = vehicle.cp.realisticDriving and courseplay:loc('COURSEPLAY_ACTIVATED') or courseplay:loc('COURSEPLAY_DEACTIVATED');
end;
-- Open hud key
vehicle.cp.hud.content.pages[6][2][1].text = courseplay:loc('COURSEPLAY_OPEN_HUD_MODE');
vehicle.cp.hud.content.pages[6][2][2].text = vehicle.cp.hud.openWithMouse and courseplay.inputBindings.mouse.secondaryTextI18n or courseplay.inputBindings.keyboard.openCloseHudTextI18n;
-- Waypoint mode
vehicle.cp.hud.content.pages[6][3][1].text = courseplay:loc('COURSEPLAY_WAYPOINT_MODE');
-- Warning lights
vehicle.cp.hud.content.pages[6][4][1].text = courseplay:loc('COURSEPLAY_WARNING_LIGHTS');
vehicle.cp.hud.content.pages[6][4][2].text = courseplay:loc('COURSEPLAY_WARNING_LIGHTS_MODE_' .. vehicle.cp.warningLightsMode);
-- Waiting point: wait time
if courseplay:getCanHaveWaitTime(vehicle) then
vehicle.cp.hud.content.pages[6][5][1].text = courseplay:loc('COURSEPLAY_WAITING_TIME');
local str;