Skip to content

Commit

Permalink
Merge pull request #386 from Grossley/gmen-chunk
Browse files Browse the repository at this point in the history
Gmen chunk
  • Loading branch information
Grossley authored Mar 12, 2021
2 parents ad7df42 + 8d7c1da commit 8c808ef
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 16 deletions.
22 changes: 6 additions & 16 deletions UndertaleModLib/UndertaleChunks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class UndertaleChunkFORM : UndertaleChunk
public UndertaleChunkPATH PATH => Chunks.GetValueOrDefault("PATH") as UndertaleChunkPATH;
public UndertaleChunkSCPT SCPT => Chunks.GetValueOrDefault("SCPT") as UndertaleChunkSCPT;
public UndertaleChunkGLOB GLOB => Chunks.GetValueOrDefault("GLOB") as UndertaleChunkGLOB;
public UndertaleChunkGMEN GMEN => Chunks.GetValueOrDefault("GMEN") as UndertaleChunkGMEN;
public UndertaleChunkSHDR SHDR => Chunks.GetValueOrDefault("SHDR") as UndertaleChunkSHDR;
public UndertaleChunkFONT FONT => Chunks.GetValueOrDefault("FONT") as UndertaleChunkFONT;
public UndertaleChunkTMLN TMLN => Chunks.GetValueOrDefault("TMLN") as UndertaleChunkTMLN;
Expand Down Expand Up @@ -182,6 +183,11 @@ public class UndertaleChunkGLOB : UndertaleSimpleListChunk<UndertaleGlobalInit>
public override string Name => "GLOB";
}

public class UndertaleChunkGMEN : UndertaleSimpleListChunk<UndertaleGlobalInit>
{
public override string Name => "GMEN";
}

public class UndertaleChunkSHDR : UndertaleListChunk<UndertaleShader>
{
public override string Name => "SHDR";
Expand Down Expand Up @@ -579,22 +585,6 @@ internal override void UnserializeChunk(UndertaleReader reader)
}
}

// Unknown if possible yet, GMS2.3+ only
public class UndertaleChunkGMEN : UndertaleChunk
{
public override string Name => "GMEN";

internal override void SerializeChunk(UndertaleWriter writer)
{
throw new NotImplementedException();
}

internal override void UnserializeChunk(UndertaleReader reader)
{
throw new NotImplementedException();
}
}

// GMS2.3+ only
public class UndertaleChunkACRV : UndertaleListChunk<UndertaleAnimationCurve>
{
Expand Down
1 change: 1 addition & 0 deletions UndertaleModLib/UndertaleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class UndertaleData
public IList<UndertalePath> Paths => FORM.PATH?.List;
public IList<UndertaleScript> Scripts => FORM.SCPT?.List;
public IList<UndertaleGlobalInit> GlobalInitScripts => FORM.GLOB?.List;
public IList<UndertaleGlobalInit> GameEndScripts => FORM.GMEN?.List;
public IList<UndertaleShader> Shaders => FORM.SHDR?.List;
public IList<UndertaleFont> Fonts => FORM.FONT?.List;
public IList<UndertaleTimeline> Timelines => FORM.TMLN?.List;
Expand Down
51 changes: 51 additions & 0 deletions UndertaleModTool/Editors/UndertaleGameEndEditor.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<UserControl x:Class="UndertaleModTool.UndertaleGameEndEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:UndertaleModTool"
xmlns:undertale="clr-namespace:UndertaleModLib;assembly=UndertaleModLib"
xmlns:undertaleModels="clr-namespace:UndertaleModLib.Models;assembly=UndertaleModLib"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:GameEndEditor}">
<StackPanel>
<TextBlock Text="Game End scripts" FontWeight="Bold"/>
<Separator/>
<DataGrid Grid.Row="20" Grid.Column="1" Margin="3" ItemsSource="{Binding GameEnds}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" HeadersVisibility="None" SelectionMode="Single" SelectionUnit="FullRow">
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF26A0DA"/>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="{x:Static CollectionView.NewItemPlaceholder}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<TextBlock Margin="5" TextAlignment="Center" FontStyle="Italic">Double click to add</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<local:UndertaleObjectReference Margin="20,0,0,0" ObjectReference="{Binding Code, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ObjectType="{x:Type undertaleModels:UndertaleCode}" CanRemove="False"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</UserControl>
28 changes: 28 additions & 0 deletions UndertaleModTool/Editors/UndertaleGameEndEditor.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UndertaleModTool
{
/// <summary>
/// Логика взаимодействия для UndertaleGameEndEditor.xaml
/// </summary>
public partial class UndertaleGameEndEditor : UserControl
{
public UndertaleGameEndEditor()
{
InitializeComponent();
}
}
}
5 changes: 5 additions & 0 deletions UndertaleModTool/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<TreeViewItem Header="Data" IsExpanded="True">
<TreeViewItem Header="General info" Visibility="{Binding GeneralInfo, Converter={StaticResource VisibleIfNotNull}}"/>
<TreeViewItem Header="Global init" Visibility="{Binding GlobalInitScripts, Converter={StaticResource VisibleIfNotNull}}"/>
<TreeViewItem Header="Game End scripts" Visibility="{Binding GameEndScripts, Converter={StaticResource VisibleIfNotNull}}"/>
<TreeViewItem Header="Audio groups" ItemsSource="{Binding AudioGroups, Converter={StaticResource FilteredViewConverter}}" Visibility="{Binding AudioGroups, Converter={StaticResource VisibleIfNotNull}}">
<TreeViewItem.ItemTemplate>
<HierarchicalDataTemplate DataType="{x:Type undertale:UndertaleAudioGroup}">
Expand Down Expand Up @@ -350,6 +351,10 @@
<local:UndertaleGlobalInitEditor/>
</DataTemplate>

<DataTemplate DataType="{x:Type local:GameEndEditor}">
<local:UndertaleGameEndEditor/>
</DataTemplate>

<DataTemplate DataType="{x:Type undertale:UndertaleAudioGroup}">
<local:UndertaleAudioGroupEditor/>
</DataTemplate>
Expand Down
13 changes: 13 additions & 0 deletions UndertaleModTool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEv
case "Global init":
Highlighted = new GlobalInitEditor(Data?.GlobalInitScripts);
break;
case "Game End scripts":
Highlighted = new GameEndEditor(Data?.GameEndScripts);
break;
case "Code locals (unused?)":
Highlighted = new DescriptionView(item, "This seems to be unused as far as I can tell - you can remove the whole list and nothing happens");
break;
Expand Down Expand Up @@ -1282,6 +1285,16 @@ public GlobalInitEditor(IList<UndertaleGlobalInit> globalInits)
}
}

public class GameEndEditor
{
public IList<UndertaleGlobalInit> GameEnds { get; private set; }

public GameEndEditor(IList<UndertaleGlobalInit> GameEnds)
{
this.GameEnds = GameEnds;
}
}

public class DescriptionView
{
public string Heading { get; private set; }
Expand Down
7 changes: 7 additions & 0 deletions UndertaleModTool/UndertaleModTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@
<Compile Include="Converters\MaskImageConverter.cs" />
<Compile Include="Converters\NullToVisibilityConverter.cs" />
<Compile Include="Converters\RectConverter.cs" />
<Compile Include="Editors\UndertaleGameEndEditor.xaml.cs">
<DependentUpon>UndertaleGameEndEditor.xaml</DependentUpon>
</Compile>
<Compile Include="Editors\UndertaleAudioGroupEditor.xaml.cs">
<DependentUpon>UndertaleAudioGroupEditor.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -512,6 +515,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Editors\UndertaleGameEndEditor.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Editors\UndertaleAudioGroupEditor.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down

0 comments on commit 8c808ef

Please sign in to comment.