|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\PlayerSetting\Lib; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Component\Player\Settings\UserSettingsProviderInterface; |
|
6
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
7
|
|
|
|
|
8
|
|
|
enum UserSettingEnum: string |
|
9
|
|
|
{ |
|
10
|
|
|
// DISTINCT |
|
11
|
|
|
case AVATAR = 'avatar'; |
|
12
|
|
|
case RGB_CODE = 'rgb_code'; |
|
13
|
|
|
|
|
14
|
|
|
// NON DISTINCT |
|
15
|
|
|
case EMAIL_NOTIFICATION = 'email_notification'; |
|
16
|
|
|
case SAVE_LOGIN = 'save_login'; |
|
17
|
|
|
case STORAGE_NOTIFICATION = 'storage_notification'; |
|
18
|
|
|
case SHOW_ONLINE_STATUS = 'show_online_status'; |
|
19
|
|
|
case SHOW_PM_READ_RECEIPT = 'show_pm_read_receipt'; |
|
20
|
|
|
case FLEET_FIXED_DEFAULT = 'fleet_fixed_default'; |
|
21
|
|
|
case WARPSPLIT_AUTO_CARRYOVER_DEFAULT = 'warpsplit_auto_carryover_default'; |
|
22
|
|
|
case SHOW_PIRATE_HISTORY_ENTRYS = 'show_pirate_history_entrys'; |
|
23
|
|
|
case INBOX_MESSENGER_STYLE = 'inbox_messenger_style'; |
|
24
|
|
|
|
|
25
|
|
|
case DEFAULT_VIEW = 'default_view'; |
|
26
|
|
|
case RPG_BEHAVIOR = 'rpg_behavior'; |
|
27
|
|
|
case CSS_COLOR_SHEET = 'css_color_sheet'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* returns true, if the setting has it's own action controller |
|
31
|
|
|
*/ |
|
32
|
1 |
|
public function isDistinctSetting(): bool |
|
33
|
|
|
{ |
|
34
|
1 |
|
return $this === self::AVATAR |
|
35
|
1 |
|
|| $this === self::RGB_CODE; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
1 |
|
public function isNullable(): bool |
|
39
|
|
|
{ |
|
40
|
1 |
|
return $this === self::DEFAULT_VIEW; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
1 |
|
public function getTitle(): string |
|
44
|
|
|
{ |
|
45
|
1 |
|
return match ($this) { |
|
46
|
1 |
|
self::AVATAR => 'Avatar', |
|
47
|
1 |
|
self::RGB_CODE => 'Territorialfarbe', |
|
48
|
1 |
|
default => '' |
|
49
|
1 |
|
}; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
public function getDescription(): mixed |
|
53
|
|
|
{ |
|
54
|
1 |
|
return match ($this) { |
|
55
|
1 |
|
self::AVATAR => 'Hier kannst Du einen Avatar |
|
56
|
|
|
hochladen der in Deinem Profil angezeigt wird. Dieses Bild sollte |
|
57
|
1 |
|
150x150 Pixel groß sein und im PNG-Format vorliegen.', |
|
58
|
1 |
|
self::RGB_CODE => 'Dieser RGB-Farbcode kennzeichnet Kartenfelder, die dem Spieler zugeordnet |
|
59
|
1 |
|
werden können. Beispiel: #9ab5ef', |
|
60
|
1 |
|
self::EMAIL_NOTIFICATION => 'Emailbenachrichtigung bei privaten Nachrichten', |
|
61
|
1 |
|
self::STORAGE_NOTIFICATION => 'Nachricht bei vollen Lagern zum Tick', |
|
62
|
1 |
|
self::SAVE_LOGIN => 'Login nicht speichern (Ideal an fremden Computern)', |
|
63
|
1 |
|
self::DEFAULT_VIEW => 'Auswahl der Startseite, welche nach dem Login angezeigt werden soll.', |
|
64
|
1 |
|
self::SHOW_ONLINE_STATUS => 'Online Status öffentlich', |
|
65
|
1 |
|
self::SHOW_PM_READ_RECEIPT => 'Lesebestätigungen bei PMs anzeigen (nur wenn sowohl Sender als auch Empfänger den Haken gesetzt haben)', |
|
66
|
1 |
|
self::FLEET_FIXED_DEFAULT => 'Flotten standardmäßig fixieren, sodass keine Schiffe beim Flug verloren gehen können.', |
|
67
|
1 |
|
self::WARPSPLIT_AUTO_CARRYOVER_DEFAULT => 'Führt dazu, dass überschüssige Reaktorleistung bei Schiffen automatisch an die übrigen Systeme transferiert wird.', |
|
68
|
1 |
|
self::RPG_BEHAVIOR => 'Information für andere Spieler ob man selbst gern Rollenspiel betreibt.', |
|
69
|
1 |
|
self::CSS_COLOR_SHEET => 'Auswahl der Interface-Farben.', |
|
70
|
1 |
|
self::SHOW_PIRATE_HISTORY_ENTRYS => 'Zeigt einträge in der History an die durch Interaktion mit dem Piraten NPC entstanden sind.', |
|
71
|
1 |
|
self::INBOX_MESSENGER_STYLE => 'Nachrichteneingang des "Persönlich"-Ordners ist wie bei einem Messenger nach Kontakten gruppiert.' |
|
72
|
1 |
|
}; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
1 |
|
public function getTemplate(): string |
|
76
|
|
|
{ |
|
77
|
1 |
|
return match ($this) { |
|
78
|
1 |
|
self::CSS_COLOR_SHEET, |
|
79
|
1 |
|
self::RPG_BEHAVIOR, |
|
80
|
1 |
|
self::DEFAULT_VIEW => 'html/user/settings/enumUserSetting.twig', |
|
81
|
1 |
|
self::AVATAR => 'html/user/settings/avatarUserSetting.twig', |
|
82
|
1 |
|
self::RGB_CODE => 'html/user/settings/rgbCodeUserSetting.twig', |
|
83
|
1 |
|
default => 'html/user/settings/booleanUserSetting.twig' |
|
84
|
1 |
|
}; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
1 |
|
public function getUserValue(UserInterface $user, UserSettingsProviderInterface $settingsProvider): mixed |
|
88
|
|
|
{ |
|
89
|
1 |
|
return match ($this) { |
|
90
|
1 |
|
self::AVATAR => $settingsProvider->getAvatar($user), |
|
91
|
1 |
|
self::RGB_CODE => $settingsProvider->getRgbCode($user), |
|
92
|
1 |
|
self::EMAIL_NOTIFICATION => $settingsProvider->isEmailNotification($user), |
|
93
|
1 |
|
self::STORAGE_NOTIFICATION => $settingsProvider->isStorageNotification($user), |
|
94
|
1 |
|
self::SAVE_LOGIN => $settingsProvider->isSaveLogin($user), |
|
95
|
1 |
|
self::DEFAULT_VIEW => $settingsProvider->getDefaultView($user), |
|
96
|
1 |
|
self::SHOW_ONLINE_STATUS => $settingsProvider->isShowOnlineState($user), |
|
97
|
1 |
|
self::SHOW_PM_READ_RECEIPT => $settingsProvider->isShowPmReadReceipt($user), |
|
98
|
1 |
|
self::FLEET_FIXED_DEFAULT => $settingsProvider->getFleetFixedDefault($user), |
|
99
|
1 |
|
self::WARPSPLIT_AUTO_CARRYOVER_DEFAULT => $settingsProvider->getWarpsplitAutoCarryoverDefault($user), |
|
100
|
1 |
|
self::RPG_BEHAVIOR => $settingsProvider->getRpgBehavior($user), |
|
101
|
1 |
|
self::CSS_COLOR_SHEET => $settingsProvider->getCss($user), |
|
102
|
1 |
|
self::SHOW_PIRATE_HISTORY_ENTRYS => $settingsProvider->isShowPirateHistoryEntrys($user), |
|
103
|
1 |
|
self::INBOX_MESSENGER_STYLE => $settingsProvider->isInboxMessengerStyle($user) |
|
104
|
1 |
|
}; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** @return array<self> */ |
|
108
|
1 |
|
public static function getDistinct(): array |
|
109
|
|
|
{ |
|
110
|
1 |
|
return array_filter(self::cases(), fn(UserSettingEnum $type): bool => $type->isDistinctSetting()); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** @return array<self> */ |
|
114
|
1 |
|
public static function getNonDistinct(): array |
|
115
|
|
|
{ |
|
116
|
1 |
|
return array_filter(self::cases(), fn(UserSettingEnum $type): bool => !$type->isDistinctSetting()); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|