Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to show unit images in TO&E #5024

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ chkCompanyGeneratorStartup.text=Company Generator Startup outside AtB (Unimpleme
chkCompanyGeneratorStartup.toolTipText=Adds the ability to use the company generator on startup outside of AtB campaigns.
chkShowCompanyGenerator.text=Show Company Generator
chkShowCompanyGenerator.toolTipText=Add a company generator menu item under the Manage Campaign header on the menu bar to allow one to generate a company after startup.
chkShowUnitPicturesOnTOE.text=Show Unit Icons in TO&E Instead of Portraits
chkShowUnitPicturesOnTOE.toolTipText=Make the TO&E Unit List display pictures of the units themselves rather than portraits of the pilots/drivers/leaders.
labelCommandCenterDisplay.text=Command Center Display Options
optionCommandCenterUseUnitMarket.text=Find Units Links to Unit Market (if enabled)
optionCommandCenterUseUnitMarket.toolTipText=The Find Units button on the Command Center will link to the Unit Market provided the Unit Market is enabled.
Expand Down
1 change: 1 addition & 0 deletions MekHQ/src/mekhq/MHQConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public final class MHQConstants extends SuiteConstants {
// also used as a limit in the UI
public static final String COMPANY_GENERATOR_STARTUP = "companyGeneratorStartup";
public static final String SHOW_COMPANY_GENERATOR = "showCompanyGenerator";
public static final String SHOW_UNIT_PICTURES_ON_TOE = "showUnitPicturesOnTOE";

// region Command Center Tab
public static final String COMMAND_CENTER_USE_UNIT_MARKET = "commandCenterUseUnitMarket";
Expand Down
8 changes: 8 additions & 0 deletions MekHQ/src/mekhq/MHQOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ public void setShowCompanyGenerator(final boolean value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putBoolean(MHQConstants.SHOW_COMPANY_GENERATOR, value);
}

public boolean getShowUnitPicturesOnTOE() {
return userPreferences.node(MHQConstants.DISPLAY_NODE).getBoolean(MHQConstants.SHOW_UNIT_PICTURES_ON_TOE, true);
}

public void setShowUnitPicturesOnTOE(final boolean value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putBoolean(MHQConstants.SHOW_UNIT_PICTURES_ON_TOE, value);
}

// region Command Center Tab
public boolean getCommandCenterUseUnitMarket() {
return userPreferences.node(MHQConstants.DISPLAY_NODE).getBoolean(MHQConstants.COMMAND_CENTER_USE_UNIT_MARKET,
Expand Down
9 changes: 7 additions & 2 deletions MekHQ/src/mekhq/gui/ForceRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.awt.Component;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

Expand Down Expand Up @@ -160,8 +161,12 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean

protected Icon getIcon(Object node) {
if (node instanceof Unit) {
final Person person = ((Unit) node).getCommander();
return (person == null) ? null : person.getPortrait().getImageIcon(58);
if (MekHQ.getMHQOptions().getShowUnitPicturesOnTOE()) {
return new ImageIcon(((Unit) node).getImage(this));
} else {
final Person person = ((Unit) node).getCommander();
return (person == null) ? null : person.getPortrait().getImageIcon(58);
}
} else if (node instanceof Force) {
return ((Force) node).getForceIcon().getImageIcon(58);
} else {
Expand Down
11 changes: 10 additions & 1 deletion MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ public class MHQOptionsDialog extends AbstractMHQButtonDialog {
// region Display
private JTextField optionDisplayDateFormat;
private JTextField optionLongDisplayDateFormat;
private final JSlider guiScale = new JSlider();
private JCheckBox optionHistoricalDailyLog;
private JCheckBox chkCompanyGeneratorStartup;
private JCheckBox chkShowCompanyGenerator;
private final JSlider guiScale = new JSlider();
private JCheckBox chkShowUnitPicturesOnTOE;

// region Command Center Tab
private JCheckBox optionCommandCenterUseUnitMarket;
Expand Down Expand Up @@ -280,6 +281,10 @@ private JPanel createDisplayTab() {
chkShowCompanyGenerator.setToolTipText(resources.getString("chkShowCompanyGenerator.toolTipText"));
chkShowCompanyGenerator.setName("chkShowCompanyGenerator");

chkShowUnitPicturesOnTOE = new JCheckBox(resources.getString("chkShowUnitPicturesOnTOE.text"));
chkShowUnitPicturesOnTOE.setToolTipText(resources.getString("chkShowUnitPicturesOnTOE.toolTipText"));
chkShowUnitPicturesOnTOE.setName("chkShowUnitPicturesOnTOE");

// region Command Center Tab
JLabel labelCommandCenterDisplay = new JLabel(resources.getString("labelCommandCenterDisplay.text"));

Expand Down Expand Up @@ -436,6 +441,7 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
.addComponent(optionHistoricalDailyLog)
.addComponent(chkCompanyGeneratorStartup)
.addComponent(chkShowCompanyGenerator)
.addComponent(chkShowUnitPicturesOnTOE)
.addComponent(labelCommandCenterDisplay)
.addComponent(optionCommandCenterUseUnitMarket)
.addComponent(optionCommandCenterMRMS)
Expand Down Expand Up @@ -476,6 +482,7 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
.addComponent(optionHistoricalDailyLog)
.addComponent(chkCompanyGeneratorStartup)
.addComponent(chkShowCompanyGenerator)
.addComponent(chkShowUnitPicturesOnTOE)
.addComponent(labelCommandCenterDisplay)
.addComponent(optionCommandCenterUseUnitMarket)
.addComponent(optionCommandCenterMRMS)
Expand Down Expand Up @@ -1292,6 +1299,7 @@ protected void okAction() {
MekHQ.getMHQOptions().setHistoricalDailyLog(optionHistoricalDailyLog.isSelected());
MekHQ.getMHQOptions().setCompanyGeneratorStartup(chkCompanyGeneratorStartup.isSelected());
MekHQ.getMHQOptions().setShowCompanyGenerator(chkShowCompanyGenerator.isSelected());
MekHQ.getMHQOptions().setShowUnitPicturesOnTOE(chkShowUnitPicturesOnTOE.isSelected());

// Command Center Tab
MekHQ.getMHQOptions().setCommandCenterUseUnitMarket(optionCommandCenterUseUnitMarket.isSelected());
Expand Down Expand Up @@ -1433,6 +1441,7 @@ private void setInitialState() {
optionHistoricalDailyLog.setSelected(MekHQ.getMHQOptions().getHistoricalDailyLog());
chkCompanyGeneratorStartup.setSelected(MekHQ.getMHQOptions().getCompanyGeneratorStartup());
chkShowCompanyGenerator.setSelected(MekHQ.getMHQOptions().getShowCompanyGenerator());
chkShowUnitPicturesOnTOE.setSelected(MekHQ.getMHQOptions().getShowUnitPicturesOnTOE());

// Command Center Tab
optionCommandCenterUseUnitMarket.setSelected(MekHQ.getMHQOptions().getCommandCenterUseUnitMarket());
Expand Down