feat: add in default instance sorting setting
This commit is contained in:
parent
5f96eafca9
commit
ec4a91a3a2
5 changed files with 40 additions and 8 deletions
|
@ -1103,6 +1103,7 @@ public class Instance extends MinecraftVersion {
|
|||
backup();
|
||||
}
|
||||
if (App.settings.keepLauncherOpen) {
|
||||
App.launcher.reloadInstancesPanel();
|
||||
App.launcher.updateData();
|
||||
}
|
||||
if (Files.isDirectory(nativesTempDir)) {
|
||||
|
@ -1939,31 +1940,31 @@ public class Instance extends MinecraftVersion {
|
|||
return settings;
|
||||
}
|
||||
|
||||
public void setNumberOfPlays(final long val){
|
||||
public void setNumberOfPlays(final long val) {
|
||||
this.numPlays = val;
|
||||
}
|
||||
|
||||
public long incrementNumberOfPlays(){
|
||||
public long incrementNumberOfPlays() {
|
||||
return this.numPlays++;
|
||||
}
|
||||
|
||||
public long decrementNumberOfPlays(){
|
||||
public long decrementNumberOfPlays() {
|
||||
return this.numPlays--;
|
||||
}
|
||||
|
||||
public long getNumberOfPlays(){
|
||||
public long getNumberOfPlays() {
|
||||
return this.numPlays;
|
||||
}
|
||||
|
||||
public void setLastPlayed(final Instant ts){
|
||||
public void setLastPlayed(final Instant ts) {
|
||||
this.lastPlayed = ts;
|
||||
}
|
||||
|
||||
public Instant getLastPlayed(){
|
||||
public Instant getLastPlayed() {
|
||||
return this.lastPlayed;
|
||||
}
|
||||
|
||||
public Instant getLastPlayedOrEpoch(){
|
||||
public Instant getLastPlayedOrEpoch() {
|
||||
return this.lastPlayed != null ? this.lastPlayed : Instant.EPOCH;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.atlauncher.managers.LogManager;
|
|||
import com.atlauncher.utils.OS;
|
||||
import com.atlauncher.utils.Timestamper;
|
||||
import com.atlauncher.utils.Utils;
|
||||
import com.atlauncher.utils.sort.InstanceSortingStrategies;
|
||||
|
||||
public class Settings {
|
||||
// Launcher things
|
||||
|
@ -62,6 +63,7 @@ public class Settings {
|
|||
public String theme = Constants.DEFAULT_THEME_CLASS;
|
||||
public String dateFormat = Constants.DATE_FORMATS[0];
|
||||
public String instanceTitleFormat = Constants.INSTANCE_TITLE_FORMATS[0];
|
||||
public InstanceSortingStrategies defaultInstanceSorting = InstanceSortingStrategies.BY_NAME;
|
||||
public int selectedTabOnStartup = 0;
|
||||
public boolean sortPacksAlphabetically = false;
|
||||
public Boolean showPackNameAndVersion = null;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.stream.Stream;
|
|||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.constants.UIConstants;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
|
@ -62,7 +63,7 @@ public final class InstancesListPanel extends JPanel
|
|||
|
||||
private final NilCard nilCard = createNilCard();
|
||||
private Pattern searchPattern;
|
||||
private InstanceSortingStrategy sortingStrategy;
|
||||
private InstanceSortingStrategy sortingStrategy = App.settings.defaultInstanceSorting;
|
||||
final InstancesTab parent;
|
||||
|
||||
public InstancesListPanel(final InstancesTab parent) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.swing.JButton;
|
|||
import javax.swing.JComboBox;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
import com.atlauncher.evnt.manager.RelocalizationManager;
|
||||
import com.atlauncher.gui.dialogs.ImportInstanceDialog;
|
||||
|
@ -51,6 +52,10 @@ public final class InstancesNavigationPanel extends JPanel implements Relocaliza
|
|||
this.searchField = new InstancesSearchField(parent);
|
||||
this.sortingBox.setMaximumSize(new Dimension(190, 23));
|
||||
|
||||
if (App.settings.defaultInstanceSorting != InstanceSortingStrategies.BY_NAME) {
|
||||
this.sortingBox.setSelectedItem(App.settings.defaultInstanceSorting);
|
||||
}
|
||||
|
||||
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
this.add(importButton);
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.atlauncher.gui.components.JLabelWithHover;
|
|||
import com.atlauncher.utils.ComboItem;
|
||||
import com.atlauncher.utils.OS;
|
||||
import com.atlauncher.utils.Utils;
|
||||
import com.atlauncher.utils.sort.InstanceSortingStrategies;
|
||||
|
||||
import org.mini2Dx.gettext.GetText;
|
||||
|
||||
|
@ -51,6 +52,7 @@ public class GeneralSettingsTab extends AbstractSettingsTab {
|
|||
private final JComboBox<ComboItem<String>> dateFormat;
|
||||
private final JComboBox<ComboItem<String>> instanceTitleFormat;
|
||||
private final JComboBox<ComboItem<Integer>> selectedTabOnStartup;
|
||||
private final JComboBox<InstanceSortingStrategies> defaultInstanceSorting;
|
||||
private final JCheckBox sortPacksAlphabetically;
|
||||
private final JCheckBox keepLauncherOpen;
|
||||
private final JCheckBox enableConsole;
|
||||
|
@ -226,6 +228,26 @@ public class GeneralSettingsTab extends AbstractSettingsTab {
|
|||
|
||||
add(selectedTabOnStartup, gbc);
|
||||
|
||||
// Default instance sorting
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy++;
|
||||
gbc.insets = UIConstants.LABEL_INSETS;
|
||||
gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
|
||||
|
||||
JLabelWithHover defaultInstanceSortingLabel = new JLabelWithHover(GetText.tr("Default Tab") + ":", HELP_ICON,
|
||||
GetText.tr("Which tab to have selected by default when opening the launcher."));
|
||||
|
||||
add(defaultInstanceSortingLabel, gbc);
|
||||
|
||||
gbc.gridx++;
|
||||
gbc.insets = UIConstants.FIELD_INSETS;
|
||||
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
|
||||
defaultInstanceSorting = new JComboBox<>(InstanceSortingStrategies.values());
|
||||
defaultInstanceSorting.setSelectedItem(App.settings.defaultInstanceSorting);
|
||||
|
||||
add(defaultInstanceSorting, gbc);
|
||||
|
||||
// Sort Packs Alphabetically
|
||||
|
||||
gbc.gridx = 0;
|
||||
|
@ -450,6 +472,7 @@ public class GeneralSettingsTab extends AbstractSettingsTab {
|
|||
App.settings.dateFormat = ((ComboItem<String>) dateFormat.getSelectedItem()).getValue();
|
||||
App.settings.instanceTitleFormat = ((ComboItem<String>) instanceTitleFormat.getSelectedItem()).getValue();
|
||||
App.settings.selectedTabOnStartup = ((ComboItem<Integer>) selectedTabOnStartup.getSelectedItem()).getValue();
|
||||
App.settings.defaultInstanceSorting = (InstanceSortingStrategies) defaultInstanceSorting.getSelectedItem();
|
||||
App.settings.sortPacksAlphabetically = sortPacksAlphabetically.isSelected();
|
||||
App.settings.keepLauncherOpen = keepLauncherOpen.isSelected();
|
||||
App.settings.enableConsole = enableConsole.isSelected();
|
||||
|
|
Loading…
Reference in a new issue