Skip to content

Commit

Permalink
Added built-in search in code function
Browse files Browse the repository at this point in the history
  • Loading branch information
luizzeroxis committed Sep 6, 2024
1 parent 69095cd commit 5f4913a
Show file tree
Hide file tree
Showing 4 changed files with 445 additions and 0 deletions.
4 changes: 4 additions & 0 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 @@ -123,6 +125,8 @@
</Style>
</MenuItem.Resources>

<MenuItem Header="Search in code" Command="{x:Static local:MainWindow.SearchInCodeCommand}"></MenuItem>

<MenuItem Header="Find unreferenced _assets" Name="FindUnreferencedAssetsItem" Click="MenuItem_FindUnreferencedAssets_Click"/>
<Separator/>
<MenuItem Header="(script links)" FontStyle="Italic" IsEnabled="False"/>
Expand Down
8 changes: 8 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,12 @@ private void Command_GoForward(object sender, ExecutedRoutedEventArgs e)
GoForward();
}

private void Command_SearchInCode(object sender, ExecutedRoutedEventArgs e)
{
SearchInCodeWindow w = new();
w.Show();
}

private void DisposeGameData()
{
if (Data is not null)
Expand Down
32 changes: 32 additions & 0 deletions UndertaleModTool/Windows/SearchInCodeWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:UndertaleModTool"
xmlns:UndertaleModTool="clr-namespace:UndertaleModTool" x:Class="UndertaleModTool.Windows.SearchInCodeWindow"
mc:Ignorable="d"
Title="Search in code" Height="500" Width="550" Closing="Window_Closing">
<Window.Resources>
<local:ContextMenuDark x:Key="linkContextMenu" Placement="MousePoint">
<local:MenuItemDark Header="Open in new tab" Click="OpenInNewTabMenuItem_Click"/>
</local:ContextMenuDark>
</Window.Resources>
<Grid>
<UndertaleModTool:TextBoxDark x:Name="SearchTextBox" Margin="10,10,10,0" TextWrapping="Wrap" AcceptsReturn="True" Height="36" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto"/>
<CheckBox x:Name="CaseSensitiveCheckBox" Content="Case sensitive" HorizontalAlignment="Left" Margin="10,51,0,0" Height="15" VerticalAlignment="Top"/>
<CheckBox x:Name="RegexSearchCheckBox" Content="Regex search" HorizontalAlignment="Left" Margin="108,51,0,0" VerticalAlignment="Top"/>
<UndertaleModTool:ButtonDark x:Name="SearchButton" Content="Search" Margin="0,51,10,0" VerticalAlignment="Top" Click="SearchButton_Click" HorizontalAlignment="Right" Width="39"/>
<RichTextBox x:Name="ResultsRichTextBox" Margin="10,76,10,10" IsDocumentEnabled="True" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" PreviewMouseDown="ResultsRichTextBox_PreviewMouseDown" FontFamily="Consolas">
<Control.CommandBindings>
<CommandBinding Command="Copy" Executed="OnCopyCommand"/>
</Control.CommandBindings>
<RichTextBox.ContextMenu>
<local:ContextMenuDark>
<MenuItem Header="Copy" Click="copyMenuItem_Click"/>
<MenuItem Header="Copy all" Click="copyAllMenuItem_Click"/>
</local:ContextMenuDark>
</RichTextBox.ContextMenu>
</RichTextBox>
</Grid>
</Window>
Loading

0 comments on commit 5f4913a

Please sign in to comment.