Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add built-in search in code function #1905

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
12 changes: 3 additions & 9 deletions UndertaleModTool/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<CommandBinding Command="{x:Static local:MainWindow.SwitchToPrevTabCommand}" Executed="Command_SwitchToPrevTab" />
<CommandBinding Command="NavigationCommands.BrowseBack" Executed="Command_GoBack" />
<CommandBinding Command="NavigationCommands.BrowseForward" Executed="Command_GoForward" />
<CommandBinding Command="{x:Static local:MainWindow.SearchInCodeCommand}" Executed="Command_SearchInCode"/>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Modifiers="Control" Key="N" Command="New"/>
Expand All @@ -64,6 +65,7 @@
<KeyBinding Gesture="Ctrl+Shift+T" Command="{x:Static local:MainWindow.RestoreClosedTabCommand}"/>
<KeyBinding Gesture="Ctrl+Tab" Command="{x:Static local:MainWindow.SwitchToNextTabCommand}"/>
<KeyBinding Gesture="Ctrl+Shift+Tab" Command="{x:Static local:MainWindow.SwitchToPrevTabCommand}"/>
<KeyBinding Gesture="Ctrl+Shift+F" Command="{x:Static local:MainWindow.SearchInCodeCommand}" />
</Window.InputBindings>
<Grid>
<DockPanel>
Expand Down Expand Up @@ -122,16 +124,8 @@
</Style.Triggers>
</Style>
</MenuItem.Resources>

<MenuItem Header="_Search in code" Command="{x:Static local:MainWindow.SearchInCodeCommand}" InputGestureText="Ctrl+Shift+F"></MenuItem>
<MenuItem Header="Find unreferenced _assets" Name="FindUnreferencedAssetsItem" Click="MenuItem_FindUnreferencedAssets_Click"/>
<Separator/>
<MenuItem Header="(script links)" FontStyle="Italic" IsEnabled="False"/>
<MenuItem Header="Search in _code (&quot;Search.csx&quot;)"
Click="MenuItem_RunBuiltinScript_Item_Click" CommandParameter="Scripts\Builtin Scripts\Search.csx"/>
<MenuItem Header="Search in _assembly (&quot;SearchASM.csx&quot;)"
Click="MenuItem_RunBuiltinScript_Item_Click" CommandParameter="Scripts\Builtin Scripts\SearchASM.csx"/>
<MenuItem Header="Search in _specific code (&quot;SearchLimited.csx&quot;)"
Click="MenuItem_RunBuiltinScript_Item_Click" CommandParameter="Scripts\Builtin Scripts\SearchLimited.csx"/>
</local:MenuItemDark>
<local:MenuItemDark Header="_Help">
<MenuItem Header="_GitHub" Click="MenuItem_GitHub_Click"/>
Expand Down
17 changes: 17 additions & 0 deletions UndertaleModTool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public partial class MainWindow : Window, INotifyPropertyChanged, IScriptInterfa
public static RoutedUICommand RestoreClosedTabCommand = new RoutedUICommand("Restore last closed tab", "RestoreClosedTab", typeof(MainWindow));
public static RoutedUICommand SwitchToNextTabCommand = new RoutedUICommand("Switch to the next tab", "SwitchToNextTab", typeof(MainWindow));
public static RoutedUICommand SwitchToPrevTabCommand = new RoutedUICommand("Switch to the previous tab", "SwitchToPrevTab", typeof(MainWindow));
public static RoutedUICommand SearchInCodeCommand = new("Search in code", "SearchInCode", typeof(MainWindow));

public ObservableCollection<Tab> Tabs { get; set; } = new();
public Tab CurrentTab
{
Expand Down Expand Up @@ -937,6 +939,21 @@ private void Command_GoForward(object sender, ExecutedRoutedEventArgs e)
GoForward();
}

private SearchInCodeWindow searchInCodeWindow;
private void Command_SearchInCode(object sender, ExecutedRoutedEventArgs e)
{
if (searchInCodeWindow is null)
{
searchInCodeWindow = new();
searchInCodeWindow.Closed += (object sender, EventArgs e) =>
{
searchInCodeWindow = null;
};
searchInCodeWindow.Show();
}
searchInCodeWindow.ActivateAndFocusOnTextBox();
}

private void DisposeGameData()
{
if (Data is not null)
Expand Down
173 changes: 0 additions & 173 deletions UndertaleModTool/Scripts/Builtin Scripts/Search.csx

This file was deleted.

121 changes: 0 additions & 121 deletions UndertaleModTool/Scripts/Builtin Scripts/SearchASM.csx

This file was deleted.

Loading
Loading