GUI: improved pick choice (dialogs with searchable list, related to #12420):

- dialog: added mana symbols and html support in headers and list;
- dialog: added custom hints for each list's item (use setHintData);
- dialog: added game object hint type (use object id as hint value);
- dialog: added fast way to add key, value, sort and hint data (use choice.withItem());
- cheats: added commands list in popup hint;
This commit is contained in:
Oleg Agafonov 2024-07-18 23:04:47 +04:00
parent d0c907242c
commit 77df387e06
6 changed files with 204 additions and 119 deletions

View file

@ -352,21 +352,21 @@ public final class SystemUtil {
logger.info("Found " + groups.size() + " groups. Need to select.");
// choice dialog
Map<String, String> list = new LinkedHashMap<>();
Map<String, Integer> sort = new LinkedHashMap<>();
for (int i = 0; i < groups.size(); i++) {
list.put(Integer.toString(i + 1), groups.get(i).getPrintNameWithStats());
sort.put(Integer.toString(i + 1), i);
}
Choice groupChoice = new ChoiceImpl(false);
groupChoice.setMessage("Choose commands group to run");
groupChoice.setKeyChoices(list);
groupChoice.setSortData(sort);
for (int i = 0; i < groups.size(); i++) {
groupChoice.withItem(
Integer.toString(i + 1),
groups.get(i).getPrintNameWithStats(),
i,
ChoiceHintType.TEXT,
String.join("<br>", groups.get(i).commands)
);
}
if (feedbackPlayer.choose(Outcome.Benefit, groupChoice, game)) {
String need = groupChoice.getChoiceKey();
if ((need != null) && list.containsKey(need)) {
if (need != null) {
runGroup = groups.get(Integer.parseInt(need) - 1);
}
}