Show tooltip for representative Shardok command

This commit is contained in:
2026-06-28 15:58:59 -07:00
parent 2571f65ac4
commit e79e8fc61c
2 changed files with 19 additions and 12 deletions
@@ -114,16 +114,18 @@ namespace eagle0 {
return commands.Where(command => CommandGroupForType(command.Type) == group).ToList();
}
public CommandDescriptor RepresentativeCommandForGroup(
List<CommandDescriptor> commands,
int group) {
return commands.Last(command => CommandGroupForType(command.Type) == group);
}
public bool WarnOnCommandType(List<CommandDescriptor> commands, int group) {
return infoForType[commands.First(command => CommandGroupForType(command.Type) == group)
.Type]
.warnOnCommit;
return infoForType[RepresentativeCommandForGroup(commands, group).Type].warnOnCommit;
}
public string WarningForCommandType(List<CommandDescriptor> commands, int group) {
return infoForType[commands.First(command => CommandGroupForType(command.Type) == group)
.Type]
.commitWarning;
return infoForType[RepresentativeCommandForGroup(commands, group).Type].commitWarning;
}
}
}
@@ -426,11 +426,11 @@ namespace Shardok {
public void WarningPanelCommitClicked() {
var commands = CommandsForSelectedCoords;
var commandsForPosition =
commandTypeUIManager.ApplicableCommandsForGroup(commands, _clickedPosition);
var sourceGridIndex = _selectedGridIndex ?? -1;
var commandType = commandsForPosition[0].Type;
var commandType =
commandTypeUIManager.RepresentativeCommandForGroup(commands, _clickedPosition)
.Type;
Model.PerformUntargetedCommand(SelectedCoords, commandType);
PlayUntargetedCommandAnimation(commandType, sourceGridIndex);
_selectedGridIndex = null;
@@ -461,7 +461,9 @@ namespace Shardok {
var commands = CommandsForSelectedCoords;
var commandsForPosition =
commandTypeUIManager.ApplicableCommandsForGroup(commands, position);
if (commandsForPosition[0].Target != null) {
var representativeCommand =
commandTypeUIManager.RepresentativeCommandForGroup(commands, position);
if (representativeCommand.Target != null) {
SetDisplayedCommandGroup(_displayedCommandGroup == position ? 0 : position);
} else {
if (commandsForPosition.Count > 1) {
@@ -476,7 +478,7 @@ namespace Shardok {
commandWarningPanel.SetActive(true);
} else {
var sourceGridIndex = _selectedGridIndex ?? -1;
var command = commandsForPosition[0];
var command = representativeCommand;
Model.PerformUntargetedCommand(SelectedCoords, command.Type);
PlayUntargetedCommandAnimation(
command.Type,
@@ -1815,7 +1817,10 @@ namespace Shardok {
buttonIndex);
if (!applicableCommands.Any()) break;
var firstApplicableCommand = applicableCommands.First();
var firstApplicableCommand =
commandTypeUIManager.RepresentativeCommandForGroup(
commands,
buttonIndex);
string commandName =
commandTypeUIManager.NameForType(firstApplicableCommand.Type);
buttonTooltipText.text = commandName;