From b504bcf5742d83254e3238bcd74cd66a410d275d Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Mon, 16 Nov 2020 13:14:17 +0800 Subject: [PATCH 1/8] ConvertSound --- .gitignore | 2 + Assets/Build.bake | 14 +++ Assets/ExampleAssets/Build.bake | 3 + Assets/ExampleAssets/Sound/Build.bake | 9 ++ Bake.Snowing/Bake.Snowing.fsproj | 22 ++++ Bake.Snowing/ConvertSound.fs | 116 ++++++++++++++++++++ Bake.Snowing/Properties/launchSettings.json | 9 ++ Snowing.sln | 14 +++ 8 files changed, 189 insertions(+) create mode 100644 Assets/Build.bake create mode 100644 Assets/ExampleAssets/Build.bake create mode 100644 Assets/ExampleAssets/Sound/Build.bake create mode 100644 Bake.Snowing/Bake.Snowing.fsproj create mode 100644 Bake.Snowing/ConvertSound.fs create mode 100644 Bake.Snowing/Properties/launchSettings.json diff --git a/.gitignore b/.gitignore index 574937d..bf71143 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ /build /packages /WindowsLive2D/Core +/Bake.Snowing/bin +/Bake.Snowing/obj diff --git a/Assets/Build.bake b/Assets/Build.bake new file mode 100644 index 0000000..fdc2fe1 --- /dev/null +++ b/Assets/Build.bake @@ -0,0 +1,14 @@ + +Set $Out "../build/data/" + +CreateDirectory $Out + +Import { + ../Bake.Snowing/bin/Release/net5.0-windows/publish/Bake.Snowing.dll +} + +Parallel { + Include { + ExampleAssets/Build.bake + } +} \ No newline at end of file diff --git a/Assets/ExampleAssets/Build.bake b/Assets/ExampleAssets/Build.bake new file mode 100644 index 0000000..d569c8b --- /dev/null +++ b/Assets/ExampleAssets/Build.bake @@ -0,0 +1,3 @@ + + +Include Sound/Build.bake diff --git a/Assets/ExampleAssets/Sound/Build.bake b/Assets/ExampleAssets/Sound/Build.bake new file mode 100644 index 0000000..8c159ad --- /dev/null +++ b/Assets/ExampleAssets/Sound/Build.bake @@ -0,0 +1,9 @@ + +Atomic { + Set $FyeeOut "$Out/Fyee" + CreateDirectory $FyeeOut + + ConvertSound $FyeeOut 155BPM { + Fyee/*.wav + } +} \ No newline at end of file diff --git a/Bake.Snowing/Bake.Snowing.fsproj b/Bake.Snowing/Bake.Snowing.fsproj new file mode 100644 index 0000000..29c06f9 --- /dev/null +++ b/Bake.Snowing/Bake.Snowing.fsproj @@ -0,0 +1,22 @@ + + + + net5.0-windows + + + + + + + + + + + + + + ..\..\..\Bake\Bake.Core\bin\Release\net5.0\Bake.Core.dll + + + + diff --git a/Bake.Snowing/ConvertSound.fs b/Bake.Snowing/ConvertSound.fs new file mode 100644 index 0000000..fd07a0e --- /dev/null +++ b/Bake.Snowing/ConvertSound.fs @@ -0,0 +1,116 @@ +module Bake.Snowing.ConvertSound + +open Bake +open Bake.Utils + +open System.IO +open WAVFileReader + + +[] +type private Options = { + Bpm : float32 + BeatsPerBar : uint32 + BeatsOffset : int32 +} + +let private PackSound scriptPath srcHead srcLoop (options:Options) (dst:string) = + if File.Exists dst then + failwith ("Sound file " + dst + " is already exists.") + + let getPath (p:string) = + if p.Trim() <> "" then + scriptPath + "\\" + p + else + "" + + let headFile,loopFile = getPath srcHead , getPath srcLoop + + let GetPCM path = + let fmt,data = WAVFileReader.ReadFile (File.OpenRead (path)) + if + fmt.Channels <> 2us || + fmt.DataFormat <> AudioDataFormat.PCM || + fmt.SampleRate <> 44100u then + failwith (path + "is not supposed,it must 44100Hz,2 Channels PCM.") + let f = File.OpenRead path + f.Position <- data.Begin + let buf = Array.init (data.Size |> int) (fun x -> 0uy) + if f.Read (buf,0,data.Size |> int) <> (data.Size |> int) then + failwith "Unknown file tail!" + buf + + let GetPCM2 f = + if System.String.IsNullOrWhiteSpace f |> not then + GetPCM f + else + [||] + let headPCM = GetPCM2 headFile + let loopPCM = GetPCM2 loopFile + + use outf = File.OpenWrite dst + use out = new BinaryWriter(outf) + out.Write (headPCM.Length |> uint32) + out.Write (loopPCM.Length |> uint32) + out.Write (options.Bpm) + out.Write (options.BeatsPerBar) + out.Write (options.BeatsOffset) + out.Write headPCM + out.Write loopPCM + out.Close() + outf.Close() + () + + + +let private GetOptions argumentStrList = + let defaultOption = { + Bpm = 120.0f + BeatsPerBar = 4u + BeatsOffset = 0 + } + + let optionFolder option (str:string) = + match str.Trim() with + | str when str.EndsWith "BPM" -> {option with Bpm = str.[..str.Length-4].Trim() |> float32 } + | str when str.EndsWith "BeatPerBar" -> {option with BeatsPerBar = str.[..str.Length - 11].Trim() |> uint32 } + | str when str.StartsWith "BeatOffset:" -> {option with BeatsOffset = str.[11..].Trim() |> int32 } + | "" -> option + | _ -> failwith "Unsuppoted argument." + + + argumentStrList + |> List.fold optionFolder defaultOption + +[] +let ConvertSound = { + help = "转换音频到Snowing引擎支持的格式" + example = [] + usage = [] + action = fun ctx script -> + let outDir = script.arguments.Head |> Utils.applyContextToArgument ctx |> normalizeDirPath + let inDir = script.scriptFile.Directory.FullName |> normalizeDirPath + let inputFiles = List.last script.arguments |> Utils.applyContextToArgument ctx + let options = script.arguments.[1..script.arguments.Length - 2] |> List.map (Utils.applyContextToArgument ctx) |> GetOptions + let tasks = + blockArgumentTaskPerLine + (fun _ script file -> + Utils.mapPathToOutputPath inDir file + |> Seq.map (fun (path, fileName) -> + let inFile = FileInfo path + let outFile = outDir + fileName |> modifyExtensionName "snd" + { + inputFiles = seq { inFile } + outputFiles = seq { outFile } + source = script + dirty = false + run = fun () -> + lock stdout (fun () -> printfn "ConvertSound:%s..." inFile.Name) + PackSound inFile.Directory.FullName inFile.Name "" options outFile + })) + ctx + script + inputFiles + + tasks, ctx +} diff --git a/Bake.Snowing/Properties/launchSettings.json b/Bake.Snowing/Properties/launchSettings.json new file mode 100644 index 0000000..67d9d6b --- /dev/null +++ b/Bake.Snowing/Properties/launchSettings.json @@ -0,0 +1,9 @@ +{ + "profiles": { + "Bake.Snowing": { + "commandName": "Executable", + "executablePath": "bake", + "workingDirectory": "../Assets" + } + } +} \ No newline at end of file diff --git a/Snowing.sln b/Snowing.sln index 1d3d7a9..b42a1b6 100644 --- a/Snowing.sln +++ b/Snowing.sln @@ -58,6 +58,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Fyee", "Fyee\Fyee.vcxitems" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FyeeDemo", "FyeeDemo\FyeeDemo.vcxproj", "{DBB0F9BE-CA10-4843-B892-17574B5B6983}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Bake.Snowing", "Bake.Snowing\Bake.Snowing.fsproj", "{A92673C4-2100-4A21-857C-16D56468E798}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Fyee\Fyee.vcxitems*{2f989ed9-9160-4cf7-9cba-83de4f7324c5}*SharedItemsImports = 9 @@ -300,6 +302,18 @@ Global {DBB0F9BE-CA10-4843-B892-17574B5B6983}.Release|x64.Build.0 = Release|x64 {DBB0F9BE-CA10-4843-B892-17574B5B6983}.Release|x86.ActiveCfg = Release|Win32 {DBB0F9BE-CA10-4843-B892-17574B5B6983}.Release|x86.Build.0 = Release|Win32 + {A92673C4-2100-4A21-857C-16D56468E798}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Debug|x64.ActiveCfg = Debug|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Debug|x64.Build.0 = Debug|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Debug|x86.ActiveCfg = Debug|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Debug|x86.Build.0 = Debug|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Release|Any CPU.Build.0 = Release|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Release|x64.ActiveCfg = Release|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Release|x64.Build.0 = Release|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Release|x86.ActiveCfg = Release|Any CPU + {A92673C4-2100-4A21-857C-16D56468E798}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From f7c8738e70927b4381e642fbd26abfe6fcddbc22 Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Mon, 16 Nov 2020 14:12:55 +0800 Subject: [PATCH 2/8] Bug fixed --- Assets/ExampleAssets/Build.bake | 1 + Bake.Snowing/Bake.Snowing.fsproj | 6 + Bake.Snowing/ConvertTexture.fs | 250 +++++++++++++++++++++++++++++++ Bake.Snowing/texconv.exe | 3 + 4 files changed, 260 insertions(+) create mode 100644 Bake.Snowing/ConvertTexture.fs create mode 100644 Bake.Snowing/texconv.exe diff --git a/Assets/ExampleAssets/Build.bake b/Assets/ExampleAssets/Build.bake index d569c8b..5bf9e12 100644 --- a/Assets/ExampleAssets/Build.bake +++ b/Assets/ExampleAssets/Build.bake @@ -1,3 +1,4 @@ Include Sound/Build.bake +ConvertTexture $Out DDS DXT1 Background.png diff --git a/Bake.Snowing/Bake.Snowing.fsproj b/Bake.Snowing/Bake.Snowing.fsproj index 29c06f9..adc4f01 100644 --- a/Bake.Snowing/Bake.Snowing.fsproj +++ b/Bake.Snowing/Bake.Snowing.fsproj @@ -5,9 +5,15 @@ + + PreserveNewest + + + + diff --git a/Bake.Snowing/ConvertTexture.fs b/Bake.Snowing/ConvertTexture.fs new file mode 100644 index 0000000..b01c81e --- /dev/null +++ b/Bake.Snowing/ConvertTexture.fs @@ -0,0 +1,250 @@ +module Bake.Snowing.ConvertTexture + +open System.IO +open SixLabors +open SixLabors.ImageSharp +open System.Diagnostics +open System.Threading +open System + +open Bake + +type TextureFormat = +| R8G8B8A8_UNORM = 0uy +| R8_UNORM = 1uy +| DDS = 2uy + +let StartWait exe arg = + use prc = new Process() + prc.StartInfo.FileName <- exe + prc.StartInfo.WorkingDirectory <- (FileInfo exe).DirectoryName + prc.StartInfo.Arguments <- arg + prc.StartInfo.WindowStyle <- ProcessWindowStyle.Hidden + prc.StartInfo.RedirectStandardOutput <- true + if prc.Start() |> not then + failwith ("Can not start " + exe) + prc.WaitForExit () + match prc.ExitCode with + | 0 -> () + | x -> + failwith ( + "Build Tool Failed. Exit Code:" + string x + + Environment.NewLine + + exe + " " + arg + + Environment.NewLine + + prc.StandardOutput.ReadToEnd()) + +let WaitForFile maxTimes path = + for _ in 0..maxTimes do + if File.Exists path |> not then + Thread.Sleep 1000 + if File.Exists path |> not then + failwith ("Can not find file " + path) + + +type RequestedTextureFormat = +| RGBA32 +| R8 +| DDS of string + +type Job = { + ScriptDir : DirectoryInfo + Input : string list + Arguments : string list + OutputPath : string +} + +let Is4MulBitmap (bitmap: Image) = + bitmap.Width % 4 = 0 && bitmap.Height % 4 = 0 + +let WrapBitmapTo4 (bitmap: Image) = + let wrapTo4 x = + (4 - (x % 4)) % 4 + x + + let newSize = + (wrapTo4 bitmap.Width,wrapTo4 bitmap.Height) + let newBitmap = new Image(fst newSize,snd newSize) + for y in 0..bitmap.Height-1 do + for x in 0..bitmap.Width-1 do + let px = bitmap.[x, y] + newBitmap.[x,y] <- px + newBitmap + + +let ParseArgument (job : Job) = + match job.Arguments.Head with + | "RGBA32" -> RGBA32 + | "R8" -> R8 + | "DDS" -> DDS(job.Arguments.[1]) + | x -> failwith ("Unknown requested texture format:" + x) + +let GetFormatFormRequestedFormat = function +| RGBA32 -> TextureFormat.R8G8B8A8_UNORM +| R8 -> TextureFormat.R8_UNORM +| DDS _ -> TextureFormat.DDS + +type SpriteFrame = { + x : uint16 + y : uint16 + w : uint16 + h : uint16 +} + +type TextureHead = { + Format : TextureFormat + Width : uint16 + Height : uint16 + SpriteSheet : SpriteFrame seq +} + +let SaveTextureHead head (stream:BinaryWriter) = + stream.Write (uint8 head.Format) + stream.Write (uint16 head.Width) + stream.Write (uint16 head.Height) + stream.Write (head.SpriteSheet |> Seq.length |> uint16) + head.SpriteSheet + |> Seq.iter (fun x -> + stream.Write (float32 x.x / float32 head.Width) + stream.Write (float32 x.y / float32 head.Height) + stream.Write (float32 x.w / float32 head.Width) + stream.Write (float32 x.h / float32 head.Height)) + +let DumpPixels (format:TextureFormat) (path:string) : uint16*uint16*byte[] = + let pixelSize = + match format with + | TextureFormat.R8G8B8A8_UNORM -> 4uy + | TextureFormat.R8_UNORM -> 1uy + | _ -> raise (System.ArgumentException()) + + use bitmap = Image.Load(path) + let pixels = Array.init ((pixelSize |> int) * bitmap.Width * bitmap.Height) (fun _ -> 0uy) + use memStream = new MemoryStream(pixels) + use binWriter = new BinaryWriter(memStream) + for y in 0..bitmap.Height-1 do + for x in 0..bitmap.Width-1 do + let px = bitmap.[x, y] + match format with + | TextureFormat.R8G8B8A8_UNORM -> + binWriter.Write px.R + binWriter.Write px.G + binWriter.Write px.B + binWriter.Write px.A + | TextureFormat.R8_UNORM -> + binWriter.Write px.R + | _ -> raise (System.ArgumentException()) + binWriter.Flush () + binWriter.Close () + memStream.Close () + bitmap.Width |> uint16,bitmap.Height |> uint16,pixels + +let ConvertTextureFunc spriteSheet inputFullName (job:Job) = + let reqFormat = ParseArgument job + let innerFormat = GetFormatFormRequestedFormat reqFormat + + use dstFile = File.OpenWrite job.OutputPath + use dstWriter = new BinaryWriter(dstFile) + + let srcPath = + match inputFullName with + | false -> job.ScriptDir.FullName + "\\" + job.Input.Head + | true -> job.Input.Head + + match reqFormat with + | RGBA32 | R8 -> + let w,h,px = DumpPixels innerFormat srcPath + let head = { + Format = innerFormat + Width = uint16 w + Height = uint16 h + SpriteSheet = spriteSheet + } + + SaveTextureHead head dstWriter + dstWriter.Write px + + | DDS (ddsFormat) -> + let orgBitmap = Image.Load(srcPath) + let is4MulBitmap = Is4MulBitmap orgBitmap + use bitmap = + if is4MulBitmap then orgBitmap + else + let ret = orgBitmap |> WrapBitmapTo4 + orgBitmap.Dispose() + ret + + let tmpout = FileInfo(job.OutputPath).DirectoryName + let texconv = + System.Reflection.Assembly.GetExecutingAssembly().Location + |> FileInfo |> fun x -> x.DirectoryName |> Utils.normalizeDirPath + let texconv = texconv + "texconv.exe" + + let incPng = + if is4MulBitmap then + FileInfo(srcPath).FullName + else + let path = job.OutputPath + ".png" + bitmap.Save path + path + + sprintf "\"%s\" -ft DDS -f %s -o \"%s\"" incPng ddsFormat tmpout + |> StartWait texconv + + if not is4MulBitmap then + File.Delete incPng + + let head = { + Format = TextureFormat.DDS + Width = uint16 bitmap.Width + Height = uint16 bitmap.Height + SpriteSheet = spriteSheet + } + SaveTextureHead head dstWriter + let ddsPath = + let baseFileName = + FileInfo(srcPath).Name + tmpout + "\\" + baseFileName.[..baseFileName.LastIndexOf '.' - 1] + ".DDS" + WaitForFile 5 ddsPath + let ddsBytes = File.ReadAllBytes ddsPath + dstWriter.Write (ddsBytes |> Array.length |> uint32) + dstWriter.Write ddsBytes + File.Delete ddsPath + + dstWriter.Close () + dstFile.Close () + +[] +let ConvertTexture = { + help = "转换纹理到Snowing引擎可以使用的格式" + usage = [] + example = [] + action = fun ctx script -> + let outDir = script.arguments.Head |> Utils.applyContextToArgument ctx + let arguments = script.arguments.[1..script.arguments.Length-2] |> List.map (Utils.applyContextToArgument ctx) + let inputFiles = List.last script.arguments |> Utils.applyContextToArgument ctx + + let tasks = + Utils.blockArgumentTaskPerLine (fun _ script inputFiles -> + Utils.mapPathToOutputPath script.scriptFile.Directory.FullName inputFiles + |> Seq.map (fun (path, fileName) -> + let outFile = outDir + fileName |> Utils.modifyExtensionName "ctx" + { + inputFiles = seq { FileInfo path } + source = script + outputFiles = seq { outFile } + dirty = false + run = fun () -> + lock stdout (fun () -> printfn "ConvertTexture:%s..." fileName) + ConvertTextureFunc Seq.empty true { + ScriptDir = script.scriptFile.Directory + Input = [ path ] + OutputPath = outFile + Arguments = arguments + } + + })) + ctx + script + inputFiles + + tasks, ctx +} \ No newline at end of file diff --git a/Bake.Snowing/texconv.exe b/Bake.Snowing/texconv.exe new file mode 100644 index 0000000..5f05ec4 --- /dev/null +++ b/Bake.Snowing/texconv.exe @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b60341c8179b764e84fd428b8e14cbbb64e5116aba1f1cd4c663d1a3a6dc655c +size 635904 From 6852e747a372388ac850c7abbf30b7c8a5c594e2 Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Mon, 16 Nov 2020 15:29:50 +0800 Subject: [PATCH 3/8] Bake --- Assets/BasicAssets/Build.bake | 1 + Assets/Build.bake | 3 +- Assets/BuildLive2D.bake | 37 +++++ Assets/ExampleAssets/Build.bake | 1 + BGMPlayer/BGMPlayer.cpp | 118 --------------- BGMPlayer/BGMPlayer.vcxproj | 152 ------------------- BGMPlayer/BGMPlayer.vcxproj.filters | 6 - BGMPlayer/BGMPlayer.vcxproj.user | 19 --- Bake.Snowing/Bake.Snowing.fsproj | 5 +- Bake.Snowing/BuildFont.fs | 124 ++++++++++++++++ Bake.Snowing/ConvertTexture.fs | 2 +- Bake.Snowing/PackSprite.fs | 96 ++++++++++++ Snowing.sln | 16 +- TestWindows/TestWindows.vcxproj | 1 - TestWindows/TestWindows.vcxproj.filters | 1 - TestWindows/XAudio2.cpp | 115 --------------- TestWindowsLive2D/LipSync.cpp | 77 ---------- TestWindowsLive2D/TestWindowsLive2D.vcxproj | 1 - TestYukimi/Audio.cpp | 153 -------------------- TestYukimi/TestTextWindow.cpp | 2 - TestYukimi/TestYukimi.vcxproj | 1 - 21 files changed, 266 insertions(+), 665 deletions(-) create mode 100644 Assets/BasicAssets/Build.bake create mode 100644 Assets/BuildLive2D.bake delete mode 100644 BGMPlayer/BGMPlayer.cpp delete mode 100644 BGMPlayer/BGMPlayer.vcxproj delete mode 100644 BGMPlayer/BGMPlayer.vcxproj.filters delete mode 100644 BGMPlayer/BGMPlayer.vcxproj.user create mode 100644 Bake.Snowing/BuildFont.fs create mode 100644 Bake.Snowing/PackSprite.fs delete mode 100644 TestWindows/XAudio2.cpp delete mode 100644 TestWindowsLive2D/LipSync.cpp delete mode 100644 TestYukimi/Audio.cpp diff --git a/Assets/BasicAssets/Build.bake b/Assets/BasicAssets/Build.bake new file mode 100644 index 0000000..8c68ef3 --- /dev/null +++ b/Assets/BasicAssets/Build.bake @@ -0,0 +1 @@ +BuildFont $Out/Font-chs.fnt Font/chs diff --git a/Assets/Build.bake b/Assets/Build.bake index fdc2fe1..18c7abc 100644 --- a/Assets/Build.bake +++ b/Assets/Build.bake @@ -9,6 +9,7 @@ Import { Parallel { Include { + BasicAssets/Build.bake ExampleAssets/Build.bake } -} \ No newline at end of file +} diff --git a/Assets/BuildLive2D.bake b/Assets/BuildLive2D.bake new file mode 100644 index 0000000..6566eaf --- /dev/null +++ b/Assets/BuildLive2D.bake @@ -0,0 +1,37 @@ +Set $Out "../build/data/Live2D" +Set $Live2D "../TestWindowsLive2D/CubismNativeSamples/Samples/Res" + +Import { + ../Bake.Snowing/bin/Release/net5.0-windows/publish/Bake.Snowing.dll +} + + +CreateDirectory { + $Out +} +Parallel { + Copy $Out $Live2D/* +} + +CreateDirectory { + $Out/Haru/Haru.2048 + $Out/Hiyori/Hiyori.2048 + $Out/Mark/Mark.2048 +} + +Parallel { + ConvertTexture $Out/Haru/Haru.2048 DDS DXT5 { + $Live2D/Haru/Haru.2048/texture_00.png + $Live2D/Haru/Haru.2048/texture_01.png + } + + ConvertTexture $Out/Hiyori/Hiyori.2048 DDS DXT5 { + $Live2D/Hiyori/Hiyori.2048/texture_01.png + $Live2D/Hiyori/Hiyori.2048/texture_00.png + } + + ConvertTexture $Out/Mark/Mark.2048 DDS DXT5 { + $Live2D/Mark/Mark.2048/texture_00.png + } + +} \ No newline at end of file diff --git a/Assets/ExampleAssets/Build.bake b/Assets/ExampleAssets/Build.bake index 5bf9e12..3809a2a 100644 --- a/Assets/ExampleAssets/Build.bake +++ b/Assets/ExampleAssets/Build.bake @@ -2,3 +2,4 @@ Include Sound/Build.bake ConvertTexture $Out DDS DXT1 Background.png +PackSprite $Out/Sprite.ctx RGBA32 Sprite diff --git a/BGMPlayer/BGMPlayer.cpp b/BGMPlayer/BGMPlayer.cpp deleted file mode 100644 index b58261f..0000000 --- a/BGMPlayer/BGMPlayer.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#define USE_XAUDIO2 //ҪWindowsʹXAudio2ΪƵʱPlatformImpls.hͷļ֮ǰ˺ -#include - -using namespace Snowing; - -int main() -{ - // ʵ - auto engine = PlatformImpls::WindowsImpl::MakeEngine( - L"BGMPlayer", - { 400,300 }, - true); - - // XAudio2ʵ - PlatformImpls::WindowsImpl::XAudio2::XADevice xaDevice; - - // BGM - auto music = LoadAsset("Dir/Sound/ExBoss.snd"); - // ڴBGMݣ - // Ϊ־StageEx Boss BGM - // ӽʾöηַ; - - // - Audio::SoundPlayer player; - - // BGM - player.Play(&music); - - // ӡ˵ - Log(L"¼ɵ"); - Log(L"Ҽɵࡣ"); - Log(L"¿ոͣ/ָš"); - Log(L"Z/XԵٶȡ"); - - // - Input::KeyWatcher up{ &Input::Input::Get(),Input::KeyboardKey::Up }; - Input::KeyWatcher down{ &Input::Input::Get(),Input::KeyboardKey::Down }; - Input::KeyWatcher left{ &Input::Input::Get(),Input::KeyboardKey::Left }; - Input::KeyWatcher right{ &Input::Input::Get(),Input::KeyboardKey::Right }; - Input::KeyWatcher space{ &Input::Input::Get(),Input::KeyboardKey::Space }; - Input::KeyWatcher z{ &Input::Input::Get(),'Z' }; - Input::KeyWatcher x{ &Input::Input::Get(),'X' }; - - // - float volume = 1.0f; - - // - float pan = 0.0f; - - // ٶ - float spd = 1.0f; - - // ͣʱʹõIJŽ - uint32_t position = 0; - - // ѭ - Engine::Get().Run([&] { - - // ÿ - up.Update(); - down.Update(); - left.Update(); - right.Update(); - space.Update(); - z.Update(); - x.Update(); - - // Ӧ° - if (up.JustPress()) - { - volume = std::clamp(volume + 0.1f, 0.0f, 1.0f); - player.SetVolume(volume); - } - - if (down.JustPress()) - { - volume = std::clamp(volume - 0.1f, 0.0f, 1.0f); - player.SetVolume(volume); - } - - // ӦҼ - if (left.JustRelease()) - { - pan = std::clamp(pan - 0.1f, -1.0f, 1.0f); - player.SetPan(pan); - } - - if (right.JustRelease()) - { - pan = std::clamp(pan + 0.1f, -1.0f, 1.0f); - player.SetPan(pan); - } - - // ӦZXòٶ - if (z.JustRelease()) - { - spd = std::clamp(spd - 0.1f, 0.001f, 10.0f); - player.SetSpeed(spd); - } - - if (x.JustRelease()) - { - spd = std::clamp(spd + 0.1f, 0.001f, 10.0f); - player.SetSpeed(spd); - } - - // Ӧոͣ/ - if (space.JustPress()) - { - if (player.GetPlaying()) // ڲ - position = player.Stop(); // ͣ浱ǰλ - else // ǰΪͣ״̬ - player.Play(&music, position); // Ӷϵ - } - }); - - return 0; -} \ No newline at end of file diff --git a/BGMPlayer/BGMPlayer.vcxproj b/BGMPlayer/BGMPlayer.vcxproj deleted file mode 100644 index f16c50c..0000000 --- a/BGMPlayer/BGMPlayer.vcxproj +++ /dev/null @@ -1,152 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {7CDAD54A-D204-4907-B516-25A5F2061CAE} - BGMPlayer - 8.1 - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - $(SolutionDir)build\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)build\objs\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)WindowsImpl;$(IncludePath) - - - $(SolutionDir)build\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)build\objs\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)WindowsImpl;$(IncludePath) - - - $(SolutionDir)build\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)build\objs\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)WindowsImpl;$(IncludePath) - - - $(SolutionDir)build\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)build\objs\$(ProjectName)$(Configuration)$(PlatformName)\ - $(SolutionDir)WindowsImpl;$(IncludePath) - - - - Level3 - Disabled - true - stdcpp17 - true - - - - - Level3 - Disabled - true - stdcpp17 - true - - - - - Level3 - MaxSpeed - true - true - true - stdcpp17 - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - stdcpp17 - true - - - true - true - - - - - - - - {36976dba-7802-4549-8f43-f56245d4115e} - - - - - - \ No newline at end of file diff --git a/BGMPlayer/BGMPlayer.vcxproj.filters b/BGMPlayer/BGMPlayer.vcxproj.filters deleted file mode 100644 index a887b95..0000000 --- a/BGMPlayer/BGMPlayer.vcxproj.filters +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/BGMPlayer/BGMPlayer.vcxproj.user b/BGMPlayer/BGMPlayer.vcxproj.user deleted file mode 100644 index 6c84d89..0000000 --- a/BGMPlayer/BGMPlayer.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - $(OutDir) - WindowsLocalDebugger - - - $(OutDir) - WindowsLocalDebugger - - - $(OutDir) - WindowsLocalDebugger - - - $(OutDir) - WindowsLocalDebugger - - \ No newline at end of file diff --git a/Bake.Snowing/Bake.Snowing.fsproj b/Bake.Snowing/Bake.Snowing.fsproj index adc4f01..5114942 100644 --- a/Bake.Snowing/Bake.Snowing.fsproj +++ b/Bake.Snowing/Bake.Snowing.fsproj @@ -9,12 +9,13 @@ PreserveNewest + + - - + diff --git a/Bake.Snowing/BuildFont.fs b/Bake.Snowing/BuildFont.fs new file mode 100644 index 0000000..72b3831 --- /dev/null +++ b/Bake.Snowing/BuildFont.fs @@ -0,0 +1,124 @@ +module Bake.Snowing.BuildFont + +open Bake +open Bake.Snowing.ConvertTexture + +open System.IO +open System.Text + +type CharInfo = { + Ch : char + FaceID : uint16 + Sprite : SpriteFrame +} + +let private ParseFontIndex txtPath = + txtPath + |> File.ReadAllLines + |> Array.map (fun x -> x.Trim()) + |> Array.filter (System.String.IsNullOrWhiteSpace >> not) + |> Array.map (fun x -> x.[0],x.[1..].Trim().Split '\t') + |> Array.map (fun (ch,strs) -> + let info = + strs + |> Array.map (fun x -> + x.Split '=' + |> Array.item 1 + |> uint16) + ch,info) + |> Array.map (fun (ch,info) ->{ + Ch = ch + FaceID = info.[0] + Sprite = { + x = info.[1] + y = info.[2] + w = info.[3] + h = info.[4] + }}) + |> Array.groupBy (fun x -> x.FaceID) + |> dict + +let private ConvertFont (job:Job) = + let fontIndex = ParseFontIndex (job.ScriptDir.FullName + "\\" + job.Input.Head + "\\font.txt") + let biggestFaceID = fontIndex.Keys |> Seq.max + + [|0us..biggestFaceID|] + |> Array.Parallel.iteri (fun _ faceID -> + let chars = fontIndex.[faceID] + let ctxJob = { + Input = [job.ScriptDir.FullName + "\\" + job.Input.Head + "\\font" + string faceID + ".bmp"] + OutputPath = job.OutputPath + "-" + string faceID + ".tmp" + Arguments = job.Arguments + ScriptDir = job.ScriptDir + } + + ConvertTextureFunc (chars |> Array.map (fun x -> x.Sprite)) true ctxJob) + + let charCount = fontIndex.Values |> Seq.map Array.length |> Seq.sum + let faceCount = fontIndex.Keys.Count + + let faceInfoChunks = Array.init (12*faceCount) (fun _ -> 0uy) + + use out = File.OpenWrite job.OutputPath + use writer = new BinaryWriter(out) + writer.Write (uint16 charCount) + writer.Write (uint16 faceCount) + + writer.Write faceInfoChunks + + fontIndex.Values + |> Seq.iter ( + Array.iteri (fun i ch -> + writer.Write (Encoding.Unicode.GetBytes (string ch.Ch)) + writer.Write (uint16 ch.FaceID) + writer.Write (uint16 i))) + + use faceInfosStream = new MemoryStream(faceInfoChunks) + use faceInfosWriter = new BinaryWriter(faceInfosStream) + for faceID in 0us..biggestFaceID do + let tmpFilePath = job.OutputPath + "-" + string faceID + ".tmp" + let bytes = File.ReadAllBytes tmpFilePath + File.Delete tmpFilePath + + faceInfosWriter.Write (uint32 faceID) + faceInfosWriter.Write (writer.BaseStream.Position |> uint32) + faceInfosWriter.Write (bytes |> Array.length |> uint32) + writer.Write bytes + faceInfosWriter.Flush () + faceInfosWriter.Close () + faceInfosStream.Close () + + writer.BaseStream.Position <- 4L + writer.Write faceInfoChunks + writer.Flush () + writer.Close () + out.Close () + +[] +let BuildFont = { + help = "从图片字模构建字体文件" + usage = [] + example = [] + action = fun ctx script -> + Utils.verifyArgumentCount script 2 + let out = script.arguments.[0] |> Utils.applyContextToArgument ctx + let input = script.arguments.[1] |> Utils.applyContextToArgument ctx + + seq { { + dirty = false + source = script + inputFiles = Utils.normalizeDirPath script.scriptFile.Directory.FullName + input |> Directory.EnumerateFiles |> Seq.map FileInfo + outputFiles = seq { out } + run = fun () -> + lock stdout (fun () -> printfn "BuildFont:%s..." input) + ConvertFont { + Arguments = [ "R8" ] + Input = [ input ] + ScriptDir = script.scriptFile.Directory + OutputPath = out + } + } }, + ctx + +} + diff --git a/Bake.Snowing/ConvertTexture.fs b/Bake.Snowing/ConvertTexture.fs index b01c81e..a046f06 100644 --- a/Bake.Snowing/ConvertTexture.fs +++ b/Bake.Snowing/ConvertTexture.fs @@ -218,7 +218,7 @@ let ConvertTexture = { usage = [] example = [] action = fun ctx script -> - let outDir = script.arguments.Head |> Utils.applyContextToArgument ctx + let outDir = script.arguments.Head |> Utils.applyContextToArgument ctx |> Utils.normalizeDirPath let arguments = script.arguments.[1..script.arguments.Length-2] |> List.map (Utils.applyContextToArgument ctx) let inputFiles = List.last script.arguments |> Utils.applyContextToArgument ctx diff --git a/Bake.Snowing/PackSprite.fs b/Bake.Snowing/PackSprite.fs new file mode 100644 index 0000000..ffcd933 --- /dev/null +++ b/Bake.Snowing/PackSprite.fs @@ -0,0 +1,96 @@ +module JobProcs.PackSprite + +open System.IO + +open Bake +open Bake.Snowing.ConvertTexture +open Newtonsoft.Json +open Newtonsoft.Json.Linq + +let CallTextureMerger inputDir outputFilePair = + let textureMerger = + [ + for i in 'C'..'Z' -> + string i + ":\\Program Files\\Egret\\TextureMerger\\TextureMerger.exe" ] + |> List.filter File.Exists + |> function + | s :: _ -> s + | [] -> + failwith "Can not find TextureMerger" + sprintf "-p \"%s\" -o \"%s.json\"" inputDir outputFilePair + |> StartWait textureMerger + WaitForFile 60 (outputFilePair + ".json") + WaitForFile 60 (outputFilePair + ".png") + +let private spriteLock = obj() + +let private PackSpriteFunc (job:Job) = + lock spriteLock (fun () -> + CallTextureMerger (job.ScriptDir.FullName + "\\" + job.Input.Head) job.OutputPath + let frames = + using (new JsonTextReader(File.OpenText(job.OutputPath + ".json"))) (fun x -> + let token = JToken.ReadFrom x + let frames = token.["frames"] + [ for i in frames -> + uint16 i.Path.[7..], + { + x = uint16 i.First.["x"] + y = uint16 i.First.["y"] + w = uint16 i.First.["w"] + h = uint16 i.First.["h"] + }]) + |> List.sortBy (fun (a,_) -> a) + + let spriteFrames = + let maxFrameID = + frames + |> List.maxBy (fun (a,_) -> a) + |> fst + let ret = + Array.init (maxFrameID |> int |> (+) 1) (fun x -> { x = 0us; y = 0us; w = 0us;h = 0us }) + frames + |> List.iter (fun (id,frame) -> + ret.[int id] <- frame) + ret |> Array.toList + + let newJob = { + Input = [ job.OutputPath + ".png" ] + OutputPath = job.OutputPath + Arguments = job.Arguments + ScriptDir = job.ScriptDir + } + + ConvertTextureFunc spriteFrames true newJob + + File.Delete (job.OutputPath + ".json") + File.Delete (job.OutputPath + ".png")) + + +[] +let PackSprite = { + help = "从图片文件夹构建精灵文件" + usage = [] + example = [] + action = fun ctx script -> + let out = script.arguments.[0] |> Utils.applyContextToArgument ctx + let input = script.arguments |> List.last |> Utils.applyContextToArgument ctx + let options = script.arguments.[1..script.arguments.Length-2] + + seq { { + dirty = false + source = script + inputFiles = Utils.normalizeDirPath script.scriptFile.Directory.FullName + input |> Directory.EnumerateFiles |> Seq.map FileInfo + outputFiles = seq { out } + run = fun () -> + lock stdout (fun () -> printfn "PackSprite:%s..." input) + PackSpriteFunc { + Arguments = options + Input = [ input ] + ScriptDir = script.scriptFile.Directory + OutputPath = FileInfo(out).FullName + } + } }, + ctx + +} + diff --git a/Snowing.sln b/Snowing.sln index b42a1b6..fa97936 100644 --- a/Snowing.sln +++ b/Snowing.sln @@ -34,8 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{30AA EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{2D9ECDC6-7F73-4991-8AB3-271D36F872BB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BGMPlayer", "BGMPlayer\BGMPlayer.vcxproj", "{7CDAD54A-D204-4907-B516-25A5F2061CAE}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\HelloWorld.vcxproj", "{85496E07-C508-46ED-89CE-F5D4A4AB5483}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Particle", "Particle\Particle.vcxproj", "{D1D71E00-3887-4EEE-9BD3-26D1D86490B7}" @@ -58,7 +56,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Fyee", "Fyee\Fyee.vcxitems" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FyeeDemo", "FyeeDemo\FyeeDemo.vcxproj", "{DBB0F9BE-CA10-4843-B892-17574B5B6983}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Bake.Snowing", "Bake.Snowing\Bake.Snowing.fsproj", "{A92673C4-2100-4A21-857C-16D56468E798}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Bake.Snowing", "Bake.Snowing\Bake.Snowing.fsproj", "{A92673C4-2100-4A21-857C-16D56468E798}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -67,7 +65,6 @@ Global Core\Core.vcxitems*{3fefea2b-2598-4299-811b-78935b1e2a10}*SharedItemsImports = 4 Core\Core.vcxitems*{677edd27-8b75-4181-82bc-cec96b71d683}*SharedItemsImports = 4 Core\Core.vcxitems*{6fc916c6-4f90-4f04-8822-7fa924836c0a}*SharedItemsImports = 4 - Core\Core.vcxitems*{7cdad54a-d204-4907-b516-25a5f2061cae}*SharedItemsImports = 4 Core\Core.vcxitems*{85496e07-c508-46ed-89ce-f5d4a4ab5483}*SharedItemsImports = 4 Yukimi\Yukimi.vcxitems*{8ecf6d8f-86cd-47e4-befd-3e80aafc3bc0}*SharedItemsImports = 9 Core\Core.vcxitems*{917aa553-454b-4ff9-a680-da5d7feb59a8}*SharedItemsImports = 9 @@ -202,16 +199,6 @@ Global {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|x64.Build.0 = Release|Any CPU {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|x86.ActiveCfg = Release|Any CPU {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|x86.Build.0 = Release|Any CPU - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Debug|x64.ActiveCfg = Debug|x64 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Debug|x64.Build.0 = Debug|x64 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Debug|x86.ActiveCfg = Debug|Win32 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Debug|x86.Build.0 = Debug|Win32 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Release|Any CPU.ActiveCfg = Release|Win32 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Release|x64.ActiveCfg = Release|x64 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Release|x64.Build.0 = Release|x64 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Release|x86.ActiveCfg = Release|Win32 - {7CDAD54A-D204-4907-B516-25A5F2061CAE}.Release|x86.Build.0 = Release|Win32 {85496E07-C508-46ED-89CE-F5D4A4AB5483}.Debug|Any CPU.ActiveCfg = Debug|Win32 {85496E07-C508-46ED-89CE-F5D4A4AB5483}.Debug|x64.ActiveCfg = Debug|x64 {85496E07-C508-46ED-89CE-F5D4A4AB5483}.Debug|x64.Build.0 = Debug|x64 @@ -323,7 +310,6 @@ Global {6FC916C6-4F90-4F04-8822-7FA924836C0A} = {30AA46A1-BF9D-4317-B419-40BE16FF82BD} {96B98788-122F-4A37-8F0C-8472CAC072DE} = {30AA46A1-BF9D-4317-B419-40BE16FF82BD} {9819E64A-728D-48E9-BE7A-CC7FE678D97F} = {30AA46A1-BF9D-4317-B419-40BE16FF82BD} - {7CDAD54A-D204-4907-B516-25A5F2061CAE} = {2D9ECDC6-7F73-4991-8AB3-271D36F872BB} {85496E07-C508-46ED-89CE-F5D4A4AB5483} = {2D9ECDC6-7F73-4991-8AB3-271D36F872BB} {D1D71E00-3887-4EEE-9BD3-26D1D86490B7} = {2D9ECDC6-7F73-4991-8AB3-271D36F872BB} {E53B8B36-214E-4419-92AC-05AE39D70531} = {2D9ECDC6-7F73-4991-8AB3-271D36F872BB} diff --git a/TestWindows/TestWindows.vcxproj b/TestWindows/TestWindows.vcxproj index 5aac475..21ea307 100644 --- a/TestWindows/TestWindows.vcxproj +++ b/TestWindows/TestWindows.vcxproj @@ -67,7 +67,6 @@ - Create Create diff --git a/TestWindows/TestWindows.vcxproj.filters b/TestWindows/TestWindows.vcxproj.filters index 38eaf87..f191148 100644 --- a/TestWindows/TestWindows.vcxproj.filters +++ b/TestWindows/TestWindows.vcxproj.filters @@ -12,7 +12,6 @@ - diff --git a/TestWindows/XAudio2.cpp b/TestWindows/XAudio2.cpp deleted file mode 100644 index 925067a..0000000 --- a/TestWindows/XAudio2.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "pch.h" -#include "Platforms.h" -#include - -using namespace std::chrono; - -static void PlayXAudio(const wchar_t* testName,const char* name,std::chrono::milliseconds secs,uint32_t begin = 0,float speed = 1.0f) -{ - WindowImpl window{ testName ,WinSize }; - D3D::Device device{ window.GetHWND(),true }; - Engine engine{ Snowing::Engine::ConstructToken{} }; - - PlatformImpls::WindowsImpl::XAudio2::XADevice audDev; - if (!audDev.Avaliable()) return; - assert(&audDev.Get() == &audDev); - - Blob blob = LoadAsset(name); - Audio::SoundPlayer player; - player.Play(&blob,begin); - player.SetSpeed(speed); - - std::chrono::high_resolution_clock clk; - auto beg = clk.now(); - engine.Run([&clk, beg, secs] { - if (clk.now() - beg > secs) - Engine::Get().Exit(); - }); -} - -TEST(XAudio2Test, PlayBGMBegin) -{ - PlayXAudio(L"TestPlayBGM", "Dir/Sound/ExBoss.snd", 500ms,3000000,100); -} - -TEST(XAudio2Test, PlayHeadOnly) -{ - PlayXAudio(L"TestPlayHeadOnly","Dir/Sound/HeadOnly.snd",700ms,0,100); -} - -TEST(XAudio2Test, PlayLoopOnly) -{ - PlayXAudio(L"TestPlayLoopOnly","Dir/Sound/LoopOnly.snd",1000ms,0,100); -} - -TEST(XAudio2Test, MultiSound_Breakpoint_Pan) -{ - WindowImpl window{ L"MultiSound" ,WinSize }; - D3D::Device device{ window.GetHWND(),true }; - Engine engine{ Snowing::Engine::ConstructToken{} }; - - PlatformImpls::WindowsImpl::XAudio2::XADevice audDev; - assert(&audDev.Get() == &audDev); - - Blob bo1{ LoadAsset("Dir/Sound/ExBoss.snd") }, bo2{ LoadAsset("Dir/Sound/HeadOnly.snd") }; - Audio::SoundPlayer player; - player.SetVolume(1); - player.SetPan(1); - player.Play(&bo1); - - Audio::SoundPlayer player2; - player2.Play(&bo2); - - std::chrono::high_resolution_clock clk; - auto beg = clk.now(); - std::uint32_t breakPoint = 0; - - Font font = LoadFont(LoadAsset("Font-chs.fnt")); - Graphics::Effect eff{ LoadAsset("HiLevelRendering") }; - Graphics::EffectTech tech1 = eff.LoadTechnique("FontTestBasic", Sprite::DataLayout); - - Scene::Debug::DebugDisplay playing( - &tech1, &font, L"Player2 is playing", [&player2] { - return std::to_wstring(reinterpret_cast(player2.GetPlaying())); - }); - - Scene::Debug::DebugDisplay playpos( - &tech1, &font, L"Player1 position", [&player] { - return std::to_wstring(player.GetPosition()); - }); - - bool b1 = true, b2 = true, b3 = true; - engine.Run([&] { - if (clk.now() - beg > 2s) - Engine::Get().Exit(); - - auto& g = Device::Get(); - auto& rt = g.MainRenderTarget(); - g.MainContext().ClearRenderTarget(rt, { 0.0f,0.0f,1.0f,1.0f }); - g.MainContext().SetRenderTarget(&rt); - - playing.Update(); - playpos.Update(); - - if (clk.now() - beg > 500ms && b1) - { - b1 = false; - breakPoint = player.Stop(); - } - - if (clk.now() - beg > 1s && b2) - { - b2 = false; - player.SetPan(-1); - player.Play(&bo1,breakPoint); - } - - if (clk.now() - beg > 1500ms && b3) - { - b3 = false; - player.SetPan(0); - player.SetVolume(0.05f); - player.SetSpeed(2.0f); - } - }); -} \ No newline at end of file diff --git a/TestWindowsLive2D/LipSync.cpp b/TestWindowsLive2D/LipSync.cpp deleted file mode 100644 index 97d93dc..0000000 --- a/TestWindowsLive2D/LipSync.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "pch.h" - -void LipSyncTest(const char* home, const char* entryJson,float height) -{ - auto engine = - PlatformImpls::WindowsImpl::MakeEngine(L"LipSync.LipSyncTest", { 800,600 }, true); - - PlatformImpls::WindowsImpl::XAudio2::XADevice d; - - Graphics::Device::MainContext().SetRenderTarget( - &Graphics::Device::MainRenderTarget()); - - auto font = LoadFont(LoadAsset("Font-chs.fnt")); - Effect eff{ LoadAsset("DebugDisplay.cso") }; - auto tech = eff.LoadTechnique("DebugDisplay", Sprite::DataLayout); - - Live2D::Device device; - - Live2D::ModelAsset ass{ home,entryJson }; - - Scene::Group<> s; - - s.Emplace( - &Graphics::Device::MainContext(), - &Graphics::Device::MainRenderTarget(), - Math::Vec4f{ 0,0,0,0 }); - - auto model = s.Emplace( - &Graphics::Device::MainContext(), - &ass, - 800.0f / 600.0f); - - auto lipSync = s.Emplace( - model); - - model->SetTranslate({ 0,-height }); - model->SetScale({ 4.0F,4.0F }); - - auto sound = LoadAsset("Dir/Sound/HeadOnly.snd"); - - Audio::SoundPlayer soundPlayer; - - s.Emplace(2.0f, [&] { - soundPlayer.Play(&sound); - }); - - s.Emplace([lipSync,&soundPlayer] { - const float t = soundPlayer.GetRealtimeVolume(); - Snowing::Log(t); - lipSync->SetVolume(t * 2); - return true; - }); - - s.Emplace(5.0f,[] { - Snowing::Engine::Get().Exit(); - }); - - - - s.Emplace( - &tech, &font, L"RealtimeVolume", [&] { - return std::to_wstring(soundPlayer.GetRealtimeVolume()); - }); - - Snowing::Engine::Get().RunObject(s); -} - -TEST(LipSync, Haru) -{ - LipSyncTest("Live2D/Haru/", "Haru.model3.json", 2.7f); -} - -TEST(LipSync, Hiyori) -{ - LipSyncTest("Live2D/Hiyori/", "Hiyori.model3.json", 1.7f); -} - diff --git a/TestWindowsLive2D/TestWindowsLive2D.vcxproj b/TestWindowsLive2D/TestWindowsLive2D.vcxproj index 989563a..dc2749f 100644 --- a/TestWindowsLive2D/TestWindowsLive2D.vcxproj +++ b/TestWindowsLive2D/TestWindowsLive2D.vcxproj @@ -60,7 +60,6 @@ - Create diff --git a/TestYukimi/Audio.cpp b/TestYukimi/Audio.cpp deleted file mode 100644 index 687a602..0000000 --- a/TestYukimi/Audio.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "pch.h" -#include "AudioChannel.h" -#include "SEPlayer.h" -#include "CVPlayer.h" -using namespace Snowing; -using namespace Yukimi; - -constexpr auto AudioLoader = [] (auto s) { return Snowing::LoadAsset(s); }; - -TEST(Audio, AudioChannel) -{ - auto engine = - PlatformImpls::WindowsImpl::MakeEngine(L"Audio.AudioChannel", { 400,300 }, true); - - PlatformImpls::WindowsImpl::XAudio2::XADevice x; - - Font font = LoadFont(LoadAsset("Font-chs.fnt")); - Graphics::Effect eff{ LoadAsset("FontRendering.cso") }; - Graphics::EffectTech tech1 = eff.LoadTechnique("Font", Sprite::DataLayout); - - Scene::Group<> scene; - scene.Emplace( - &Graphics::Device::MainContext(),&Graphics::Device::MainRenderTarget()); - scene.Emplace( - &tech1, &font, L"Time", Scene::Debug::DebugDisplay::FrameTimeGetter); - scene.Emplace( - &tech1, &font, L"FPS", Scene::Debug::DebugDisplay::FPSGetter); - scene.Emplace( - &tech1, &font, L"Scene Objs", [&scene] { return std::to_wstring(scene.Count()); }); - - scene.Emplace(0.5f,[&] { - scene.Emplace(AudioLoader,"Dir/Sound/ExBoss.snd", 0.5f, 90000u); - scene.Emplace(0.5f, [&] { - scene.IterType([](auto & player) { - player.Pause(0.5f); - }); - }); - - scene.Emplace(1.0f, [&] { - scene.IterType([](auto & player) { - player.Resume(0.5f); - }); - }); - - scene.Emplace(2.0f, [&] { - scene.IterType([](auto & player) { - player.Stop(0.5f); - }); - }); - }); - - - scene.Emplace(3.5f, [&] { - Engine::Get().Exit(); - }); - - Engine::Get().RunObject(scene); -} - -TEST(Audio, SEPlayer) -{ - auto engine = - PlatformImpls::WindowsImpl::MakeEngine(L"Audio.SEPlayer", { 400,300 }, true); - - PlatformImpls::WindowsImpl::XAudio2::XADevice x; - - Font font = LoadFont(LoadAsset("Font-chs.fnt")); - Graphics::Effect eff{ LoadAsset("FontRendering.cso") }; - Graphics::EffectTech tech1 = eff.LoadTechnique("Font", Sprite::DataLayout); - - Scene::Group<> scene; - scene.Emplace(AudioLoader); - scene.Emplace( - &Graphics::Device::MainContext(), &Graphics::Device::MainRenderTarget()); - scene.Emplace( - &tech1, &font, L"Time", Scene::Debug::DebugDisplay::FrameTimeGetter); - scene.Emplace( - &tech1, &font, L"FPS", Scene::Debug::DebugDisplay::FPSGetter); - scene.Emplace( - &tech1, &font, L"Scene Objs", [&scene] { return std::to_wstring(scene.Count()); }); - - scene.Emplace(0.5f, [&] { - SEPlayer::Get().Play("Dir/Sound/HeadOnly.snd"); - - scene.Emplace(0.5f, [&] { - SEPlayer::Get().Play("Dir/Sound/HeadOnly.snd",1); - }); - - scene.Emplace(1.0f, [&] { - SEPlayer::Get().Play("Dir/Sound/HeadOnly.snd", -1); - }); - - scene.Emplace(1.5f, [&] { - SEPlayer::Get().Play("Dir/Sound/HeadOnly.snd", 1,0.5F); - }); - - scene.Emplace(2.0f, [&] { - SEPlayer::Get().Play("Dir/Sound/HeadOnly.snd", -1,0.5F); - }); - }); - - - scene.Emplace(2.5f, [&] { - Engine::Get().Exit(); - }); - - Engine::Get().RunObject(scene); -} - -TEST(Audio, CVPlayer) -{ - auto engine = - PlatformImpls::WindowsImpl::MakeEngine(L"Audio.CVPlayer", { 400,300 }, true); - - PlatformImpls::WindowsImpl::XAudio2::XADevice x; - - Font font = LoadFont(LoadAsset("Font-chs.fnt")); - Graphics::Effect eff{ LoadAsset("FontRendering.cso") }; - Graphics::EffectTech tech1 = eff.LoadTechnique("Font", Sprite::DataLayout); - - Scene::Group<> scene; - auto cv = scene.Emplace(AudioLoader); - scene.Emplace( - &Graphics::Device::MainContext(), &Graphics::Device::MainRenderTarget()); - scene.Emplace( - &tech1, &font, L"Time", Scene::Debug::DebugDisplay::FrameTimeGetter); - scene.Emplace( - &tech1, &font, L"FPS", Scene::Debug::DebugDisplay::FPSGetter); - scene.Emplace( - &tech1, &font, L"Scene Objs", [&scene] { return std::to_wstring(scene.Count()); }); - - scene.Emplace(0.5f, [&, cv] { - cv->Play("Dir/Sound/HeadOnly.snd"); - }); - - scene.Emplace(0.75f, [&, cv] { - auto& player = *cv; - player.Play("Dir/Sound/HeadOnly.snd"); - player.VolumeDown(); - }); - - scene.Emplace(1.0f, [&, cv] { - auto& player = *cv; - player.Play("Dir/Sound/HeadOnly.snd"); - - }); - - scene.Emplace(2.5f, [&] { - Engine::Get().Exit(); - }); - - Engine::Get().RunObject(scene); -} diff --git a/TestYukimi/TestTextWindow.cpp b/TestYukimi/TestTextWindow.cpp index 9b35049..199dda5 100644 --- a/TestYukimi/TestTextWindow.cpp +++ b/TestYukimi/TestTextWindow.cpp @@ -191,8 +191,6 @@ constexpr TextWindowFontStyle DefaultFontStyle auto CreateShowTextScene(SimpleTextWindowAdapter& adapter) { Scene::Group<> scene; - scene.Emplace( - &Device::Get().MainContext(), &Device::Get().MainRenderTarget(), Math::Vec4f{ 0,0,0,1 }); scene.Emplace(5.0f, [] { Engine::Get().Exit(); diff --git a/TestYukimi/TestYukimi.vcxproj b/TestYukimi/TestYukimi.vcxproj index 5515873..4e17a44 100644 --- a/TestYukimi/TestYukimi.vcxproj +++ b/TestYukimi/TestYukimi.vcxproj @@ -59,7 +59,6 @@ - Create Create From 01df857a33620835ae934283b73729a1e6c177e6 Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Tue, 17 Nov 2020 14:49:32 +0800 Subject: [PATCH 4/8] Encrypt --- Bake.Snowing/Bake.Snowing.fsproj | 1 + Bake.Snowing/ConvertSound.fs | 5 +- Bake.Snowing/ConvertTexture.fs | 7 ++- Bake.Snowing/Encrypt.fs | 80 ++++++++++++++++++++++++++++++++ Bake.Snowing/PackSprite.fs | 4 ++ 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 Bake.Snowing/Encrypt.fs diff --git a/Bake.Snowing/Bake.Snowing.fsproj b/Bake.Snowing/Bake.Snowing.fsproj index 5114942..29fc2c1 100644 --- a/Bake.Snowing/Bake.Snowing.fsproj +++ b/Bake.Snowing/Bake.Snowing.fsproj @@ -8,6 +8,7 @@ PreserveNewest + diff --git a/Bake.Snowing/ConvertSound.fs b/Bake.Snowing/ConvertSound.fs index fd07a0e..fdf299a 100644 --- a/Bake.Snowing/ConvertSound.fs +++ b/Bake.Snowing/ConvertSound.fs @@ -95,7 +95,7 @@ let ConvertSound = { let tasks = blockArgumentTaskPerLine (fun _ script file -> - Utils.mapPathToOutputPath inDir file + Utils.matchInputFiles inDir file |> Seq.map (fun (path, fileName) -> let inFile = FileInfo path let outFile = outDir + fileName |> modifyExtensionName "snd" @@ -114,3 +114,6 @@ let ConvertSound = { tasks, ctx } + +[] +let ``ConvertSound-Encrypt`` = Encrypt.wrapToEncryptAction ConvertSound diff --git a/Bake.Snowing/ConvertTexture.fs b/Bake.Snowing/ConvertTexture.fs index a046f06..014cd5b 100644 --- a/Bake.Snowing/ConvertTexture.fs +++ b/Bake.Snowing/ConvertTexture.fs @@ -224,7 +224,7 @@ let ConvertTexture = { let tasks = Utils.blockArgumentTaskPerLine (fun _ script inputFiles -> - Utils.mapPathToOutputPath script.scriptFile.Directory.FullName inputFiles + Utils.matchInputFiles script.scriptFile.Directory.FullName inputFiles |> Seq.map (fun (path, fileName) -> let outFile = outDir + fileName |> Utils.modifyExtensionName "ctx" { @@ -247,4 +247,7 @@ let ConvertTexture = { inputFiles tasks, ctx -} \ No newline at end of file +} + +[] +let ``ConvertTexture-Encrypt`` = Encrypt.wrapToEncryptAction ConvertTexture diff --git a/Bake.Snowing/Encrypt.fs b/Bake.Snowing/Encrypt.fs new file mode 100644 index 0000000..3b458db --- /dev/null +++ b/Bake.Snowing/Encrypt.fs @@ -0,0 +1,80 @@ +module Bake.Snowing.Encrypt + +open Bake + +open System.Diagnostics +open System.IO +open System.Threading +open System +open System.Security.Cryptography + +let mutable private aes : System.Security.Cryptography.AesCryptoServiceProvider = null + +let EncryptFile src dst = + src + |> File.ReadAllBytes + |> fun fileBytes -> + let outputContent = Array.copy fileBytes + aes.CreateEncryptor().TransformBlock(fileBytes,0,fileBytes.Length/16*16,outputContent,0) + |> ignore + File.WriteAllBytes(dst,outputContent) + +[] +let SetAESKey = { + help = "设置AES密钥文件" + usage = [] + example = [] + action = fun ctx script -> + Utils.verifyArgumentCount script 1 + let key,iv = + "AesKey.bin" + |> File.ReadAllBytes + |> Array.splitAt 16 + aes <- new System.Security.Cryptography.AesCryptoServiceProvider () + aes.KeySize <- 128 + aes.BlockSize <- 128 + aes.Key <- key + aes.IV <- iv + + Seq.empty, ctx +} + +[] +let AESEncrypt = { + help = "对文件进行AES加密" + usage = [] + example = [] + action = fun ctx script -> + Utils.verifyArgumentCount script 3 + let dstDir = script.arguments.[0] |> Utils.applyContextToArgument ctx |> Utils.normalizeDirPath + let ext = script.arguments.[1] |> Utils.applyContextToArgument ctx + let inputFile = script.arguments.[2] |> Utils.applyContextToArgument ctx + Utils.blockArgumentTaskPerLine (fun ctx script line -> + Utils.matchInputFiles script.scriptFile.DirectoryName line + |> Seq.map (fun (path, fileName) -> + let dst = dstDir + fileName + { + inputFiles = seq { FileInfo path } + source = script + outputFiles = seq { dst } + dirty = false + run = fun () -> + lock stdout (fun () -> printfn "AESEncrypt:%s..." fileName) + EncryptFile path dst + })) ctx script inputFile + , ctx +} + +let wrapToEncryptAction (action: BakeAction) = + { action with + help = "(AES加密)" + action = fun ctx script -> + let tasks, ctx = action.action ctx script + let tasks = + tasks + |> Seq.map (fun task -> + { task with + run = fun () -> + task.run () + task.outputFiles |> Seq.toArray |> Array.Parallel.iter (fun x -> EncryptFile x x) } ) + tasks, ctx } diff --git a/Bake.Snowing/PackSprite.fs b/Bake.Snowing/PackSprite.fs index ffcd933..065f202 100644 --- a/Bake.Snowing/PackSprite.fs +++ b/Bake.Snowing/PackSprite.fs @@ -3,6 +3,7 @@ open System.IO open Bake +open Bake.Snowing open Bake.Snowing.ConvertTexture open Newtonsoft.Json open Newtonsoft.Json.Linq @@ -94,3 +95,6 @@ let PackSprite = { } + +[] +let ``PackSprite-Encrypt`` = Encrypt.wrapToEncryptAction PackSprite From 3678a74ee4f508f94a9a9f7555eb278c34077ed6 Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Tue, 17 Nov 2020 15:31:39 +0800 Subject: [PATCH 5/8] Bug fixed --- WindowsImpl/PlatformImpls.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/WindowsImpl/PlatformImpls.h b/WindowsImpl/PlatformImpls.h index ea6fac8..3cc53ab 100644 --- a/WindowsImpl/PlatformImpls.h +++ b/WindowsImpl/PlatformImpls.h @@ -58,17 +58,12 @@ namespace Snowing inline void CallAssetBuilder() { - constexpr char path[] = "../AssetBuilderRelease/AssetBuilder.exe"; +#ifdef _DEBUG constexpr char cmd[] = "start /wait /b " "/d ..\\..\\Assets " - "../AssetBuilderRelease/AssetBuilder.exe " - "../build/data"; - if (std::filesystem::exists(path)) - system(cmd); -#ifdef _DEBUG - else - Snowing::PlatformImpls::Log("Warning:Asset Build Not Found!"); + "Bake.exe"; + system(cmd); #endif } From 6348cb988a5fc4b368d55cba1e9f14b34aa9a2c6 Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Wed, 18 Nov 2020 02:50:41 +0800 Subject: [PATCH 6/8] Bug fixed --- Bake.Snowing/Encrypt.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bake.Snowing/Encrypt.fs b/Bake.Snowing/Encrypt.fs index 3b458db..b65bd20 100644 --- a/Bake.Snowing/Encrypt.fs +++ b/Bake.Snowing/Encrypt.fs @@ -40,7 +40,7 @@ let SetAESKey = { } [] -let AESEncrypt = { +let Encrypt = { help = "对文件进行AES加密" usage = [] example = [] @@ -52,14 +52,14 @@ let AESEncrypt = { Utils.blockArgumentTaskPerLine (fun ctx script line -> Utils.matchInputFiles script.scriptFile.DirectoryName line |> Seq.map (fun (path, fileName) -> - let dst = dstDir + fileName + let dst = dstDir + fileName |> Utils.modifyExtensionName ext { inputFiles = seq { FileInfo path } source = script outputFiles = seq { dst } dirty = false run = fun () -> - lock stdout (fun () -> printfn "AESEncrypt:%s..." fileName) + lock stdout (fun () -> printfn "Encrypt:%s..." fileName) EncryptFile path dst })) ctx script inputFile , ctx From 6e8372ad1480afc1ccfa7191c571ec21462a10c2 Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Thu, 19 Nov 2020 15:34:30 +0800 Subject: [PATCH 7/8] Bug fixed --- Bake.Snowing/ConvertSound.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bake.Snowing/ConvertSound.fs b/Bake.Snowing/ConvertSound.fs index fdf299a..f4c5a85 100644 --- a/Bake.Snowing/ConvertSound.fs +++ b/Bake.Snowing/ConvertSound.fs @@ -8,13 +8,13 @@ open WAVFileReader [] -type private Options = { +type Options = { Bpm : float32 BeatsPerBar : uint32 BeatsOffset : int32 } -let private PackSound scriptPath srcHead srcLoop (options:Options) (dst:string) = +let PackSound scriptPath srcHead srcLoop (options:Options) (dst:string) = if File.Exists dst then failwith ("Sound file " + dst + " is already exists.") @@ -63,7 +63,7 @@ let private PackSound scriptPath srcHead srcLoop (options:Options) (dst:string) -let private GetOptions argumentStrList = +let GetOptions argumentStrList = let defaultOption = { Bpm = 120.0f BeatsPerBar = 4u From d0a1da5ab16f3fe8b373af7e4bafcb4df1621a07 Mon Sep 17 00:00:00 2001 From: Seng Jik <853974536@qq.com> Date: Fri, 20 Nov 2020 16:01:08 +0800 Subject: [PATCH 8/8] bug fixed --- AssetBuilder/App.config | 6 - AssetBuilder/AssetBuilder.fs | 37 ---- AssetBuilder/AssetBuilder.fsproj | 97 ---------- AssetBuilder/BuildScriptParser.fs | 89 --------- AssetBuilder/Job.fs | 29 --- AssetBuilder/JobProcs/ConvertFont.fs | 108 ----------- AssetBuilder/JobProcs/ConvertTexture.fs | 179 ------------------- AssetBuilder/JobProcs/CopyFile.fs | 16 -- AssetBuilder/JobProcs/GenerateVersionText.fs | 13 -- AssetBuilder/JobProcs/JobProcs.fs | 66 ------- AssetBuilder/JobProcs/MakeDir.fs | 16 -- AssetBuilder/JobProcs/PackSound.fs | 98 ---------- AssetBuilder/JobProcs/PackSprite.fs | 77 -------- AssetBuilder/JobProcs/RunCommand.fs | 29 --- AssetBuilder/ProcRunner.fs | 114 ------------ AssetBuilder/Utils.fs | 45 ----- AssetBuilder/packages.config | 6 - AssetBuilder/texconv.exe | 3 - Assets/BasicAssets/BuildScript.txt | 1 - Assets/BuildScript.txt | 44 ----- Assets/ExampleAssets/BuildScript.txt | 6 - Assets/ExampleAssets/Sound/ExBoss_Head.wav | 3 - Assets/ExampleAssets/Sound/ExBoss_Loop.wav | 3 - Assets/ExampleAssets/Sound/SoundEffect.wav | 3 - Assets/ExampleAssets/Sound/SoundScript.txt | 11 -- Assets/Live2DAssetBuildScript.txt | 88 --------- Readme.md | 20 ++- Snowing.sln | 14 -- 28 files changed, 12 insertions(+), 1209 deletions(-) delete mode 100644 AssetBuilder/App.config delete mode 100644 AssetBuilder/AssetBuilder.fs delete mode 100644 AssetBuilder/AssetBuilder.fsproj delete mode 100644 AssetBuilder/BuildScriptParser.fs delete mode 100644 AssetBuilder/Job.fs delete mode 100644 AssetBuilder/JobProcs/ConvertFont.fs delete mode 100644 AssetBuilder/JobProcs/ConvertTexture.fs delete mode 100644 AssetBuilder/JobProcs/CopyFile.fs delete mode 100644 AssetBuilder/JobProcs/GenerateVersionText.fs delete mode 100644 AssetBuilder/JobProcs/JobProcs.fs delete mode 100644 AssetBuilder/JobProcs/MakeDir.fs delete mode 100644 AssetBuilder/JobProcs/PackSound.fs delete mode 100644 AssetBuilder/JobProcs/PackSprite.fs delete mode 100644 AssetBuilder/JobProcs/RunCommand.fs delete mode 100644 AssetBuilder/ProcRunner.fs delete mode 100644 AssetBuilder/Utils.fs delete mode 100644 AssetBuilder/packages.config delete mode 100644 AssetBuilder/texconv.exe delete mode 100644 Assets/BasicAssets/BuildScript.txt delete mode 100644 Assets/BuildScript.txt delete mode 100644 Assets/ExampleAssets/BuildScript.txt delete mode 100644 Assets/ExampleAssets/Sound/ExBoss_Head.wav delete mode 100644 Assets/ExampleAssets/Sound/ExBoss_Loop.wav delete mode 100644 Assets/ExampleAssets/Sound/SoundEffect.wav delete mode 100644 Assets/ExampleAssets/Sound/SoundScript.txt delete mode 100644 Assets/Live2DAssetBuildScript.txt diff --git a/AssetBuilder/App.config b/AssetBuilder/App.config deleted file mode 100644 index 731f6de..0000000 --- a/AssetBuilder/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AssetBuilder/AssetBuilder.fs b/AssetBuilder/AssetBuilder.fs deleted file mode 100644 index 9bfff8c..0000000 --- a/AssetBuilder/AssetBuilder.fs +++ /dev/null @@ -1,37 +0,0 @@ -open System.IO -open System -open System.Diagnostics - - -[] -let main args = - try - let timer = Stopwatch () - timer.Start () - try - Console.SetWindowSize(90,40) - with _ -> () - let OutputPath = - if Directory.Exists (Array.head args) then - DirectoryInfo(Array.head args) - else - Directory.CreateDirectory (Array.head args) - - let Jobs = - BuildScriptParser.ParseBuildScript OutputPath.FullName "BuildScript.txt" - - ProcRunner.RunProcs Jobs (OutputPath.FullName) - - printfn "" - printfn "Build Time:%A" timer.Elapsed - 0 - with - | :?FileNotFoundException -> - printfn "BuildScript.txt not found!" - -1 - | e -> - printfn "Error:" - printfn "%A" e - printfn "=========" - printfn "Command Line: AssetBuilder outputPath" - -1 diff --git a/AssetBuilder/AssetBuilder.fsproj b/AssetBuilder/AssetBuilder.fsproj deleted file mode 100644 index b8e5be1..0000000 --- a/AssetBuilder/AssetBuilder.fsproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - bf7f2ba8-9a61-4d2d-8b0a-37fd17b74ba1 - Exe - AssetBuilder - AssetBuilder - v4.6.1 - true - true - AssetBuilder - - - true - full - false - false - $(SolutionDir)build\AssetBuilder$(Configuration)\ - $(SolutionDir)build\objs\AssetBuilder$(Configuration) - DEBUG;TRACE - 3 - AnyCPU - - - true - $(SolutionDir)build\data - $(SolutionDir)Assets\ - - - pdbonly - true - true - $(SolutionDir)build\AssetBuilder$(Configuration) - $(SolutionDir)build\objs\AssetBuilder$(Configuration) - TRACE - 3 - AnyCPU - - - true - $(SolutionDir)build\data - $(SolutionDir)Assets\ - - - 11 - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - $(SolutionDir)packages\FSharp.Core.4.6.0\lib\net45\FSharp.Core.dll - - - - $(SolutionDir)packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll - - - - - $(SolutionDir)packages\WAVFileReader.1.0.0\lib\netstandard2.0\WAVFileReader.dll - - - - \ No newline at end of file diff --git a/AssetBuilder/BuildScriptParser.fs b/AssetBuilder/BuildScriptParser.fs deleted file mode 100644 index e2a69b2..0000000 --- a/AssetBuilder/BuildScriptParser.fs +++ /dev/null @@ -1,89 +0,0 @@ -module BuildScriptParser - -open JobProcs - -let rec ParseBuildScript baseOutputPath scriptFilePath = - - let scriptInfo = - System.IO.FileInfo scriptFilePath - - let makeJob command args input output encrypt : Job.Job = { - Processor = JobProcs.FindProcByCommand command |> Option.get - Input = input |> Array.toList - OutputPath = baseOutputPath + "\\" + output - Arguments = args |> Array.toList - ScriptDir = scriptInfo.Directory - ScriptFile = scriptInfo - Encrypt = encrypt } - - scriptFilePath - |> System.IO.File.ReadAllLines - |> Array.map (fun x -> x + "#") - |> Array.map (fun x -> x.[0..x.IndexOf '#' - 1]) - |> Array.map (fun x -> x.Trim()) - |> Array.filter (not << System.String.IsNullOrWhiteSpace) - |> Array.map (fun x -> - let pos = - match x.IndexOf '(',x.IndexOf '[' with - | a,-1 -> a - | -1,b -> b - | a,_ -> a - x.[0..pos-1],x.[pos..]) - - |> Array.map (fun (command,args) -> - match args.IndexOf '(' with - | -1 -> command,"",args - | pos -> command,args.[pos+1..args.IndexOf ')' - 1],args.[args.IndexOf ')'+1..]) - - |> Array.map (fun (command,args,io) -> - let iPos = io.IndexOf '[' - let oPos = io.IndexOf ']' - command,args,io.[iPos+1..oPos-1],io.[oPos+1..]) - - |> Array.map (fun (command,args,input,output) -> - let p = output.IndexOf '[' - let output = - match p with - | -1 -> "" - | x -> - let q = output.IndexOf ']' - output.[p+1..q-1] - command,args,input,output) - - |> Array.map (fun (command,args,input,output) -> - command.Trim(), - args.Split ',' |> Array.map (fun x -> x.Trim()), - input.Split ',' |> Array.map (fun x -> x.Trim()), - output.Trim()) - - |> Array.collect (fun (cmdWithEncryptFlag,args,i,o) -> - let encrypt = cmdWithEncryptFlag.StartsWith "*" - let cmd = - if encrypt then cmdWithEncryptFlag.[1..] - else cmdWithEncryptFlag - match cmd with - | "Include" -> - scriptInfo.DirectoryName + "\\" + (Array.head i) - |> ParseBuildScript baseOutputPath - | "Batch" -> - System.IO.Directory.EnumerateFiles(scriptInfo.DirectoryName,i.[0],System.IO.SearchOption.AllDirectories) - |> Seq.cast - |> Seq.map (fun (x:string) -> x.[1+scriptInfo.DirectoryName.Length..]) - |> Seq.map (fun path -> - let fileName = - let n = - System.IO.FileInfo(path).Name - o + "\\" + n.[.. -1 + n.IndexOf '.'] + "." + args.[1] - makeJob args.[0] args.[2..] [|path|] fileName encrypt) - |> Seq.toArray - - | _ when JobProcs.JobProcs.FindProcByCommand cmd |> Option.isSome -> - let j = makeJob cmd args i o encrypt - match j.Processor.Command with - | "Custum" -> - j.Processor.Proc j - [||] - | _ -> [| j |] - | x -> failwith ("Unknown command:" + x)) - - \ No newline at end of file diff --git a/AssetBuilder/Job.fs b/AssetBuilder/Job.fs deleted file mode 100644 index ebf74a8..0000000 --- a/AssetBuilder/Job.fs +++ /dev/null @@ -1,29 +0,0 @@ -module Job - -open System.IO - -type InputType = -| File -| Files -| Directory -| None - -type JobProc = { - Proc : Job -> unit - InputType : InputType - Command : string - FinishLogEnabled : bool - Prority : int -} - -and Job = { - Processor : JobProc - Input : string list - OutputPath : string - Arguments : string list - ScriptDir : DirectoryInfo - ScriptFile : FileInfo - Encrypt : bool -} - - diff --git a/AssetBuilder/JobProcs/ConvertFont.fs b/AssetBuilder/JobProcs/ConvertFont.fs deleted file mode 100644 index c24011e..0000000 --- a/AssetBuilder/JobProcs/ConvertFont.fs +++ /dev/null @@ -1,108 +0,0 @@ -module JobProcs.ConvertFont - -open System.IO -open Job -open JobProcs.ConvertTexture -open System.Text - -type CharInfo = { - Ch : char - FaceID : uint16 - Sprite : SpriteFrame -} - -let private ParseFontIndex txtPath = - txtPath - |> File.ReadAllLines - |> Array.map (fun x -> x.Trim()) - |> Array.filter (System.String.IsNullOrWhiteSpace >> not) - |> Array.map (fun x -> x.[0],x.[1..].Trim().Split '\t') - |> Array.map (fun (ch,strs) -> - let info = - strs - |> Array.map (fun x -> - x.Split '=' - |> Array.item 1 - |> uint16) - ch,info) - |> Array.map (fun (ch,info) ->{ - Ch = ch - FaceID = info.[0] - Sprite = { - x = info.[1] - y = info.[2] - w = info.[3] - h = info.[4] - }}) - |> Array.groupBy (fun x -> x.FaceID) - |> dict - -let private ConvertFont (job:Job) = - let fontIndex = ParseFontIndex (job.ScriptDir.FullName + "\\" + job.Input.Head + "\\font.txt") - let biggestFaceID = fontIndex.Keys |> Seq.max - - [|0us..biggestFaceID|] - |> Array.Parallel.iteri (fun _ faceID -> - let chars = fontIndex.[faceID] - let ctxJob = { - Processor = JobProcs.ConvertTexture.Proc - Input = [job.ScriptDir.FullName + "\\" + job.Input.Head + "\\font" + string faceID + ".bmp"] - OutputPath = job.OutputPath + "-" + string faceID + ".tmp" - Arguments = job.Arguments - ScriptDir = job.ScriptDir - ScriptFile = job.ScriptFile - Encrypt = false - } - - ConvertTexture (chars |> Array.map (fun x -> x.Sprite)) true ctxJob) - - let charCount = fontIndex.Values |> Seq.map Array.length |> Seq.sum - let faceCount = fontIndex.Keys.Count - - let faceInfoChunks = Array.init (12*faceCount) (fun _ -> 0uy) - - use out = File.OpenWrite job.OutputPath - use writer = new BinaryWriter(out) - writer.Write (uint16 charCount) - writer.Write (uint16 faceCount) - - writer.Write faceInfoChunks - - fontIndex.Values - |> Seq.iter ( - Array.iteri (fun i ch -> - writer.Write (Encoding.Unicode.GetBytes (string ch.Ch)) - writer.Write (uint16 ch.FaceID) - writer.Write (uint16 i))) - - use faceInfosStream = new MemoryStream(faceInfoChunks) - use faceInfosWriter = new BinaryWriter(faceInfosStream) - for faceID in 0us..biggestFaceID do - let tmpFilePath = job.OutputPath + "-" + string faceID + ".tmp" - let bytes = File.ReadAllBytes tmpFilePath - File.Delete tmpFilePath - - faceInfosWriter.Write (uint32 faceID) - faceInfosWriter.Write (writer.BaseStream.Position |> uint32) - faceInfosWriter.Write (bytes |> Array.length |> uint32) - writer.Write bytes - faceInfosWriter.Flush () - faceInfosWriter.Close () - faceInfosStream.Close () - - writer.BaseStream.Position <- 4L - writer.Write faceInfoChunks - writer.Flush () - writer.Close () - out.Close () - - - -let Proc = { - Proc = ConvertFont - InputType = InputType.Directory - Command = "ConvertFont" - FinishLogEnabled = true - Prority = 100 -} - diff --git a/AssetBuilder/JobProcs/ConvertTexture.fs b/AssetBuilder/JobProcs/ConvertTexture.fs deleted file mode 100644 index 073c441..0000000 --- a/AssetBuilder/JobProcs/ConvertTexture.fs +++ /dev/null @@ -1,179 +0,0 @@ -module JobProcs.ConvertTexture - -open Job -open System.IO -open System.Drawing -open System - -type TextureFormat = -| R8G8B8A8_UNORM = 0uy -| R8_UNORM = 1uy -| DDS = 2uy - -type RequestedTextureFormat = -| RGBA32 -| R8 -| DDS of string - -let Is4MulBitmap (bitmap:Bitmap) = - bitmap.Width % 4 = 0 && bitmap.Height % 4 = 0 - -let WrapBitmapTo4 (bitmap:Bitmap) = - let wrapTo4 x = - (4 - (x % 4)) % 4 + x - - let newSize = - (wrapTo4 bitmap.Size.Width,wrapTo4 bitmap.Size.Height) - let newBitmap = new Bitmap(fst newSize,snd newSize) - for y in 0..bitmap.Height-1 do - for x in 0..bitmap.Width-1 do - let px = bitmap.GetPixel(x,y) - newBitmap.SetPixel(x,y,px) - newBitmap - - -let ParseArgument (job : Job) = - match job.Arguments.Head with - | "RGBA32" -> RGBA32 - | "R8" -> R8 - | "DDS" -> DDS(job.Arguments.[1]) - | x -> failwith ("Unknown requested texture format:" + x) - -let GetFormatFormRequestedFormat = function -| RGBA32 -> TextureFormat.R8G8B8A8_UNORM -| R8 -> TextureFormat.R8_UNORM -| DDS _ -> TextureFormat.DDS - -type SpriteFrame = { - x : uint16 - y : uint16 - w : uint16 - h : uint16 -} - -type TextureHead = { - Format : TextureFormat - Width : uint16 - Height : uint16 - SpriteSheet : SpriteFrame seq -} - -let SaveTextureHead head (stream:BinaryWriter) = - stream.Write (uint8 head.Format) - stream.Write (uint16 head.Width) - stream.Write (uint16 head.Height) - stream.Write (head.SpriteSheet |> Seq.length |> uint16) - head.SpriteSheet - |> Seq.iter (fun x -> - stream.Write (float32 x.x / float32 head.Width) - stream.Write (float32 x.y / float32 head.Height) - stream.Write (float32 x.w / float32 head.Width) - stream.Write (float32 x.h / float32 head.Height)) - -let DumpPixels (format:TextureFormat) (path:string) : uint16*uint16*byte[] = - let pixelSize = - match format with - | TextureFormat.R8G8B8A8_UNORM -> 4uy - | TextureFormat.R8_UNORM -> 1uy - | _ -> raise (System.ArgumentException()) - - use bitmap = new Bitmap(path) - let pixels = Array.init ((pixelSize |> int) * bitmap.Width * bitmap.Height) (fun _ -> 0uy) - use memStream = new MemoryStream(pixels) - use binWriter = new BinaryWriter(memStream) - for y in 0..bitmap.Height-1 do - for x in 0..bitmap.Width-1 do - let px = bitmap.GetPixel(x,y) - match format with - | TextureFormat.R8G8B8A8_UNORM -> - binWriter.Write px.R - binWriter.Write px.G - binWriter.Write px.B - binWriter.Write px.A - | TextureFormat.R8_UNORM -> - binWriter.Write px.R - | _ -> raise (System.ArgumentException()) - binWriter.Flush () - binWriter.Close () - memStream.Close () - bitmap.Width |> uint16,bitmap.Height |> uint16,pixels - -let ConvertTexture spriteSheet inputFullName (job:Job) = - let reqFormat = ParseArgument job - let innerFormat = GetFormatFormRequestedFormat reqFormat - - use dstFile = File.OpenWrite job.OutputPath - use dstWriter = new BinaryWriter(dstFile) - - let srcPath = - match inputFullName with - | false -> job.ScriptDir.FullName + "\\" + job.Input.Head - | true -> job.Input.Head - - match reqFormat with - | RGBA32 | R8 -> - let w,h,px = DumpPixels innerFormat srcPath - let head = { - Format = innerFormat - Width = uint16 w - Height = uint16 h - SpriteSheet = spriteSheet - } - - SaveTextureHead head dstWriter - dstWriter.Write px - - | DDS (ddsFormat) -> - let orgBitmap = new Bitmap(srcPath) - let is4MulBitmap = Is4MulBitmap orgBitmap - use bitmap = - if is4MulBitmap then orgBitmap - else - let ret = orgBitmap |> WrapBitmapTo4 - orgBitmap.Dispose() - ret - - let tmpout = FileInfo(job.OutputPath).DirectoryName - let texconv = AppContext.BaseDirectory + "\\texconv.exe" - - let incPng = - if is4MulBitmap then - FileInfo(srcPath).FullName - else - let path = job.OutputPath + ".png" - bitmap.Save path - path - - sprintf "\"%s\" -ft DDS -f %s -o \"%s\"" incPng ddsFormat tmpout - |> Utils.StartWait texconv - - if not is4MulBitmap then - File.Delete incPng - - let head = { - Format = TextureFormat.DDS - Width = uint16 bitmap.Width - Height = uint16 bitmap.Height - SpriteSheet = spriteSheet - } - SaveTextureHead head dstWriter - let ddsPath = - let baseFileName = - FileInfo(srcPath).Name - tmpout + "\\" + baseFileName.[..baseFileName.LastIndexOf '.' - 1] + ".DDS" - Utils.WaitForFile 5 ddsPath - let ddsBytes = File.ReadAllBytes ddsPath - dstWriter.Write (ddsBytes |> Array.length |> uint32) - dstWriter.Write ddsBytes - File.Delete ddsPath - - dstWriter.Close () - dstFile.Close () - -let Proc = { - Proc = ConvertTexture Seq.empty false - InputType = InputType.File - Command = "ConvertTexture" - FinishLogEnabled = true - Prority = 100 -} diff --git a/AssetBuilder/JobProcs/CopyFile.fs b/AssetBuilder/JobProcs/CopyFile.fs deleted file mode 100644 index 9045959..0000000 --- a/AssetBuilder/JobProcs/CopyFile.fs +++ /dev/null @@ -1,16 +0,0 @@ -module JobProcs.CopyFile - -open System.IO -open Job - -let Proc = { - Proc = (fun job -> - File.ReadAllBytes (job.ScriptDir.FullName + "\\" + job.Input.Head) - |> fun bytes -> File.WriteAllBytes(job.OutputPath,bytes)) - InputType = InputType.File - Command = "CopyFile" - FinishLogEnabled = true - Prority = 100 -} - - diff --git a/AssetBuilder/JobProcs/GenerateVersionText.fs b/AssetBuilder/JobProcs/GenerateVersionText.fs deleted file mode 100644 index e596f56..0000000 --- a/AssetBuilder/JobProcs/GenerateVersionText.fs +++ /dev/null @@ -1,13 +0,0 @@ -module JobProcs.GenerateVersionText -open Job - -let Proc = { - Proc = (fun job -> - let date = System.DateTime.Now - sprintf "%02d-%02d | %02d:%02d:%02d" date.Month date.Day date.Hour date.Minute date.Month - |> fun x -> System.IO.File.WriteAllText(job.OutputPath,x)) - InputType = None - Command = "GenerateVersionText" - FinishLogEnabled = false - Prority = 0 -} \ No newline at end of file diff --git a/AssetBuilder/JobProcs/JobProcs.fs b/AssetBuilder/JobProcs/JobProcs.fs deleted file mode 100644 index 8f477d8..0000000 --- a/AssetBuilder/JobProcs/JobProcs.fs +++ /dev/null @@ -1,66 +0,0 @@ -module JobProcs.JobProcs -open Job - -open System.Collections.Generic - - -let mutable AllProcs = [ - MakeDir.Proc - PackSound.Proc - ConvertTexture.Proc - PackSprite.Proc - ConvertFont.Proc - CopyFile.Proc - GenerateVersionText.Proc - RunCommand.FinalRunProc - RunCommand.PostRunProc - RunCommand.PreRunProc - ] - -let FindProcByCommand command = - try - AllProcs - |> List.find (fun x -> x.Command = command) - |> Some - with - | :? KeyNotFoundException -> - Option.None - - -let private allProcsLock = obj() -let AddCustumProc (cusJob:Job) = - lock allProcsLock (fun _ -> - let CommandProc (job:Job) = - let args = - let a1 = - "\"" + job.OutputPath + "\"" :: - List.map (fun x -> "\"" + job.ScriptDir.FullName + "\\" + x + "\"") job.Input - List.concat (seq {yield a1;yield job.Arguments}) - - let arg = List.reduce (fun x y -> x + " " + y) args - Utils.StartWait (job.ScriptDir.FullName + "\\" + cusJob.Input.Head) arg - Utils.WaitForFile 10 job.OutputPath - - let newProc = { - Proc = CommandProc - InputType = - match cusJob.Arguments.[0] with - | "File" -> File - | "Files" -> Files - | "Dir" -> Directory - | "None" -> Job.None - | _ -> failwith "Bad custum tool define." - Command = cusJob.Arguments.[1] - FinishLogEnabled = true - Prority = 100 } - AllProcs <- newProc :: AllProcs) - -let CustumJobProc = { - Proc = AddCustumProc - InputType = File - Command = "Custum" - FinishLogEnabled = false - Prority = 0 } - -AllProcs <- CustumJobProc :: AllProcs - diff --git a/AssetBuilder/JobProcs/MakeDir.fs b/AssetBuilder/JobProcs/MakeDir.fs deleted file mode 100644 index 2f9a23c..0000000 --- a/AssetBuilder/JobProcs/MakeDir.fs +++ /dev/null @@ -1,16 +0,0 @@ -module JobProcs.MakeDir - -open Job - -let Proc : JobProc = { - Proc = (fun job -> - job.OutputPath - |> System.IO.Directory.CreateDirectory - |> ignore) - - InputType = None - Command = "MakeDir" - FinishLogEnabled = false - Prority = 0 -} - diff --git a/AssetBuilder/JobProcs/PackSound.fs b/AssetBuilder/JobProcs/PackSound.fs deleted file mode 100644 index 833f124..0000000 --- a/AssetBuilder/JobProcs/PackSound.fs +++ /dev/null @@ -1,98 +0,0 @@ -module JobProcs.PackSound - -open Job -open System.IO -open WAVFileReader - - -[] -type private Options = { - Bpm : float32 - BeatsPerBar : uint32 - BeatsOffset : int32 -} - -let private PackSound scriptPath srcHead srcLoop (options:Options) (dst:string) = - if File.Exists dst then - failwith ("Sound file " + dst + " is already exists.") - - let getPath (p:string) = - if p.Trim() <> "" then - scriptPath + "\\" + p - else - "" - - let headFile,loopFile = getPath srcHead , getPath srcLoop - - let GetPCM path = - let fmt,data = WAVFileReader.ReadFile (File.OpenRead (path)) - if - fmt.Channels <> 2us || - fmt.DataFormat <> AudioDataFormat.PCM || - fmt.SampleRate <> 44100u then - failwith (path + "is not supposed,it must 44100Hz,2 Channels PCM.") - let f = File.OpenRead path - f.Position <- data.Begin - let buf = Array.init (data.Size |> int) (fun x -> 0uy) - if f.Read (buf,0,data.Size |> int) <> (data.Size |> int) then - failwith "Unknown file tail!" - buf - - let GetPCM2 f = - if System.String.IsNullOrWhiteSpace f |> not then - GetPCM f - else - [||] - let headPCM = GetPCM2 headFile - let loopPCM = GetPCM2 loopFile - - use outf = File.OpenWrite dst - use out = new BinaryWriter(outf) - out.Write (headPCM.Length |> uint32) - out.Write (loopPCM.Length |> uint32) - out.Write (options.Bpm) - out.Write (options.BeatsPerBar) - out.Write (options.BeatsOffset) - out.Write headPCM - out.Write loopPCM - out.Close() - outf.Close() - () - - - -let private GetOptions argumentStrList = - let defaultOption = { - Bpm = 120.0f - BeatsPerBar = 4u - BeatsOffset = 0 - } - - let optionFolder option (str:string) = - match str.Trim() with - | str when str.EndsWith "BPM" -> {option with Bpm = str.[..str.Length-4].Trim() |> float32 } - | str when str.EndsWith "BeatPerBar" -> {option with BeatsPerBar = str.[..str.Length - 11].Trim() |> uint32 } - | str when str.StartsWith "BeatOffset:" -> {option with BeatsOffset = str.[11..].Trim() |> int32 } - | "" -> option - | _ -> failwith "Unsuppoted argument." - - - argumentStrList - |> List.fold optionFolder defaultOption - -let Proc = { - Proc = (fun job -> - PackSound - job.ScriptDir.FullName - job.Input.[0] - (List.tryItem 1 job.Input - |> function - | Some x -> x - | Option.None -> "") - (GetOptions job.Arguments) - job.OutputPath) - InputType = Files - Command = "PackSound" - FinishLogEnabled = true - Prority = 100 -} \ No newline at end of file diff --git a/AssetBuilder/JobProcs/PackSprite.fs b/AssetBuilder/JobProcs/PackSprite.fs deleted file mode 100644 index 924b952..0000000 --- a/AssetBuilder/JobProcs/PackSprite.fs +++ /dev/null @@ -1,77 +0,0 @@ -module JobProcs.PackSprite - -open System.IO -open Utils -open Job -open Newtonsoft.Json -open Newtonsoft.Json.Linq -open ConvertTexture - -let CallTextureMerger inputDir outputFilePair = - let textureMerger = - [ - for i in 'C'..'Z' -> - string i + ":\\Program Files\\Egret\\TextureMerger\\TextureMerger.exe" ] - |> List.filter File.Exists - |> function - | s :: _ -> s - | [] -> - failwith "Can not find TextureMerger" - sprintf "-p \"%s\" -o \"%s.json\"" inputDir outputFilePair - |> StartWait textureMerger - WaitForFile 60 (outputFilePair + ".json") - WaitForFile 60 (outputFilePair + ".png") - -let private PackSprite (job:Job) = - CallTextureMerger (job.ScriptDir.FullName + "\\" + job.Input.Head) job.OutputPath - let frames = - using (new JsonTextReader(File.OpenText(job.OutputPath + ".json"))) (fun x -> - let token = JToken.ReadFrom x - let frames = token.["frames"] - [ for i in frames -> - uint16 i.Path.[7..], - { - x = uint16 i.First.["x"] - y = uint16 i.First.["y"] - w = uint16 i.First.["w"] - h = uint16 i.First.["h"] - }]) - |> List.sortBy (fun (a,_) -> a) - - let spriteFrames = - let maxFrameID = - frames - |> List.maxBy (fun (a,_) -> a) - |> fst - let ret = - Array.init (maxFrameID |> int |> (+) 1) (fun x -> { x = 0us; y = 0us; w = 0us;h = 0us }) - frames - |> List.iter (fun (id,frame) -> - ret.[int id] <- frame) - ret |> Array.toList - - let newJob = { - Processor = JobProcs.ConvertTexture.Proc - Input = [ job.OutputPath + ".png" ] - OutputPath = job.OutputPath - Arguments = job.Arguments - ScriptDir = job.ScriptDir - ScriptFile = job.ScriptFile - Encrypt = false - } - - JobProcs.ConvertTexture.ConvertTexture spriteFrames true newJob - - File.Delete (job.OutputPath + ".json") - File.Delete (job.OutputPath + ".png") - () - -let private spriteLock = obj() - -let Proc = { - Proc = (fun job -> lock spriteLock (fun () -> PackSprite job)) - InputType = Directory - Command = "PackSprite" - FinishLogEnabled = true - Prority = 100 -} diff --git a/AssetBuilder/JobProcs/RunCommand.fs b/AssetBuilder/JobProcs/RunCommand.fs deleted file mode 100644 index 8665dd8..0000000 --- a/AssetBuilder/JobProcs/RunCommand.fs +++ /dev/null @@ -1,29 +0,0 @@ -module JobProcs.RunCommand - -open Job - -let private runCommandProc job = - Utils.StartWait (job.ScriptDir.FullName + "\\" + job.Arguments.[0]) - (job.Input - |> List.reduce (fun a b -> a + " " + b)) - -let FinalRunProc = { - Proc = runCommandProc - InputType = InputType.None - Command = "FinalRun" - FinishLogEnabled = false - Prority = System.Int32.MaxValue -} - -let PostRunProc = { - FinalRunProc with - Command = "PostRun" - Prority = System.Int32.MaxValue - 1 -} - -let PreRunProc = { - FinalRunProc with - Command = "PreRun" - Prority = 0 -} - diff --git a/AssetBuilder/ProcRunner.fs b/AssetBuilder/ProcRunner.fs deleted file mode 100644 index 8eb6a77..0000000 --- a/AssetBuilder/ProcRunner.fs +++ /dev/null @@ -1,114 +0,0 @@ -module ProcRunner -open Job -open System.IO -open System - -let private FilesLastWriteTime (files : string list) = - files - |> List.filter (String.IsNullOrWhiteSpace >> not) - |> List.map FileInfo - |> List.map (fun x -> x.LastWriteTimeUtc) - |> List.max - -let private ShoudRebuild (job : Job) : bool = - try - if File.Exists job.OutputPath |> not then - raise (FileNotFoundException()) - - let outputTime = - let outputFile = - job.OutputPath - |> FileInfo - outputFile.LastWriteTimeUtc - - let scriptTime = job.ScriptFile.LastWriteTimeUtc - - match job.Processor.InputType with - | None -> true - | File -> - let inputTime = - let inputFile = - job.ScriptDir.FullName + "\\" + job.Input.Head |> FileInfo - inputFile.LastWriteTimeUtc - inputTime > outputTime || scriptTime > outputTime - | Files -> - let inputTime = - FilesLastWriteTime (job.Input |> List.map (fun x -> job.ScriptDir.FullName + "\\" + x)) - inputTime > outputTime || scriptTime > outputTime - | Directory -> - let dir = - job.Input - |> List.head - |> (fun x -> job.ScriptDir.FullName + "\\" + x) - |> DirectoryInfo - let inputTime = - dir.EnumerateFiles ("*",SearchOption.AllDirectories) - |> Seq.toList - |> List.map (fun x -> x.FullName) - |> FilesLastWriteTime - inputTime > outputTime || scriptTime > outputTime - with _ -> true - -let RunProcs (procs : Job[]) outputPath = - let failed = ref 0 - let logLock = obj() - - let aes = - if File.Exists "AesKey.bin" then - let key,iv = - "AesKey.bin" - |> File.ReadAllBytes - |> Array.splitAt 16 - let aes = new System.Security.Cryptography.AesCryptoServiceProvider () - aes.KeySize <- 128 - aes.BlockSize <- 128 - aes.Key <- key - aes.IV <- iv - Some aes - else - Option.None - - - let p = - procs - |> Array.filter ShoudRebuild - - - p - |> Array.groupBy (fun x -> x.Processor.Prority) - |> Array.sortBy fst - |> Array.iter - (snd >> (Array.Parallel.iter (fun job -> - if File.Exists job.OutputPath then - File.Delete job.OutputPath - - try - job.Processor.Proc job - if job.Encrypt && not (System.String.IsNullOrEmpty job.OutputPath) then - if File.Exists job.OutputPath then - Utils.EncryptFile aes (job.OutputPath) - if job.Processor.FinishLogEnabled then - lock logLock (fun () -> - printfn "%s: %A -> %s" - job.Processor.Command - job.Input - job.OutputPath.[String.length outputPath + 1..]) - - with jobException -> - System.Threading.Interlocked.Increment(failed) |> ignore - lock logLock (fun () -> - try - File.Delete job.OutputPath - with _ -> () - Console.ForegroundColor <- ConsoleColor.Red - printfn "Exception in %s" job.Processor.Command - printfn "JobInfo:" - printfn "%A" job - printfn "ExceptionMessage:%s" jobException.Message - printfn "ExceptionInfo:" - printfn "%A" jobException - Console.ResetColor () - Console.Beep ())))) - - if !failed > 0 then - Directory.Delete (outputPath,true) diff --git a/AssetBuilder/Utils.fs b/AssetBuilder/Utils.fs deleted file mode 100644 index 8512910..0000000 --- a/AssetBuilder/Utils.fs +++ /dev/null @@ -1,45 +0,0 @@ -module Utils - -open System.Diagnostics -open System.IO -open System.Threading -open System -open System.Security.Cryptography - -let EncryptFile (aes:System.Security.Cryptography.AesCryptoServiceProvider option) fileName = - fileName - |> File.ReadAllBytes - |> fun fileBytes -> - match aes with - | None -> failwith "AesKey.bin not found!" - | Some aes -> - let outputContent = Array.copy fileBytes - aes.CreateEncryptor().TransformBlock(fileBytes,0,fileBytes.Length/16*16,outputContent,0) - |> ignore - File.WriteAllBytes(fileName,outputContent) - -let StartWait exe arg = - use prc = new Process() - prc.StartInfo.FileName <- exe - prc.StartInfo.WorkingDirectory <- (FileInfo exe).DirectoryName - prc.StartInfo.Arguments <- arg - prc.StartInfo.WindowStyle <- ProcessWindowStyle.Hidden - if prc.Start() |> not then - failwith ("Can not start " + exe) - prc.WaitForExit () - match prc.ExitCode with - | 0 -> () - | x -> - failwith ( - "Build Tool Failed. Exit Code:" + string x + - Environment.NewLine + - exe + " " + arg + - Environment.NewLine + - prc.StandardOutput.ReadToEnd()) - -let WaitForFile maxTimes path = - for _ in 0..maxTimes do - if File.Exists path |> not then - Thread.Sleep 1000 - if File.Exists path |> not then - failwith ("Can not find file " + path) diff --git a/AssetBuilder/packages.config b/AssetBuilder/packages.config deleted file mode 100644 index 4d08fd1..0000000 --- a/AssetBuilder/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AssetBuilder/texconv.exe b/AssetBuilder/texconv.exe deleted file mode 100644 index 5f05ec4..0000000 --- a/AssetBuilder/texconv.exe +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b60341c8179b764e84fd428b8e14cbbb64e5116aba1f1cd4c663d1a3a6dc655c -size 635904 diff --git a/Assets/BasicAssets/BuildScript.txt b/Assets/BasicAssets/BuildScript.txt deleted file mode 100644 index 6ad77d2..0000000 --- a/Assets/BasicAssets/BuildScript.txt +++ /dev/null @@ -1 +0,0 @@ -ConvertFont (R8) [Font/chs] [Font-chs.fnt] diff --git a/Assets/BuildScript.txt b/Assets/BuildScript.txt deleted file mode 100644 index 41f3e3f..0000000 --- a/Assets/BuildScript.txt +++ /dev/null @@ -1,44 +0,0 @@ -Include [BasicAssets/BuildScript.txt] -Include [ExampleAssets/BuildScript.txt] -Include [Live2DAssetBuildScript.txt] - -# ˵ -# PackSpritePackSoundConvertFontΪ -# ʹ()ʹ[]ļ -# в()Ӧ÷ǰ棬ûвҪд -# һ[]дļдļУļļ֮ʹöŷָ -# ڶ[]дļһֻдһļ - -# ָ -# PackSprite飩 -# Ϊڲʽ -# ΪһļУ0.png1.png2.png... -# ΪSpriteļ -# һобľ -# ע⣺˹ҪEgret Texture Merger -# ConvertTextureת -# Ϊڲʽ -# ΪһPNGļ -# ΪһĬSpriteSpriteļ -# PackSoundѭϢ -# ûв -# Ϊ44100hz16bit˫ƵļһΪͷΣڶΪѭΣһΪ -# һѭϢļ -# ConvertSDFontתSDF壩 -# Ϊڲʽ -# һSDFFontɵļڵļУұ뺬font.txt -# һļ -# SDFFontrepogithub.com/SmallLuma/SDFFont -# MakeDirһļУ -# Ϊ -# Ϊһļ - -# ָ˵ -# Include԰һűļ - -# Custum ָ Զ幹 -# ļΪߵĿִļļ -# һΪͣFileFilesDirNone -# ڶΪƣ֮ʹøԶ幹 -# ִйʱĵһΪ˫ŵĿ¼֮ԴΪ˫ŵĸ룬Dz - diff --git a/Assets/ExampleAssets/BuildScript.txt b/Assets/ExampleAssets/BuildScript.txt deleted file mode 100644 index 6e97951..0000000 --- a/Assets/ExampleAssets/BuildScript.txt +++ /dev/null @@ -1,6 +0,0 @@ -Include [Sound/SoundScript.txt] -#PackSprite (RGBA32) [Sprite] [Sprite.ctx] -ConvertTexture (DDS,DXT1) [Background.png] [Background.ctx] -MakeDir [] [Dir] -#Custum (Files,HelloWorld) [..\HelloWorld.exe] [] -#HelloWorld (1,2,3,Fuck) [Background.png,Background.png] [BGP.dat] diff --git a/Assets/ExampleAssets/Sound/ExBoss_Head.wav b/Assets/ExampleAssets/Sound/ExBoss_Head.wav deleted file mode 100644 index 14d5b82..0000000 --- a/Assets/ExampleAssets/Sound/ExBoss_Head.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:93d624b9bc2e21a623a6c3dd81b18405f63157bf0c33c13e9d37e588dc69e338 -size 5017876 diff --git a/Assets/ExampleAssets/Sound/ExBoss_Loop.wav b/Assets/ExampleAssets/Sound/ExBoss_Loop.wav deleted file mode 100644 index 6f49388..0000000 --- a/Assets/ExampleAssets/Sound/ExBoss_Loop.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:28eff4d92b4d03a52409908aec5122fe37da2d6b2797233944d2ea312c275ddf -size 20070578 diff --git a/Assets/ExampleAssets/Sound/SoundEffect.wav b/Assets/ExampleAssets/Sound/SoundEffect.wav deleted file mode 100644 index 9711164..0000000 --- a/Assets/ExampleAssets/Sound/SoundEffect.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3a8765e3a28a56a234126bd746d88ca3c47ef413e46d443ecb8b6df5ebb15aac -size 243698 diff --git a/Assets/ExampleAssets/Sound/SoundScript.txt b/Assets/ExampleAssets/Sound/SoundScript.txt deleted file mode 100644 index adb5504..0000000 --- a/Assets/ExampleAssets/Sound/SoundScript.txt +++ /dev/null @@ -1,11 +0,0 @@ -MakeDir [] [Dir/Sound] -PackSound [ExBoss_Head.wav,ExBoss_Loop.wav] [Dir/Sound/ExBoss.snd] -PackSound [SoundEffect.wav,] [Dir/Sound/HeadOnly.snd] -PackSound [,SoundEffect.wav] [Dir/Sound/LoopOnly.snd] - -MakeDir [] [Fyee] -PackSound(155BPM) [Fyee/Head.wav] [Fyee/Head.snd] -PackSound(155BPM) [Fyee/Loop1.wav] [Fyee/Loop1.snd] -PackSound(155BPM) [Fyee/Melody1.wav] [Fyee/Melody1.snd] -PackSound(155BPM) [Fyee/Melody2.wav] [Fyee/Melody2.snd] -PackSound(155BPM) [Fyee/Ending.wav] [Fyee/Ending.snd] \ No newline at end of file diff --git a/Assets/Live2DAssetBuildScript.txt b/Assets/Live2DAssetBuildScript.txt deleted file mode 100644 index d9870fe..0000000 --- a/Assets/Live2DAssetBuildScript.txt +++ /dev/null @@ -1,88 +0,0 @@ -# Live2DԵز - -MakeDir [] [Live2D] - -MakeDir [] [Live2D\Haru] -MakeDir [] [Live2D\Haru\expressions] -MakeDir [] [Live2D\Haru\motions] -MakeDir [] [Live2D\Haru\Haru.2048] - -MakeDir [] [Live2D\Hiyori] -MakeDir [] [Live2D\Hiyori\motions] -MakeDir [] [Live2D\Hiyori\Hiyori.2048] - -MakeDir [] [Live2D\Mark] -MakeDir [] [Live2D\Mark\motions] -MakeDir [] [Live2D\Mark\Mark.2048] - -ConvertTexture (DDS,DXT5) [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\Haru.2048\texture_00.png] [Live2D\Haru\Haru.2048\texture_00.ctx] -ConvertTexture (DDS,DXT5) [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\Haru.2048\texture_01.png] [Live2D\Haru\Haru.2048\texture_01.ctx] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\Haru.moc3] [Live2D\Haru\Haru.moc3] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\Haru.model3.json] [Live2D\Haru\Haru.model3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\Haru.pose3.json] [Live2D\Haru\Haru.pose3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\Haru.userdata3.json] [Live2D\Haru\Haru.userdata3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F01.exp3.json] [Live2D\Haru\expressions\F01.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F02.exp3.json] [Live2D\Haru\expressions\F02.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F03.exp3.json] [Live2D\Haru\expressions\F03.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F04.exp3.json] [Live2D\Haru\expressions\F04.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F05.exp3.json] [Live2D\Haru\expressions\F05.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F06.exp3.json] [Live2D\Haru\expressions\F06.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F07.exp3.json] [Live2D\Haru\expressions\F07.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\expressions\F08.exp3.json] [Live2D\Haru\expressions\F08.exp3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_idle.motion3.json] [Live2D\Haru\motions\haru_g_idle.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m01.motion3.json] [Live2D\Haru\motions\haru_g_m01.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m02.motion3.json] [Live2D\Haru\motions\haru_g_m02.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m03.motion3.json] [Live2D\Haru\motions\haru_g_m03.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m04.motion3.json] [Live2D\Haru\motions\haru_g_m04.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m05.motion3.json] [Live2D\Haru\motions\haru_g_m05.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m06.motion3.json] [Live2D\Haru\motions\haru_g_m06.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m07.motion3.json] [Live2D\Haru\motions\haru_g_m07.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m08.motion3.json] [Live2D\Haru\motions\haru_g_m08.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m09.motion3.json] [Live2D\Haru\motions\haru_g_m09.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m10.motion3.json] [Live2D\Haru\motions\haru_g_m10.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m11.motion3.json] [Live2D\Haru\motions\haru_g_m11.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m12.motion3.json] [Live2D\Haru\motions\haru_g_m12.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m13.motion3.json] [Live2D\Haru\motions\haru_g_m13.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m14.motion3.json] [Live2D\Haru\motions\haru_g_m14.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m15.motion3.json] [Live2D\Haru\motions\haru_g_m15.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m16.motion3.json] [Live2D\Haru\motions\haru_g_m16.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m17.motion3.json] [Live2D\Haru\motions\haru_g_m17.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m18.motion3.json] [Live2D\Haru\motions\haru_g_m18.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m19.motion3.json] [Live2D\Haru\motions\haru_g_m19.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m20.motion3.json] [Live2D\Haru\motions\haru_g_m20.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m21.motion3.json] [Live2D\Haru\motions\haru_g_m21.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m22.motion3.json] [Live2D\Haru\motions\haru_g_m22.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m23.motion3.json] [Live2D\Haru\motions\haru_g_m23.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m24.motion3.json] [Live2D\Haru\motions\haru_g_m24.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m25.motion3.json] [Live2D\Haru\motions\haru_g_m25.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Haru\motions\haru_g_m26.motion3.json] [Live2D\Haru\motions\haru_g_m26.motion3.json] - -ConvertTexture (DDS,DXT5) [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\Hiyori.2048\texture_00.png] [Live2D\Hiyori\Hiyori.2048\texture_00.ctx] -ConvertTexture (DDS,DXT5) [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\Hiyori.2048\texture_01.png] [Live2D\Hiyori\Hiyori.2048\texture_01.ctx] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\Hiyori.moc3] [Live2D\Hiyori\Hiyori.moc3] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\Hiyori.physics3.json] [Live2D\Hiyori\Hiyori.physics3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\Hiyori.model3.json] [Live2D\Hiyori\Hiyori.model3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\Hiyori.pose3.json] [Live2D\Hiyori\Hiyori.pose3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\Hiyori.userdata3.json] [Live2D\Hiyori\Hiyori.userdata3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m01.motion3.json] [Live2D\Hiyori\motions\Hiyori_m01.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m02.motion3.json] [Live2D\Hiyori\motions\Hiyori_m02.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m03.motion3.json] [Live2D\Hiyori\motions\Hiyori_m03.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m04.motion3.json] [Live2D\Hiyori\motions\Hiyori_m04.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m05.motion3.json] [Live2D\Hiyori\motions\Hiyori_m05.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m06.motion3.json] [Live2D\Hiyori\motions\Hiyori_m06.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m07.motion3.json] [Live2D\Hiyori\motions\Hiyori_m07.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m08.motion3.json] [Live2D\Hiyori\motions\Hiyori_m08.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m09.motion3.json] [Live2D\Hiyori\motions\Hiyori_m09.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Hiyori\motions\Hiyori_m10.motion3.json] [Live2D\Hiyori\motions\Hiyori_m10.motion3.json] - -ConvertTexture (DDS,DXT5) [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\Mark.2048\texture_00.png] [Live2D\Mark\Mark.2048\texture_00.ctx] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\Mark.moc3] [Live2D\Mark\Mark.moc3] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\Mark.physics3.json] [Live2D\Mark\Mark.physics3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\Mark.model3.json] [Live2D\Mark\Mark.model3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\Mark.userdata3.json] [Live2D\Mark\Mark.userdata3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\motions\mark_m01.motion3.json] [Live2D\Mark\motions\mark_m01.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\motions\mark_m02.motion3.json] [Live2D\Mark\motions\mark_m02.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\motions\mark_m03.motion3.json] [Live2D\Mark\motions\mark_m03.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\motions\mark_m04.motion3.json] [Live2D\Mark\motions\mark_m04.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\motions\mark_m05.motion3.json] [Live2D\Mark\motions\mark_m05.motion3.json] -CopyFile [..\TestWindowsLive2D\CubismNativeSamples\Samples\Res\Mark\motions\mark_m06.motion3.json] [Live2D\Mark\motions\mark_m06.motion3.json] diff --git a/Readme.md b/Readme.md index b4a06a4..ed2db8c 100644 --- a/Readme.md +++ b/Readme.md @@ -2,15 +2,13 @@ 弦语蝶梦 第二代游戏引擎 Snowing -[![Build status](https://ci.appveyor.com/api/projects/status/xsg86whgh0d00lma?svg=true)](https://ci.appveyor.com/project/SmallLuma/snowing) - [快速入门](https://www.bilibili.com/video/av43701922/) ### 基本组件 - Core - 引擎核心代码 - Assets - 基本素材与示例素材 - WindowsImpl - Windows下的实现 -- AssetsBuilder - 素材转换、打包、部署工具 +- Bake.Snowing - 素材转换、打包、部署工具([Bake](https://github.com/Strrationalism/Bake)构建系统的插件) - TestWindow - Windows下的单元测试 - TestWindowsInput - Windows下的基本输入设备测试 - FX11(submodule) - Microsoft Effects 11 框架运行时 @@ -30,7 +28,6 @@ - Fyee - 动态BGM系统 ### 范例 -- BGMPlayer - BGM播放器 - HelloWorld - 基本范例 - Particle - 2D粒子范例 - TextRendering - 2D文本范例 @@ -52,6 +49,11 @@ ### FAQ +##### 运行范例时找不到素材 +在此之前需要安装[Bake构建系统](https://github.com/Strrationalism/Bake)。 +之后在Assets目录下执行Bake。 +如果需要执行Live2D范例,应当额外执行`Bake BuildLive2D`。 + ##### 对Windows 7兼容性 已经向Windows 7 SP1妥协,可支持到Windows 7 SP1,但是更低版本的Windows不再支持。 @@ -67,10 +69,12 @@ Clone此项目需要确保安装[git-lfs](https://git-lfs.github.com/),并已 git-lfs install ``` -##### 资源构建器的用法 -AssetsBuilder 目标路径 -它将读取工作目录下的BuildScript.txt,根据此文件构建内容。 -关于BuildScript.txt的写法,参见Assets\BuildScript.txt例子。 +##### Bake.Snowing的用法 +在Assets目录下执行Bake命令即可构建素材。 +在Bake.Snowing目录下执行`dotnet publish -c Release`即可得到可用于导入的DLL。 +如果你需要自己编写Bake Script,应当导入Bake.Snowing.dll以访问素材构建器的功能。 + +参见[Bake构建系统](https://github.com/Strrationalism/Bake)。 需要安装[Erget TextureMerger](https://www.egret.com/products/others.html#egret-texture)到X:\Program Files\Egret\TextureMerger\下。 X可以为任意盘符,该工具用于打包纹理。 diff --git a/Snowing.sln b/Snowing.sln index fa97936..314464e 100644 --- a/Snowing.sln +++ b/Snowing.sln @@ -28,8 +28,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Effects11", "FX11\Effects11 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestWindows", "TestWindows\TestWindows.vcxproj", "{E72CB55E-FC8D-46EF-96D6-7CD5921B58BF}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AssetBuilder", "AssetBuilder\AssetBuilder.fsproj", "{BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{30AA46A1-BF9D-4317-B419-40BE16FF82BD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{2D9ECDC6-7F73-4991-8AB3-271D36F872BB}" @@ -187,18 +185,6 @@ Global {E72CB55E-FC8D-46EF-96D6-7CD5921B58BF}.Release|x64.Build.0 = Release|x64 {E72CB55E-FC8D-46EF-96D6-7CD5921B58BF}.Release|x86.ActiveCfg = Release|Win32 {E72CB55E-FC8D-46EF-96D6-7CD5921B58BF}.Release|x86.Build.0 = Release|Win32 - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Debug|x64.ActiveCfg = Debug|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Debug|x64.Build.0 = Debug|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Debug|x86.ActiveCfg = Debug|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Debug|x86.Build.0 = Debug|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|Any CPU.Build.0 = Release|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|x64.ActiveCfg = Release|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|x64.Build.0 = Release|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|x86.ActiveCfg = Release|Any CPU - {BF7F2BA8-9A61-4D2D-8B0A-37FD17B74BA1}.Release|x86.Build.0 = Release|Any CPU {85496E07-C508-46ED-89CE-F5D4A4AB5483}.Debug|Any CPU.ActiveCfg = Debug|Win32 {85496E07-C508-46ED-89CE-F5D4A4AB5483}.Debug|x64.ActiveCfg = Debug|x64 {85496E07-C508-46ED-89CE-F5D4A4AB5483}.Debug|x64.Build.0 = Debug|x64