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