forked from JohnnyCheese/TTS_X-Wing2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnassigned Dial.ttslua
More file actions
923 lines (818 loc) · 26.4 KB
/
Unassigned Dial.ttslua
File metadata and controls
923 lines (818 loc) · 26.4 KB
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
-- ~~~~~~
-- Script by dzikakulka
-- Issues, history at: http://github.com/tjakubo2/TTS_xwing
--
-- Token for easy barrel rolls with StarViper Mk.II title
-- ~~~~~~
-- Scripted token properties
__XW_Token = false
__XW_TokenIdle = true
__XW_TokenType = 'helper:Dial'
-- Ref to assigned ship if there is one
assignedShip = nil
currMan = nil
playerColor = nil
openpanel = nil
openbutton = nil
opencolor = "#555555"
closedcolor = "#222222"
-- Save self state
function onSave()
if assignedShip ~= nil then
local state = {assignedShipGUID=assignedShip.getGUID(),
owningPlayer=playerColor}
return JSON.encode(state)
end
end
faceStat = nil
firstSet=false
setSinceTemplatePlaced = false -- True if the user has set a movement since the movement template was last placed on the table
templatePlaced = false -- True if the movement template is currently on the table (as far as we can tell based on just dial button clicks, anyway)
exOptions = {}
exOptSelected = false
exOptValue = {}
exOptButtons = { "ExOpt1", "ExOpt2", "ExOpt3", "ExOpt4", "ExOpt5"}
-- Restore self state
function onLoad()
--self.UI.setCustomAssets(assetTable)
clearDial()
if savedData ~= nil then
state = JSON.decode(savedData)
savedShip = getObjectFromGUID(state.assignedShipGUID)
playerColor = state.owningPlayer
if savedShip ~= nil then
assignShip(savedShip)
end
end
end
function clearOpenPanel()
if openpanel ~= nil then
self.UI.hide(openpanel)
self.UI.setAttribute(openbutton, "color", closedcolor)
self.UI.setAttribute(openbutton, "textColor", "#FFFFFF")
end
openpanel = nil
openbutton = nil
end
function clearDial()
self.UI.hide('TalonPanel') -- Talon has to come before CenterFU which it is inside -- hide doesn't work when the parent is already hidden (could also use active=false instead)
self.UI.hide("ExecutionOptionsPanel")
self.UI.hide("CenterFD")
self.UI.hide('CenterFU')
self.UI.hide("ManWin")
self.UI.hide('arcPanel')
self.UI.hide('relocPanel')
self.UI.hide('tokenPanel')
self.UI.hide("setManPeekPanel")
winStat = false
clearOpenPanel()
end
function onUpdate()
if assignedShip ~= nil then
if self.getTransformUp().y >0 then
if faceStat ~= 'Down' then
faceStat = 'Down'
clearDial()
self.UI.setAttribute("Main", "rotation", "0 0 0")
self.UI.show("CenterFD")
end
else
if faceStat ~= 'Up' then
faceStat = 'Up'
clearDial()
manSetting()
self.UI.setAttribute("Main", "rotation", "180 180 180")
self.UI.show('CenterFU')
end
end
end
end
function getManouverIcons(manouver)
if manouver:sub(1,1) == 'w' then
manColor="White"
elseif manouver:sub(1,1) == 'b' then
manColor="Blue"
elseif manouver:sub(1,1) == 'r' then
manColor="Red"
end
if manouver:sub(-1,-1) == 't' then
manType = "Talon"
elseif manouver:sub(-1,-1) == 's' then
if manouver:sub(2,2) == 't' then
manType = "TurnSloop"
else
manType = "Sloop"
end
elseif manouver:sub(-1,-1) == 'z' then
if manouver:sub(2,2) == 't' then
manType = "TurnSlip"
else
manType = "BankSlip"
end
elseif manouver:sub(-1,-1) == 'r' then
if manouver:sub(2,2) == 'b' then
manType = "ReverseBank"
else
manType = "ReverseStraight"
end
elseif manouver:sub(2,2) == 't' then
manType = "Turn"
elseif manouver:sub(2,2) == 'b' then
manType = "Bank"
elseif manouver:sub(2,2) == 's' then
manType = "Straight"
elseif manouver:sub(2,2) == 'k' then
manType = 'K'
end
local Char= manouver:find("%d")
manSpeed = manouver:sub(Char,Char)
if manouver:sub(3,3) == 'l' then
manBear = "L"
elseif manouver:sub(3,3) == 'r' then
manBear = "R"
else
manBear = ""
end
if manSpeed=="0" and manType=="Straight" then
manType='Stall'
end
return {speed = "Speed"..manSpeed, type = manColor .. manType .. manBear }
end
function manSelect(p, option, id)
if spectReturn(p) == true or option == false then
return
end
firstSet=true
self.UI.setAttribute("ManBtnGroup","allowSwitchOff","false")
curMan=string.lower(id)
icons = getManouverIcons(curMan)
speedIcon= icons.speed
typeIcon= icons.type
setMan = curMan:sub(2)
befAft = '_B'
end
function manSetting()
if setStat == true then
self.UI.setAttribute("TypeIcon", "image", typeIcon)
self.UI.setAttribute("SpeedIcon", "image", speedIcon)
self.UI.setAttribute("TypeIcon", "active", "true")
self.UI.setAttribute("SpeedIcon", "active", "true")
self.UI.setAttribute("MoveBtn", "active", "true")
self.UI.setAttribute("MoveBtn", "textColor", "#FFFFFF")
self.UI.setAttribute("UndoBtn", "active", "false")
self.UI.setAttribute("Templ", "active", "true")
self.UI.setAttribute("Templ", "textColor", "#222222") -- Make the text same color as the background since goal is to only have the type / speed icons showing anyway
else
self.UI.setAttribute("TypeIcon", "active", "false")
self.UI.setAttribute("SpeedIcon", "active", "false")
self.UI.setAttribute("MoveBtn", "active", "false")
self.UI.setAttribute("UndoBtn", "active", "false")
self.UI.setAttribute("Templ", "textColor", "#FFFFFF")
-- Hide the template button when there isn't a manuver set, since it's confusing and undefined in some cases what template should be shown then
if not templatePlaced then
self.UI.setAttribute("Templ", "active", "false")
end
end
if firstSet== false then
self.UI.setAttribute("TypeIcon", "active", "false")
self.UI.setAttribute("SpeedIcon", "active", "false")
self.UI.setAttribute("MoveBtn", "active", "false")
self.UI.setAttribute("UndoBtn", "active", "false")
self.UI.setAttribute("Templ", "textColor", "#FFFFFF")
-- Hide the template button when there isn't a manuver set, since it's confusing and undefined in some cases what template should be shown then
if not templatePlaced then
self.UI.setAttribute("Templ", "active", "false")
end
end
-- Remove template if a new manuver has been set since it was shown, since it could be confusing to still show the old template (and to show the new one you would have to click the button twice, which would be confusing)
if setSinceTemplatePlaced and templatePlaced then
deleteTemplate()
end
end
function Undo(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("q")
self.UI.setAttribute("UndoBtn", "active", "false")
if setMan:sub(-1,-1) ~='t' then
self.UI.setAttribute("MoveBtn", "active", "true")
self.UI.setAttribute("MoveBtn", "textColor", "#FFFFFF")
else
self.UI.show("TalonPanel")
end
befAft='_B'
end
function performMove(P)
if spectReturn(P) == true then
return
end
if setMan ~= nil and setMan ~="" then
self.UI.setAttribute("MoveBtn", "active", "false")
-- Check alternate execution options
--print("curMan:" .. curMan)
if exOptions[curMan] ~= nil and exOptSelected == false then
setupAlternateExecutionPanel(P, exOptions[curMan])
elseif setMan:sub(-1,-1) == 't' then
self.UI.show("TalonPanel")
else
self.UI.setAttribute("UndoBtn", "active", "true")
self.UI.setAttribute("UndoBtn", "textColor", "#FFFFFF")
assignedShip.setDescription(setMan)
exOptSelected = false
befAft = '_A'
setDial(P)
end
end
end
function setupAlternateExecutionPanel(P, executionOptions)
self.UI.setAttribute("TypeIcon", "active", "false")
self.UI.setAttribute("SpeedIcon", "active", "false")
self.UI.setAttribute("Templ", "active", "false")
self.UI.setAttribute("undoFU", "active", "false")
self.UI.show("ExecutionOptionsPanel")
for i, button in pairs(exOptButtons) do
self.UI.setAttribute(button .. 'But', "active", "false")
end
for i, option in pairs(executionOptions) do
self.UI.setAttribute(exOptButtons[i] .. "But", "active", "true")
exOptValue[exOptButtons[i] .. 'But'] = option
local icons = getManouverIcons(option)
self.UI.setAttribute(exOptButtons[i] .. "TypeIcon", "image", icons.type)
self.UI.setAttribute(exOptButtons[i] .. "SpeedIcon", "image", icons.speed)
end
end
function selectExecuteOption(P, option, id)
if spectReturn(P) == true then
return
end
self.UI.hide("ExecutionOptionsPanel")
exOptSelected = true
setMan = exOptValue[id]:sub(2)
local icons = getManouverIcons(exOptValue[id])
self.UI.setAttribute("TypeIcon", "active", "true")
self.UI.setAttribute("SpeedIcon", "active", "true")
self.UI.setAttribute("Templ", "active", "true")
self.UI.setAttribute("Templ", "textColor", "#222222")
self.UI.setAttribute("undoFU", "active", "true")
self.UI.setAttribute("undoFU", "textColor", "#FFFFFF")
self.UI.setAttribute("TypeIcon", "image", icons.type)
self.UI.setAttribute("SpeedIcon", "image", icons.speed)
performMove(P)
end
function performTalon(P,option,id)
if spectReturn(P) == true then
return
end
self.UI.hide("TalonPanel")
self.UI.setAttribute("UndoBtn", "active", "true")
self.UI.setAttribute("UndoBtn", "textColor", "#FFFFFF")
if id=="TalonMidBtn" then
assignedShip.setDescription(setMan)
elseif id=="TalonReaBtn" then
talonMove = setMan:sub(1,3).."b"..setMan:sub(-1,-1)
assignedShip.setDescription(talonMove)
elseif id=="TalonForBtn" then
talonMove = setMan:sub(1,3).."f"..setMan:sub(-1,-1)
assignedShip.setDescription(talonMove)
end
befAft ='_A'
setDial(P)
end
function onPickUp(player_color)
if assignedShip == nil then
pColor = self.held_by_color
end
end
-- Assign a ship to the dial
function assignShip(ship)
self.UI.setAttribute("CenterFD", "active", "true")
self.UI.setAttribute("CenterFU", "active", "true")
self.UI.setAttribute("arcPanel", "active", "true")
self.UI.setAttribute("tokenPanel", "active", "true")
self.UI.setAttribute("relocPanel", "active", "true")
self.UI.setAttribute("CenterFD", "active", "true")
self.UI.setAttribute("setManPeekPanel", "active", "true")
assignedShip = ship
Name=assignedShip.getName()
self.setName(Name)
--self.UI.setAttribute("DialName", Name)
self.UI.setValue("Name",Name)
shipData=assignedShip.getTable("Data")
exOptions = shipData.executeOptions
self.UI.setAttribute("BackGround", "image", tostring(shipData['Faction']).."BG")
for k,v in pairs(shipData['moveSet']) do
self.UI.setAttribute(string.upper(v), "active", "true")
end
setMan=""
local repos = false
for k,v in pairs(shipData['actSet']) do
if v == 'F' then
self.UI.setAttribute('FocusBtn', 'active', 'true')
elseif v == 'TL' then
self.UI.setAttribute("TargetLockBtn", 'active', 'true')
elseif v == 'E' then
self.UI.setAttribute("EvadeBtn", 'active', 'true')
elseif v == 'R' then
self.UI.setAttribute("ReinforceBtn", 'active', 'true')
elseif v == 'C' then
self.UI.setAttribute("CalculateBtn", 'active', 'true')
elseif v == 'CL' then
self.UI.setAttribute("CloakBtn", 'active', 'true')
elseif v == 'BR' then
repos = true
self.UI.setAttribute("BarrelRBtn", "active", "true")
self.UI.setAttribute("BarrelRFBtn", "active", "true")
self.UI.setAttribute("BarrelRBBtn", "active", "true")
self.UI.setAttribute("BarrelLBtn", "active", "true")
self.UI.setAttribute("BarrelLFBtn", "active", "true")
self.UI.setAttribute("BarrelLBBtn", "active", "true")
elseif v == 'B' then
repos = true
self.UI.setAttribute("BoostSBtn", "active", "true")
self.UI.setAttribute("BoostRBtn", "active", "true")
self.UI.setAttribute("BoostLBtn", "active", "true")
elseif v =='Ail' then
repos = true
self.UI.setAttribute("AilSBtn", "active", "true")
self.UI.setAttribute("AilRBtn", "active", "true")
self.UI.setAttribute("AilLBtn", "active", "true")
elseif v =='Piv' then
repos = true
self.UI.setAttribute("PivKBtn", "active", "true")
self.UI.setAttribute("PivRBtn", "active", "true")
self.UI.setAttribute("PivLBtn", "active", "true")
end
end
if repos == false then
self.UI.setAttribute("RelocMenu", "active", "false")
self.UI.setAttribute("RelocMenuFU", "active", "false")
end
end
-- Assign on drop near a small base ship
function onDropped()
if assignedShip == nil then
local spos = self.getPosition()
local nearest = nil
local minDist = 2.89 -- 80mm
for k,ship in pairs(getAllObjects()) do
if ship.tag == 'Figurine' and ship.name ~= '' then
local pos = ship.getPosition()
local dist = math.sqrt(math.pow((spos[1]-pos[1]),2) + math.pow((spos[3]-pos[3]),2))
if dist < minDist then
nearest = ship
minDist = dist
end
end
end
if nearest ~= nil then
if pColor=="White" then
printToAll("Please, pick a color before assigning dials")
else
assignedShip = nearest
playerColor=pColor
nearest.setVar('owningPlayer', pColor)
printToAll('Dial assigned to to ' .. nearest.getName(), {0.2, 0.2, 1})
printToAll('Controlled by the '.. playerColor .. ' player')
printToAll('')
self.setRotation(nearest.getRotation())
assignShip(nearest)
end
end
end
end
-- functions called when buttons are pressed
function genericAction(a,b,c,d)
print(a)
print(b)
print(c)
print(d)
end
function focusTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Focus', playerColor, id ~= '-1'})
end
function evadeTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Evade', playerColor, id ~= '-1'})
end
function tlTok(p, id)
if spectReturn(p) == true then
return
end
if id == '-1' then
Global.call('proxyPerformAction', {assignedShip, 'Target Lock', playerColor})
end
end
function tractorTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Tractor', playerColor, id ~= '-1'})
end
function jamTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Jam', playerColor, id ~= '-1'})
end
function disarmTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Disarm', playerColor, id ~= '-1'})
end
function cloakTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Cloak', playerColor, id ~= '-1'})
end
function calcTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Calculate', playerColor, id ~= '-1'})
end
function reinforceTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Reinforce', playerColor, id ~= '-1'})
end
function stressTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Stress', playerColor, id ~= '-1'})
end
function strainTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Strain', playerColor, id ~= '-1'})
end
function depleteTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Deplete', playerColor, id ~= '-1'})
end
function ionTok(p,id)
if spectReturn(p) == true then
return
end
Global.call('proxyPerformAction', {assignedShip, 'Ion', playerColor, id ~= '-1'})
end
function BoostS(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("s1b")
end
function BoostR(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("br1b")
end
function BoostL(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("bl1b")
end
function AilS(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("s1")
end
function AilR(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("br1")
end
function AilL(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("bl1")
end
function BarrelL(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("rl2")
end
function BarrelLF(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("rl1")
end
function BarrelLB(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("rl3")
end
function BarrelR(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("rr2")
end
function BarrelRF(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("rr1")
end
function BarrelRB(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("rr3")
end
function range1(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("r1")
end
function range2(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("r2")
end
function range3(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("r3")
end
function arcF(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("f")
end
function arcFF(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("ff")
end
function arcL(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("sl")
end
function arcR(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("sr")
end
function arcB(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("b")
end
function arcFB(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription("fb")
end
function pivK(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription('k0')
end
function pivR(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription('tr4')
end
function pivL(p)
if spectReturn(p) == true then
return
end
assignedShip.setDescription('tl4')
end
function Window(p)
if winStat == nil then
winStat = false
end
if spectReturn(p) == false then
if winStat == false then
winStat = true
self.UI.show("ManWin")
self.UI.setAttribute("ManWin", "visibility", playerColor .. "|Black")
self.UI.setAttribute("ManBtnGroup", "active", "true")
else
winStat = false
self.UI.setAttribute("ManBtnGroup", "active", "false")
self.UI.hide('ManWin')
end
end
end
function spectReturn(p)
if p.color == 'Black' then
return false
end
return p.color ~= playerColor
end
function showSetMan(p)
if spectReturn(p) == true then
return
end
self.UI.show("setManPeekPanel")
self.UI.setAttribute("setManPeekPanel", "visibility", playerColor)
self.UI.setAttribute("setManTypeIcon", "image", typeIcon)
self.UI.setAttribute("setManSpeedIcon", "image", speedIcon)
self.UI.setAttribute("setManTypeIcon", "active", "true")
self.UI.setAttribute("setManSpeedIcon", "active", "true")
self.UI.setAttribute("setManPeekPanel", "position", "-100 -150 -50")
self.UI.setAttribute("setManPeekPanel", "rotation", "180 180 0")
end
function hideSetMan(p)
if spectReturn(p) == true then
return
end
self.UI.hide("setManPeekPanel")
end
function showTokMFD(p)
if spectReturn(p) == true then
return
end
self.UI.show("tokenPanel")
self.UI.setAttribute("TokenMenu", "color", opencolor)
clearOpenPanel()
openpanel = "tokenPanel"
openbutton = "TokenMenu"
self.UI.setAttribute("tokenPanel", "position", "-360 -165 -25")
self.UI.setAttribute("tokenPanel", "rotation", "180 180 0")
end
function showTokMFU(p)
if spectReturn(p) == true then
return
end
self.UI.show("tokenPanel")
self.UI.setAttribute("TokenMenuFu", "color", opencolor)
clearOpenPanel()
openpanel = "tokenPanel"
openbutton = "TokenMenuFu"
self.UI.setAttribute("tokenPanel", "position", "360 -165 1")
self.UI.setAttribute("tokenPanel", "rotation", "180 0 0")
end
function hideTokM(p)
if spectReturn(p) == true then
return
end
if openpanel == "tokenPanel" then
self.UI.hide(openpanel)
self.UI.setAttribute(openbutton, "color", closedcolor)
self.UI.setAttribute(openbutton, "textColor", "#FFFFFF")
end
openpanel = nil
openbutton = nil
end
function showArcMFD(p)
if spectReturn(p) == true then
return
end
self.UI.show("arcPanel")
self.UI.setAttribute("ArcMenu", "color", opencolor)
clearOpenPanel()
openpanel = "arcPanel"
openbutton = "ArcMenu"
self.UI.setAttribute("arcPanel", "position", "250 -150 -25")
self.UI.setAttribute("arcPanel", "rotation", "180 180 0")
end
function showArcMFU(p)
if spectReturn(p) == true then
return
end
self.UI.show("arcPanel")
self.UI.setAttribute("ArcMenuFu", "color", opencolor)
clearOpenPanel()
openpanel = "arcPanel"
openbutton = "ArcMenuFu"
self.UI.setAttribute("arcPanel", "position", "-250 -150 1")
self.UI.setAttribute("arcPanel", "rotation", "180 0 0")
end
function hideArcM(p)
if spectReturn(p) == true then
return
end
if openpanel == "arcPanel" then
self.UI.hide(openpanel)
self.UI.setAttribute(openbutton, "color", closedcolor)
self.UI.setAttribute(openbutton, "textColor", "#FFFFFF")
end
openpanel = nil
openbutton = nil
end
function showRelocMFD(p)
if spectReturn(p) == true then
return
end
self.UI.show("relocPanel")
self.UI.setAttribute("RelocMenu", "color", opencolor)
clearOpenPanel()
openpanel = "relocPanel"
openbutton = "RelocMenu"
self.UI.setAttribute("relocPanel", "position", "0 -215 -25")
self.UI.setAttribute("relocPanel", "rotation", "180 180 0")
end
function showRelocMFU(p)
if spectReturn(p) == true then
return
end
self.UI.show("relocPanel")
self.UI.setAttribute("RelocMenuFu", "color", opencolor)
clearOpenPanel()
openpanel = "relocPanel"
openbutton = "RelocMenuFu"
self.UI.setAttribute("relocPanel", "position", "0 -215 1")
self.UI.setAttribute("relocPanel", "rotation", "180 0 0")
end
function hideRelocM(p)
if spectReturn(p) == true then
return
end
if openpanel == "relocPanel" then
self.UI.hide(openpanel)
self.UI.setAttribute(openbutton, "color", closedcolor)
self.UI.setAttribute(openbutton, "textColor", "#FFFFFF")
end
openpanel = nil
openbutton = nil
end
function setDial(P)
if spectReturn(P) == false then
if firstSet == true then
if setStat == nil then
setStat = false
end
if setStat == false then
self.UI.setAttribute("setBtnFD", "color", playerColor)
self.UI.setAttribute("setBtnFD", "active", "true")
self.UI.setAttribute("setBtnFD", "textColor", "#FFFFFF")
if (P.color == "Yellow") then
-- White text on yellow button is pretty hard to read, so for the Yellow player change the text to black instead
self.UI.setAttribute("setBtnFD", "textColor", "#000000")
end
self.UI.setAttribute("moveWindow", "active", "false")
setStat = true
setSinceTemplatePlaced = true
printToAll(P.color.." player has set the maneuver for "..assignedShip.getName(), P.color)
if winStat==true then
Window(P)
end
else
--TODO: Now that the set dial and unset dial buttons are 2 different buttons, this file's code would probably be more readable with this function split in to setDial() and unsetDial()
self.UI.setAttribute("setBtnFD", "active", "false")
self.UI.setAttribute("setManPeekPanel", "active", "false")
self.UI.setAttribute("moveWindow", "active", "true")
self.UI.setAttribute("moveWindow", "textColor", "#FFFFFF")
setStat = false
end
else
print("Pick a maneuver before setting the dial")
end
end
end
function spawnTemplate(p)
if spectReturn(p) == true then
return
end
if setMan~='' then
setSinceTemplatePlaced = false
templatePlaced = not templatePlaced
-- if a manuver is not visible on dial, template button is only here to allow removal, and after that it can be hidden again
if self.UI.getAttribute("SpeedIcon", "active") == "false" then
self.UI.setAttribute("Templ", "active", "false")
end
Table={[1]=assignedShip,[2]='spawnMoveTemplate:'..setMan..befAft,[3]=playerColor}
Global.call("proxyPerformAction",Table)
end
end
function deleteTemplate()
templatePlaced = false
Table={[1]=assignedShip,[2]='deleteMoveTemplate',[3]=playerColor}
Global.call("proxyPerformAction",Table)
end