Skip to content

Commit

Permalink
Remove game notes action tab (#8925)
Browse files Browse the repository at this point in the history
Several discussions have happened in forums, generall agreed that the
game notes in the action tabs is not particularly useful. To keep things
simpler, this update remove the game notes tab.
  • Loading branch information
DanVanAtta authored Feb 28, 2021
1 parent 1b1f976 commit 51b2a42
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 33 deletions.
26 changes: 0 additions & 26 deletions game-core/src/main/java/games/strategy/triplea/ui/NotesPanel.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public final class TripleAFrame extends JFrame implements QuitHandler {
private final StatPanel statsPanel;
private final EconomyPanel economyPanel;
private ObjectivePanel objectivePanel;
private final NotesPanel notesPanel;
@Getter private final TerritoryDetailPanel territoryDetails;
private final JPanel historyComponent = new JPanel();
private final JPanel gameSouthPanel;
Expand Down Expand Up @@ -597,8 +596,6 @@ public void focusGained(final FocusEvent e) {
} else {
addTab(objectivePanel.getName(), objectivePanel, KeyCode.O);
}
notesPanel = new NotesPanel(data.getProperties().get("notes", "").trim());
addTab("Notes", notesPanel, KeyCode.N);
territoryDetails = new TerritoryDetailPanel(mapPanel, data, uiContext, this);
addTab("Territory", territoryDetails, KeyCode.T);
editPanel = new EditPanel(data, mapPanel, this);
Expand Down Expand Up @@ -2070,7 +2067,6 @@ private void showHistory() {
if (objectivePanel != null && !objectivePanel.isEmpty()) {
addTab(objectivePanel.getName(), objectivePanel, KeyCode.O);
}
addTab("Notes", notesPanel, KeyCode.N);
addTab("Territory", territoryDetails, KeyCode.T);
if (mapPanel.getEditMode()) {
tabsPanel.add("Edit", editPanel);
Expand Down Expand Up @@ -2259,7 +2255,6 @@ private void showGame() {
if (objectivePanel != null && !objectivePanel.isEmpty()) {
addTab(objectivePanel.getName(), objectivePanel, KeyCode.O);
}
addTab("Notes", notesPanel, KeyCode.N);
addTab("Territory", territoryDetails, KeyCode.T);
if (mapPanel.getEditMode()) {
tabsPanel.add("Edit", editPanel);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package games.strategy.triplea.ui.menubar.help;

import games.strategy.triplea.ui.NotesPanel;
import games.strategy.triplea.ui.UiContext;
import java.awt.Color;
import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.SwingUtilities;
import lombok.experimental.UtilityClass;
import org.triplea.swing.SwingAction;
import org.triplea.swing.SwingComponents;
import org.triplea.util.LocalizeHtml;

@UtilityClass
class GameNotesMenu {
Expand All @@ -18,7 +23,7 @@ Action buildMenu(final String gameNotes) {
SwingUtilities.invokeLater(
() -> {
final JDialog dialog =
InformationDialog.createDialog(new NotesPanel(gameNotes), gameNotesTitle);
InformationDialog.createDialog(notesPanel(gameNotes), gameNotesTitle);
if (dialog.getWidth() < 400) {
dialog.setSize(400, dialog.getHeight());
}
Expand All @@ -34,4 +39,16 @@ Action buildMenu(final String gameNotes) {
dialog.setVisible(true);
}));
}

private static JComponent notesPanel(final String gameNotes) {
final String localizedHtml =
LocalizeHtml.localizeImgLinksInHtml(
gameNotes.trim(), UiContext.getResourceLoader().getMapLocation());

final JEditorPane gameNotesPane = new JEditorPane("text/html", localizedHtml);
gameNotesPane.setEditable(false);
gameNotesPane.setForeground(Color.BLACK);
gameNotesPane.setCaretPosition(0);
return SwingComponents.newJScrollPane(gameNotesPane);
}
}

0 comments on commit 51b2a42

Please sign in to comment.