diff options
Diffstat (limited to 'src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.java')
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.java | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.java deleted file mode 100644 index 3126eba73..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.yuzu.yuzu_emu.features.settings.model; - -import android.text.TextUtils; - -import org.yuzu.yuzu_emu.YuzuApplication; -import org.yuzu.yuzu_emu.R; -import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivityView; -import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -public class Settings { - public static final String SECTION_GENERAL = "General"; - public static final String SECTION_SYSTEM = "System"; - public static final String SECTION_RENDERER = "Renderer"; - public static final String SECTION_AUDIO = "Audio"; - public static final String SECTION_CPU = "Cpu"; - - private String gameId; - - private static final Map<String, List<String>> configFileSectionsMap = new HashMap<>(); - - static { - configFileSectionsMap.put(SettingsFile.FILE_NAME_CONFIG, Arrays.asList(SECTION_GENERAL, SECTION_SYSTEM, SECTION_RENDERER, SECTION_AUDIO, SECTION_CPU)); - } - - /** - * A HashMap<String, SettingSection> that constructs a new SettingSection instead of returning null - * when getting a key not already in the map - */ - public static final class SettingsSectionMap extends HashMap<String, SettingSection> { - @Override - public SettingSection get(Object key) { - if (!(key instanceof String)) { - return null; - } - - String stringKey = (String) key; - - if (!super.containsKey(stringKey)) { - SettingSection section = new SettingSection(stringKey); - super.put(stringKey, section); - return section; - } - return super.get(key); - } - } - - private HashMap<String, SettingSection> sections = new Settings.SettingsSectionMap(); - - public SettingSection getSection(String sectionName) { - return sections.get(sectionName); - } - - public boolean isEmpty() { - return sections.isEmpty(); - } - - public HashMap<String, SettingSection> getSections() { - return sections; - } - - public void loadSettings(SettingsActivityView view) { - sections = new Settings.SettingsSectionMap(); - loadCitraSettings(view); - - if (!TextUtils.isEmpty(gameId)) { - loadCustomGameSettings(gameId, view); - } - } - - private void loadCitraSettings(SettingsActivityView view) { - for (Map.Entry<String, List<String>> entry : configFileSectionsMap.entrySet()) { - String fileName = entry.getKey(); - sections.putAll(SettingsFile.readFile(fileName, view)); - } - } - - private void loadCustomGameSettings(String gameId, SettingsActivityView view) { - // custom game settings - mergeSections(SettingsFile.readCustomGameSettings(gameId, view)); - } - - private void mergeSections(HashMap<String, SettingSection> updatedSections) { - for (Map.Entry<String, SettingSection> entry : updatedSections.entrySet()) { - if (sections.containsKey(entry.getKey())) { - SettingSection originalSection = sections.get(entry.getKey()); - SettingSection updatedSection = entry.getValue(); - originalSection.mergeSection(updatedSection); - } else { - sections.put(entry.getKey(), entry.getValue()); - } - } - } - - public void loadSettings(String gameId, SettingsActivityView view) { - this.gameId = gameId; - loadSettings(view); - } - - public void saveSettings(SettingsActivityView view) { - if (TextUtils.isEmpty(gameId)) { - view.showToastMessage(YuzuApplication.getAppContext().getString(R.string.ini_saved), false); - - for (Map.Entry<String, List<String>> entry : configFileSectionsMap.entrySet()) { - String fileName = entry.getKey(); - List<String> sectionNames = entry.getValue(); - TreeMap<String, SettingSection> iniSections = new TreeMap<>(); - for (String section : sectionNames) { - iniSections.put(section, sections.get(section)); - } - - SettingsFile.saveFile(fileName, iniSections, view); - } - } else { - // custom game settings - view.showToastMessage(YuzuApplication.getAppContext().getString(R.string.gameid_saved, gameId), false); - - SettingsFile.saveCustomGameSettings(gameId, sections); - } - - } -}
\ No newline at end of file |