summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt
blob: fa84f94f5eec2e46edeaf59b3c91780604a0a480 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

package org.yuzu.yuzu_emu.features.settings.model

enum class IntSetting(
    override val key: String,
    override val section: String,
    override val defaultValue: Int
) : AbstractIntSetting {
    RENDERER_USE_SPEED_LIMIT(
        "use_speed_limit",
        Settings.SECTION_RENDERER,
        1
    ),
    USE_DOCKED_MODE(
        "use_docked_mode",
        Settings.SECTION_SYSTEM,
        0
    ),
    RENDERER_USE_DISK_SHADER_CACHE(
        "use_disk_shader_cache",
        Settings.SECTION_RENDERER,
        1
    ),
    RENDERER_FORCE_MAX_CLOCK(
        "force_max_clock",
        Settings.SECTION_RENDERER,
        0
    ),
    RENDERER_ASYNCHRONOUS_SHADERS(
        "use_asynchronous_shaders",
        Settings.SECTION_RENDERER,
        0
    ),
    RENDERER_REACTIVE_FLUSHING(
        "use_reactive_flushing",
        Settings.SECTION_RENDERER,
        0
    ),
    RENDERER_DEBUG(
        "debug",
        Settings.SECTION_RENDERER,
        0
    ),
    RENDERER_SPEED_LIMIT(
        "speed_limit",
        Settings.SECTION_RENDERER,
        100
    ),
    CPU_ACCURACY(
        "cpu_accuracy",
        Settings.SECTION_CPU,
        0
    ),
    REGION_INDEX(
        "region_index",
        Settings.SECTION_SYSTEM,
        -1
    ),
    LANGUAGE_INDEX(
        "language_index",
        Settings.SECTION_SYSTEM,
        1
    ),
    RENDERER_BACKEND(
        "backend",
        Settings.SECTION_RENDERER,
        1
    ),
    RENDERER_ACCURACY(
        "gpu_accuracy",
        Settings.SECTION_RENDERER,
        0
    ),
    RENDERER_RESOLUTION(
        "resolution_setup",
        Settings.SECTION_RENDERER,
        2
    ),
    RENDERER_VSYNC(
        "use_vsync",
        Settings.SECTION_RENDERER,
        0
    ),
    RENDERER_SCALING_FILTER(
        "scaling_filter",
        Settings.SECTION_RENDERER,
        1
    ),
    RENDERER_ANTI_ALIASING(
        "anti_aliasing",
        Settings.SECTION_RENDERER,
        0
    ),
    RENDERER_ASPECT_RATIO(
        "aspect_ratio",
        Settings.SECTION_RENDERER,
        0
    ),
    AUDIO_VOLUME(
        "volume",
        Settings.SECTION_AUDIO,
        100
    );

    override var int: Int = defaultValue

    override val valueAsString: String
        get() = int.toString()

    override val isRuntimeEditable: Boolean
        get() {
            for (setting in NOT_RUNTIME_EDITABLE) {
                if (setting == this) {
                    return false
                }
            }
            return true
        }

    companion object {
        private val NOT_RUNTIME_EDITABLE = listOf(
            RENDERER_USE_DISK_SHADER_CACHE,
            RENDERER_ASYNCHRONOUS_SHADERS,
            RENDERER_DEBUG,
            RENDERER_BACKEND,
            RENDERER_RESOLUTION,
            RENDERER_VSYNC
        )

        fun from(key: String): IntSetting? = IntSetting.values().firstOrNull { it.key == key }

        fun clear() = IntSetting.values().forEach { it.int = it.defaultValue }
    }
}