Skip to content

Commit

Permalink
Merge pull request #5034 from WeaverThree/wvr-fatigue-gone-linebkgs
Browse files Browse the repository at this point in the history
New row highlights for Personnel Table: Gone, Absent, Fatigued
  • Loading branch information
IllianiCBT authored Oct 12, 2024
2 parents 9d76549 + 67eb6d1 commit 318bbef
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 15 deletions.
6 changes: 6 additions & 0 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,12 @@ optionHealedInjuriesForeground.text=Healed Injuries Foreground
optionHealedInjuriesBackground.text=Healed Injuries Background
optionPregnantForeground.text=Pregnant Foreground
optionPregnantBackground.text=Pregnant Background
optionGoneForeground.text=Gone Foreground
optionGoneBackground.text=Gone Background
optionAbsentForeground.text=Absent Foreground
optionAbsentBackground.text=Absent Background
optionFatiguedForeground.text=Fatigued Foreground
optionFatiguedBackground.text=Fatigued Background
optionStratConHexCoordForeground.text=StratCon Hex Coordinate Foreground
optionFontColorNegative.text=Font Color Negative Event
optionFontColorWarning.text=Font Color Warning
Expand Down
6 changes: 6 additions & 0 deletions MekHQ/src/mekhq/MHQConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public final class MHQConstants extends SuiteConstants {
public static final String HEALED_INJURIES_BACKGROUND = "healedInjuriesBackground";
public static final String PREGNANT_FOREGROUND = "pregnantForeground";
public static final String PREGNANT_BACKGROUND = "pregnantBackground";
public static final String GONE_FOREGROUND = "goneForeground";
public static final String GONE_BACKGROUND = "goneBackground";
public static final String ABSENT_FOREGROUND = "absentForeground";
public static final String ABSENT_BACKGROUND = "absentBackground";
public static final String FATIGUED_FOREGROUND = "fatiguedForeground";
public static final String FATIGUED_BACKGROUND = "fatiguedBackground";
public static final String STRATCON_HEX_COORD_FOREGROUND = "stratconHexCoordForeground";
public static final String FONT_COLOR_NEGATIVE = "fontColorNegative";
public static final String FONT_COLOR_POSITIVE = "fontColorPositive";
Expand Down
54 changes: 54 additions & 0 deletions MekHQ/src/mekhq/MHQOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,60 @@ public void setPregnantBackground(Color value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putInt(MHQConstants.PREGNANT_BACKGROUND, value.getRGB());
}

public Color getGoneForeground() {
return new Color(
userPreferences.node(MHQConstants.DISPLAY_NODE).getInt(MHQConstants.GONE_FOREGROUND, 0xffffff));
}

public void setGoneForeground(Color value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putInt(MHQConstants.GONE_FOREGROUND, value.getRGB());
}

public Color getGoneBackground() {
return new Color(
userPreferences.node(MHQConstants.DISPLAY_NODE).getInt(MHQConstants.GONE_BACKGROUND, 0x222222));
}

public void setGoneBackground(Color value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putInt(MHQConstants.GONE_BACKGROUND, value.getRGB());
}

public Color getAbsentForeground() {
return new Color(
userPreferences.node(MHQConstants.DISPLAY_NODE).getInt(MHQConstants.ABSENT_FOREGROUND, 0x000000));
}

public void setAbsentForeground(Color value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putInt(MHQConstants.ABSENT_FOREGROUND, value.getRGB());
}

public Color getAbsentBackground() {
return new Color(
userPreferences.node(MHQConstants.DISPLAY_NODE).getInt(MHQConstants.ABSENT_BACKGROUND, 0xffffff));
}

public void setAbsentBackground(Color value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putInt(MHQConstants.ABSENT_BACKGROUND, value.getRGB());
}

public Color getFatiguedForeground() {
return new Color(
userPreferences.node(MHQConstants.DISPLAY_NODE).getInt(MHQConstants.FATIGUED_FOREGROUND, 0x000000));
}

public void setFatiguedForeground(Color value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putInt(MHQConstants.FATIGUED_FOREGROUND, value.getRGB());
}

public Color getFatiguedBackground() {
return new Color(
userPreferences.node(MHQConstants.DISPLAY_NODE).getInt(MHQConstants.FATIGUED_BACKGROUND, 0xeeee00));
}

public void setFatiguedBackground(Color value) {
userPreferences.node(MHQConstants.DISPLAY_NODE).putInt(MHQConstants.FATIGUED_BACKGROUND, value.getRGB());
}

public Color getStratConHexCoordForeground() {
return new Color(userPreferences.node(MHQConstants.DISPLAY_NODE)
.getInt(MHQConstants.STRATCON_HEX_COORD_FOREGROUND, Color.GREEN.getRGB()));
Expand Down
57 changes: 57 additions & 0 deletions MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ public class MHQOptionsDialog extends AbstractMHQButtonDialog {
private ColourSelectorButton optionHealedInjuriesBackground;
private ColourSelectorButton optionPregnantForeground;
private ColourSelectorButton optionPregnantBackground;
private ColourSelectorButton optionGoneForeground;
private ColourSelectorButton optionGoneBackground;
private ColourSelectorButton optionAbsentForeground;
private ColourSelectorButton optionAbsentBackground;
private ColourSelectorButton optionFatiguedForeground;
private ColourSelectorButton optionFatiguedBackground;
private ColourSelectorButton optionStratConHexCoordForeground;
private ColourSelectorButton optionFontColorNegative;
private ColourSelectorButton optionFontColorWarning;
Expand Down Expand Up @@ -598,6 +604,24 @@ private JPanel createColoursTab() {
optionPregnantBackground = new ColourSelectorButton(
resources.getString("optionPregnantBackground.text"));

optionGoneForeground = new ColourSelectorButton(
resources.getString("optionGoneForeground.text"));

optionGoneBackground = new ColourSelectorButton(
resources.getString("optionGoneBackground.text"));

optionAbsentForeground = new ColourSelectorButton(
resources.getString("optionAbsentForeground.text"));

optionAbsentBackground = new ColourSelectorButton(
resources.getString("optionAbsentBackground.text"));

optionFatiguedForeground = new ColourSelectorButton(
resources.getString("optionFatiguedForeground.text"));

optionFatiguedBackground = new ColourSelectorButton(
resources.getString("optionFatiguedBackground.text"));

optionStratConHexCoordForeground = new ColourSelectorButton(
resources.getString("optionStratConHexCoordForeground.text"));

Expand Down Expand Up @@ -679,6 +703,18 @@ private JPanel createColoursTab() {
.addComponent(optionPregnantForeground)
.addComponent(optionPregnantBackground,
Alignment.TRAILING))
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(optionGoneForeground)
.addComponent(optionGoneBackground,
Alignment.TRAILING))
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(optionAbsentForeground)
.addComponent(optionAbsentBackground,
Alignment.TRAILING))
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(optionFatiguedForeground)
.addComponent(optionFatiguedBackground,
Alignment.TRAILING))
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(optionStratConHexCoordForeground))
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
Expand Down Expand Up @@ -735,6 +771,15 @@ private JPanel createColoursTab() {
.addGroup(layout.createSequentialGroup()
.addComponent(optionPregnantForeground)
.addComponent(optionPregnantBackground))
.addGroup(layout.createSequentialGroup()
.addComponent(optionGoneForeground)
.addComponent(optionGoneBackground))
.addGroup(layout.createSequentialGroup()
.addComponent(optionAbsentForeground)
.addComponent(optionAbsentBackground))
.addGroup(layout.createSequentialGroup()
.addComponent(optionFatiguedForeground)
.addComponent(optionFatiguedBackground))
.addGroup(layout.createSequentialGroup()
.addComponent(optionStratConHexCoordForeground))
.addGroup(layout.createSequentialGroup()
Expand Down Expand Up @@ -1362,6 +1407,12 @@ protected void okAction() {
MekHQ.getMHQOptions().setHealedInjuriesBackground(optionHealedInjuriesBackground.getColour());
MekHQ.getMHQOptions().setPregnantForeground(optionPregnantForeground.getColour());
MekHQ.getMHQOptions().setPregnantBackground(optionPregnantBackground.getColour());
MekHQ.getMHQOptions().setGoneForeground(optionGoneForeground.getColour());
MekHQ.getMHQOptions().setGoneBackground(optionGoneBackground.getColour());
MekHQ.getMHQOptions().setAbsentForeground(optionAbsentForeground.getColour());
MekHQ.getMHQOptions().setAbsentBackground(optionAbsentBackground.getColour());
MekHQ.getMHQOptions().setFatiguedForeground(optionFatiguedForeground.getColour());
MekHQ.getMHQOptions().setFatiguedBackground(optionFatiguedBackground.getColour());
MekHQ.getMHQOptions().setStratConHexCoordForeground(optionStratConHexCoordForeground.getColour());
MekHQ.getMHQOptions().setFontColorNegative(optionFontColorNegative.getColour());
MekHQ.getMHQOptions().setFontColorWarning(optionFontColorWarning.getColour());
Expand Down Expand Up @@ -1510,6 +1561,12 @@ private void setInitialState() {
optionHealedInjuriesBackground.setColour(MekHQ.getMHQOptions().getHealedInjuriesBackground());
optionPregnantForeground.setColour(MekHQ.getMHQOptions().getPregnantForeground());
optionPregnantBackground.setColour(MekHQ.getMHQOptions().getPregnantBackground());
optionGoneForeground.setColour(MekHQ.getMHQOptions().getGoneForeground());
optionGoneBackground.setColour(MekHQ.getMHQOptions().getGoneBackground());
optionAbsentForeground.setColour(MekHQ.getMHQOptions().getAbsentForeground());
optionAbsentBackground.setColour(MekHQ.getMHQOptions().getAbsentBackground());
optionFatiguedForeground.setColour(MekHQ.getMHQOptions().getFatiguedForeground());
optionFatiguedBackground.setColour(MekHQ.getMHQOptions().getFatiguedBackground());
optionStratConHexCoordForeground.setColour(MekHQ.getMHQOptions().getStratConHexCoordForeground());
optionFontColorNegative.setColour(MekHQ.getMHQOptions().getFontColorNegative());
optionFontColorWarning.setColour(MekHQ.getMHQOptions().getFontColorWarning());
Expand Down
37 changes: 22 additions & 15 deletions MekHQ/src/mekhq/gui/model/PersonnelTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,30 +164,37 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
setToolTipText(personnelColumn.getToolTipText(person, loadAssignmentFromMarket));

// Colouring
boolean personIsDamaged = false;
if (campaign.getCampaignOptions().isUseAdvancedMedical()) {
personIsDamaged = person.hasInjuries(false);
} else {
personIsDamaged = person.getHits() > 0;
}
boolean personIsFatigued = (campaign.getCampaignOptions().isUseFatigue()
&& (person.getEffectiveFatigue(campaign) >= 5));

if (!isSelected) {
if (person.getStatus().isDead() || person.getStatus().isRetired()
|| person.getStatus().isDeserted()) {
setBackground(UIManager.getColor("Table.background"));
setForeground(UIManager.getColor("Table.foreground"));
} else if (person.getStatus().isAbsent()) {
// TODO : Add a specific colour for absent personnel, as they are treated
// TODO : differently than normal personnel
setBackground(UIManager.getColor("Table.background"));
setForeground(UIManager.getColor("Table.foreground"));
if (person.getStatus().isAbsent()) {
setBackground(MekHQ.getMHQOptions().getAbsentBackground());
setForeground(MekHQ.getMHQOptions().getAbsentForeground());
} else if (person.getStatus().isDepartedUnit()) {
setBackground(MekHQ.getMHQOptions().getGoneBackground());
setForeground(MekHQ.getMHQOptions().getGoneForeground());
} else if (person.isDeployed()) {
setForeground(MekHQ.getMHQOptions().getDeployedForeground());
setBackground(MekHQ.getMHQOptions().getDeployedBackground());
} else if (person.hasInjuries(true)
|| (Integer.parseInt((String) getValueAt(modelRow,
PersonnelTableModelColumn.INJURIES.ordinal())) > 0)) {
} else if (personIsDamaged) {
setForeground(MekHQ.getMHQOptions().getInjuredForeground());
setBackground(MekHQ.getMHQOptions().getInjuredBackground());
} else if (person.hasOnlyHealedPermanentInjuries()) {
setForeground(MekHQ.getMHQOptions().getHealedInjuriesForeground());
setBackground(MekHQ.getMHQOptions().getHealedInjuriesBackground());
} else if (person.isPregnant()) {
setForeground(MekHQ.getMHQOptions().getPregnantForeground());
setBackground(MekHQ.getMHQOptions().getPregnantBackground());
} else if (personIsFatigued) {
setForeground(MekHQ.getMHQOptions().getFatiguedForeground());
setBackground(MekHQ.getMHQOptions().getFatiguedBackground());
} else if (person.hasOnlyHealedPermanentInjuries()) {
setForeground(MekHQ.getMHQOptions().getHealedInjuriesForeground());
setBackground(MekHQ.getMHQOptions().getHealedInjuriesBackground());
} else {
setBackground(UIManager.getColor("Table.background"));
setForeground(UIManager.getColor("Table.foreground"));
Expand Down

0 comments on commit 318bbef

Please sign in to comment.