@@ -23,10 +23,11 @@ public class SettingsTabAutoUpdates : SettingsTab
23
23
{
24
24
private AutoUpdateBehavior behavior ;
25
25
private bool checkPeriodically ;
26
+ private bool chatNotification ;
26
27
private string pickerSearch = string . Empty ;
27
28
private List < AutoUpdatePreference > autoUpdatePreferences = [ ] ;
28
-
29
- public override SettingsEntry [ ] Entries { get ; } = Array . Empty < SettingsEntry > ( ) ;
29
+
30
+ public override SettingsEntry [ ] Entries { get ; } = [ ] ;
30
31
31
32
public override string Title => Loc . Localize ( "DalamudSettingsAutoUpdates" , "Auto-Updates" ) ;
32
33
@@ -36,15 +37,15 @@ public override void Draw()
36
37
"Dalamud can update your plugins automatically, making sure that you always " +
37
38
"have the newest features and bug fixes. You can choose when and how auto-updates are run here." ) ) ;
38
39
ImGuiHelpers . ScaledDummy ( 2 ) ;
39
-
40
+
40
41
ImGuiHelpers . SafeTextColoredWrapped ( ImGuiColors . DalamudGrey , Loc . Localize ( "DalamudSettingsAutoUpdateDisclaimer1" ,
41
42
"You can always update your plugins manually by clicking the update button in the plugin list. " +
42
43
"You can also opt into updates for specific plugins by right-clicking them and selecting \" Always auto-update\" ." ) ) ;
43
44
ImGuiHelpers . SafeTextColoredWrapped ( ImGuiColors . DalamudGrey , Loc . Localize ( "DalamudSettingsAutoUpdateDisclaimer2" ,
44
45
"Dalamud will only notify you about updates while you are idle." ) ) ;
45
-
46
+
46
47
ImGuiHelpers . ScaledDummy ( 8 ) ;
47
-
48
+
48
49
ImGuiHelpers . SafeTextColoredWrapped ( ImGuiColors . DalamudWhite , Loc . Localize ( "DalamudSettingsAutoUpdateBehavior" ,
49
50
"When the game starts..." ) ) ;
50
51
var behaviorInt = ( int ) this . behavior ;
@@ -62,46 +63,47 @@ public override void Draw()
62
63
"These updates are not reviewed by the Dalamud team and may contain malicious code." ) ;
63
64
ImGuiHelpers . SafeTextColoredWrapped ( ImGuiColors . DalamudOrange , warning ) ;
64
65
}
65
-
66
+
66
67
ImGuiHelpers . ScaledDummy ( 8 ) ;
67
-
68
+
69
+ ImGui . Checkbox ( Loc . Localize ( "DalamudSettingsAutoUpdateChatMessage" , "Show notification about updates available in chat" ) , ref this . chatNotification ) ;
68
70
ImGui . Checkbox ( Loc . Localize ( "DalamudSettingsAutoUpdatePeriodically" , "Periodically check for new updates while playing" ) , ref this . checkPeriodically ) ;
69
71
ImGuiHelpers . SafeTextColoredWrapped ( ImGuiColors . DalamudGrey , Loc . Localize ( "DalamudSettingsAutoUpdatePeriodicallyHint" ,
70
72
"Plugins won't update automatically after startup, you will only receive a notification while you are not actively playing." ) ) ;
71
-
73
+
72
74
ImGuiHelpers . ScaledDummy ( 5 ) ;
73
75
ImGui . Separator ( ) ;
74
76
ImGuiHelpers . ScaledDummy ( 5 ) ;
75
-
77
+
76
78
ImGuiHelpers . SafeTextColoredWrapped ( ImGuiColors . DalamudWhite , Loc . Localize ( "DalamudSettingsAutoUpdateOptedIn" ,
77
79
"Per-plugin overrides" ) ) ;
78
-
80
+
79
81
ImGuiHelpers . SafeTextColoredWrapped ( ImGuiColors . DalamudWhite , Loc . Localize ( "DalamudSettingsAutoUpdateOverrideHint" ,
80
82
"Here, you can choose to receive or not to receive updates for specific plugins. " +
81
83
"This will override the settings above for the selected plugins." ) ) ;
82
84
83
85
if ( this . autoUpdatePreferences . Count == 0 )
84
86
{
85
87
ImGuiHelpers . ScaledDummy ( 20 ) ;
86
-
88
+
87
89
using ( ImRaii . PushColor ( ImGuiCol . Text , ImGuiColors . DalamudGrey ) )
88
90
{
89
91
ImGuiHelpers . CenteredText ( Loc . Localize ( "DalamudSettingsAutoUpdateOptedInHint2" ,
90
92
"You don't have auto-update rules for any plugins." ) ) ;
91
93
}
92
-
94
+
93
95
ImGuiHelpers . ScaledDummy ( 2 ) ;
94
96
}
95
97
else
96
98
{
97
99
ImGuiHelpers . ScaledDummy ( 5 ) ;
98
-
100
+
99
101
var pic = Service < PluginImageCache > . Get ( ) ;
100
102
101
103
var windowSize = ImGui . GetWindowSize ( ) ;
102
104
var pluginLineHeight = 32 * ImGuiHelpers . GlobalScale ;
103
105
Guid ? wantRemovePluginGuid = null ;
104
-
106
+
105
107
foreach ( var preference in this . autoUpdatePreferences )
106
108
{
107
109
var pmPlugin = Service < PluginManager > . Get ( ) . InstalledPlugins
@@ -120,11 +122,12 @@ public override void Draw()
120
122
if ( pmPlugin . IsDev )
121
123
{
122
124
ImGui . SetCursorPos ( cursorBeforeIcon ) ;
123
- ImGui . PushStyleVar ( ImGuiStyleVar . Alpha , 0.7f ) ;
124
- ImGui . Image ( pic . DevPluginIcon . ImGuiHandle , new Vector2 ( pluginLineHeight ) ) ;
125
- ImGui . PopStyleVar ( ) ;
125
+ using ( ImRaii . PushStyle ( ImGuiStyleVar . Alpha , 0.7f ) )
126
+ {
127
+ ImGui . Image ( pic . DevPluginIcon . ImGuiHandle , new Vector2 ( pluginLineHeight ) ) ;
128
+ }
126
129
}
127
-
130
+
128
131
ImGui . SameLine ( ) ;
129
132
130
133
var text = $ "{ pmPlugin . Name } { ( pmPlugin . IsDev ? " (dev plugin" : string . Empty ) } ";
@@ -147,7 +150,7 @@ public override void Draw()
147
150
148
151
ImGui . SetCursorPosY ( ImGui . GetCursorPosY ( ) + ( pluginLineHeight / 2 ) - ( textHeight . Y / 2 ) ) ;
149
152
ImGui . TextUnformatted ( text ) ;
150
-
153
+
151
154
ImGui . SetCursorPos ( before ) ;
152
155
}
153
156
@@ -166,19 +169,18 @@ string OptKindToString(AutoUpdatePreference.OptKind kind)
166
169
}
167
170
168
171
ImGui . SetNextItemWidth ( ImGuiHelpers . GlobalScale * 250 ) ;
169
- if ( ImGui . BeginCombo (
170
- $ "###autoUpdateBehavior{ preference . WorkingPluginId } ",
171
- OptKindToString ( preference . Kind ) ) )
172
+ using ( var combo = ImRaii . Combo ( $ "###autoUpdateBehavior{ preference . WorkingPluginId } ", OptKindToString ( preference . Kind ) ) )
172
173
{
173
- foreach ( var kind in Enum . GetValues < AutoUpdatePreference . OptKind > ( ) )
174
+ if ( combo . Success )
174
175
{
175
- if ( ImGui . Selectable ( OptKindToString ( kind ) ) )
176
+ foreach ( var kind in Enum . GetValues < AutoUpdatePreference . OptKind > ( ) )
176
177
{
177
- preference . Kind = kind ;
178
+ if ( ImGui . Selectable ( OptKindToString ( kind ) ) )
179
+ {
180
+ preference . Kind = kind ;
181
+ }
178
182
}
179
183
}
180
-
181
- ImGui . EndCombo ( ) ;
182
184
}
183
185
184
186
ImGui . SameLine ( ) ;
@@ -193,7 +195,7 @@ string OptKindToString(AutoUpdatePreference.OptKind kind)
193
195
if ( ImGui . IsItemHovered ( ) )
194
196
ImGui . SetTooltip ( Loc . Localize ( "DalamudSettingsAutoUpdateOptInRemove" , "Remove this override" ) ) ;
195
197
}
196
-
198
+
197
199
if ( wantRemovePluginGuid != null )
198
200
{
199
201
this . autoUpdatePreferences . RemoveAll ( x => x . WorkingPluginId == wantRemovePluginGuid ) ;
@@ -205,19 +207,19 @@ void OnPluginPicked(LocalPlugin plugin)
205
207
var id = plugin . EffectiveWorkingPluginId ;
206
208
if ( id == Guid . Empty )
207
209
throw new InvalidOperationException ( "Plugin ID is empty." ) ;
208
-
210
+
209
211
this . autoUpdatePreferences . Add ( new AutoUpdatePreference ( id ) ) ;
210
212
}
211
-
213
+
212
214
bool IsPluginDisabled ( LocalPlugin plugin )
213
215
=> this . autoUpdatePreferences . Any ( x => x . WorkingPluginId == plugin . EffectiveWorkingPluginId ) ;
214
-
216
+
215
217
bool IsPluginFiltered ( LocalPlugin plugin )
216
218
=> ! plugin . IsDev ;
217
-
219
+
218
220
var pickerId = DalamudComponents . DrawPluginPicker (
219
221
"###autoUpdatePicker" , ref this . pickerSearch , OnPluginPicked , IsPluginDisabled , IsPluginFiltered ) ;
220
-
222
+
221
223
const FontAwesomeIcon addButtonIcon = FontAwesomeIcon . Plus ;
222
224
var addButtonText = Loc . Localize ( "DalamudSettingsAutoUpdateOptInAdd" , "Add new override" ) ;
223
225
ImGuiHelpers . CenterCursorFor ( ImGuiComponents . GetIconButtonWithTextWidth ( addButtonIcon , addButtonText ) ) ;
@@ -235,20 +237,22 @@ public override void Load()
235
237
var configuration = Service < DalamudConfiguration > . Get ( ) ;
236
238
237
239
this . behavior = configuration . AutoUpdateBehavior ?? AutoUpdateBehavior . None ;
240
+ this . chatNotification = configuration . SendUpdateNotificationToChat ;
238
241
this . checkPeriodically = configuration . CheckPeriodicallyForUpdates ;
239
242
this . autoUpdatePreferences = configuration . PluginAutoUpdatePreferences ;
240
-
243
+
241
244
base . Load ( ) ;
242
245
}
243
246
244
247
public override void Save ( )
245
248
{
246
249
var configuration = Service < DalamudConfiguration > . Get ( ) ;
247
-
250
+
248
251
configuration . AutoUpdateBehavior = this . behavior ;
252
+ configuration . SendUpdateNotificationToChat = this . chatNotification ;
249
253
configuration . CheckPeriodicallyForUpdates = this . checkPeriodically ;
250
254
configuration . PluginAutoUpdatePreferences = this . autoUpdatePreferences ;
251
-
255
+
252
256
base . Save ( ) ;
253
257
}
254
258
}
0 commit comments