Skip to content

Commit b98e0ef

Browse files
preparing for release
1 parent d4c62ec commit b98e0ef

31 files changed

+400
-864
lines changed

FlipnoteDesktop.sln

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlipnoteDesktop", "Flipnote
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{668EC33D-F7E1-4F5C-8614-EFB8FE82553F}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "G_TypeConsole", "G_TypeConsole\G_TypeConsole.csproj", "{D0010493-9A51-44C7-A56C-8F685C7E1448}"
11-
EndProject
1210
Global
1311
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1412
Debug|Any CPU = Debug|Any CPU
@@ -19,17 +17,10 @@ Global
1917
{9E15DC82-CCDE-447D-91F9-988E917147EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
2018
{9E15DC82-CCDE-447D-91F9-988E917147EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
2119
{9E15DC82-CCDE-447D-91F9-988E917147EA}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Release|Any CPU.ActiveCfg = Release|Any CPU
25-
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Release|Any CPU.Build.0 = Release|Any CPU
2620
EndGlobalSection
2721
GlobalSection(SolutionProperties) = preSolution
2822
HideSolutionNode = FALSE
2923
EndGlobalSection
30-
GlobalSection(NestedProjects) = preSolution
31-
{D0010493-9A51-44C7-A56C-8F685C7E1448} = {668EC33D-F7E1-4F5C-8614-EFB8FE82553F}
32-
EndGlobalSection
3324
GlobalSection(ExtensibilityGlobals) = postSolution
3425
SolutionGuid = {3D063199-4222-4D97-9059-BCE39666CE39}
3526
EndGlobalSection

FlipnoteDesktop/App.xaml.cs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,17 @@ public static string AuthorName
4343
public delegate void OnAuthorNameChanged();
4444
public static event OnAuthorNameChanged AuthorNameChanged;
4545

46+
static double BorderWidth = (SystemParameters.MaximizedPrimaryScreenWidth - SystemParameters.FullPrimaryScreenWidth) / 2.0;
47+
static double TitleBarHeight = BorderWidth + SystemParameters.WindowCaptionHeight;
48+
4649
private void Application_Startup(object sender, StartupEventArgs e)
4750
{
4851
if (e.Args.Length == 1)
4952
{
5053
var filename = e.Args[0];
5154
var flipnote = new Flipnote(filename);
52-
double BorderWidth = (SystemParameters.MaximizedPrimaryScreenWidth - SystemParameters.FullPrimaryScreenWidth) / 2.0;
53-
double TitleBarHeight = BorderWidth + SystemParameters.WindowCaptionHeight;
54-
Window wnd = new Window
55-
{
56-
Title = "Flipnote Player",
57-
Width = 512,
58-
Height = 384 + TitleBarHeight - 4
59-
};
60-
SimpleFlipnotePlayer player = new SimpleFlipnotePlayer();
61-
player.Source = flipnote;
62-
wnd.Content = player;
63-
wnd.Loaded += delegate (object o, RoutedEventArgs ev)
64-
{
65-
player.Start();
66-
};
67-
wnd.Show();
55+
56+
CreateFlipnotePlayerWindow(flipnote).Show();
6857
}
6958
else if (e.Args.Length == 0)
7059
{
@@ -74,6 +63,24 @@ private void Application_Startup(object sender, StartupEventArgs e)
7463
{
7564

7665
}
77-
}
66+
}
67+
68+
public static Window CreateFlipnotePlayerWindow(Flipnote src)
69+
{
70+
Window wnd = new Window
71+
{
72+
Title = "Flipnote Player",
73+
Width = 512,
74+
Height = 384 + TitleBarHeight - 4
75+
};
76+
SimpleFlipnotePlayer player = new SimpleFlipnotePlayer();
77+
player.Source = src;
78+
wnd.Content = player;
79+
wnd.Loaded += delegate (object o, RoutedEventArgs ev)
80+
{
81+
player.Start();
82+
};
83+
return wnd;
84+
}
7885
}
7986
}

FlipnoteDesktop/Controls/FrameCanvasEditor.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
<StackPanel Width="1" Height="30" Background="#F97300" Margin="7 0"/>
3333
<Button Style="{DynamicResource ResourceKey=SimpleButton}" Width="18" Height="18" BorderThickness="0"
3434
Name="PlayFlipnoteButton"
35-
ToolTip="Compile and Play flipnote">
35+
ToolTip="Compile and Play flipnote"
36+
Click="PlayFlipnoteButton_Click">
3637
<Button.Content>
3738
<drawable:RightPointingTriangle/>
3839
</Button.Content>

FlipnoteDesktop/Controls/FrameCanvasEditor.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using FlipnoteDesktop.Data;
22
using FlipnoteDesktop.Environment.Canvas;
33
using FlipnoteDesktop.Environment.Canvas.DrawingTools;
4+
using FlipnoteDesktop.Windows;
5+
using System.Collections.Generic;
46
using System.Windows;
57
using System.Windows.Controls;
68
using System.Windows.Input;
@@ -224,6 +226,13 @@ private void LayerSelector_Unchecked(object sender, RoutedEventArgs e)
224226
public delegate void OnSelectedLayerChanged(object o);
225227
public event OnSelectedLayerChanged SelectedLayerChanged;
226228

229+
private void PlayFlipnoteButton_Click(object sender, RoutedEventArgs e)
230+
{
231+
var wnd = Window.GetWindow(this) as MainWindow;
232+
var flipnote = Flipnote.New(null, null, wnd.FramesList.List.ItemsSource as List<DecodedFrame>, true);
233+
App.CreateFlipnotePlayerWindow(flipnote).ShowDialog();
234+
}
235+
227236
public void ForceToolBoxDrag(Point pt)
228237
{
229238
Canvas.SetLeft(ToolBox, pt.X + Canvas.GetLeft(ToolBox) - ToolBox.dX);

FlipnoteDesktop/Controls/SpeedSelector.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ private static void ValuePropertyChanged(DependencyObject d, DependencyPropertyC
4343
var o = d as SpeedSelector;
4444
o.ValueDisplay.Width = o.Value * 10;
4545
o.ValueText.Text = o.Value.ToString();
46+
if (e.OldValue != e.NewValue)
47+
o.ValueChanged?.Invoke(o);
4648
}
4749

4850
int msOverValue = 1;
@@ -63,5 +65,8 @@ private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
6365
{
6466
Value = msOverValue;
6567
}
68+
69+
public delegate void OnValueChanged(object sender);
70+
public event OnValueChanged ValueChanged;
6671
}
6772
}

FlipnoteDesktop/Data/DecodedFrame.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class DecodedFrame
1919
/// <summary>
2020
/// Layer 2 pixels as double array. Usage: Layer2Data[x,y]= ~true|false~;
2121
/// </summary>
22-
public bool[,] Layer2Data = new bool[256, 192];
22+
public bool[,] Layer2Data = new bool[256, 192];
2323

2424
public DecodedFrame()
2525
{

FlipnoteDesktop/Data/Flipnote.cs

Lines changed: 72 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public Flipnote(string filename)
135135
SoundHeader.SE2TrackSize = r.ReadUInt32();
136136
SoundHeader.SE3TrackSize = r.ReadUInt32();
137137
SoundHeader.CurrentFramespeed = r.ReadByte();
138-
SoundHeader.RecordedBGMFramespeed = r.ReadByte();
138+
SoundHeader.RecordingBGMFramespeed = r.ReadByte();
139139
r.ReadBytes(14);
140140

141141
SoundData.RawBGM = r.ReadBytes((int)SoundHeader.BGMTrackSize);
@@ -285,73 +285,75 @@ public WriteableBitmap RenderFrame(int index)
285285

286286
public string Filename;
287287

288-
public static Flipnote New(string authorName, byte[] authorId, List<DecodedFrame> frames)
288+
public static Flipnote New(string authorName, byte[] authorId, List<DecodedFrame> frames, bool ignoreMetadata = false)
289289
{
290290
var f = new Flipnote();
291291
f.FrameCount = (ushort)(frames.Count - 1);
292292
f.FormatVersion = 0x24;
293293

294-
f.Metadata.RootAuthorId = new byte[8];
295-
f.Metadata.ParentAuthorId = new byte[8];
296-
f.Metadata.CurrentAuthorId = new byte[8];
297-
Array.Copy(authorId, f.Metadata.RootAuthorId, 8);
298-
Array.Copy(authorId, f.Metadata.ParentAuthorId, 8);
299-
Array.Copy(authorId, f.Metadata.CurrentAuthorId, 8);
300-
f.Metadata.RootAuthorName = authorName;
301-
f.Metadata.ParentAuthorName = authorName;
302-
f.Metadata.CurrentAuthorName = authorName;
303-
304-
string mac6 = string.Join("", authorId.Take(3).Reverse().Select(t => t.ToString("X2")));
305-
var asm = Assembly.GetEntryAssembly().GetName().Version;
306-
var dt = DateTime.UtcNow;
307-
var fnVM = ((byte)asm.Major).ToString("X2");
308-
var fnVm = ((byte)asm.Minor).ToString("X2");
309-
var fnYY = (byte)(dt.Year - 2009);
310-
var fnMD = dt.Month * 32 + dt.Day;
311-
var fnTi = (((dt.Hour * 3600 + dt.Minute * 60 + dt.Second) % 4096) >> 1) + (fnMD > 255 ? 1 : 0);
312-
fnMD = (byte)fnMD;
313-
var fnYMD = (fnYY << 9) + fnMD;
314-
var H6_9 = fnYMD.ToString("X4");
315-
var H89 = ((byte)fnMD).ToString("X2");
316-
var HABC = fnTi.ToString("X3");
317-
318-
string _13str = $"80{fnVM}{fnVm}{H6_9}{HABC}";
319-
string nEdited = 0.ToString().PadLeft(3, '0');
320-
var filename = $"{mac6}_{_13str}_{nEdited}.ppm";
321-
f.Filename = FilenameChecksumDigit(filename) + filename.Remove(0, 1);
322-
323-
var rawfn = new byte[18];
324-
for (int i = 0; i < 3; i++)
294+
if (!ignoreMetadata)
325295
{
326-
rawfn[i] = byte.Parse("" + mac6[2 * i] + mac6[2 * i + 1], System.Globalization.NumberStyles.HexNumber);
327-
}
328-
for (int i = 3; i < 16; i++)
329-
{
330-
rawfn[i] = (byte)_13str[i - 3];
331-
}
332-
rawfn[16] = rawfn[17] = 0;
296+
f.Metadata.RootAuthorId = new byte[8];
297+
f.Metadata.ParentAuthorId = new byte[8];
298+
f.Metadata.CurrentAuthorId = new byte[8];
299+
Array.Copy(authorId, f.Metadata.RootAuthorId, 8);
300+
Array.Copy(authorId, f.Metadata.ParentAuthorId, 8);
301+
Array.Copy(authorId, f.Metadata.CurrentAuthorId, 8);
302+
f.Metadata.RootAuthorName = authorName;
303+
f.Metadata.ParentAuthorName = authorName;
304+
f.Metadata.CurrentAuthorName = authorName;
305+
306+
string mac6 = string.Join("", authorId.Take(3).Reverse().Select(t => t.ToString("X2")));
307+
var asm = Assembly.GetEntryAssembly().GetName().Version;
308+
var dt = DateTime.UtcNow;
309+
var fnVM = ((byte)asm.Major).ToString("X2");
310+
var fnVm = ((byte)asm.Minor).ToString("X2");
311+
var fnYY = (byte)(dt.Year - 2009);
312+
var fnMD = dt.Month * 32 + dt.Day;
313+
var fnTi = (((dt.Hour * 3600 + dt.Minute * 60 + dt.Second) % 4096) >> 1) + (fnMD > 255 ? 1 : 0);
314+
fnMD = (byte)fnMD;
315+
var fnYMD = (fnYY << 9) + fnMD;
316+
var H6_9 = fnYMD.ToString("X4");
317+
var H89 = ((byte)fnMD).ToString("X2");
318+
var HABC = fnTi.ToString("X3");
319+
320+
string _13str = $"80{fnVM}{fnVm}{H6_9}{HABC}";
321+
string nEdited = 0.ToString().PadLeft(3, '0');
322+
var filename = $"{mac6}_{_13str}_{nEdited}.ppm";
323+
f.Filename = FilenameChecksumDigit(filename) + filename.Remove(0, 1);
324+
325+
var rawfn = new byte[18];
326+
for (int i = 0; i < 3; i++)
327+
{
328+
rawfn[i] = byte.Parse("" + mac6[2 * i] + mac6[2 * i + 1], System.Globalization.NumberStyles.HexNumber);
329+
}
330+
for (int i = 3; i < 16; i++)
331+
{
332+
rawfn[i] = (byte)_13str[i - 3];
333+
}
334+
rawfn[16] = rawfn[17] = 0;
333335

334-
f.Metadata.ParentFilename = new byte[18];
335-
f.Metadata.CurrentFilename = new byte[18];
336+
f.Metadata.ParentFilename = new byte[18];
337+
f.Metadata.CurrentFilename = new byte[18];
336338

337-
Array.Copy(rawfn, f.Metadata.ParentFilename, 18);
338-
Array.Copy(rawfn, f.Metadata.CurrentFilename, 18);
339+
Array.Copy(rawfn, f.Metadata.ParentFilename, 18);
340+
Array.Copy(rawfn, f.Metadata.CurrentFilename, 18);
339341

340-
f.Metadata.RootFileFragment = new byte[8];
341-
for (int i = 0; i < 3; i++)
342-
{
343-
f.Metadata.RootFileFragment[i] =
344-
byte.Parse("" + mac6[2 * i] + mac6[2 * i + 1], System.Globalization.NumberStyles.HexNumber);
345-
}
346-
for (int i = 3; i < 8; i++)
347-
{
348-
f.Metadata.RootFileFragment[i] =
349-
(byte)((byte.Parse("" + _13str[2 * (i - 3)], System.Globalization.NumberStyles.HexNumber) << 4)
350-
+ byte.Parse("" + _13str[2 * (i - 3) + 1], System.Globalization.NumberStyles.HexNumber));
342+
f.Metadata.RootFileFragment = new byte[8];
343+
for (int i = 0; i < 3; i++)
344+
{
345+
f.Metadata.RootFileFragment[i] =
346+
byte.Parse("" + mac6[2 * i] + mac6[2 * i + 1], System.Globalization.NumberStyles.HexNumber);
347+
}
348+
for (int i = 3; i < 8; i++)
349+
{
350+
f.Metadata.RootFileFragment[i] =
351+
(byte)((byte.Parse("" + _13str[2 * (i - 3)], System.Globalization.NumberStyles.HexNumber) << 4)
352+
+ byte.Parse("" + _13str[2 * (i - 3) + 1], System.Globalization.NumberStyles.HexNumber));
353+
}
354+
f.Metadata.Timestamp = (uint)((dt - new DateTime(2000, 1, 1, 0, 0, 0)).TotalSeconds);
355+
f.RawThumbnail = new DecodedFrame().CreateThumbnailW64();
351356
}
352-
f.Metadata.Timestamp = (uint)((dt - new DateTime(2000, 1, 1, 0, 0, 0)).TotalSeconds);
353-
f.RawThumbnail = new DecodedFrame().CreateThumbnailW64();
354-
355357
// write the animation data
356358
// THIS PART MUST BE CHANGED
357359

@@ -371,7 +373,7 @@ public static Flipnote New(string authorName, byte[] authorId, List<DecodedFrame
371373
f.AnimationDataSize = animDataSize;
372374

373375
f.SoundHeader.CurrentFramespeed = 3;
374-
f.SoundHeader.RecordedBGMFramespeed = 1;
376+
f.SoundHeader.RecordingBGMFramespeed = 1;
375377
return f;
376378
}
377379

@@ -432,7 +434,7 @@ public void Save(string fn)
432434
w.Write((uint)0); // SE3
433435

434436
w.Write(SoundHeader.CurrentFramespeed); // Frame speed
435-
w.Write(SoundHeader.RecordedBGMFramespeed); //BGM speed
437+
w.Write(SoundHeader.RecordingBGMFramespeed); //BGM speed
436438
w.Write(new byte[14]);
437439

438440
using (var ms = new MemoryStream())
@@ -441,7 +443,14 @@ public void Save(string fn)
441443
w.BaseStream.Seek(0, SeekOrigin.Begin);
442444
w.BaseStream.CopyTo(ms);
443445
w.BaseStream.Seek(p, SeekOrigin.Begin);
444-
w.Write(ComputeSignature(ms.ToArray()));
446+
if (File.Exists("private-key"))
447+
{
448+
w.Write(ComputeSignature(ms.ToArray()));
449+
}
450+
else
451+
{
452+
// maybe throw an error
453+
}
445454
}
446455
w.Write(new byte[0x10]);
447456
}
@@ -913,7 +922,7 @@ public class _SoundHeader
913922
public uint SE2TrackSize;
914923
public uint SE3TrackSize;
915924
public byte CurrentFramespeed;
916-
public byte RecordedBGMFramespeed;
925+
public byte RecordingBGMFramespeed;
917926
}
918927

919928
public class _SoundData
@@ -961,6 +970,6 @@ public int this[int i]
961970
}
962971
}
963972
}
964-
}
973+
}
965974
}
966975
}

FlipnoteDesktop/FlipnoteDesktop.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
<DebugType>pdbonly</DebugType>
3737
<Optimize>true</Optimize>
3838
<OutputPath>bin\Release\</OutputPath>
39-
<DefineConstants>TRACE</DefineConstants>
39+
<DefineConstants>
40+
</DefineConstants>
4041
<ErrorReport>prompt</ErrorReport>
4142
<WarningLevel>4</WarningLevel>
4243
</PropertyGroup>
@@ -98,7 +99,6 @@
9899
</Compile>
99100
<Compile Include="Data\DecodedFrame.cs" />
100101
<Compile Include="Data\LayerColor.cs" />
101-
<Compile Include="Data\FlipnoteProperties.cs" />
102102
<Compile Include="Drawable\AddIcon.xaml.cs">
103103
<DependentUpon>AddIcon.xaml</DependentUpon>
104104
</Compile>
@@ -176,6 +176,9 @@
176176
<DesignTime>True</DesignTime>
177177
<DependentUpon>VersionCounter.tt</DependentUpon>
178178
</Compile>
179+
<Compile Include="Windows\AboutWindow.xaml.cs">
180+
<DependentUpon>AboutWindow.xaml</DependentUpon>
181+
</Compile>
179182
<Compile Include="Windows\FlipnoteUserIdGetterPages\CheckIdentityPage.xaml.cs">
180183
<DependentUpon>CheckIdentityPage.xaml</DependentUpon>
181184
</Compile>
@@ -350,6 +353,10 @@
350353
<SubType>Designer</SubType>
351354
<Generator>MSBuild:Compile</Generator>
352355
</Page>
356+
<Page Include="Windows\AboutWindow.xaml">
357+
<SubType>Designer</SubType>
358+
<Generator>MSBuild:Compile</Generator>
359+
</Page>
353360
<Page Include="Windows\FlipnoteUserIdGetterPages\CheckIdentityPage.xaml">
354361
<SubType>Designer</SubType>
355362
<Generator>MSBuild:Compile</Generator>
@@ -421,6 +428,8 @@
421428
<Resource Include="icon.ico" />
422429
</ItemGroup>
423430
<ItemGroup>
431+
<Resource Include="Images\GitHub-Mark-64px.png" />
432+
<Resource Include="Images\nil-profile.png" />
424433
<Content Include="Properties\VersionCounter.tt">
425434
<Generator>TextTemplatingFileGenerator</Generator>
426435
<LastGenOutput>VersionCounter.cs</LastGenOutput>
2.56 KB
Loading
37.2 KB
Loading

0 commit comments

Comments
 (0)