1 Commits
v1.1 ... v1.2

Author SHA1 Message Date
96f61362d3 fix: fix issue that fail to open legal TAS file.
- switch zlib library from zlib.net to DotNetZip because old one can not handle zlib-compressed file properly.
- bump version to 1.2
2024-07-26 23:20:11 +08:00
7 changed files with 71 additions and 36 deletions

View File

@ -40,6 +40,9 @@
<ApplicationIcon>icon.ico</ApplicationIcon> <ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -57,9 +60,6 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="zlib.net, Version=1.0.3.0, Culture=neutral, PublicKeyToken=47d7877cb3620160">
<HintPath>..\packages\zlib.net.1.0.4.0\lib\zlib.net.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ApplicationDefinition Include="App.xaml"> <ApplicationDefinition Include="App.xaml">

View File

@ -1,4 +1,4 @@
using BallanceTASEditor.Core.TASStruct; using BallanceTASEditor.Core.TASStruct;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -12,34 +12,63 @@ namespace BallanceTASEditor.Core {
public static void CompressTAS(LinkedList<FrameData> mem, FileStream file) { public static void CompressTAS(LinkedList<FrameData> mem, FileStream file) {
file.Write(BitConverter.GetBytes(mem.Count * ConstValue.FRAMEDATA_SIZE), 0, 4); file.Write(BitConverter.GetBytes(mem.Count * ConstValue.FRAMEDATA_SIZE), 0, 4);
var zo = new zlib.ZOutputStream(file, 9); using (var zo = new Ionic.Zlib.ZlibStream(file, Ionic.Zlib.CompressionMode.Compress, Ionic.Zlib.CompressionLevel.Level9, true)) {
var node = mem.First; var node = mem.First;
while (node != null) { while (node != null) {
zo.Write(BitConverter.GetBytes(node.Value.deltaTime), 0, 4); zo.Write(BitConverter.GetBytes(node.Value.deltaTime), 0, 4);
zo.Write(BitConverter.GetBytes(node.Value.keystates), 0, 4); zo.Write(BitConverter.GetBytes(node.Value.keystates), 0, 4);
node = node.Next; node = node.Next;
}
zo.Close();
} }
zo.finish();
zo.Close(); //var zo = new zlib.ZOutputStream(file, 9);
//var node = mem.First;
//while (node != null) {
// zo.Write(BitConverter.GetBytes(node.Value.deltaTime), 0, 4);
// zo.Write(BitConverter.GetBytes(node.Value.keystates), 0, 4);
// node = node.Next;
//}
//zo.finish();
//zo.Close();
} }
public static void DecompressTAS(LinkedList<FrameData> ls, FileStream file) { public static void DecompressTAS(LinkedList<FrameData> ls, FileStream file) {
var lengthTemp = new byte[4]; var lengthTemp = new byte[4];
var mem = new MemoryStream();
file.Read(lengthTemp, 0, 4); file.Read(lengthTemp, 0, 4);
Int32 expectedLength = BitConverter.ToInt32(lengthTemp, 0); Int32 expectedLength = BitConverter.ToInt32(lengthTemp, 0);
long expectedCount = expectedLength / ConstValue.FRAMEDATA_SIZE; long expectedCount = expectedLength / ConstValue.FRAMEDATA_SIZE;
var zo = new zlib.ZOutputStream(mem); using (var mem = new MemoryStream()) {
CopyStream(file, zo); using (var zo = new Ionic.Zlib.ZlibStream(mem, Ionic.Zlib.CompressionMode.Decompress, true)) {
zo.finish(); CopyStream(file, zo);
zo.Close();
}
mem.Seek(0, SeekOrigin.Begin); mem.Seek(0, SeekOrigin.Begin);
for(long i = 0; i < expectedCount; i++) { for (long i = 0; i < expectedCount; i++) {
ls.AddLast(new FrameData(mem)); ls.AddLast(new FrameData(mem));
}
mem.Close();
} }
mem.Close();
zo.Close(); //mem.Seek(0, SeekOrigin.Begin);
//for (long i = 0; i < expectedCount; i++) {
// ls.AddLast(new FrameData(mem));
//}
//mem.Close();
//zo.Close();
//var zo = new zlib.ZOutputStream(mem);
//CopyStream(file, zo);
//zo.finish();
//mem.Seek(0, SeekOrigin.Begin);
//for (long i = 0; i < expectedCount; i++) {
// ls.AddLast(new FrameData(mem));
//}
//mem.Close();
//zo.Close();
} }
public static void CopyStream(Stream origin, Stream target) { public static void CopyStream(Stream origin, Stream target) {

View File

@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BallanceTASEditor.Language" xmlns:local="clr-namespace:BallanceTASEditor.Language"
xmlns:sys="clr-namespace:System;assembly=mscorlib"> xmlns:sys="clr-namespace:System;assembly=mscorlib">
@ -62,7 +62,7 @@
<sys:String x:Key="code_Shared_ProgramName">Ballance TAS 编辑器</sys:String> <sys:String x:Key="code_Shared_ProgramName">Ballance TAS 编辑器</sys:String>
<sys:String x:Key="code_MainWindow_Menu_Help_About" xml:space="preserve">基于 MIT 开源许可证发布 <sys:String x:Key="code_MainWindow_Menu_Help_About" xml:space="preserve">基于 MIT 开源许可证发布
版本1.1 stable 版本1.2 stable
程序yyc12345. 程序yyc12345.
图标设计plAer_2</sys:String> 图标设计plAer_2</sys:String>
<sys:String x:Key="code_MainWindow_Closing">文件未关闭。您想直接退出吗?所有修改不会被保存。</sys:String> <sys:String x:Key="code_MainWindow_Closing">文件未关闭。您想直接退出吗?所有修改不会被保存。</sys:String>

View File

@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BallanceTASEditor.Language" xmlns:local="clr-namespace:BallanceTASEditor.Language"
xmlns:sys="clr-namespace:System;assembly=mscorlib"> xmlns:sys="clr-namespace:System;assembly=mscorlib">
@ -62,7 +62,7 @@
<sys:String x:Key="code_Shared_ProgramName">Ballance TAS Editor</sys:String> <sys:String x:Key="code_Shared_ProgramName">Ballance TAS Editor</sys:String>
<sys:String x:Key="code_MainWindow_Menu_Help_About" xml:space="preserve">Under MIT License <sys:String x:Key="code_MainWindow_Menu_Help_About" xml:space="preserve">Under MIT License
Version: 1.1 stable Version: 1.2 stable
Program: yyc12345. Program: yyc12345.
Icon design: plAer_2</sys:String> Icon design: plAer_2</sys:String>
<sys:String x:Key="code_MainWindow_Closing">File is not closed. Do you want to just quit? All changes will not be saved.</sys:String> <sys:String x:Key="code_MainWindow_Closing">File is not closed. Do you want to just quit? All changes will not be saved.</sys:String>

View File

@ -1,4 +1,4 @@
<Window x:Class="BallanceTASEditor.MainWindow" <Window x:Class="BallanceTASEditor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -262,7 +262,7 @@
</StatusBarItem> </StatusBarItem>
<StatusBarItem DockPanel.Dock="Right" HorizontalAlignment="Right"> <StatusBarItem DockPanel.Dock="Right" HorizontalAlignment="Right">
<TextBlock Text="v1.1 stable" Foreground="Gray" FontStyle="Italic"/> <TextBlock Text="v1.2 stable" Foreground="Gray" FontStyle="Italic"/>
</StatusBarItem> </StatusBarItem>
</StatusBar> </StatusBar>

View File

@ -1,4 +1,4 @@
using BallanceTASEditor.Core; using BallanceTASEditor.Core;
using BallanceTASEditor.Core.TASStruct; using BallanceTASEditor.Core.TASStruct;
using BallanceTASEditor.UI; using BallanceTASEditor.UI;
using System; using System;
@ -90,8 +90,8 @@ namespace BallanceTASEditor {
} }
private void funcMenu_Help_About(object sender, RoutedEventArgs e) { private void funcMenu_Help_About(object sender, RoutedEventArgs e) {
MessageBox.Show(I18NProcessor.GetI18N("code_MainWindow_Menu_Help_About"), MessageBox.Show(I18NProcessor.GetI18N("code_MainWindow_Menu_Help_About"),
I18NProcessor.GetI18N("code_Shared_ProgramName"), I18NProcessor.GetI18N("code_Shared_ProgramName"),
MessageBoxButton.OK, MessageBoxImage.Information); MessageBoxButton.OK, MessageBoxImage.Information);
} }
@ -248,7 +248,7 @@ namespace BallanceTASEditor {
private void funcWindow_KeyUp(object sender, KeyEventArgs e) { private void funcWindow_KeyUp(object sender, KeyEventArgs e) {
if (mFile == null || mViewer == null) return; if (mFile == null || mViewer == null) return;
switch(e.Key) { switch (e.Key) {
case Key.A: case Key.A:
mSlider.MoveSliderManually(true, true, mViewer.GetItemCountInPage()); mSlider.MoveSliderManually(true, true, mViewer.GetItemCountInPage());
break; break;
@ -280,7 +280,7 @@ namespace BallanceTASEditor {
// normally move // normally move
mSlider.MoveSliderManually(true, false, mViewer.GetItemCountInPage()); mSlider.MoveSliderManually(true, false, mViewer.GetItemCountInPage());
} }
} else if (e.Delta < 0) { } else if (e.Delta < 0) {
// wheel down // wheel down
if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_SHIFT)) { if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_SHIFT)) {
@ -309,8 +309,7 @@ namespace BallanceTASEditor {
var arr = (System.Array)e.Data.GetData(DataFormats.FileDrop); var arr = (System.Array)e.Data.GetData(DataFormats.FileDrop);
if (arr.Length != 1) e.Effects = DragDropEffects.None; if (arr.Length != 1) e.Effects = DragDropEffects.None;
else e.Effects = DragDropEffects.Link; else e.Effects = DragDropEffects.Link;
} } else e.Effects = DragDropEffects.None;
else e.Effects = DragDropEffects.None;
} }
#endregion #endregion
@ -331,15 +330,22 @@ namespace BallanceTASEditor {
} }
private void OpenFile(string file) { private void OpenFile(string file) {
#if DEBUG
#else
try { try {
#endif
mFile = new TASFile(file); mFile = new TASFile(file);
#if DEBUG
#else
} catch { } catch {
MessageBox.Show(I18NProcessor.GetI18N("code_MainWindow_Menu_File_Open_Fail"), MessageBox.Show(I18NProcessor.GetI18N("code_MainWindow_Menu_File_Open_Fail"),
I18NProcessor.GetI18N("code_Shared_ProgramName"), I18NProcessor.GetI18N("code_Shared_ProgramName"),
MessageBoxButton.OK, MessageBoxImage.Error); MessageBoxButton.OK, MessageBoxImage.Error);
mFile = null; mFile = null;
return; return;
} }
#endif
mViewer = new TASViewer(mFile, mSlider, mFlow); mViewer = new TASViewer(mFile, mSlider, mFlow);

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
<package id="zlib.net" version="1.0.4.0" targetFramework="net40" />
</packages> </packages>