This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting up logic between full and lite versions of PixelVision8's r…
…unner code.
- Loading branch information
1 parent
f8f3775
commit a1cf44b
Showing
31 changed files
with
1,304 additions
and
1,200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// | ||
// Copyright (c) Jesse Freeman, Pixel Vision 8. All rights reserved. | ||
// | ||
// Licensed under the Microsoft Public License (MS-PL) except for a few | ||
// portions of the code. See LICENSE file in the project root for full | ||
// license information. Third-party libraries used by Pixel Vision 8 are | ||
// under their own licenses. Please refer to those libraries for details | ||
// on the license they use. | ||
// | ||
// Contributors | ||
// -------------------------------------------------------- | ||
// This is the official list of Pixel Vision 8 contributors: | ||
// | ||
// Jesse Freeman - @JesseFreeman | ||
// Christina-Antoinette Neofotistou @CastPixel | ||
// Christer Kaitila - @McFunkypants | ||
// Pedro Medeiros - @saint11 | ||
// Shawn Rakowski - @shwany | ||
// | ||
|
||
using System.Text; | ||
using PixelVision8.Engine; | ||
using PixelVision8.Engine.Chips; | ||
using PixelVision8.Runner.Utils; | ||
|
||
namespace PixelVision8.Runner.Exporters | ||
{ | ||
public class SfxrSoundExporter : AbstractExporter | ||
{ | ||
private readonly IEngine targetEngine; | ||
private StringBuilder sb; | ||
private SfxrSoundChip _sfxrSoundChip; | ||
|
||
public SfxrSoundExporter(string fileName, IEngine targetEngine) : base(fileName) | ||
{ | ||
this.targetEngine = targetEngine; | ||
|
||
_sfxrSoundChip = targetEngine.SoundChip as SfxrSoundChip; | ||
|
||
// CalculateSteps(); | ||
} | ||
|
||
public override void CalculateSteps() | ||
{ | ||
base.CalculateSteps(); | ||
|
||
// Create a new string builder | ||
steps.Add(CreateStringBuilder); | ||
|
||
|
||
steps.Add(SaveGameData); | ||
|
||
// Save the final string builder | ||
steps.Add(CloseStringBuilder); | ||
} | ||
|
||
private void SaveGameData() | ||
{ | ||
var soundChip = targetEngine.SoundChip; | ||
|
||
sb.Append("\"version\":\"v2\","); | ||
JsonUtil.GetLineBreak(sb, 1); | ||
|
||
JsonUtil.indentLevel++; | ||
sb.Append("\"sounds\": ["); | ||
|
||
var total = soundChip.TotalSounds; | ||
for (var i = 0; i < total; i++) | ||
{ | ||
var sound = _sfxrSoundChip.ReadSound(i); | ||
// if (sound != null) | ||
// { | ||
JsonUtil.indentLevel++; | ||
|
||
|
||
// { | ||
// "name":"Melody", | ||
// "settings":"0,.5,,.2,,.2,.3,.1266,,,,,,,,,,,,,,,,,,1,,,,,," | ||
// }, | ||
|
||
|
||
sb.Append("{"); | ||
JsonUtil.GetLineBreak(sb, 1); | ||
|
||
sb.Append("\"name\":\""); | ||
sb.Append(sound.name); | ||
sb.Append("\","); | ||
JsonUtil.GetLineBreak(sb, 1); | ||
sb.Append("\"settings\":"); | ||
sb.Append("\"" + sound.param + "\""); | ||
JsonUtil.GetLineBreak(sb, 1); | ||
sb.Append("}"); | ||
|
||
// sb.Append(sound.ReadSettings()); | ||
if (i < total - 1) sb.Append(","); | ||
|
||
JsonUtil.GetLineBreak(sb, 1); | ||
JsonUtil.indentLevel--; | ||
// } | ||
} | ||
|
||
JsonUtil.indentLevel--; | ||
JsonUtil.GetLineBreak(sb, 1); | ||
sb.Append("]"); | ||
|
||
currentStep++; | ||
} | ||
|
||
private void CreateStringBuilder() | ||
{ | ||
sb = new StringBuilder(); | ||
|
||
sb.Append("{"); | ||
JsonUtil.indentLevel++; | ||
|
||
JsonUtil.GetLineBreak(sb); | ||
sb.Append("\"SoundChip\":"); | ||
|
||
JsonUtil.GetLineBreak(sb); | ||
sb.Append("{"); | ||
JsonUtil.GetLineBreak(sb, 1); | ||
|
||
// JsonUtil.indentLevel++; | ||
|
||
currentStep++; | ||
} | ||
|
||
private void CloseStringBuilder() | ||
{ | ||
JsonUtil.indentLevel--; | ||
JsonUtil.GetLineBreak(sb); | ||
sb.Append("}"); | ||
|
||
JsonUtil.indentLevel--; | ||
JsonUtil.GetLineBreak(sb, 1); | ||
sb.Append("}"); | ||
|
||
bytes = Encoding.UTF8.GetBytes(sb.ToString()); | ||
|
||
currentStep++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.