summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-03-15 03:24:50 -0400
committerCharles Lombardo <clombardo169@gmail.com>2023-03-15 17:34:49 -0400
commit46e68171b984726a0b09f8237901f4233cdc3e93 (patch)
tree1d7e5c4e1763748c8f3270a5aff65209a0413d88 /Source/Android/app/src/main/java
parent3ac72855e39ba44fa531496c642378d0b2a245e6 (diff)
Android: Convert FloatSetting to Kotlin
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java73
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.kt41
2 files changed, 41 insertions, 73 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java
deleted file mode 100644
index 99d15957c4..0000000000
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package org.dolphinemu.dolphinemu.features.settings.model;
-
-import androidx.annotation.NonNull;
-
-public enum FloatSetting implements AbstractFloatSetting
-{
- // These entries have the same names and order as in C++, just for consistency.
-
- MAIN_EMULATION_SPEED(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "EmulationSpeed", 1.0f),
- MAIN_OVERCLOCK(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "Overclock", 1.0f);
-
- private final String mFile;
- private final String mSection;
- private final String mKey;
- private final float mDefaultValue;
-
- FloatSetting(String file, String section, String key, float defaultValue)
- {
- mFile = file;
- mSection = section;
- mKey = key;
- mDefaultValue = defaultValue;
- }
-
- @Override
- public boolean isOverridden()
- {
- return NativeConfig.isOverridden(mFile, mSection, mKey);
- }
-
- @Override
- public boolean isRuntimeEditable()
- {
- return NativeConfig.isSettingSaveable(mFile, mSection, mKey);
- }
-
- @Override
- public boolean delete(@NonNull Settings settings)
- {
- if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
- {
- throw new UnsupportedOperationException(
- "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
- }
-
- return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey);
- }
-
- @Override
- public float getFloat()
- {
- return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
- }
-
- @Override
- public void setFloat(@NonNull Settings settings, float newValue)
- {
- if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
- {
- throw new UnsupportedOperationException(
- "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
- }
-
- NativeConfig.setFloat(settings.getWriteLayer(), mFile, mSection, mKey, newValue);
- }
-
- public void setFloat(int layer, float newValue)
- {
- NativeConfig.setFloat(layer, mFile, mSection, mKey, newValue);
- }
-}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.kt
new file mode 100644
index 0000000000..99b73251e7
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.kt
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.dolphinemu.features.settings.model
+
+enum class FloatSetting(
+ private val file: String,
+ private val section: String,
+ private val key: String,
+ private val defaultValue: Float
+) : AbstractFloatSetting {
+ // These entries have the same names and order as in C++, just for consistency.
+ MAIN_EMULATION_SPEED(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "EmulationSpeed", 1.0f),
+ MAIN_OVERCLOCK(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "Overclock", 1.0f);
+
+ override val isOverridden: Boolean
+ get() = NativeConfig.isOverridden(file, section, key)
+
+ override val isRuntimeEditable: Boolean
+ get() = NativeConfig.isSettingSaveable(file, section, key)
+
+ override fun delete(settings: Settings): Boolean {
+ if (!NativeConfig.isSettingSaveable(file, section, key)) {
+ throw UnsupportedOperationException("Unsupported setting: $file, $section, $key")
+ }
+ return NativeConfig.deleteKey(settings.writeLayer, file, section, key)
+ }
+
+ override val float: Float
+ get() = NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, file, section, key, defaultValue)
+
+ override fun setFloat(settings: Settings, newValue: Float) {
+ if (!NativeConfig.isSettingSaveable(file, section, key)) {
+ throw UnsupportedOperationException("Unsupported setting: $file, $section, $key")
+ }
+ NativeConfig.setFloat(settings.writeLayer, file, section, key, newValue)
+ }
+
+ fun setFloat(layer: Int, newValue: Float) {
+ NativeConfig.setFloat(layer, file, section, key, newValue)
+ }
+}