Skip to content

Commit

Permalink
feat: create auto-close option for closing game
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Nov 12, 2022
1 parent 92080a8 commit ffe4453
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
3 changes: 3 additions & 0 deletions MHFZ_Overlay/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@
<setting name="MaxFaintsOverride" serializeAs="String">
<value>Automatic</value>
</setting>
<setting name="EnableAutoClose" serializeAs="String">
<value>False</value>
</setting>
</MHFZ_Overlay.Settings>
</userSettings>
</configuration>
5 changes: 5 additions & 0 deletions MHFZ_Overlay/ConfigWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>

<TextBlock Margin="5,5,5,5" Foreground="#cdd6f4" Grid.Column="0" Grid.Row="0" Text="Text Background Color" Style="{StaticResource ConfigTextBox}"/>
Expand Down Expand Up @@ -274,6 +276,9 @@
<ComboBoxItem>Normal Quests</ComboBoxItem>
<ComboBoxItem>Shiten/Conquest/Pioneer/Daily/Caravan/Interception Quests</ComboBoxItem>
</ComboBox>

<TextBlock Margin="5,5,5,5" ToolTip="Close overlay when closing game" Style="{StaticResource ConfigTextBox}" Grid.Row="23" Grid.Column="0" Text="Close overlay when closing game"/>
<ToggleButton Grid.Row="23" Grid.Column="1" Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding Source={StaticResource Settings}, Path=EnableAutoClose}"/>
</Grid>
</ScrollViewer>
<Grid Background="Transparent" Grid.Row="1" Grid.ColumnSpan="1">
Expand Down
4 changes: 4 additions & 0 deletions MHFZ_Overlay/MHFZ_Overlay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="Octokit" Version="4.0.1" />
<PackageReference Include="ShowMeTheXAML.MSBuild" Version="2.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

Expand Down
22 changes: 17 additions & 5 deletions MHFZ_Overlay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,19 @@ public void CheckGameState()

//if (state == "NULL")
DataLoader.closedGame = true;
System.Windows.MessageBox.Show("Detected closed game, please restart overlay when fully loading into Mezeporta.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
Settings s = (Settings)Application.Current.TryFindResource("Settings");

if (s.EnableAutoClose)
{
System.Windows.MessageBox.Show("Detected closed game, closing overlay. Please restart overlay when fully loading into Mezeporta.", "Warning", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
//https://stackoverflow.com/a/9050477/18859245
Cleanup();
Environment.Exit(0);
}
else
{
System.Windows.MessageBox.Show("Detected closed game, please restart overlay when fully loading into Mezeporta.", "Warning", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
}
};
};
}
Expand Down Expand Up @@ -3999,7 +4011,7 @@ private void ElementMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
private void ReloadButton_Click(object sender, RoutedEventArgs e)
{
Cleanup();
Application.Current.Shutdown();
Environment.Exit(0);
System.Windows.Forms.Application.Restart();
}

Expand All @@ -4016,13 +4028,13 @@ private void OpenConfigButton_Click(object sender, RoutedEventArgs e)
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Cleanup();
Application.Current.Shutdown();
Environment.Exit(0);
}

private void ReloadButton_Key()
{
Cleanup();
Application.Current.Shutdown();
Environment.Exit(0);
System.Windows.Forms.Application.Restart();
}

Expand All @@ -4042,7 +4054,7 @@ private void OpenConfigButton_Key()
private void CloseButton_Key()
{
Cleanup();
Application.Current.Shutdown();
Environment.Exit(0);
}

private void MainGrid_MouseMove(object sender, MouseEventArgs e)
Expand Down
12 changes: 12 additions & 0 deletions MHFZ_Overlay/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions MHFZ_Overlay/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,8 @@
<Setting Name="MaxFaintsOverride" Type="System.String" Scope="User">
<Value Profile="(Default)">Automatic</Value>
</Setting>
<Setting Name="EnableAutoClose" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit ffe4453

Please sign in to comment.