forked from Courseplay/courseplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.lua
958 lines (857 loc) · 39.6 KB
/
button.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
-- #################################################################
-- courseplay.button class
courseplay.button = {};
cpButton_mt = Class(courseplay.button);
function courseplay.button:new(vehicle, hudPage, img, functionToCall, parameter, x, y, width, height, hudRow, modifiedParameter, hoverText, isMouseWheelArea, isToggleButton, toolTip)
local self = setmetatable({}, cpButton_mt);
if img then
if type(img) == 'table' then
if img[1] == 'iconSprite.png' then
self.overlay = Overlay:new( courseplay.hud.iconSpritePath, x, y, width, height);
self.spriteSection = img[2];
end;
else
self.overlay = Overlay:new(Utils.getFilename('img/' .. img, courseplay.path), x, y, width, height);
end;
end;
if hoverText == nil then
hoverText = false;
end;
if isMouseWheelArea == nil then
isMouseWheelArea = false;
end;
if isToggleButton == nil then
isToggleButton = false;
end;
if not vehicle.isCourseplayManager then
self.vehicle = vehicle;
end;
self.page = hudPage;
self.functionToCall = functionToCall;
self:setParameter(parameter);
self.width = width;
self.height = height;
self.x_init = x;
self.x = x;
self.x2 = (x + width);
self.y_init = y;
self.y = y;
self.y2 = (y + height);
self.row = hudRow;
self.hoverText = hoverText;
self:setColor('white')
self:setToolTip(toolTip);
self.isMouseWheelArea = isMouseWheelArea and functionToCall ~= nil;
self.isToggleButton = isToggleButton;
self:setCanBeClicked(not isMouseWheelArea and functionToCall ~= nil);
self:setShow(true);
self:setClicked(false);
self:setActive(false);
self:setDisabled(false);
self:setHovered(false);
if modifiedParameter then
self.modifiedParameter = modifiedParameter;
end
if isMouseWheelArea then
self.canScrollUp = true;
self.canScrollDown = true;
end;
if self.spriteSection then
self:setSpriteSectionUVs(self.spriteSection);
else
self:setSpecialButtonUVs();
end;
if vehicle.isCourseplayManager then
table.insert(vehicle[hudPage].buttons, self);
else
table.insert(vehicle.cp.buttons[hudPage], self);
end;
return self;
end;
function courseplay.button:setSpriteSectionUVs(spriteSection)
if not spriteSection or courseplay.hud.buttonUVsPx[spriteSection] == nil then return; end;
self.spriteSection = spriteSection;
courseplay.utils:setOverlayUVsPx(self.overlay, courseplay.hud.buttonUVsPx[spriteSection], courseplay.hud.iconSpriteSize.x, courseplay.hud.iconSpriteSize.y);
end;
function courseplay.button:setSpecialButtonUVs()
if not self.overlay then return; end;
local fn = self.functionToCall;
local prm = self.parameter;
local txtSizeX, txtSizeY = courseplay.hud.iconSpriteSize.x, courseplay.hud.iconSpriteSize.y;
if fn == 'setCpMode' then
courseplay.utils:setOverlayUVsPx(self.overlay, courseplay.hud.modeButtonsUVsPx[prm], txtSizeX, txtSizeY);
elseif fn == 'setHudPage' then
courseplay.utils:setOverlayUVsPx(self.overlay, courseplay.hud.pageButtonsUVsPx[prm], txtSizeX, txtSizeY);
elseif fn == 'generateCourse' then
courseplay.utils:setOverlayUVsPx(self.overlay, courseplay.hud.pageButtonsUVsPx[courseplay.hud.PAGE_COURSE_GENERATION], txtSizeX, txtSizeY);
elseif fn == 'toggleDebugChannel' then
self:setSpriteSectionUVs('recordingStop');
-- CpManager buttons
elseif fn == 'goToVehicle' then
courseplay.utils:setOverlayUVsPx(self.overlay, courseplay.hud.pageButtonsUVsPx[courseplay.hud.PAGE_DRIVING_SETTINGS], txtSizeX, txtSizeY);
end;
end;
function courseplay.button:render()
-- self = courseplay.button
local vehicle, pg, fn, prm = self.vehicle, self.page, self.functionToCall, self.parameter;
local hoveredButton = false;
--mouseWheelAreas conditionals
if self.isMouseWheelArea then
local canScrollUp, canScrollDown;
if pg == courseplay.hud.PAGE_CP_CONTROL then
if fn == "setCustomFieldEdgePathNumber" then
canScrollUp = vehicle.cp.fieldEdge.customField.isCreated and vehicle.cp.fieldEdge.customField.fieldNum < courseplay.fields.customFieldMaxNum;
canScrollDown = vehicle.cp.fieldEdge.customField.isCreated and vehicle.cp.fieldEdge.customField.fieldNum > 0;
elseif fn == "changeSiloFillType" then
canScrollUp = vehicle.cp.canDrive and not vehicle:getIsCourseplayDriving() and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE)and #vehicle.cp.easyFillTypeList > 0;
canScrollDown = vehicle.cp.canDrive and not vehicle:getIsCourseplayDriving() and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE)and #vehicle.cp.easyFillTypeList > 0;
elseif fn == 'changeRunNumber' then
local canChange = true
if ((vehicle.cp.fillTrigger or vehicle.cp.isInFilltrigger) or vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT) and not vehicle.cp.runCounterBool then
canChange = vehicle.cp.runNumber - vehicle.cp.runCounter > 1
end
canScrollUp = vehicle.cp.runNumber < 11 and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.canDrive and (not vehicle.cp.runReset or vehicle.cp.runCounter == 0) and #vehicle.cp.easyFillTypeList > 0;
canScrollDown = vehicle.cp.runNumber > vehicle.cp.runCounter and vehicle.cp.runNumber > 1 and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.canDrive and canChange and #vehicle.cp.easyFillTypeList > 0;
end;
elseif pg == courseplay.hud.PAGE_MANAGE_COURSES then
if fn == "shiftHudCourses" then
canScrollUp = vehicle.cp.hud.courseListPrev == true;
canScrollDown = vehicle.cp.hud.courseListNext == true;
end;
elseif pg == courseplay.hud.PAGE_COMBI_MODE then
if fn == 'changeCombineOffset' or fn == 'changeTipperOffset' then
canScrollUp = vehicle.cp.mode == courseplay.MODE_COMBI or vehicle.cp.mode == courseplay.MODE_OVERLOADER;
canScrollDown = canScrollUp;
elseif fn == "changeTurnDiameter" then
canScrollUp = true;
canScrollDown = vehicle.cp.turnDiameter > 0;
elseif fn == "changeFollowAtFillLevel" then
canScrollUp = vehicle.cp.followAtFillLevel < 100;
canScrollDown = vehicle.cp.followAtFillLevel > 0;
elseif fn == "changeDriveOnAtFillLevel" then
canScrollUp = vehicle.cp.driveOnAtFillLevel < 100;
canScrollDown = vehicle.cp.driveOnAtFillLevel > 0;
elseif fn == 'changeRefillUntilPct' then
canScrollUp = (vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.refillUntilPct < 100;
canScrollDown = (vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.refillUntilPct > 1;
end;
elseif pg == courseplay.hud.PAGE_MANAGE_COMBINES then
if fn == 'setSearchCombineOnField' then
canScrollUp = courseplay.fields.numAvailableFields > 0 and vehicle.cp.searchCombineAutomatically and vehicle.cp.searchCombineOnField < courseplay.fields.numAvailableFields;
canScrollDown = courseplay.fields.numAvailableFields > 0 and vehicle.cp.searchCombineAutomatically and vehicle.cp.searchCombineOnField > 0;
end;
elseif pg == courseplay.hud.PAGE_SPEEDS then
if fn == 'changeTurnSpeed' then
canScrollUp = vehicle.cp.speeds.turn < vehicle.cp.speeds.max;
canScrollDown = vehicle.cp.speeds.turn > vehicle.cp.speeds.minTurn;
elseif fn == 'changeFieldSpeed' then
canScrollUp = vehicle.cp.speeds.field < vehicle.cp.speeds.max;
canScrollDown = vehicle.cp.speeds.field > vehicle.cp.speeds.minField;
elseif fn == 'changeMaxSpeed' then
canScrollUp = vehicle.cp.speeds.useRecordingSpeed == false and vehicle.cp.speeds.street < vehicle.cp.speeds.max;
canScrollDown = vehicle.cp.speeds.useRecordingSpeed == false and vehicle.cp.speeds.street > vehicle.cp.speeds.minStreet;
elseif fn == 'changeReverseSpeed' then
canScrollUp = vehicle.cp.speeds.reverse < vehicle.cp.speeds.max;
canScrollDown = vehicle.cp.speeds.reverse > vehicle.cp.speeds.minReverse;
end;
elseif pg == courseplay.hud.PAGE_GENERAL_SETTINGS then
if fn == "changeWaitTime" then
canScrollUp = courseplay:getCanHaveWaitTime(vehicle);
canScrollDown = canScrollUp and vehicle.cp.waitTime > 0;
elseif fn == 'changeDebugChannelSection' then
canScrollUp = courseplay.debugChannelSection > 1;
canScrollDown = courseplay.debugChannelSection < courseplay.numDebugChannelSections;
end;
elseif pg == courseplay.hud.PAGE_DRIVING_SETTINGS then
if fn == "changeLaneOffset" then
canScrollUp = vehicle.cp.multiTools == 1 and (vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_FIELDWORK)
canScrollDown = canScrollUp;
elseif fn == 'changeLaneNumber' then
canScrollUp = math.floor(vehicle.cp.multiTools/2) > vehicle.cp.laneNumber
canScrollDown = math.floor(vehicle.cp.multiTools/2)*-1 < vehicle.cp.laneNumber
elseif fn == "changeToolOffsetX" or fn == "changeToolOffsetZ" then
canScrollUp = vehicle.cp.mode == courseplay.MODE_OVERLOADER
or vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE
or vehicle.cp.mode == courseplay.MODE_FIELDWORK
or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT;
canScrollDown = canScrollUp;
elseif fn == "changeLoadUnloadOffsetX" or fn == "changeLoadUnloadOffsetZ" then
canScrollUp = vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT
or vehicle.cp.mode == courseplay.MODE_OVERLOADER
or vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE
or vehicle.cp.mode == courseplay.MODE_FIELDWORK
or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT;
canScrollDown = canScrollUp;
end;
elseif pg == courseplay.hud.PAGE_COURSE_GENERATION then
if fn == "setFieldEdgePath" then
canScrollUp = courseplay.fields.numAvailableFields > 0 and vehicle.cp.fieldEdge.selectedField.fieldNum < courseplay.fields.numAvailableFields;
canScrollDown = courseplay.fields.numAvailableFields > 0 and vehicle.cp.fieldEdge.selectedField.fieldNum > 0;
elseif fn == "changeWorkWidth" then
canScrollUp = true;
canScrollDown = vehicle.cp.workWidth > 0.1;
elseif fn == 'changeByMultiTools' then
canScrollUp = vehicle.cp.multiTools < 8
canScrollDown = vehicle.cp.multiTools > 1
elseif fn == 'changeRowAngle' then
canScrollUp = true
canScrollDown = true
end;
elseif pg == courseplay.hud.PAGE_SHOVEL_POSITIONS then
if fn == "changeWorkWidth" then
canScrollUp = true;
canScrollDown = vehicle.cp.workWidth > 0.1;
end
elseif pg == courseplay.hud.PAGE_BUNKERSILO_SETTINGS then
if fn == "changeMode10Radius" then
canScrollUp = true;
canScrollDown = vehicle.cp.mode10.searchRadius > 1;
elseif fn == "changeShieldHeight" then
canScrollUp = not vehicle.cp.mode10.automaticHeigth and vehicle.cp.mode10.shieldHeight < 1.5
canScrollDown = not vehicle.cp.mode10.automaticHeigth and vehicle.cp.mode10.shieldHeight > 0
elseif fn == "changeBunkerSpeed" then
local uMayUseIt = (vehicle.cp.mode10.leveling and not vehicle.cp.mode10.automaticSpeed) or not vehicle.cp.mode10.leveling
canScrollUp = uMayUseIt and vehicle.cp.speeds.bunkerSilo < 20;
canScrollDown = uMayUseIt and vehicle.cp.speeds.bunkerSilo > 3;
elseif fn == "changeWorkWidth" then
canScrollUp = true;
canScrollDown = vehicle.cp.workWidth > 0.1;
end
end;
if canScrollUp ~= nil then
self:setCanScrollUp(canScrollUp);
end;
if canScrollDown ~= nil then
self:setCanScrollDown(canScrollDown);
end;
elseif self.overlay ~= nil then
if pg ~= -courseplay.hud.PAGE_MANAGE_COURSES then -- NOTE: course buttons' (page -2) visibility are handled in buttonsActiveEnabled(), section 'page2'
local show = true;
-- CONDITIONAL DISPLAY
-- Global
if pg == "global" then
if fn == "showSaveCourseForm" and prm == "course" then
show = vehicle.cp.canDrive and not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused and vehicle.Waypoints ~= nil and vehicle.cp.numWaypoints > 0;
end;
-- Page 1
elseif pg == courseplay.hud.PAGE_CP_CONTROL then
if fn == "setCpMode" then
show = vehicle.cp.canSwitchMode and not vehicle.cp.distanceCheck;
elseif fn == "clearCustomFieldEdge" or fn == "toggleCustomFieldEdgePathShow" then
show = not vehicle.cp.canDrive and vehicle.cp.fieldEdge.customField.isCreated;
elseif fn == "setCustomFieldEdgePathNumber" then
if prm < 0 then
show = not vehicle.cp.canDrive and vehicle.cp.fieldEdge.customField.isCreated and vehicle.cp.fieldEdge.customField.fieldNum > 0;
elseif prm > 0 then
show = not vehicle.cp.canDrive and vehicle.cp.fieldEdge.customField.isCreated and vehicle.cp.fieldEdge.customField.fieldNum < courseplay.fields.customFieldMaxNum;
end;
elseif fn == 'toggleFindFirstWaypoint' then
show = vehicle.cp.canDrive and not vehicle:getIsCourseplayDriving() and not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused;
elseif fn == 'stop_record' or fn == 'setRecordingPause' or fn == 'delete_waypoint' or fn == 'set_waitpoint' or fn == 'set_unloadPoint' or fn == 'set_crossing' or fn == 'setRecordingTurnManeuver' or fn == 'change_DriveDirection' or fn == 'addSplitRecordingPoints' then
show = vehicle.cp.isRecording or vehicle.cp.recordingIsPaused;
elseif fn == 'clearCurrentLoadedCourse' then
show = vehicle.cp.canDrive and not vehicle.cp.isDriving;
elseif fn == 'changeSiloFillType' then
show = vehicle.cp.canDrive and not vehicle:getIsCourseplayDriving() and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE) and #vehicle.cp.easyFillTypeList > 0;
elseif fn == 'movePipeToPosition' then
show = vehicle.cp.canDrive and not vehicle:getIsCourseplayDriving() and vehicle.cp.hasAugerWagon and not vehicle.cp.hasSugarCaneAugerWagon and (vehicle.cp.mode == courseplay.MODE_OVERLOADER or vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT);
elseif fn == 'changeRunNumber' then
if prm < 0 then
local canChange = true
if ((vehicle.cp.fillTrigger or vehicle.cp.isInFilltrigger) or vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT) and not vehicle.cp.runCounterBool then
canChange = vehicle.cp.runNumber - vehicle.cp.runCounter > 1
end
show = vehicle.cp.runNumber > vehicle.cp.runCounter and vehicle.cp.runNumber > 1 and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.canDrive and canChange and #vehicle.cp.easyFillTypeList > 0;
elseif prm > 0 then
show = vehicle.cp.runNumber < 11 and (vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.canDrive and (not vehicle.cp.runReset or vehicle.cp.runCounter == 0) and #vehicle.cp.easyFillTypeList > 0;
end;
end;
-- Page 2
elseif pg == courseplay.hud.PAGE_MANAGE_COURSES then
if fn == "reloadCoursesFromXML" then
show = g_server ~= nil and not vehicle.cp.canDrive and not g_currentMission.missionDynamicInfo.isMultiplayer;
elseif fn == "showSaveCourseForm" and prm == "filter" then
show = not vehicle.cp.hud.choose_parent;
elseif fn == 'clearCurrentLoadedCourse' then
show = vehicle.cp.canDrive and not vehicle.cp.isDriving;
elseif fn == "shiftHudCourses" then
if prm < 0 then
show = vehicle.cp.hud.courseListPrev;
elseif prm > 0 then
show = vehicle.cp.hud.courseListNext;
end;
end;
-- Page 3
elseif pg == courseplay.hud.PAGE_COMBI_MODE then
if fn == 'changeCombineOffset' or fn == 'changeTipperOffset' then
show = vehicle.cp.mode == courseplay.MODE_COMBI or vehicle.cp.mode == courseplay.MODE_OVERLOADER;
elseif fn == "changeTurnDiameter" and prm < 0 then
show = vehicle.cp.turnDiameter > 0;
elseif fn == "changeFollowAtFillLevel" then
if prm < 0 then
show = vehicle.cp.followAtFillLevel > 0;
elseif prm > 0 then
show = vehicle.cp.followAtFillLevel < 100;
end;
elseif fn == "changeDriveOnAtFillLevel" then
if prm < 0 then
show = vehicle.cp.driveOnAtFillLevel > 0;
elseif prm > 0 then
show = vehicle.cp.driveOnAtFillLevel < 100;
end;
elseif fn == 'changeRefillUntilPct' then
if prm < 0 then
show = (vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.refillUntilPct > 1;
elseif prm > 0 then
show = (vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT) and vehicle.cp.refillUntilPct < 100;
end;
elseif fn == 'changeLastValidTipDistance' then
show = vehicle.cp.lastValidTipDistance ~= nil
end;
-- Page 4
elseif pg == courseplay.hud.PAGE_MANAGE_COMBINES then
if fn == 'selectAssignedCombine' then
show = not vehicle.cp.searchCombineAutomatically;
if show and prm < 0 then
show = vehicle.cp.selectedCombineNumber > 0;
end;
elseif fn == 'setSearchCombineOnField' then
show = courseplay.fields.numAvailableFields > 0 and vehicle.cp.searchCombineAutomatically;
if show then
if prm < 0 then
show = vehicle.cp.searchCombineOnField > 0;
else
show = vehicle.cp.searchCombineOnField < courseplay.fields.numAvailableFields;
end;
end;
elseif fn == 'removeActiveCombineFromTractor' then
show = vehicle.cp.activeCombine ~= nil;
end;
-- Page 5
elseif pg == courseplay.hud.PAGE_SPEEDS then
if fn == 'changeTurnSpeed' then
if prm < 0 then
show = vehicle.cp.speeds.turn > vehicle.cp.speeds.minTurn;
elseif prm > 0 then
show = vehicle.cp.speeds.turn < vehicle.cp.speeds.max;
end;
elseif fn == 'changeFieldSpeed' then
if prm < 0 then
show = vehicle.cp.speeds.field > vehicle.cp.speeds.minField;
elseif prm > 0 then
show = vehicle.cp.speeds.field < vehicle.cp.speeds.max;
end;
elseif fn == 'changeMaxSpeed' then
if prm < 0 then
show = not vehicle.cp.speeds.useRecordingSpeed and vehicle.cp.speeds.street > vehicle.cp.speeds.minStreet;
elseif prm > 0 then
show = not vehicle.cp.speeds.useRecordingSpeed and vehicle.cp.speeds.street < vehicle.cp.speeds.max;
end;
elseif fn == 'changeReverseSpeed' then
if prm < 0 then
show = vehicle.cp.speeds.reverse > vehicle.cp.speeds.minReverse;
elseif prm > 0 then
show = vehicle.cp.speeds.reverse < vehicle.cp.speeds.max;
end;
elseif fn == 'changeDriveControlMode' then
if prm < 0 then
show = vehicle.cp.hasDriveControl and vehicle.cp.driveControl.hasFourWD and vehicle.cp.driveControl.mode > vehicle.cp.driveControl.OFF
else
show = vehicle.cp.hasDriveControl and vehicle.cp.driveControl.hasFourWD and vehicle.cp.driveControl.mode < vehicle.cp.driveControl.AWD_BOTH_DIFF
end;
end;
-- Page 6
elseif pg == courseplay.hud.PAGE_GENERAL_SETTINGS then
if fn == 'toggleRealisticDriving' then
show = vehicle.cp.mode == courseplay.MODE_COMBI or vehicle.cp.mode == courseplay.MODE_OVERLOADER;
elseif fn == 'changeWarningLightsMode' then
if prm < 0 then
show = vehicle.cp.warningLightsMode > courseplay.lights.WARNING_LIGHTS_NEVER;
else
show = vehicle.cp.warningLightsMode < courseplay.lights.WARNING_LIGHTS_BEACON_ALWAYS;
end;
elseif fn == "changeWaitTime" then
show = courseplay:getCanHaveWaitTime(vehicle);
if show and prm < 0 then
show = vehicle.cp.waitTime > 0;
end;
elseif fn == "toggleDebugChannel" then
show = prm >= courseplay.debugChannelSectionStart and prm <= courseplay.debugChannelSectionEnd;
elseif fn == "changeDebugChannelSection" then
if prm < 0 then
show = courseplay.debugChannelSection > 1;
elseif prm > 0 then
show = courseplay.debugChannelSection < courseplay.numDebugChannelSections;
end;
end;
-- Page 7
elseif pg == courseplay.hud.PAGE_DRIVING_SETTINGS then
if fn == "changeLaneOffset" then
show = vehicle.cp.multiTools == 1 and (vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_FIELDWORK);
elseif fn == 'changeLaneNumber' then
if prm > 0 then
show = math.floor(vehicle.cp.multiTools/2) > vehicle.cp.laneNumber
elseif prm < 0 then
show = math.floor(vehicle.cp.multiTools/2)*-1 < vehicle.cp.laneNumber
end;
elseif fn == "toggleSymmetricLaneChange" then
show = (vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_FIELDWORK) and vehicle.cp.laneOffset ~= 0;
elseif fn == "changeToolOffsetX" or fn == "changeToolOffsetZ" then
show = vehicle.cp.mode == courseplay.MODE_OVERLOADER
or vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE
or vehicle.cp.mode == courseplay.MODE_FIELDWORK
or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT;
elseif fn == "changeLoadUnloadOffsetX" or fn == "changeLoadUnloadOffsetZ" then
show = vehicle.cp.mode == courseplay.MODE_GRAIN_TRANSPORT
or vehicle.cp.mode == courseplay.MODE_OVERLOADER
or vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE
or vehicle.cp.mode == courseplay.MODE_FIELDWORK
or vehicle.cp.mode == courseplay.MODE_LIQUIDMANURE_TRANSPORT;
elseif fn == "switchDriverCopy" and prm < 0 then
show = vehicle.cp.selectedDriverNumber > 0;
elseif fn == "copyCourse" then
show = vehicle.cp.hasFoundCopyDriver;
end;
-- Page 8
elseif pg == courseplay.hud.PAGE_COURSE_GENERATION then
if fn == 'clearCurrentLoadedCourse' then
show = vehicle.cp.canDrive and not vehicle.cp.isDriving;
elseif fn == 'toggleSucHud' then
show = courseplay.fields.numAvailableFields > 0 and vehicle.cp.fieldEdge.selectedField.fieldNum > 0;
elseif fn == "toggleSelectedFieldEdgePathShow" then
show = courseplay.fields.numAvailableFields > 0 and vehicle.cp.fieldEdge.selectedField.fieldNum > 0;
elseif fn == "setFieldEdgePath" then
show = courseplay.fields.numAvailableFields > 0;
if show then
if prm < 0 then
show = vehicle.cp.fieldEdge.selectedField.fieldNum > 0;
elseif prm > 0 then
show = vehicle.cp.fieldEdge.selectedField.fieldNum < courseplay.fields.numAvailableFields;
end;
end;
elseif fn == "changeWorkWidth" and prm < 0 then
show = vehicle.cp.workWidth > 0.1;
elseif fn == "changeStartingDirection" then
show = vehicle.cp.hasStartingCorner;
elseif fn == 'toggleHeadlandDirection' or fn == 'toggleHeadlandOrder' then
show = vehicle.cp.headland.exists();
elseif fn == 'changeHeadlandNumLanes' then
if prm < 0 then
show = vehicle.cp.headland.numLanes > vehicle.cp.headland.getMinNumLanes();
elseif prm > 0 then
show = vehicle.cp.headland.getNumLanes() < vehicle.cp.headland.getMaxNumLanes();
end;
-- NOTE: generateCourse button is handled in buttonsActiveEnabled(), section 'generateCourse'
elseif fn == 'changeByMultiTools' then
if prm > 0 then
show = vehicle.cp.multiTools < 8
elseif prm < 0 then
show = vehicle.cp.multiTools > 1
end;
elseif fn == 'changeRowAngle' then
-- This whole button show/not show thing should be refactored, this is not the right place for it
-- and this three hundred line if statement is bad a joke...
show = vehicle.cp.startingDirection == courseGenerator.ROW_DIRECTION_MANUAL
end;
-- Page 10
elseif pg == courseplay.hud.PAGE_BUNKERSILO_SETTINGS then
if fn == 'changeShieldHeight' then
show = (not vehicle.cp.mode10.automaticHeigth) and vehicle.cp.mode10.leveling
if show and prm < 0 then
show = vehicle.cp.mode10.shieldHeight > 0;
end
elseif fn == 'changeBunkerSpeed' then
show = (not vehicle.cp.mode10.automaticSpeed or not vehicle.cp.mode10.leveling)
if show then
if prm < 0 then
show = vehicle.cp.speeds.bunkerSilo > 3
else
show = (vehicle.cp.speeds.bunkerSilo < 15 and vehicle.cp.mode10.leveling) or (vehicle.cp.speeds.bunkerSilo < 20 and not vehicle.cp.mode10.leveling)
end
end
elseif fn == "changeWorkWidth" and prm < 0 then
show = vehicle.cp.workWidth > 0.1;
elseif fn == 'changeMode10Radius' then
if prm < 0 then
show = vehicle.cp.mode10.searchRadius > 1
end
end
end;
self:setShow(show);
end;
if self.show then
-- set color
local currentColor = self.curColor;
local targetColor = currentColor;
local hoverColor = 'hover';
if fn == 'openCloseHud' then
hoverColor = 'closeRed';
end;
if fn == 'movePipeToPosition' then
if vehicle.cp.pipeWorkToolIndex ~= nil and vehicle.cp.manualPipePositionOrder then
targetColor = 'warningRed';
elseif vehicle.cp.pipeWorkToolIndex ~= nil then
targetColor = 'activeGreen';
end
elseif fn == 'moveShovelToPosition' and not self.isDisabled and vehicle.cp.manualShovelPositionOrder and vehicle.cp.manualShovelPositionOrder == prm then -- forced color
targetColor = 'warningRed';
elseif not self.isDisabled and not self.isActive and not self.isHovered and self.canBeClicked and not self.isClicked then
targetColor = 'white';
elseif self.isDisabled then
targetColor = 'whiteDisabled';
elseif not self.isDisabled and self.canBeClicked and self.isClicked and fn ~= 'openCloseHud' then
targetColor = 'activeRed';
elseif self.isHovered and ((not self.isDisabled and self.isToggleButton and self.isActive and self.canBeClicked and not self.isClicked) or (not self.isDisabled and not self.isActive and self.canBeClicked and not self.isClicked)) then
targetColor = hoverColor;
hoveredButton = true;
if self.isToggleButton then
--print(string.format('self %q (loop %d): isHovered=%s, isActive=%s, isDisabled=%s, canBeClicked=%s -> hoverColor', fn, g_updateLoopIndex, tostring(self.isHovered), tostring(self.isActive), tostring(self.isDisabled), tostring(self.canBeClicked)));
end;
elseif self.isActive and (not self.isToggleButton or (self.isToggleButton and not self.isHovered)) then
targetColor = 'activeGreen';
if self.isToggleButton then
--print(string.format('button %q (loop %d): isHovered=%s, isActive=%s, isDisabled=%s, canBeClicked=%s -> activeGreen', fn, g_updateLoopIndex, tostring(self.isHovered), tostring(self.isActive), tostring(self.isDisabled), tostring(self.canBeClicked)));
end;
end;
if currentColor ~= targetColor then
self:setColor(targetColor);
end;
-- render
self.overlay:render();
end;
end; --elseif button.overlay ~= nil
return hoveredButton;
end;
function courseplay.button:setColor(colorName)
if self.overlay and colorName and (self.curColor == nil or self.curColor ~= colorName) and courseplay.hud.colors[colorName] then
self.overlay:setColor(unpack(courseplay.hud.colors[colorName]));
self.curColor = colorName;
end;
end;
function courseplay.button:setPosition(posX, posY)
self.x = posX;
self.x_init = posX;
self.x2 = posX + self.width;
self.y = posY;
self.y_init = posY;
self.y2 = posY + self.height;
if not self.overlay then return; end;
self.overlay:setPosition(self.x, self.y);
end;
function courseplay.button:setOffset(offsetX, offsetY)
offsetX = offsetX or 0
offsetY = offsetY or 0
self.x = self.x_init + offsetX;
self.y = self.y_init + offsetY;
self.x2 = self.x + self.width;
self.y2 = self.y + self.height;
if not self.overlay then return; end;
self.overlay:setPosition(self.x, self.y);
end
function courseplay.button:setParameter(parameter)
if self.parameter ~= parameter then
self.parameter = parameter;
end;
end;
function courseplay.button:setToolTip(text)
if self.toolTip ~= text then
self.toolTip = text;
end;
end;
function courseplay.button:setActive(active)
if self.isActive ~= active then
self.isActive = active;
end;
end;
function courseplay.button:setCanBeClicked(canBeClicked)
if self.canBeClicked ~= canBeClicked then
self.canBeClicked = canBeClicked;
end;
end;
function courseplay.button:setClicked(clicked)
if self.isClicked ~= clicked then
self.isClicked = clicked;
end;
end;
function courseplay.button:setDisabled(disabled)
if self.isDisabled ~= disabled then
self.isDisabled = disabled;
end;
end;
function courseplay.button:setHovered(hovered)
if self.isHovered ~= hovered then
self.isHovered = hovered;
end;
end;
function courseplay.button:setCanScrollUp(canScrollUp)
if self.canScrollUp ~= canScrollUp then
self.canScrollUp = canScrollUp;
end;
end;
function courseplay.button:setCanScrollDown(canScrollDown)
if self.canScrollDown ~= canScrollDown then
self.canScrollDown = canScrollDown;
end;
end;
function courseplay.button:setShow(show)
if self.show ~= show then
self.show = show;
end;
end;
function courseplay.button:setAttribute(attribute, value)
if self[attribute] ~= value then
self[attribute] = value;
end;
end;
function courseplay.button:deleteOverlay()
if self.overlay ~= nil and self.overlay.overlayId ~= nil and self.overlay.delete ~= nil then
self.overlay:delete();
end;
end;
function courseplay.button:getHasMouse(mouseX, mouseY)
-- return mouseX > self.x and mouseX < self.x2 and mouseY > self.y and mouseY < self.y2;
return courseplay:mouseIsInArea(mouseX, mouseY, self.x, self.x2, self.y, self.y2);
end;
-- #################################################################
-- courseplay.buttons
function courseplay.buttons:renderButtons(vehicle, page)
-- self = courseplay.buttons
local hoveredButton;
for _,button in pairs(vehicle.cp.buttons.global) do
if button:render() then
hoveredButton = button;
end;
end;
for _,button in pairs(vehicle.cp.buttons[page]) do
if button:render() then
hoveredButton = button;
end;
end;
if page == courseplay.hud.PAGE_MANAGE_COURSES then
for _,button in pairs(vehicle.cp.buttons[-courseplay.hud.PAGE_MANAGE_COURSES]) do
if button:render() then
hoveredButton = button;
end;
end;
end;
if vehicle.cp.suc.active then
if vehicle.cp.suc.fruitNegButton:render() then
hoveredButton = vehicle.cp.suc.fruitNegButton;
end;
if vehicle.cp.suc.fruitPosButton:render() then
hoveredButton = vehicle.cp.suc.fruitPosButton;
end;
end;
-- set currently hovered button in vehicle
self:setHoveredButton(vehicle, hoveredButton);
end;
function courseplay.buttons:setHoveredButton(vehicle, button)
if vehicle.cp.buttonHovered == button then
return;
end;
vehicle.cp.buttonHovered = button;
self:onHoveredButtonChanged(vehicle);
end;
function courseplay.buttons:onHoveredButtonChanged(vehicle)
-- set toolTip in vehicle
if vehicle.cp.buttonHovered ~= nil and vehicle.cp.buttonHovered.toolTip ~= nil then
courseplay:setToolTip(vehicle, vehicle.cp.buttonHovered.toolTip);
elseif vehicle.cp.buttonHovered == nil then
courseplay:setToolTip(vehicle, nil);
end;
end;
function courseplay.buttons:deleteButtonOverlays(vehicle)
for k,buttonSection in pairs(vehicle.cp.buttons) do
for i,button in pairs(buttonSection) do
button:deleteOverlay();
end;
end;
end;
function courseplay.buttons:setActiveEnabled(vehicle, section)
local anySection = section == nil or section == 'all';
if anySection or section == 'pageNav' then
for _,button in pairs(vehicle.cp.buttons.global) do
if button.functionToCall == 'setHudPage' then
local pageNum = button.parameter;
button:setActive(pageNum == vehicle.cp.hud.currentPage);
if vehicle.cp.mode == nil then
button:setDisabled(false);
elseif courseplay.hud.pagesPerMode[vehicle.cp.mode] ~= nil and courseplay.hud.pagesPerMode[vehicle.cp.mode][pageNum] then
if pageNum == 0 then
local disabled = not (vehicle.cp.minHudPage == 0 or vehicle.cp.isCombine or vehicle.cp.isChopper or vehicle.cp.isHarvesterSteerable or vehicle.cp.isSugarBeetLoader or vehicle.cp.attachedCombine ~= nil);
button:setDisabled(disabled);
else
button:setDisabled(false);
end;
else
button:setDisabled(true);
end;
button:setCanBeClicked(not button.isDisabled and not button.isActive);
end;
end;
end;
if vehicle.cp.hud.currentPage == 1 and (anySection or section == 'quickModes' or section == 'recording' or section == 'customFieldShow' or section == 'findFirstWaypoint') then
local isMode2_3_4_6 = vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_FIELDWORK or vehicle.cp.mode == courseplay.MODE_COMBI or vehicle.cp.mode == courseplay.MODE_OVERLOADER;
local isMode4or6 = vehicle.cp.mode == courseplay.MODE_SEED_FERTILIZE or vehicle.cp.mode == courseplay.MODE_FIELDWORK
for _,button in pairs(vehicle.cp.buttons[1]) do
local fn, prm = button.functionToCall, button.parameter;
if fn == 'setCpMode' and (anySection or section == 'quickModes') then
button:setActive(vehicle.cp.mode == prm);
local disabled = not courseplay:getCanVehicleUseMode(vehicle, prm);
button:setDisabled(disabled);
button:setCanBeClicked(not button.isDisabled and not button.isActive);
end;
if fn == 'toggleCustomFieldEdgePathShow' and (anySection or section == 'customFieldShow') then
button:setActive(vehicle.cp.fieldEdge.customField.show);
end;
if fn == 'toggleFindFirstWaypoint' and (anySection or section == 'findFirstWaypoint') then
button:setActive(vehicle.cp.distanceCheck);
end;
if button.row == 7 and button.functionToCall == 'rowButton' then
button:setDisabled(not isMode2_3_4_6);
button:setShow(isMode2_3_4_6);
button:setActive(vehicle.cp.turnOnField);
button:setCanBeClicked(not button.isDisabled);
elseif button.row == 8 and button.functionToCall == 'rowButton' then
button:setDisabled(not isMode4or6);
button:setShow(isMode4or6);
button:setActive(vehicle.cp.turnOnField);
button:setCanBeClicked(not button.isDisabled);
end;
if anySection or section == 'recording' then
if fn == 'stop_record' then
button:setDisabled(vehicle.cp.recordingIsPaused or vehicle.cp.isRecordingTurnManeuver);
button:setCanBeClicked(not button.isDisabled);
elseif fn == 'setRecordingPause' then
button:setActive(vehicle.cp.recordingIsPaused);
button:setDisabled(vehicle.cp.waypointIndex < 4 or vehicle.cp.isRecordingTurnManeuver);
button:setCanBeClicked(not button.isDisabled);
elseif fn == 'delete_waypoint' then
button:setDisabled(not vehicle.cp.recordingIsPaused or vehicle.cp.waypointIndex <= 4);
button:setCanBeClicked(not button.isDisabled);
elseif fn == 'set_waitpoint' or fn == 'set_crossing' then
button:setDisabled(vehicle.cp.recordingIsPaused or vehicle.cp.isRecordingTurnManeuver);
button:setCanBeClicked(not button.isDisabled);
elseif fn == 'setRecordingTurnManeuver' then --isToggleButton
button:setActive(vehicle.cp.isRecordingTurnManeuver);
button:setDisabled(vehicle.cp.recordingIsPaused or vehicle.cp.drivingDirReverse);
button:setCanBeClicked(not button.isDisabled);
elseif fn == 'change_DriveDirection' then --isToggleButton
button:setActive(vehicle.cp.drivingDirReverse);
button:setDisabled(vehicle.cp.recordingIsPaused or vehicle.cp.isRecordingTurnManeuver);
button:setCanBeClicked(not button.isDisabled);
elseif fn == 'addSplitRecordingPoints' then
button:setDisabled(not vehicle.cp.recordingIsPaused);
button:setCanBeClicked(not button.isDisabled);
end;
end;
end;
elseif vehicle.cp.hud.currentPage == 2 and (anySection or section == 'page2') then
local enable, show = true, true;
local numVisibleCourses = #(vehicle.cp.hud.courses);
local nofolders = nil == next(g_currentMission.cp_folders);
local indent = courseplay.hud.indent;
local row, fn;
for _, button in pairs(vehicle.cp.buttons[-2]) do
row = button.row;
fn = button.functionToCall;
enable = true;
show = true;
if row > numVisibleCourses then
show = false;
else
if fn == 'expandFolder' then
if vehicle.cp.hud.courses[row].type == 'course' then
show = false;
else
-- position the expandFolder buttons
button:setOffset(vehicle.cp.hud.courses[row].level * indent, 0)
if vehicle.cp.hud.courses[row].id == 0 then
show = false; --hide for level 0 'folder'
else
-- check if plus or minus should show up
if vehicle.cp.folder_settings[vehicle.cp.hud.courses[row].id].showChildren then
button:setSpriteSectionUVs('navMinus');
else
button:setSpriteSectionUVs('navPlus');
end;
if g_currentMission.cp_sorted.info[ vehicle.cp.hud.courses[row].uid ].lastChild == 0 then
enable = false; -- button has no children
end;
end;
end;
else
if vehicle.cp.hud.courses[row].type == 'folder' and (fn == 'loadSortedCourse' or fn == 'addSortedCourse') then
show = false;
elseif vehicle.cp.hud.choose_parent ~= true then
if fn == 'deleteSortedItem' and vehicle.cp.hud.courses[row].type == 'folder' and g_currentMission.cp_sorted.info[ vehicle.cp.hud.courses[row].uid ].lastChild ~= 0 then
enable = false;
elseif fn == 'linkParent' then
button:setSpriteSectionUVs('folderParentFrom');
if nofolders then
enable = false;
end;
elseif vehicle.cp.hud.courses[row].type == 'course' and (fn == 'loadSortedCourse' or fn == 'addSortedCourse' or fn == 'deleteSortedItem') and vehicle.cp.isDriving then
enable = false;
end;
else
if fn ~= 'linkParent' then
enable = false;
else
button:setSpriteSectionUVs('folderParentTo');
end;
end;
end;
end;
button:setDisabled(not enable or not show);
button:setShow(show);
end; -- for buttons
courseplay.settings.validateCourseListArrows(vehicle);
elseif vehicle.cp.hud.currentPage == 3 and anySection then
for _,button in pairs(vehicle.cp.buttons[3]) do
if button.functionToCall == 'changeLastValidTipDistance' then
local activate = vehicle.cp.lastValidTipDistance ~= nil
button:setDisabled(not activate);
button:setCanBeClicked(activate);
button:setShow(activate);
end;
end;
elseif vehicle.cp.hud.currentPage == 6 then
if anySection or section == 'debug' then
for _,button in pairs(vehicle.cp.buttons[6]) do
if button.functionToCall == 'toggleDebugChannel' then
button:setDisabled(button.parameter > courseplay.numDebugChannels);
button:setActive(courseplay.debugChannels[button.parameter] == true);
button:setCanBeClicked(not button.isDisabled);
end;
end;
end;
if anySection or section == 'visualWaypoints' then
vehicle.cp.visualWaypointsStartEndButton1:setActive(vehicle.cp.visualWaypointsStartEnd);
vehicle.cp.visualWaypointsStartEndButton1:setCanBeClicked(true);
vehicle.cp.visualWaypointsStartEndButton2:setActive(vehicle.cp.visualWaypointsStartEnd);
vehicle.cp.visualWaypointsStartEndButton2:setCanBeClicked(true);
vehicle.cp.visualWaypointsAllEndButton:setActive(vehicle.cp.visualWaypointsAll);
vehicle.cp.visualWaypointsAllEndButton:setCanBeClicked(true);
vehicle.cp.visualWaypointsCrossingButton:setActive(vehicle.cp.visualWaypointsCrossing);
vehicle.cp.visualWaypointsCrossingButton:setCanBeClicked(true);
end;
elseif vehicle.cp.hud.currentPage == 8 and (anySection or section == 'generateCourse' or section == 'selectedFieldShow' or section == 'suc') then
vehicle.cp.hud.generateCourseButton:setDisabled(not vehicle.cp.hasValidCourseGenerationData);
if vehicle.cp.hud.showSelectedFieldEdgePathButton then
vehicle.cp.hud.showSelectedFieldEdgePathButton:setActive(vehicle.cp.fieldEdge.selectedField.show);
end;
if vehicle.cp.suc.toggleHudButton then
vehicle.cp.suc.toggleHudButton:setActive(vehicle.cp.suc.active);
end;
elseif vehicle.cp.hud.currentPage == 9 and (anySection or section == 'shovel') then
for _,button in pairs(vehicle.cp.buttons[9]) do
if button.functionToCall == 'saveShovelPosition' then --isToggleButton
button:setActive(vehicle.cp.shovelStatePositions[button.parameter] ~= nil);
button:setCanBeClicked(true);
elseif button.functionToCall == 'moveShovelToPosition' then
button:setDisabled(not vehicle.cp.hasShovelStatePositions[button.parameter]);
end;
end;
end;
end;