1 | using System;
|
---|
2 | using JetBrains.Annotations;
|
---|
3 | using Utf8Json;
|
---|
4 |
|
---|
5 | namespace Webserver.WebAPI.APIs.ServerState {
|
---|
6 | [UsedImplicitly]
|
---|
7 | public class GamePrefs : KeyValueListAbs {
|
---|
8 | public GamePrefs () : base ("GamePrefs") {
|
---|
9 | }
|
---|
10 |
|
---|
11 | protected override void iterateList (ref JsonWriter _writer, ref bool _first) {
|
---|
12 | foreach (EnumGamePrefs stat in EnumUtils.Values<EnumGamePrefs> ()) {
|
---|
13 | string name = stat.ToStringCached ();
|
---|
14 |
|
---|
15 | if (name.Contains ("Password", StringComparison.Ordinal)) {
|
---|
16 | continue;
|
---|
17 | }
|
---|
18 |
|
---|
19 | global::GamePrefs.EnumType? type = global::GamePrefs.GetPrefType (stat);
|
---|
20 | object defaultValue = global::GamePrefs.GetDefault (stat);
|
---|
21 |
|
---|
22 | switch (type) {
|
---|
23 | case global::GamePrefs.EnumType.Int:
|
---|
24 | int? defaultInt = defaultValue as int?;
|
---|
25 | addItem (ref _writer, ref _first, name, global::GamePrefs.GetInt (stat), defaultInt);
|
---|
26 | break;
|
---|
27 | case global::GamePrefs.EnumType.Float:
|
---|
28 | float? defaultFloat = defaultValue as float?;
|
---|
29 | addItem (ref _writer, ref _first, name, global::GamePrefs.GetFloat (stat), defaultFloat);
|
---|
30 | break;
|
---|
31 | case global::GamePrefs.EnumType.String:
|
---|
32 | string defaultString = defaultValue as string;
|
---|
33 | addItem (ref _writer, ref _first, name, global::GamePrefs.GetString (stat), defaultString);
|
---|
34 | break;
|
---|
35 | case global::GamePrefs.EnumType.Bool:
|
---|
36 | bool? defaultBool = defaultValue as bool?;
|
---|
37 | addItem (ref _writer, ref _first, name, global::GamePrefs.GetBool (stat), defaultBool);
|
---|
38 | break;
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
44 | }
|
---|