Skip to content

Commit

Permalink
Import/Export window improvements (#208)
Browse files Browse the repository at this point in the history
- Add a 'Select All' button
- Display the number of loaded DBCs
- Asynchronously import/export all DBCs
- Add progress bars for each DBC
- Scale the two update stages so the progress bars do not jump around (applies to headless exporter too)
- Make the default export MPQ name configurable
  • Loading branch information
stoneharry authored Jun 17, 2023
1 parent 398aca2 commit bc6d351
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 132 deletions.
37 changes: 35 additions & 2 deletions SpellGUIV2/ConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ partial class ConfigWindow
private Grid MySQLConfigGrid;
private Grid SQLiteConfigGrid;
private DatabaseIdentifier defaultConfigType;
private TextBox _MpqNameText;

public ConfigWindow(DatabaseIdentifier defaultConfigToShow)
{
Expand Down Expand Up @@ -58,10 +59,12 @@ private void BuildConfigWindow()
ConfigGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
// Database type row
ConfigGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
// Bindings and directory settings, 2 rows
// Icon config row
ConfigGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
// MPQ name config row
ConfigGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
// Bindings and directory settings, 2 rows
ConfigGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
// Icon config row
ConfigGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
// Database type specific grid
ConfigGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
Expand Down Expand Up @@ -124,6 +127,8 @@ private void BuildConfigWindow()

currentRow = BuildIconConfig(ConfigGrid, currentRow);

currentRow = BuildMpqConfig(ConfigGrid, currentRow);

currentRow = BuildBindingsAndDbcUI(ConfigGrid, currentRow);

++currentRow;
Expand Down Expand Up @@ -297,13 +302,15 @@ private void SaveMySQLConfirmBtn_Click(object sender, RoutedEventArgs e)
Config.Pass = button.Pass();
Config.Port = button.Port();
Config.Database = button.Database();
Config.DefaultMpqName = _MpqNameText.Text;
ShowFlyoutMessage("Saved config.xml - Changes will be loaded on next program startup");
}

private void SaveSQLiteConfirmBtn_Click(object sender, RoutedEventArgs e)
{
var button = sender as SQLiteConfirmButton;
Config.SQLiteFilename = button.SQLiteFilename();
Config.DefaultMpqName = _MpqNameText.Text;
ShowFlyoutMessage("Saved config.xml - Changes will be loaded on next program startup");
}

Expand Down Expand Up @@ -337,6 +344,32 @@ private int BuildIconConfig(Grid grid, int currentRow)
return currentRow;
}

private int BuildMpqConfig(Grid grid, int currentRow)
{
var label = new Label
{
Content = "Default MPQ name for Export:",
Margin = new Thickness(10)
};

var textBox = new TextBox
{
Margin = new Thickness(10),
Text = Config.DefaultMpqName
};
_MpqNameText = textBox;

Grid.SetRow(label, currentRow);
Grid.SetRow(textBox, currentRow++);
Grid.SetColumn(label, 0);
Grid.SetColumn(textBox, 1);

grid.Children.Add(label);
grid.Children.Add(textBox);

return currentRow;
}

private void RenderIconsInView_Checked(object sender, RoutedEventArgs e)
{
Config.RenderImagesInView = (sender as System.Windows.Controls.CheckBox).IsChecked.Value;
Expand Down
35 changes: 25 additions & 10 deletions SpellGUIV2/ImportExportWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@
<Style TargetType="c:ThreadSafeCheckBox" BasedOn="{StaticResource {x:Type CheckBox}}"/>
</ResourceDictionary>
</controls:MetroWindow.Resources>
<controls:MetroWindow.Flyouts>
<controls:FlyoutsControl>
<controls:Flyout Name="Flyout" Position="Bottom" Height="65">
<TextBlock Name="FlyoutText" Text="Placeholder" FontSize ="20" VerticalAlignment="Center"/>
</controls:Flyout>
</controls:FlyoutsControl>
</controls:MetroWindow.Flyouts>
<Grid>
<TabControl Name="MainTabControl" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,10,10" SelectionChanged="TabControl_SelectionChanged">
<TabControl Name="MainTabControl" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,10,10">
<TabItem Header="{DynamicResource butImportExportWindowImport}">
<Grid Name="ImportGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="AUTO"/>
<ColumnDefinition Width="AUTO"/>
<ColumnDefinition Width="AUTO"/>
<ColumnDefinition Width="AUTO"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="AUTO"/>
Expand All @@ -34,10 +42,13 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Content="The required DBCs are checked by default." Margin="10" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
<Button Content="Import Checked DBC Files" Margin="10" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Click="ImportClick"/>
<ComboBox Name="ImportTypeCombo" Margin="5" Grid.Row="1" Grid.Column="2"/>
<ScrollViewer Grid.Row="3" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="2" MinWidth="500">
<UniformGrid Name="ImportGridDbcs" Columns="1"/>
<Button Name="ImportClickBtn" Content="Import Checked DBC Files" Margin="10" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Click="ImportClick"/>
<Label Name="ImportLoadedCount" Margin="5" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center"/>
<CheckBox Name="ImportSelectAll" Content="Select All" Margin="5" Grid.Row="0" Grid.Column="3" Checked="SelectAllChanged" Unchecked="SelectAllChanged"/>
<Label Content="Import Type:" Margin="5" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center"/>
<ComboBox Name="ImportTypeCombo" Margin="5" Grid.Row="1" Grid.Column="3"/>
<ScrollViewer Grid.Row="3" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="4" MinWidth="500">
<UniformGrid Name="ImportGridDbcs" Columns="2"/>
</ScrollViewer>
</Grid>
</TabItem>
Expand All @@ -47,6 +58,7 @@
<ColumnDefinition Width="AUTO"/>
<ColumnDefinition Width="AUTO"/>
<ColumnDefinition Width="AUTO"/>
<ColumnDefinition Width="AUTO"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="AUTO"/>
Expand All @@ -55,14 +67,17 @@
<RowDefinition Height="AUTO"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Content="{DynamicResource ExportCheckedFiles}" Margin="10" Click="ExportClick" Grid.Row="0" Grid.Column="0"/>
<Button Content="{DynamicResource ExportCheckedFilesMpq}" Margin="10" Click="MpqClick" Grid.Row="0" Grid.Column="1"/>
<Button Name="ExportClickBtn1" Content="{DynamicResource ExportCheckedFiles}" Margin="10" Click="ExportClick" Grid.Row="0" Grid.Column="0"/>
<Button Name="ExportClickBtn2" Content="{DynamicResource ExportCheckedFilesMpq}" Margin="10" Click="MpqClick" Grid.Row="0" Grid.Column="1"/>
<Label Content="{DynamicResource ExportMpqName}" HorizontalAlignment="Right" Margin="5" Grid.Row="1" Grid.Column="0"/>
<TextBox Name="ExportMpqNameTxt" Text="patch-4.mpq" Margin="10,5,10,5" Grid.Row="1" Grid.Column="1"/>
<Label Content="{DynamicResource TablesToExport}" Margin="5" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"/>
<ComboBox Name="ExportTypeCombo" Margin="5" Grid.Row="1" Grid.Column="2"/>
<ScrollViewer Grid.Row="3" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="2" MinWidth="500">
<UniformGrid Name="ExportGridDbcs" Columns="1"/>
<Label Name="ExportLoadedCount" Margin="5" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center"/>
<CheckBox Name="ExportSelectAll" Content="Select All" Margin="5" Grid.Row="0" Grid.Column="3" Checked="SelectAllChanged" Unchecked="SelectAllChanged"/>
<Label Content="Export Type:" Margin="5" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center"/>
<ComboBox Name="ExportTypeCombo" Margin="5" Grid.Row="1" Grid.Column="3"/>
<ScrollViewer Grid.Row="3" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="4" MinWidth="500">
<UniformGrid Name="ExportGridDbcs" Columns="2"/>
</ScrollViewer>
</Grid>
</TabItem>
Expand Down
Loading

0 comments on commit bc6d351

Please sign in to comment.