Skip to content

Commit 476d205

Browse files
committed
Add GameMode
1 parent 8f8636a commit 476d205

File tree

8 files changed

+53
-8
lines changed

8 files changed

+53
-8
lines changed

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
<ProjectReference Include="..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
105105
</ItemGroup>
106106

107+
<ItemGroup>
108+
<Resource Include="Images\gamemode.ico" />
109+
</ItemGroup>
107110
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
108111
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
109112
</Target>

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
using Flow.Launcher.Core.Resource;
77
using System.Windows;
88
using Flow.Launcher.ViewModel;
9+
using Flow.Launcher;
910
using System.Threading.Tasks;
1011
using System.Threading;
1112

1213
namespace Flow.Launcher.Helper
1314
{
14-
internal static class HotKeyMapper
15+
internal class HotKeyMapper
1516
{
1617
private static Settings settings;
1718
private static MainViewModel mainViewModel;
@@ -27,7 +28,13 @@ internal static void Initialize(MainViewModel mainVM)
2728

2829
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
2930
{
30-
mainViewModel.ToggleFlowLauncher();
31+
if (mainViewModel.gameModeStatus == true)
32+
{
33+
}
34+
else
35+
{
36+
mainViewModel.ToggleFlowLauncher();
37+
}
3138
}
3239

3340
private static void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
@@ -75,7 +82,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
7582
{
7683
SetHotkey(hotkey.Hotkey, (s, e) =>
7784
{
78-
if (mainViewModel.ShouldIgnoreHotkeys())
85+
if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.gameModeStatus == true)
7986
return;
8087

8188
mainViewModel.MainWindowVisibility = Visibility.Visible;

Flow.Launcher/Images/gamemode.ico

9.44 KB
Binary file not shown.

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<system:String x:Key="iconTrayAbout">About</system:String>
1616
<system:String x:Key="iconTrayExit">Exit</system:String>
1717
<system:String x:Key="closeWindow">Close</system:String>
18+
<system:String x:Key="GameMode">Game Mode</system:String>
1819

1920
<!-- Setting General -->
2021
<system:String x:Key="flowlauncher_settings">Flow Launcher Settings</system:String>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ private void UpdateNotifyIconText()
164164
{
165165
var menu = contextMenu;
166166
((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen");
167-
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
168-
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
167+
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
168+
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
169+
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
169170
}
170171

171172
private void InitializeNotifyIcon()
@@ -187,6 +188,10 @@ private void InitializeNotifyIcon()
187188
{
188189
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen")
189190
};
191+
var gamemode = new MenuItem
192+
{
193+
Header = InternationalizationManager.Instance.GetTranslation("GameMode")
194+
};
190195
var settings = new MenuItem
191196
{
192197
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings")
@@ -197,10 +202,12 @@ private void InitializeNotifyIcon()
197202
};
198203

199204
open.Click += (o, e) => Visibility = Visibility.Visible;
205+
gamemode.Click += (o, e) => GameMode();
200206
settings.Click += (o, e) => App.API.OpenSettingDialog();
201207
exit.Click += (o, e) => Close();
202208
contextMenu.Items.Add(header);
203209
contextMenu.Items.Add(open);
210+
contextMenu.Items.Add(gamemode);
204211
contextMenu.Items.Add(settings);
205212
contextMenu.Items.Add(exit);
206213

@@ -220,6 +227,19 @@ private void InitializeNotifyIcon()
220227
};
221228
}
222229

230+
public void GameMode()
231+
{
232+
if (_viewModel.gameModeStatus)
233+
{
234+
_notifyIcon.Icon = Properties.Resources.app;
235+
_viewModel.gameModeStatus = false;
236+
}
237+
else
238+
{
239+
_notifyIcon.Icon = Properties.Resources.gamemode;
240+
_viewModel.gameModeStatus = true;
241+
}
242+
}
223243
private void InitProgressbarAnimation()
224244
{
225245
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150,

Flow.Launcher/Properties/Resources.Designer.cs

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Flow.Launcher/Properties/Resources.resx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,16 @@
112112
<value>2.0</value>
113113
</resheader>
114114
<resheader name="reader">
115-
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116116
</resheader>
117117
<resheader name="writer">
118-
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120-
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
120+
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121121
<data name="app" type="System.Resources.ResXFileRef, System.Windows.Forms">
122122
<value>..\Resources\app.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123123
</data>
124+
<data name="gamemode" type="System.Resources.ResXFileRef, System.Windows.Forms">
125+
<value>..\Images\gamemode.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126+
</data>
124127
</root>

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class MainViewModel : BaseModel, ISavable
4444
private readonly History _history;
4545
private readonly UserSelectedRecord _userSelectedRecord;
4646
private readonly TopMostRecord _topMostRecord;
47+
private MainWindow _mainWindow;
4748

4849
private CancellationTokenSource _updateSource;
4950
private CancellationToken _updateToken;
@@ -304,6 +305,8 @@ private void InitializeKeyCommands()
304305
public ResultsViewModel ContextMenu { get; private set; }
305306
public ResultsViewModel History { get; private set; }
306307

308+
public bool gameModeStatus = false;
309+
307310
private string _queryText;
308311

309312
public string QueryText

0 commit comments

Comments
 (0)