Skip to content

Commit

Permalink
Tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
asvitkine committed Jul 15, 2023
1 parent 5f41dfd commit f99a335
Showing 1 changed file with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public void focusGained(final FocusEvent e) {
}
territoryDetails = new TerritoryDetailPanel(mapPanel, data, uiContext, this);
editPanel = new EditPanel(data, mapPanel, this);
addTabs(true);
addTabs(null);
// Register a change listener
tabsPanel.addChangeListener(
evt -> {
Expand Down Expand Up @@ -516,6 +516,24 @@ private void addZoomKeyboardShortcuts() {
mapPanel.getScale() - (ClientSetting.mapZoomFactor.getValueOrThrow() / 100f)));
}

private void addTabs(HistoryDetailsPanel historyDetailPanel) {
if (historyDetailPanel != null) {
tabsPanel.add("History", historyDetailPanel);
} else {
addTab("Actions", actionButtons, KeyCode.C);
}
addTab("Players", statsPanel, KeyCode.P);
addTab("Resources", economyPanel, KeyCode.R);
if (objectivePanel != null && !objectivePanel.isEmpty()) {
String objectivePanelName = new ObjectiveProperties(uiContext.getResourceLoader()).getName();
addTab(objectivePanelName, objectivePanel, KeyCode.O);
}
addTab("Territory", territoryDetails, KeyCode.T);
if (mapPanel.getEditMode()) {
tabsPanel.add("Edit", editPanel);
}
}

private void addTab(final String title, final Component component, final KeyCode hotkey) {
tabsPanel.addTab(title, null, component, "Hotkey: CTRL+" + hotkey);
SwingKeyBinding.addKeyBindingWithMetaAndCtrlMasks(
Expand Down Expand Up @@ -1769,8 +1787,7 @@ private void showHistory() {
final HistoryDetailsPanel historyDetailPanel =
new HistoryDetailsPanel(clonedGameData, mapPanel);
tabsPanel.removeAll();
tabsPanel.add("History", historyDetailPanel);
addTabs(false);
addTabs(historyDetailPanel);
actionButtons.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(false));
historyComponent.removeAll();
historyComponent.setLayout(new BorderLayout());
Expand Down Expand Up @@ -1938,7 +1955,7 @@ private void showGame() {
tabsPanel.removeAll();
}
setWidgetActivation();
addTabs(true);
addTabs(null);
actionButtons.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(true));
gameMainPanel.removeAll();
gameMainPanel.setLayout(new BorderLayout());
Expand All @@ -1952,22 +1969,6 @@ private void showGame() {
mapPanel.setRoute(null);
}

private void addTabs(boolean includeActionsTab) {
if (includeActionsTab) {
addTab("Actions", actionButtons, KeyCode.C);
}
addTab("Players", statsPanel, KeyCode.P);
addTab("Resources", economyPanel, KeyCode.R);
if (objectivePanel != null && !objectivePanel.isEmpty()) {
String objectivePanelName = new ObjectiveProperties(uiContext.getResourceLoader()).getName();
addTab(objectivePanelName, objectivePanel, KeyCode.O);
}
addTab("Territory", territoryDetails, KeyCode.T);
if (mapPanel.getEditMode()) {
tabsPanel.add("Edit", editPanel);
}
}

private void setWidgetActivation() {
SwingAction.invokeNowOrLater(
() -> {
Expand Down

0 comments on commit f99a335

Please sign in to comment.