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

MHQ Colours: Adding Customizability as part of MHQ Options #2284

Merged
merged 12 commits into from
May 31, 2021
Merged
33 changes: 33 additions & 0 deletions MekHQ/resources/mekhq/resources/MekHqOptionsDialog.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,39 @@ optionPersonnelFilterStyle.text=Personnel Filter Style
optionPersonnelFilterStyle.toolTipText=This is the style for which Personnel Filters will be displayed
optionPersonnelFilterOnPrimaryRole.text=Filter Personnel Based On Primary Role

#Display Colour Tab
displayColourTab.title=Display Colour Options
optionDeployedForeground.text=Deployed Foreground
optionDeployedBackground.text=Deployed Background
optionBelowContractMinimumForeground.text=Below Contract Minimum Foreground
optionBelowContractMinimumBackground.text=Below Contract Minimum Background
optionInTransitForeground.text=In-Transit Foreground
optionInTransitBackground.text=In-Transit Background
optionRefittingForeground.text=Refitting Foreground
optionRefittingBackground.text=Refitting Background
optionMothballingForeground.text=Mothballing Foreground
optionMothballingBackground.text=Mothballing Background
optionMothballedForeground.text=Mothballed Foreground
optionMothballedBackground.text=Mothballed Background
optionNotRepairableForeground.text=Not Repairable Foreground
optionNotRepairableBackground.text=Not Repairable Background
optionNonFunctionalForeground.text=Non-Functional Foreground
optionNonFunctionalBackground.text=Non-Functional Background
optionNeedsPartsFixedForeground.text=Needs Parts Fixed Foreground
optionNeedsPartsFixedBackground.text=Needs Parts Fixed Background
optionUnmaintainedForeground.text=Unmaintained Foreground
optionUnmaintainedBackground.text=Unmaintained Background
optionUncrewedForeground.text=Uncrewed Foreground
optionUncrewedBackground.text=Uncrewed Background
optionLoanOverdueForeground.text=Loan Overdue Foreground
optionLoanOverdueBackground.text=Loan Overdue Background
optionInjuredForeground.text=Injured Foreground
optionInjuredBackground.text=Injured Background
optionHealedInjuriesForeground.text=Healed Injuries Foreground
optionHealedInjuriesBackground.text=Healed Injuries Background
optionPaidRetirementForeground.text=Paid Retirement Foreground
optionPaidRetirementBackground.text=Paid Retirement Background

#Autosave Tab
autosaveTab.title=Autosave options
optionNoSave.text=Don't save periodically
Expand Down
254 changes: 254 additions & 0 deletions MekHQ/src/mekhq/MekHQOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@

import mekhq.gui.enums.PersonnelFilterStyle;

import javax.swing.*;
import java.awt.*;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.prefs.Preferences;

public final class MekHQOptions {
//region Variable Declarations
private static final Preferences userPreferences = Preferences.userRoot();
//endregion Variable Declarations

//region Display
public String getDisplayDateFormat() {
Expand Down Expand Up @@ -64,6 +68,7 @@ public void setHistoricalDailyLog(boolean value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putBoolean(MekHqConstants.HISTORICAL_DAILY_LOG, value);
}

//region Expanded MekHQ Display Options
//region Command Center Display
public boolean getCommandCenterUseUnitMarket() {
return userPreferences.node(MekHqConstants.DISPLAY_NODE).getBoolean(MekHqConstants.COMMAND_CENTER_USE_UNIT_MARKET, true);
Expand Down Expand Up @@ -100,6 +105,255 @@ public void setPersonnelFilterOnPrimaryRole(boolean value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putBoolean(MekHqConstants.PERSONNEL_FILTER_ON_PRIMARY_ROLE, value);
}
//endregion Personnel Tab Display Options
//endregion Expanded MekHQ Display Options

//region Colours
public Color getDeployedForeground() {
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.DEPLOYED_FOREGROUND, Color.BLACK.getRGB()));
}

public void setDeployedForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.DEPLOYED_FOREGROUND, value.getRGB());
}

public Color getDeployedBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.DEPLOYED_BACKGROUND, Color.LIGHT_GRAY.getRGB()));
}

public void setDeployedBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.DEPLOYED_BACKGROUND, value.getRGB());
}

public Color getBelowContractMinimumForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.BELOW_CONTRACT_MINIMUM_FOREGROUND, Color.RED.getRGB()));
}

public void setBelowContractMinimumForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.BELOW_CONTRACT_MINIMUM_FOREGROUND, value.getRGB());
}

public Color getBelowContractMinimumBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.BELOW_CONTRACT_MINIMUM_BACKGROUND, UIManager.getColor("Table.background").getRGB()));
}

public void setBelowContractMinimumBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.BELOW_CONTRACT_MINIMUM_BACKGROUND, value.getRGB());
}

public Color getInTransitForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.IN_TRANSIT_FOREGROUND, Color.BLACK.getRGB()));
}

public void setInTransitForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.IN_TRANSIT_FOREGROUND, value.getRGB());
}

public Color getInTransitBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.IN_TRANSIT_BACKGROUND, Color.MAGENTA.getRGB()));
}

public void setInTransitBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.IN_TRANSIT_BACKGROUND, value.getRGB());
}

public Color getRefittingForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.REFITTING_FOREGROUND, Color.BLACK.getRGB()));
}

public void setRefittingForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.REFITTING_FOREGROUND, value.getRGB());
}

public Color getRefittingBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.REFITTING_BACKGROUND, Color.CYAN.getRGB()));
}

public void setRefittingBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.REFITTING_BACKGROUND, value.getRGB());
}

public Color getMothballingForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.MOTHBALLING_FOREGROUND, Color.BLACK.getRGB()));
}

public void setMothballingForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.MOTHBALLING_FOREGROUND, value.getRGB());
}

public Color getMothballingBackground() {
// new Color(153, 153, 255)
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.MOTHBALLING_BACKGROUND, 0xFF9999FF));
}

public void setMothballingBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.MOTHBALLING_BACKGROUND, value.getRGB());
}

public Color getMothballedForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.MOTHBALLED_FOREGROUND, Color.BLACK.getRGB()));
}

public void setMothballedForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.MOTHBALLED_FOREGROUND, value.getRGB());
}

public Color getMothballedBackground() {
// new Color(204, 204, 255)
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.MOTHBALLED_BACKGROUND, 0xFFCCCCFF));
}

public void setMothballedBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.MOTHBALLED_BACKGROUND, value.getRGB());
}

public Color getNotRepairableForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.NOT_REPAIRABLE_FOREGROUND, Color.BLACK.getRGB()));
}

public void setNotRepairableForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.NOT_REPAIRABLE_FOREGROUND, value.getRGB());
}

public Color getNotRepairableBackground() {
// new Color(190, 150, 55)
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.NOT_REPAIRABLE_BACKGROUND, 0xFFBE9637));
}

public void setNotRepairableBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.NOT_REPAIRABLE_BACKGROUND, value.getRGB());
}

public Color getNonFunctionalForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.NON_FUNCTIONAL_FOREGROUND, Color.BLACK.getRGB()));
}

public void setNonFunctionalForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.NON_FUNCTIONAL_FOREGROUND, value.getRGB());
}

public Color getNonFunctionalBackground() {
// new Color(205, 92, 92)
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.NON_FUNCTIONAL_BACKGROUND, 0xFFCD5C5C));
}

public void setNonFunctionalBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.NON_FUNCTIONAL_BACKGROUND, value.getRGB());
}

public Color getNeedsPartsFixedForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.NEEDS_PARTS_FIXED_FOREGROUND, Color.BLACK.getRGB()));
}

public void setNeedsPartsFixedForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.NEEDS_PARTS_FIXED_FOREGROUND, value.getRGB());
}

public Color getNeedsPartsFixedBackground() {
// new Color(238, 238, 0)
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.NEEDS_PARTS_FIXED_BACKGROUND, 0xFFEEEE00));
}

public void setNeedsPartsFixedBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.NEEDS_PARTS_FIXED_BACKGROUND, value.getRGB());
}

public Color getUnmaintainedForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.UNMAINTAINED_FOREGROUND, Color.BLACK.getRGB()));
}

public void setUnmaintainedForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.UNMAINTAINED_FOREGROUND, value.getRGB());
}

public Color getUnmaintainedBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.UNMAINTAINED_BACKGROUND, Color.ORANGE.getRGB()));
}

public void setUnmaintainedBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.UNMAINTAINED_BACKGROUND, value.getRGB());
}

public Color getUncrewedForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.UNCREWED_FOREGROUND, Color.BLACK.getRGB()));
}

public void setUncrewedForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.UNCREWED_FOREGROUND, value.getRGB());
}

public Color getUncrewedBackground() {
// new Color(218, 130, 255)
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.UNCREWED_BACKGROUND, 0xFFDA82FF));
}

public void setUncrewedBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.UNCREWED_BACKGROUND, value.getRGB());
}

public Color getLoanOverdueForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.LOAN_OVERDUE_FOREGROUND, Color.BLACK.getRGB()));
}

public void setLoanOverdueForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.LOAN_OVERDUE_FOREGROUND, value.getRGB());
}

public Color getLoanOverdueBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.LOAN_OVERDUE_BACKGROUND, Color.RED.getRGB()));
}

public void setLoanOverdueBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.LOAN_OVERDUE_BACKGROUND, value.getRGB());
}

public Color getInjuredForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.INJURED_FOREGROUND, Color.BLACK.getRGB()));
}

public void setInjuredForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.INJURED_FOREGROUND, value.getRGB());
}

public Color getInjuredBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.INJURED_BACKGROUND, Color.RED.getRGB()));
}

public void setInjuredBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.INJURED_BACKGROUND, value.getRGB());
}

public Color getHealedInjuriesForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.HEALED_INJURIES_FOREGROUND, Color.BLACK.getRGB()));
}

public void setHealedInjuriesForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.HEALED_INJURIES_FOREGROUND, value.getRGB());
}

public Color getHealedInjuriesBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.HEALED_INJURIES_BACKGROUND, 0xEE9A00));
}

public void setHealedInjuriesBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.HEALED_INJURIES_BACKGROUND, value.getRGB());
}

public Color getPaidRetirementForeground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.PAID_RETIREMENT_FOREGROUND, Color.BLACK.getRGB()));
}

public void setPaidRetirementForeground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.PAID_RETIREMENT_FOREGROUND, value.getRGB());
}

public Color getPaidRetirementBackground() {
return new Color(userPreferences.node(MekHqConstants.DISPLAY_NODE).getInt(MekHqConstants.PAID_RETIREMENT_BACKGROUND, Color.LIGHT_GRAY.getRGB()));
}

public void setPaidRetirementBackground(Color value) {
userPreferences.node(MekHqConstants.DISPLAY_NODE).putInt(MekHqConstants.PAID_RETIREMENT_BACKGROUND, value.getRGB());
}
//endregion Colours
//endregion Display

//region Autosave
Expand Down
35 changes: 34 additions & 1 deletion MekHQ/src/mekhq/MekHqConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class MekHqConstants {
public static final String HISTORICAL_DAILY_LOG = "historicalDailyLog";
public static final int MAX_HISTORICAL_LOG_DAYS = 120; // max number of days that will be stored in the history, also used as a limit in the UI

// region Command Center
//region Command Center
public static final String COMMAND_CENTER_USE_UNIT_MARKET = "commandCenterUseUnitMarket";
public static final String COMMAND_CENTER_MRMS = "commandCenterMRMS";
//endregion Command Center
Expand All @@ -38,6 +38,39 @@ public final class MekHqConstants {
public static final String PERSONNEL_FILTER_STYLE = "personnelFilterStyle";
public static final String PERSONNEL_FILTER_ON_PRIMARY_ROLE = "personnelFilterOnPrimaryRole";
//endregion Personnel Tab Display Options

//region Colours
public static final String DEPLOYED_FOREGROUND = "deployedForeground";
public static final String DEPLOYED_BACKGROUND = "deployedBackground";
public static final String BELOW_CONTRACT_MINIMUM_FOREGROUND = "belowContractMinimumForeground";
public static final String BELOW_CONTRACT_MINIMUM_BACKGROUND = "belowContractMinimumBackground";
public static final String IN_TRANSIT_FOREGROUND = "inTransitForeground";
public static final String IN_TRANSIT_BACKGROUND = "inTransitBackground";
public static final String REFITTING_FOREGROUND = "refittingForeground";
public static final String REFITTING_BACKGROUND = "refittingBackground";
public static final String MOTHBALLING_FOREGROUND = "mothballingForeground";
public static final String MOTHBALLING_BACKGROUND = "mothballingBackground";
public static final String MOTHBALLED_FOREGROUND = "mothballedForeground";
public static final String MOTHBALLED_BACKGROUND = "mothballedBackground";
public static final String NOT_REPAIRABLE_FOREGROUND = "notRepairableForeground";
public static final String NOT_REPAIRABLE_BACKGROUND = "notRepairableBackground";
public static final String NON_FUNCTIONAL_FOREGROUND = "nonFunctionalForeground";
public static final String NON_FUNCTIONAL_BACKGROUND = "nonFunctionalBackground";
public static final String NEEDS_PARTS_FIXED_FOREGROUND = "needsPartsFixedForeground";
public static final String NEEDS_PARTS_FIXED_BACKGROUND = "needsPartsFixedBackground";
public static final String UNMAINTAINED_FOREGROUND = "unmaintainedForeground";
public static final String UNMAINTAINED_BACKGROUND = "unmaintainedBackground";
public static final String UNCREWED_FOREGROUND = "uncrewedForeground";
public static final String UNCREWED_BACKGROUND = "uncrewedBackground";
public static final String LOAN_OVERDUE_FOREGROUND = "loanOverdueForeground";
public static final String LOAN_OVERDUE_BACKGROUND = "loanOverdueBackground";
public static final String INJURED_FOREGROUND = "injuredForeground";
public static final String INJURED_BACKGROUND = "injuredBackground";
public static final String HEALED_INJURIES_FOREGROUND = "healedInjuriesForeground";
public static final String HEALED_INJURIES_BACKGROUND = "healedInjuriesBackground";
public static final String PAID_RETIREMENT_FOREGROUND = "paidRetirementForeground";
public static final String PAID_RETIREMENT_BACKGROUND = "paidRetirementBackground";
//endregion Colours
//endregion Display

//region Autosave
Expand Down
Loading