Skip to content

Commit 10c0f97

Browse files
committed
configure_v3: add an hidden setting to choose the shortcut type
1 parent 33e544d commit 10c0f97

File tree

7 files changed

+39
-12
lines changed

7 files changed

+39
-12
lines changed

thcrap_configure/src/configure.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ int TH_CDECL win32_utf8_main(int argc, const char *argv[])
314314
// Other default settings
315315
json_object_set_new(new_cfg, "dat_dump", json_false());
316316
json_object_set_new(new_cfg, "patched_files_dump", json_false());
317+
json_object_set_new(new_cfg, "developper_mode", json_false());
317318

318319
run_cfg_fn = run_cfg_fn_build(sel_stack);
319320
run_cfg_fn = EnterRunCfgFN(run_cfg_fn);

thcrap_configure_v3/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<LineBreak />
2323
Click Next to continue, or click "Configure Settings" to change settings.
2424
</TextBlock>
25-
<Button Content="Configure Settings" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="SettingsWindow_Open" />
25+
<Button Content="Configure Settings" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="SettingsWindow_Open" Padding="3,2" />
2626
<TextBlock Name="VersionText" HorizontalAlignment="Right" VerticalAlignment="Bottom"></TextBlock>
2727
</Grid>
2828
</xctk:WizardPage>

thcrap_configure_v3/Page5.xaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@
1212
<CheckBox Margin="0,7,0,0" Checked="checkbox_Checked" Unchecked="checkbox_Checked" x:Name="checkboxStartMenu" IsChecked="True">In the Start menu</CheckBox>
1313
<CheckBox Margin="0,7,0,0" Checked="checkbox_Checked" Unchecked="checkbox_Checked" x:Name="checkboxGamesFolder">In the games' folder</CheckBox>
1414
<CheckBox Margin="0,7,0,0" Checked="checkbox_Checked" Unchecked="checkbox_Checked" x:Name="checkboxThcrapFolder">In the thcrap folder</CheckBox>
15-
<StackPanel Margin="0,7,0,0" Orientation="Horizontal" x:Name="warningPanel" Visibility="Hidden">
15+
<StackPanel Margin="0,7,0,0" Orientation="Horizontal" x:Name="warningPanel" Visibility="Collapsed">
1616
<Image x:Name="warningImage" Margin="0,0,7,0" Height="14" />
1717
<TextBlock>You need shortcuts to run the patched games! <TextBlock Foreground="Blue" TextDecorations="Underline" Cursor="Hand" MouseUp="NoShortcutsMoreDetails">More details...</TextBlock></TextBlock>
1818
</StackPanel>
19+
<StackPanel Margin="0,7,0,0" Orientation="Horizontal" x:Name="shortcutTypePanel" Visibility="Hidden">
20+
<TextBlock Margin="0,0,7,0">Shortcut type: </TextBlock>
21+
<ComboBox x:Name="shortcutType">
22+
<ComboBoxItem>Choose automatically (default)</ComboBoxItem>
23+
<ComboBoxItem>Shortcut</ComboBoxItem>
24+
<ComboBoxItem>Wrapper with absolute path</ComboBoxItem>
25+
<ComboBoxItem>Wrapper with realtive path</ComboBoxItem>
26+
</ComboBox>
27+
</StackPanel>
1928
</StackPanel>
2029
</UserControl>

thcrap_configure_v3/Page5.xaml.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Windows.Media.Imaging;
1616
using System.Windows.Navigation;
1717
using System.Windows.Shapes;
18+
using ShortcutDestinations = thcrap_configure_v3.GlobalConfig.ShortcutDestinations;
1819

1920
namespace thcrap_configure_v3
2021
{
@@ -42,12 +43,18 @@ public void Enter()
4243
if (config == null)
4344
{
4445
config = new GlobalConfig();
45-
GlobalConfig.ShortcutDestinations dest = config.default_shortcut_destinations;
46+
ShortcutDestinations dest = config.default_shortcut_destinations;
4647

47-
checkboxDesktop.IsChecked = dest.HasFlag(GlobalConfig.ShortcutDestinations.Desktop);
48-
checkboxStartMenu.IsChecked = dest.HasFlag(GlobalConfig.ShortcutDestinations.StartMenu);
49-
checkboxGamesFolder.IsChecked = dest.HasFlag(GlobalConfig.ShortcutDestinations.GamesFolder);
50-
checkboxThcrapFolder.IsChecked = dest.HasFlag(GlobalConfig.ShortcutDestinations.ThcrapFolder);
48+
checkboxDesktop.IsChecked = dest.HasFlag(ShortcutDestinations.Desktop);
49+
checkboxStartMenu.IsChecked = dest.HasFlag(ShortcutDestinations.StartMenu);
50+
checkboxGamesFolder.IsChecked = dest.HasFlag(ShortcutDestinations.GamesFolder);
51+
checkboxThcrapFolder.IsChecked = dest.HasFlag(ShortcutDestinations.ThcrapFolder);
52+
}
53+
54+
if (config.developer_mode)
55+
{
56+
shortcutTypePanel.Visibility = Visibility.Visible;
57+
shortcutType.SelectedIndex = (int)config.shortcuts_type;
5158
}
5259
}
5360

@@ -61,7 +68,7 @@ private void checkbox_Checked(object sender, RoutedEventArgs e)
6168

6269
if (checkboxDesktop.IsChecked == true || checkboxStartMenu.IsChecked == true ||
6370
checkboxGamesFolder.IsChecked == true || checkboxThcrapFolder.IsChecked == true || isUTLPresent == true)
64-
warningPanel.Visibility = Visibility.Hidden;
71+
warningPanel.Visibility = Visibility.Collapsed;
6572
else
6673
warningPanel.Visibility = Visibility.Visible;
6774
}
@@ -90,10 +97,14 @@ private void CreateShortcuts(string configName, IEnumerable<ThcrapDll.games_js_e
9097
public void Leave(string configName, IEnumerable<ThcrapDll.games_js_entry> games)
9198
{
9299
config.default_shortcut_destinations =
93-
(checkboxDesktop.IsChecked == true ? GlobalConfig.ShortcutDestinations.Desktop : 0) |
94-
(checkboxStartMenu.IsChecked == true ? GlobalConfig.ShortcutDestinations.StartMenu : 0) |
95-
(checkboxGamesFolder.IsChecked == true ? GlobalConfig.ShortcutDestinations.GamesFolder : 0) |
96-
(checkboxThcrapFolder.IsChecked == true ? GlobalConfig.ShortcutDestinations.ThcrapFolder : 0);
100+
(checkboxDesktop.IsChecked == true ? ShortcutDestinations.Desktop : 0) |
101+
(checkboxStartMenu.IsChecked == true ? ShortcutDestinations.StartMenu : 0) |
102+
(checkboxGamesFolder.IsChecked == true ? ShortcutDestinations.GamesFolder : 0) |
103+
(checkboxThcrapFolder.IsChecked == true ? ShortcutDestinations.ThcrapFolder : 0);
104+
if (config.developer_mode)
105+
{
106+
config.shortcuts_type = (ThcrapDll.ShortcutsType)shortcutType.SelectedIndex;
107+
}
97108
config.Save();
98109

99110
if (checkboxDesktop.IsChecked == true)

thcrap_configure_v3/Runconfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public enum ShortcutDestinations
5454
public bool console { get; set; }
5555
public long exception_detail { get; set; }
5656
public long codepage { get; set; }
57+
public bool developer_mode { get; set; }
5758
public ShortcutDestinations default_shortcut_destinations { get; set; }
5859
public ThcrapDll.ShortcutsType shortcuts_type { get; set; }
5960

@@ -66,6 +67,7 @@ public GlobalConfig()
6667
console = ThcrapDll.globalconfig_get_boolean("console", false);
6768
exception_detail = ThcrapDll.globalconfig_get_integer("exception_detail", 1);
6869
codepage = ThcrapDll.globalconfig_get_integer("codepage", 932);
70+
developer_mode = ThcrapDll.globalconfig_get_boolean("developer_mode", false);
6971

7072
long _default_shortcut_destinations = ThcrapDll.globalconfig_get_integer("default_shortcut_destinations",
7173
(long)(ShortcutDestinations.Desktop | ShortcutDestinations.StartMenu));
@@ -89,6 +91,7 @@ public void Save()
8991
ThcrapDll.globalconfig_set_boolean("console", console);
9092
ThcrapDll.globalconfig_set_integer("exception_detail", exception_detail);
9193
ThcrapDll.globalconfig_set_integer("codepage", codepage);
94+
ThcrapDll.globalconfig_set_boolean("developer_mode", developer_mode);
9295

9396
long _default_shortcut_destinations = (long)default_shortcut_destinations | ((long)shortcuts_type << configTypeOffset);
9497
ThcrapDll.globalconfig_set_integer("default_shortcut_destinations", _default_shortcut_destinations);

thcrap_configure_v3/SettingsWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
<StackPanel Margin="0,10,0,0">
2424
<Label Content="Advanced" />
25+
<CheckBox Name="developer_mode" Content="Developer mode"/>
2526
<CheckBox Name="console" Content="Enable the log console"/>
2627
<CheckBox Name="use_wininet" Content="Use WinInet"/>
2728
<Grid Margin="0,5,0,0">

thcrap_configure_v3/SettingsWindow.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ void WindowOpened(object sender, RoutedEventArgs e)
2222
update_at_exit.IsChecked = ThcrapDll.globalconfig_get_boolean("update_at_exit", false);
2323
time_between_updates.Text = ThcrapDll.globalconfig_get_integer("time_between_updates", 5).ToString();
2424

25+
developer_mode.IsChecked = ThcrapDll.globalconfig_get_boolean("developer_mode", false);
2526
console.IsChecked = ThcrapDll.globalconfig_get_boolean("console", false);
2627
use_wininet.IsChecked = ThcrapDll.globalconfig_get_boolean("use_wininet", false);
2728
codepage.Text = ThcrapDll.globalconfig_get_integer("codepage", 932).ToString();
@@ -111,6 +112,7 @@ private void Settings_Save(object sender, RoutedEventArgs e)
111112
ThcrapDll.globalconfig_set_boolean("update_at_exit", update_at_exit.IsChecked == true);
112113
ThcrapDll.globalconfig_set_integer("time_between_updates", Int32.Parse(time_between_updates.Text));
113114

115+
ThcrapDll.globalconfig_set_boolean("developer_mode", developer_mode.IsChecked == true);
114116
ThcrapDll.globalconfig_set_boolean("console", console.IsChecked == true);
115117
ThcrapDll.globalconfig_set_boolean("use_wininet", use_wininet.IsChecked == true);
116118
ThcrapDll.globalconfig_set_integer("codepage", Int32.Parse(codepage.Text));

0 commit comments

Comments
 (0)