Skip to content

Commit

Permalink
Allow modifying unique lights via Edit Token dialog.
Browse files Browse the repository at this point in the history
Disable unique light sources panel for non-GMs; player can still see the definitions, no harm in that.

Some layout changes were necessary to prevent the portrait etc. from shrinking too much. The terrain modifier input
width was fixed as well.
  • Loading branch information
kwvanderlinde committed Dec 11, 2023
1 parent cc96246 commit 0f92499
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ public void initTerrainModifiersIgnoredList() {
EnumSet.allOf(TerrainModifierOperation.class).forEach(operationModel::addElement);
}

public void initUniqueLightSourcesTextPane() {
setUniqueLightSourcesEnabled(MapTool.getPlayer().isGM());
}

public void initJtsMethodComboBox() {
getJtsMethodComboBox().setModel(new DefaultComboBoxModel<>(JTS_SimplifyMethodType.values()));
}
Expand Down Expand Up @@ -202,6 +206,8 @@ public void closeDialog() {
setGmNotesEnabled(MapTool.getPlayer().isGM());
getComponent("@GMName").setEnabled(MapTool.getPlayer().isGM());

setUniqueLightSourcesEnabled(MapTool.getPlayer().isGM());

dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

setLibTokenPaneEnabled(token.isLibToken());
Expand Down Expand Up @@ -372,6 +378,9 @@ public void bind(final Token token) {
.mapToInt(Integer::valueOf)
.toArray());

getUniqueLightSourcesTextPane()
.setText(new LightSyntax().stringifyLights(token.getUniqueLightSources()));

// Jamz: Init the Topology tab...
JTabbedPane tabbedPane = getTabbedPane();

Expand Down Expand Up @@ -710,6 +719,15 @@ public JList<TerrainModifierOperation> getTerrainModifiersIgnoredList() {
return (JList<TerrainModifierOperation>) getComponent("terrainModifiersIgnored");
}

public void setUniqueLightSourcesEnabled(boolean enabled) {
getUniqueLightSourcesTextPane().setEnabled(enabled);
getLabel("uniqueLightSourcesLabel").setEnabled(enabled);
}

public JTextPane getUniqueLightSourcesTextPane() {
return (JTextPane) getComponent("uniqueLightSources");
}

public JLabel getLibTokenURIErrorLabel() {
return (JLabel) getComponent("Label.LibURIError");
}
Expand Down Expand Up @@ -784,6 +802,14 @@ public boolean commit() {
token.setTerrainModifiersIgnored(
new HashSet<>(getTerrainModifiersIgnoredList().getSelectedValuesList()));

var uniqueLightSources =
new LightSyntax()
.parseLights(getUniqueLightSourcesTextPane().getText(), token.getUniqueLightSources());
token.removeAllUniqueLightsources();
for (var lightSource : uniqueLightSources.values()) {
token.addUniqueLightSource(lightSource);
}

// Get the states
Component[] stateComponents = getStatesPanel().getComponents();
Container barPanel = null;
Expand Down Expand Up @@ -1211,6 +1237,7 @@ public void initTokenDetails() {

public void initTokenLayoutPanel() {
TokenLayoutPanel layoutPanel = new TokenLayoutPanel();
layoutPanel.setMinimumSize(new Dimension(150, 125));
layoutPanel.setPreferredSize(new Dimension(150, 125));
layoutPanel.setName("tokenLayout");

Expand All @@ -1219,6 +1246,7 @@ public void initTokenLayoutPanel() {

public void initCharsheetPanel() {
ImageAssetPanel panel = new ImageAssetPanel();
panel.setMinimumSize(new Dimension(150, 125));
panel.setPreferredSize(new Dimension(150, 125));
panel.setName("charsheet");
panel.setLayout(new GridLayout());
Expand All @@ -1228,6 +1256,7 @@ public void initCharsheetPanel() {

public void initPortraitPanel() {
ImageAssetPanel panel = new ImageAssetPanel();
panel.setMinimumSize(new Dimension(150, 125));
panel.setPreferredSize(new Dimension(150, 125));
panel.setName("portrait");
panel.setLayout(new GridLayout());
Expand Down
Loading

0 comments on commit 0f92499

Please sign in to comment.