Repository navigation
Expand file tree
/
Copy pathTamerPanelHandler.cs
More file actions
1319 lines (1170 loc) · 51.9 KB
/
Copy pathTamerPanelHandler.cs
File metadata and controls
1319 lines (1170 loc) · 51.9 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
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
using Il2Cpp;
using UnityEngine;
namespace DigimonNOAccess
{
/// <summary>
/// Handles accessibility for the Tamer menu, including:
/// - Status view with tamer stats
/// - SkillCheck (view learned skills)
/// - SkillGet (buy new skills with TP)
/// </summary>
public class TamerPanelHandler : IAccessibilityHandler
{
public int Priority => 70;
private uDigiviceTamerPanel _panel;
private bool _wasActive = false;
private uDigiviceTamerPanel.State _lastState = uDigiviceTamerPanel.State.None;
// Status panel tracking
private int _lastStatusCommand = -1;
// SkillGet tracking
private int _lastSkillGetTab = -1;
private int _lastSkillGetCategory = -1;
private string _lastSkillGetName = "";
private bool _wasOnSkillScreen = false;
// SkillCheck tracking
private int _lastSkillCheckSelectNo = -1;
public bool IsOpen()
{
if (_panel == null)
{
_panel = Object.FindObjectOfType<uDigiviceTamerPanel>();
}
if (_panel == null)
return false;
try
{
var state = _panel.m_CurrentState;
return state != uDigiviceTamerPanel.State.None && state != uDigiviceTamerPanel.State.Close;
}
catch
{
return false;
}
}
public void Update()
{
bool isActive = IsOpen();
if (isActive && !_wasActive)
{
OnOpen();
}
else if (!isActive && _wasActive)
{
OnClose();
}
else if (isActive)
{
CheckStateChange();
}
_wasActive = isActive;
}
private void OnOpen()
{
_lastState = uDigiviceTamerPanel.State.None;
_lastStatusCommand = -1;
_lastSkillGetTab = -1;
_lastSkillGetCategory = -1;
_lastSkillGetName = "";
_wasOnSkillScreen = false;
_lastSkillCheckSelectNo = -1;
if (_panel == null)
return;
var state = _panel.m_CurrentState;
_lastState = state;
string stateName = GetStateName(state);
string announcement = $"{GetMenuName()}, {stateName}";
if (state == uDigiviceTamerPanel.State.Status)
{
announcement += ". " + GetStatusInfo();
}
ScreenReader.Say(announcement);
DebugLogger.Log($"[TamerPanel] Opened, state={state}");
}
private void OnClose()
{
_panel = null;
_lastState = uDigiviceTamerPanel.State.None;
DebugLogger.Log("[TamerPanel] Closed");
}
private void CheckStateChange()
{
if (_panel == null)
return;
var currentState = _panel.m_CurrentState;
if (currentState != _lastState)
{
HandleStateChange(currentState);
_lastState = currentState;
}
else
{
switch (currentState)
{
case uDigiviceTamerPanel.State.Status:
CheckStatusChange();
break;
case uDigiviceTamerPanel.State.SkillGet:
CheckSkillGetChange();
break;
case uDigiviceTamerPanel.State.SkillCheck:
CheckSkillCheckChange();
break;
}
}
}
private void HandleStateChange(uDigiviceTamerPanel.State newState)
{
string stateName = GetStateName(newState);
string announcement = stateName;
// Reset sub-state tracking
_lastStatusCommand = -1;
_lastSkillGetTab = -1;
_lastSkillGetCategory = -1;
_lastSkillGetName = "";
_wasOnSkillScreen = false;
_lastSkillCheckSelectNo = -1;
if (newState == uDigiviceTamerPanel.State.Status)
{
announcement += ". " + GetStatusInfo();
}
else if (newState == uDigiviceTamerPanel.State.SkillGet)
{
announcement += ". " + GetSkillGetInfo();
}
else if (newState == uDigiviceTamerPanel.State.SkillCheck)
{
announcement += ". " + GetSkillCheckInfo();
}
ScreenReader.Say(announcement);
DebugLogger.Log($"[TamerPanel] State changed to {newState}");
}
#region Status State
private void CheckStatusChange()
{
try
{
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Status change: m_panel was null");
return;
}
var statusPanel = _panel.m_status;
if (statusPanel == null)
{
DebugLogger.Log("[TamerPanel] Status change: m_status was null");
return;
}
int currentCommand = (int)statusPanel.GetSelectIndex();
if (currentCommand != _lastStatusCommand && _lastStatusCommand >= 0)
{
string commandName = GetStatusCommandName(currentCommand);
ScreenReader.Say($"{commandName}, {currentCommand + 1} of 2");
}
_lastStatusCommand = currentCommand;
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in CheckStatusChange: {ex.Message}");
}
}
private string GetStatusInfo()
{
try
{
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Status info: m_panel was null");
return "";
}
var statusPanel = _panel.m_status;
if (statusPanel == null)
{
DebugLogger.Log("[TamerPanel] Status info: m_status was null");
return "";
}
int commandIndex = (int)statusPanel.GetSelectIndex();
_lastStatusCommand = commandIndex;
string commandName = GetStatusCommandName(commandIndex);
string tp = GetTextSafe(statusPanel.m_StatusTPValue, "m_StatusTPValue");
string level = GetRenderedText(statusPanel.m_StatusLevel, "m_StatusLevel", "Level");
string skills = GetTextSafe(statusPanel.m_StatusLearnedSkillCurrentValue, "m_StatusLearnedSkillCurrentValue");
string maxSkills = GetTextSafe(statusPanel.m_StatusLearnedSkillMaxValue, "m_StatusLearnedSkillMaxValue");
string bits = GetTextSafe(statusPanel.m_StatusHaveBitValue, "m_StatusHaveBitValue");
string stats = "";
stats += $"{level}. ";
if (!string.IsNullOrEmpty(tp))
{
string tpLabel = GetRenderedText(statusPanel.m_StatusTPText, "m_StatusTPText", "TP");
stats += $"{tpLabel} {tp}. ";
}
if (!string.IsNullOrEmpty(skills) && !string.IsNullOrEmpty(maxSkills))
{
string skillsLabel = GetRenderedText(statusPanel.m_StatusLearnedSkillText, "m_StatusLearnedSkillText", "Skills");
stats += $"{skillsLabel} {skills} of {maxSkills}. ";
}
if (!string.IsNullOrEmpty(bits))
{
string bitsLabel = GetRenderedText(statusPanel.m_StatusHaveBitText, "m_StatusHaveBitText", "Bits");
stats += $"{bitsLabel} {bits}. ";
}
return $"{stats}{commandName}, {commandIndex + 1} of 2";
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in GetStatusInfo: {ex.Message}");
return "";
}
}
private string GetStatusCommandName(int index)
{
string fallback = index switch
{
0 => "Skill Check",
1 => "Skill Get",
_ => AnnouncementBuilder.FallbackItem("Option", index)
};
try
{
if (index < 0 || index > 1)
return fallback;
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Status command: m_panel was null");
return fallback;
}
var statusPanel = _panel.m_status;
if (statusPanel == null)
{
DebugLogger.Log("[TamerPanel] Status command: m_status was null");
return fallback;
}
var text = index == 0
? statusPanel.m_CommandSkillCheckText
: statusPanel.m_CommandSKillGetText;
string fieldName = index == 0
? "m_CommandSkillCheckText"
: "m_CommandSKillGetText";
return GetRenderedText(text, fieldName, fallback);
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Status command read failed for index {index}: {ex.Message}");
return fallback;
}
}
#endregion
#region SkillGet State
private void CheckSkillGetChange()
{
try
{
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Skill Get change: m_panel was null");
return;
}
var skillGetPanel = _panel.m_skillGet;
if (skillGetPanel == null)
{
DebugLogger.Log("[TamerPanel] Skill Get change: m_skillGet was null");
return;
}
var mainWindow = skillGetPanel.m_uDigiviceTamerPanelSkill_Get_MainWindow;
if (mainWindow == null)
{
DebugLogger.Log("[TamerPanel] Skill Get change: m_uDigiviceTamerPanelSkill_Get_MainWindow was null");
return;
}
int currentTab = mainWindow.m_SelectedTabIndex;
var tabPanel = GetCurrentTabPanel(mainWindow, currentTab);
if (tabPanel == null)
{
DebugLogger.Log($"[TamerPanel] Skill Get change: {GetTabPanelFieldName(currentTab)} was null");
return;
}
var tabState = tabPanel.m_State;
bool onSkillScreen = (tabState == uGetSkillPanelBase.State.SELECT_SKILL);
bool onCategoryScreen = (tabState == uGetSkillPanelBase.State.SELECT_KIND);
string currentSkillName = GetTextSafe(skillGetPanel.m_SelectSklName);
int currentCategory = GetCurrentCategoryIndex(mainWindow, currentTab);
// Detect screen transitions
if (onSkillScreen && !_wasOnSkillScreen)
{
string skillInfo = GetSkillAnnouncementText(mainWindow, skillGetPanel, tabPanel, currentTab, currentCategory, currentSkillName);
ScreenReader.Say($"Skills. {skillInfo}");
_lastSkillGetName = currentSkillName;
}
else if (onCategoryScreen && _wasOnSkillScreen)
{
string tabName = GetSkillTabName(currentTab);
string announcement = $"Category selection. {tabName} tab";
if (currentCategory >= 0)
{
string categoryName = GetCategoryName(currentTab, currentCategory);
int categoryCount = GetCategoryCount(currentTab);
announcement += $". {AnnouncementBuilder.CursorPosition(categoryName, currentCategory, categoryCount)}";
}
ScreenReader.Say(announcement);
_lastSkillGetCategory = currentCategory;
}
_wasOnSkillScreen = onSkillScreen;
// Tab changes
if (currentTab != _lastSkillGetTab && _lastSkillGetTab >= 0)
{
string tabName = GetSkillTabName(currentTab);
string announcement = $"{tabName} tab, {currentTab + 1} of 4";
if (onCategoryScreen && currentCategory >= 0)
{
string categoryName = GetCategoryName(currentTab, currentCategory);
int categoryCount = GetCategoryCount(currentTab);
announcement += $". {AnnouncementBuilder.CursorPosition(categoryName, currentCategory, categoryCount)}";
}
ScreenReader.Say(announcement);
_lastSkillGetCategory = currentCategory;
}
// Category changes on category screen
if (onCategoryScreen)
{
if (currentCategory >= 0 && currentCategory != _lastSkillGetCategory && _lastSkillGetCategory >= 0)
{
string categoryName = GetCategoryName(currentTab, currentCategory);
int categoryCount = GetCategoryCount(currentTab);
ScreenReader.Say(AnnouncementBuilder.CursorPosition(categoryName, currentCategory, categoryCount));
}
_lastSkillGetCategory = currentCategory;
}
// Skill changes on skill screen
else if (onSkillScreen)
{
if (currentSkillName != _lastSkillGetName)
{
AnnounceSelectedSkillInGet(mainWindow, skillGetPanel, tabPanel, currentTab, currentCategory, currentSkillName);
}
_lastSkillGetName = currentSkillName;
}
_lastSkillGetTab = currentTab;
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in CheckSkillGetChange: {ex.Message}");
}
}
private uGetSkillPanelBase GetCurrentTabPanel(uDigiviceTamerPanelSkill_Get_MainWindow mainWindow, int tabIndex)
{
return tabIndex switch
{
0 => mainWindow.m_uDigiviceTamerSKillPanel_GetBasic,
1 => mainWindow.m_uDigiviceTamerSKillPanel_GetTrainer,
2 => mainWindow.m_uDigiviceTamerSKillPanel_GetSurvivor,
3 => mainWindow.m_uDigiviceTamerSKillPanel_GetCommander,
_ => null
};
}
private string GetSkillAnnouncementText(uDigiviceTamerPanelSkill_Get_MainWindow mainWindow, uDigiviceTamerPanelSkill_Get skillGetPanel, uGetSkillPanelBase tabPanel, int tabIndex, int categoryIndex, string skillName)
{
string tpCost = GetTextSafe(skillGetPanel.m_SelectSklTpValue);
string description = GetTextSafe(skillGetPanel.m_SelectSklDescription);
bool isLearned = false;
try
{
var skill = mainWindow.GetSelectedTamerSkill();
if (skill != ParameterTamerSkill.TamerSkill.NONE)
{
isLearned = ParameterTamerSkill.IsLearnedSkill(skill);
}
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error checking skill learned status: {ex.Message}");
}
string announcement = skillName;
if (isLearned)
announcement += ", learned";
else if (!string.IsNullOrEmpty(tpCost))
announcement += $", not learned, costs {tpCost} TP";
else
announcement += ", not learned";
if (!string.IsNullOrEmpty(description))
announcement += $". {description}";
// Add skill index
try
{
int skillIndex = GetSkillCursorIndex(tabPanel, tabIndex);
var subKind = GetSubKindFromTabAndCategory(tabIndex, categoryIndex);
var skillList = ParameterTamerSkill.GetSkillInSubKind(subKind);
if (skillList != null && skillList.Count > 0 && skillIndex >= 0)
{
announcement += $", {skillIndex + 1} of {skillList.Count}";
}
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error getting skill index: {ex.Message}");
}
return announcement;
}
private void AnnounceSelectedSkillInGet(uDigiviceTamerPanelSkill_Get_MainWindow mainWindow, uDigiviceTamerPanelSkill_Get skillGetPanel, uGetSkillPanelBase tabPanel, int tabIndex, int categoryIndex, string skillName)
{
string announcement = GetSkillAnnouncementText(mainWindow, skillGetPanel, tabPanel, tabIndex, categoryIndex, skillName);
ScreenReader.Say(announcement);
}
private int GetSkillCursorIndex(uGetSkillPanelBase tabPanel, int tabIndex)
{
try
{
// Each specific panel type has m_SkillCursorIndex
return tabIndex switch
{
0 => ((uDigiviceTamerSKillPanel_GetBasic)tabPanel).m_SkillCursorIndex,
1 => ((uDigiviceTamerSKillPanel_GetTrainer)tabPanel).m_SkillCursorIndex,
2 => ((uDigiviceTamerSKillPanel_GetSurvivor)tabPanel).m_SkillCursorIndex,
3 => ((uDigiviceTamerSKillPanel_GetCommander)tabPanel).m_SkillCursorIndex,
_ => -1
};
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in GetSkillCursorIndex: {ex.Message}");
return -1;
}
}
private ParameterTamerSkill.TamerSkillSubKind GetSubKindFromTabAndCategory(int tabIndex, int categoryIndex)
{
// Map tab and category indices to TamerSkillSubKind enum
return tabIndex switch
{
0 => categoryIndex switch // Basic
{
0 => ParameterTamerSkill.TamerSkillSubKind.TREAT,
1 => ParameterTamerSkill.TamerSkillSubKind.LIFE,
2 => ParameterTamerSkill.TamerSkillSubKind.CARRIER,
3 => ParameterTamerSkill.TamerSkillSubKind.REVERSE,
_ => ParameterTamerSkill.TamerSkillSubKind.NONE
},
1 => categoryIndex switch // Trainer
{
0 => ParameterTamerSkill.TamerSkillSubKind.TEACHER,
1 => ParameterTamerSkill.TamerSkillSubKind.LIFECARE,
2 => ParameterTamerSkill.TamerSkillSubKind.EVOLUTE,
_ => ParameterTamerSkill.TamerSkillSubKind.NONE
},
2 => categoryIndex switch // Survivor
{
0 => ParameterTamerSkill.TamerSkillSubKind.FINDER,
1 => ParameterTamerSkill.TamerSkillSubKind.EXTRACTOR,
2 => ParameterTamerSkill.TamerSkillSubKind.CAMPER,
3 => ParameterTamerSkill.TamerSkillSubKind.WALKER,
_ => ParameterTamerSkill.TamerSkillSubKind.NONE
},
3 => categoryIndex switch // Commander
{
0 => ParameterTamerSkill.TamerSkillSubKind.ORDER,
1 => ParameterTamerSkill.TamerSkillSubKind.TACTICS,
2 => ParameterTamerSkill.TamerSkillSubKind.ITEMTHROW,
3 => ParameterTamerSkill.TamerSkillSubKind.DROP,
4 => ParameterTamerSkill.TamerSkillSubKind.LEARNING,
_ => ParameterTamerSkill.TamerSkillSubKind.NONE
},
_ => ParameterTamerSkill.TamerSkillSubKind.NONE
};
}
private int GetCurrentCategoryIndex(uDigiviceTamerPanelSkill_Get_MainWindow mainWindow, int tabIndex)
{
try
{
var tabPanel = GetCurrentTabPanel(mainWindow, tabIndex);
if (tabPanel != null)
{
return tabPanel.GetNextCursorIndex();
}
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in GetCurrentCategoryIndex: {ex.Message}");
}
return -1;
}
private string GetCategoryName(int tabIndex, int categoryIndex)
{
string fallback = GetEnglishCategoryName(tabIndex, categoryIndex);
try
{
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Category name: m_panel was null");
return fallback;
}
var skillGetPanel = _panel.m_skillGet;
if (skillGetPanel == null)
{
DebugLogger.Log("[TamerPanel] Category name: m_skillGet was null");
return fallback;
}
var mainWindow = skillGetPanel.m_uDigiviceTamerPanelSkill_Get_MainWindow;
if (mainWindow == null)
{
DebugLogger.Log("[TamerPanel] Category name: m_uDigiviceTamerPanelSkill_Get_MainWindow was null");
return fallback;
}
var tabPanel = GetCurrentTabPanel(mainWindow, tabIndex);
if (tabPanel == null)
{
DebugLogger.Log($"[TamerPanel] Category name: {GetTabPanelFieldName(tabIndex)} was null");
return fallback;
}
uGetSkillPanelManager manager = null;
string managerField = null;
switch (tabIndex)
{
case 0:
var basic = (uDigiviceTamerSKillPanel_GetBasic)tabPanel;
manager = categoryIndex switch
{
0 => basic.m_TreatTypeManager,
1 => basic.m_LifeTypeManager,
2 => basic.m_CarrierTypeManager,
3 => basic.m_ReverseTypeManager,
_ => null
};
managerField = categoryIndex switch
{
0 => "m_TreatTypeManager",
1 => "m_LifeTypeManager",
2 => "m_CarrierTypeManager",
3 => "m_ReverseTypeManager",
_ => null
};
break;
case 1:
var trainer = (uDigiviceTamerSKillPanel_GetTrainer)tabPanel;
manager = categoryIndex switch
{
0 => trainer.m_TeacherTypeManager,
1 => trainer.m_LifeCareTypeManager,
2 => trainer.m_EvoluteTypeManager,
_ => null
};
managerField = categoryIndex switch
{
0 => "m_TeacherTypeManager",
1 => "m_LifeCareTypeManager",
2 => "m_EvoluteTypeManager",
_ => null
};
break;
case 2:
var survivor = (uDigiviceTamerSKillPanel_GetSurvivor)tabPanel;
manager = categoryIndex switch
{
0 => survivor.m_FinderTypeManager,
1 => survivor.m_ExtractorTypeManager,
2 => survivor.m_CamperTypeManager,
3 => survivor.m_WalkerTypeManager,
_ => null
};
managerField = categoryIndex switch
{
0 => "m_FinderTypeManager",
1 => "m_ExtractorTypeManager",
2 => "m_CamperTypeManager",
3 => "m_WalkerTypeManager",
_ => null
};
break;
case 3:
var commander = (uDigiviceTamerSKillPanel_GetCommander)tabPanel;
manager = categoryIndex switch
{
0 => commander.m_OrderTypeManager,
1 => commander.m_TacticsTypeManager,
2 => commander.m_ItemThrowTypeManager,
3 => commander.m_DropTypeManager,
4 => commander.m_LearningTypeManager,
_ => null
};
managerField = categoryIndex switch
{
0 => "m_OrderTypeManager",
1 => "m_TacticsTypeManager",
2 => "m_ItemThrowTypeManager",
3 => "m_DropTypeManager",
4 => "m_LearningTypeManager",
_ => null
};
break;
}
if (string.IsNullOrEmpty(managerField))
{
DebugLogger.Log($"[TamerPanel] Category name: no manager field for tab {tabIndex}, category {categoryIndex}");
return fallback;
}
if (manager == null)
{
DebugLogger.Log($"[TamerPanel] Category name: {managerField} was null");
return fallback;
}
return GetRenderedText(manager.m_HeadLine, $"{managerField}.m_HeadLine", fallback);
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Category name read failed for tab {tabIndex}, category {categoryIndex}: {ex.Message}");
return fallback;
}
}
private string GetEnglishCategoryName(int tabIndex, int categoryIndex)
{
return tabIndex switch
{
0 => categoryIndex switch
{
0 => "Treat",
1 => "Life",
2 => "Carrier",
3 => "Reverse",
_ => AnnouncementBuilder.FallbackItem("Category", categoryIndex)
},
1 => categoryIndex switch
{
0 => "Teacher",
1 => "Lifecare",
2 => "Evolute",
_ => AnnouncementBuilder.FallbackItem("Category", categoryIndex)
},
2 => categoryIndex switch
{
0 => "Finder",
1 => "Extractor",
2 => "Camper",
3 => "Walker",
_ => AnnouncementBuilder.FallbackItem("Category", categoryIndex)
},
3 => categoryIndex switch
{
0 => "Order",
1 => "Tactics",
2 => "Item Throw",
3 => "Drop",
4 => "Learning",
_ => AnnouncementBuilder.FallbackItem("Category", categoryIndex)
},
_ => AnnouncementBuilder.FallbackItem("Category", categoryIndex)
};
}
private int GetCategoryCount(int tabIndex)
{
return tabIndex switch
{
0 => 4, // Basic
1 => 3, // Trainer
2 => 4, // Survivor
3 => 5, // Commander
_ => 1
};
}
private string GetSkillGetInfo()
{
try
{
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Skill Get info: m_panel was null");
return "";
}
var skillGetPanel = _panel.m_skillGet;
if (skillGetPanel == null)
{
DebugLogger.Log("[TamerPanel] Skill Get info: m_skillGet was null");
return "";
}
var mainWindow = skillGetPanel.m_uDigiviceTamerPanelSkill_Get_MainWindow;
if (mainWindow == null)
{
DebugLogger.Log("[TamerPanel] Skill Get info: m_uDigiviceTamerPanelSkill_Get_MainWindow was null");
return "";
}
_lastSkillGetTab = mainWindow.m_SelectedTabIndex;
_wasOnSkillScreen = false;
int currentCategory = GetCurrentCategoryIndex(mainWindow, _lastSkillGetTab);
_lastSkillGetCategory = currentCategory;
string tabName = GetSkillTabName(_lastSkillGetTab);
string info = $"{tabName} tab, {_lastSkillGetTab + 1} of 4";
if (currentCategory >= 0)
{
string categoryName = GetCategoryName(_lastSkillGetTab, currentCategory);
int categoryCount = GetCategoryCount(_lastSkillGetTab);
info += $". {AnnouncementBuilder.CursorPosition(categoryName, currentCategory, categoryCount)}";
}
return info;
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in GetSkillGetInfo: {ex.Message}");
return "";
}
}
private string GetSkillTabName(int index)
{
string fallback = index switch
{
0 => "Basic",
1 => "Trainer",
2 => "Survivor",
3 => "Commander",
_ => AnnouncementBuilder.FallbackItem("Tab", index)
};
try
{
if (index < 0 || index > 3)
return fallback;
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Skill tab name: m_panel was null");
return fallback;
}
var skillGetPanel = _panel.m_skillGet;
if (skillGetPanel == null)
{
DebugLogger.Log("[TamerPanel] Skill tab name: m_skillGet was null");
return fallback;
}
var mainWindow = skillGetPanel.m_uDigiviceTamerPanelSkill_Get_MainWindow;
if (mainWindow == null)
{
DebugLogger.Log("[TamerPanel] Skill tab name: m_uDigiviceTamerPanelSkill_Get_MainWindow was null");
return fallback;
}
var tabPanel = mainWindow.m_uDigiviceTamerPanelSkill_GetTab;
if (tabPanel == null)
{
DebugLogger.Log("[TamerPanel] Skill tab name: m_uDigiviceTamerPanelSkill_GetTab was null");
return fallback;
}
var text = index switch
{
0 => tabPanel.m_Basic,
1 => tabPanel.m_Trainer,
2 => tabPanel.m_Survivor,
3 => tabPanel.m_Commander,
_ => null
};
string fieldName = index switch
{
0 => "m_Basic",
1 => "m_Trainer",
2 => "m_Survivor",
3 => "m_Commander",
_ => "tab label"
};
return GetRenderedText(text, fieldName, fallback);
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Skill tab name read failed for index {index}: {ex.Message}");
return fallback;
}
}
#endregion
#region SkillCheck State
private void CheckSkillCheckChange()
{
try
{
if (_panel == null)
{
DebugLogger.Log("[TamerPanel] Skill Check change: m_panel was null");
return;
}
var skillCheckPanel = _panel.m_skillCheck;
if (skillCheckPanel == null)
{
DebugLogger.Log("[TamerPanel] Skill Check change: m_skillCheck was null");
return;
}
var tamerSkillPanel = skillCheckPanel.m_uTamerSkillPanel;
if (tamerSkillPanel == null)
{
DebugLogger.Log("[TamerPanel] Skill Check change: m_uTamerSkillPanel was null");
return;
}
int currentSelectNo = tamerSkillPanel.m_selectNo;
if (currentSelectNo != _lastSkillCheckSelectNo)
{
// Check if this is the automatic follow-up announcement after entering menu
bool isInitialAnnouncement = (_lastSkillCheckSelectNo == -1);
// Get the selected skill from the panel
var skill = tamerSkillPanel.GetCurrentSelectSkill();
string skillName = GetTamerSkillName(skill);
string description = GetTextSafe(skillCheckPanel.DescriptionText);
// Get skill count for index
int total = 0;
var skillList = tamerSkillPanel.m_ListSklData;
if (skillList != null)
total = skillList.Count;
if (!string.IsNullOrEmpty(skillName))
{
string announcement = skillName;
// Add description if valid (filter out "None" placeholder)
if (!string.IsNullOrEmpty(description) && description != "None")
announcement += $". {description}";
// Add index
if (total > 0)
announcement += $", {currentSelectNo + 1} of {total}";
// Queue initial announcement so it doesn't interrupt menu opening speech
if (isInitialAnnouncement)
ScreenReader.SayQueued(announcement);
else
ScreenReader.Say(announcement);
}
_lastSkillCheckSelectNo = currentSelectNo;
}
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in CheckSkillCheckChange: {ex.Message}");
}
}
private string GetSkillCheckInfo()
{
string info = GetLearnedSkillsHeading();
try
{
if (_panel == null)
return info;
var skillCheckPanel = _panel.m_skillCheck;
if (skillCheckPanel == null)
return info;
var tamerSkillPanel = skillCheckPanel.m_uTamerSkillPanel;
// Set to -1 so CheckSkillCheckChange() will announce full info on next frame
// (description isn't populated until game's Update() runs)
_lastSkillCheckSelectNo = -1;
string tp = GetTextSafe(skillCheckPanel.TPValue);
// Get skill count
int total = 0;
if (tamerSkillPanel != null)
{
var skillList = tamerSkillPanel.m_ListSklData;
if (skillList != null)
total = skillList.Count;
}
if (!string.IsNullOrEmpty(tp))
info += $", TP {tp}";
if (total > 0)
info += $", {total} skills";
return info;
}
catch (System.Exception ex)
{
DebugLogger.Log($"[TamerPanel] Error in GetSkillCheckInfo: {ex.Message}");
return info;
}
}
#endregion
#region Helpers
private string GetTamerSkillName(ParameterTamerSkill.TamerSkill skill)
{
string fallback = GetEnglishTamerSkillName(skill);
if (skill == ParameterTamerSkill.TamerSkill.NONE)
return fallback;
try
{
var parameterManager = AppMainScript.parameterManager;
if (parameterManager == null)
{
DebugLogger.Log("[TamerPanel] Tamer skill name: AppMainScript.parameterManager was null");
return fallback;
}
var tamerSkillData = parameterManager.tamerSkillData;
if (tamerSkillData == null)
{
DebugLogger.Log("[TamerPanel] Tamer skill name: ParameterManager.tamerSkillData was null");
return fallback;