Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Cleaning up core classes and fields/properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed Jan 30, 2021
1 parent 82eb4ec commit c100fc1
Show file tree
Hide file tree
Showing 62 changed files with 228 additions and 318 deletions.
2 changes: 1 addition & 1 deletion SDK/Editor/Editors/GameEditor.cs
Expand Up @@ -1222,7 +1222,7 @@ public string SaveFont(string fontName)

var files = new Dictionary<string, byte[]>
{
{fontPath.Path, exporter.bytes}
{fontPath.Path, exporter.Bytes}
};

workspace.SaveExporterFiles(files);
Expand Down
6 changes: 3 additions & 3 deletions SDK/Editor/Exporters/BackgroundScriptRunner.cs
Expand Up @@ -95,7 +95,7 @@ public void AddStep(string functionName)
{
stepQueue.Add(functionName);

_steps.Add(CallStep);
Steps.Add(CallStep);
}

protected void CallStep()
Expand All @@ -118,7 +118,7 @@ public void SetStringAsData(string value)
// TODO need to make sure nothing is saved if bytes is empty
try
{
bytes = Encoding.UTF8.GetBytes(value);
Bytes = Encoding.UTF8.GetBytes(value);
}
catch (Exception e)
{
Expand All @@ -145,7 +145,7 @@ public void SetImageAsData(ImageData imageData, string maskColor = "#FF00FF")
exporter.NextStep();
}

bytes = exporter.bytes;
Bytes = exporter.Bytes;
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion SDK/Editor/Exporters/ColorPaletteExporter.cs
Expand Up @@ -92,7 +92,7 @@ public void Dispose()
}

public Dictionary<string, object> Response => exporter.Response;
public byte[] bytes => exporter.bytes;
public byte[] Bytes => exporter.Bytes;

public string fileName => exporter.fileName;

Expand Down
4 changes: 2 additions & 2 deletions SDK/Editor/Exporters/DiskExporter.cs
Expand Up @@ -39,7 +39,7 @@ public override void CalculateSteps()
{
base.CalculateSteps();

_steps.Add(ValidateSize);
Steps.Add(ValidateSize);
;
}

Expand All @@ -61,7 +61,7 @@ private void ValidateSize()
// Set the success back to false
Response["success"] = false;

bytes = null;
Bytes = null;
}
}

Expand Down
10 changes: 5 additions & 5 deletions SDK/Editor/Exporters/GifExporter.cs
Expand Up @@ -65,13 +65,13 @@ public override void CalculateSteps()
{
base.CalculateSteps();

_steps.Add(StartGif);
Steps.Add(StartGif);

_steps.Add(IndexColors);
Steps.Add(IndexColors);

_steps.Add(BuildColorTable);
Steps.Add(BuildColorTable);

_steps.Add(ConvertFrame);
Steps.Add(ConvertFrame);
}

public void AddFrame(float delay = 0)
Expand Down Expand Up @@ -238,7 +238,7 @@ public void ConvertFrame()
binary.AddRange(encoded.OrderBy(j => j.Key).SelectMany(j => j.Value));
binary.Add(0x3B); // GIF Trailer.

bytes = binary.ToArray();
Bytes = binary.ToArray();
// encodeProgress.Completed = true;
}

Expand Down
4 changes: 2 additions & 2 deletions SDK/Editor/Exporters/ImageExporter.cs
Expand Up @@ -47,7 +47,7 @@ public override void CalculateSteps()
{
base.CalculateSteps();

_steps.Add(WriteBytes);
Steps.Add(WriteBytes);
}

protected virtual void WriteBytes()
Expand All @@ -58,7 +58,7 @@ protected virtual void WriteBytes()

imageExporter.Write(width, height, stream, colors);

bytes = stream.ToArray();
Bytes = stream.ToArray();
}

CurrentStep++;
Expand Down
8 changes: 4 additions & 4 deletions SDK/Editor/Exporters/MetaDataExporter.cs
Expand Up @@ -44,13 +44,13 @@ public override void CalculateSteps()
base.CalculateSteps();

// Create a new string builder
_steps.Add(CreateStringBuilder);
Steps.Add(CreateStringBuilder);

// Serialize Game
if (engine.GameChip != null) _steps.Add(delegate { SerializeGameChip(_gameChip); });
if (engine.GameChip != null) Steps.Add(delegate { SerializeGameChip(_gameChip); });

// Save the final string builder
_steps.Add(CloseStringBuilder);
Steps.Add(CloseStringBuilder);
}

private void CreateStringBuilder()
Expand All @@ -69,7 +69,7 @@ private void CloseStringBuilder()
JsonUtil.GetLineBreak(sb);
sb.Append("}");

bytes = Encoding.UTF8.GetBytes(sb.ToString());
Bytes = Encoding.UTF8.GetBytes(sb.ToString());

CurrentStep++;
}
Expand Down
8 changes: 4 additions & 4 deletions SDK/Editor/Exporters/MetaSpriteExporter.cs
Expand Up @@ -46,13 +46,13 @@ public override void CalculateSteps()
base.CalculateSteps();

// Create a new string builder
_steps.Add(CreateStringBuilder);
Steps.Add(CreateStringBuilder);


_steps.Add(MetaSpriteData);
Steps.Add(MetaSpriteData);

// Save the final string builder
_steps.Add(CloseStringBuilder);
Steps.Add(CloseStringBuilder);
}

private void MetaSpriteData()
Expand Down Expand Up @@ -159,7 +159,7 @@ private void CloseStringBuilder()
JsonUtil.GetLineBreak(sb);
sb.Append("}");

bytes = Encoding.UTF8.GetBytes(sb.ToString());
Bytes = Encoding.UTF8.GetBytes(sb.ToString());

CurrentStep++;
}
Expand Down
8 changes: 4 additions & 4 deletions SDK/Editor/Exporters/MusicExporter.cs
Expand Up @@ -41,13 +41,13 @@ public override void CalculateSteps()
base.CalculateSteps();

// Create a new string builder
_steps.Add(CreateStringBuilder);
Steps.Add(CreateStringBuilder);


_steps.Add(SaveGameData);
Steps.Add(SaveGameData);

// Save the final string builder
_steps.Add(CloseStringBuilder);
Steps.Add(CloseStringBuilder);
}

private void SaveGameData()
Expand Down Expand Up @@ -128,7 +128,7 @@ private void CloseStringBuilder()
JsonUtil.GetLineBreak(sb, 1);
sb.Append("}");

bytes = Encoding.UTF8.GetBytes(sb.ToString());
Bytes = Encoding.UTF8.GetBytes(sb.ToString());

CurrentStep++;
}
Expand Down
4 changes: 2 additions & 2 deletions SDK/Editor/Exporters/PixelDataExporter.cs
Expand Up @@ -41,9 +41,9 @@ public override void CalculateSteps()
{
CurrentStep = 0;

_steps.Add(CopyPixels);
Steps.Add(CopyPixels);

_steps.Add(WriteBytes);
Steps.Add(WriteBytes);
}

protected virtual void CopyPixels()
Expand Down
8 changes: 4 additions & 4 deletions SDK/Editor/Exporters/SfxrSoundExporter.cs
Expand Up @@ -44,13 +44,13 @@ public override void CalculateSteps()
base.CalculateSteps();

// Create a new string builder
_steps.Add(CreateStringBuilder);
Steps.Add(CreateStringBuilder);


_steps.Add(SaveGameData);
Steps.Add(SaveGameData);

// Save the final string builder
_steps.Add(CloseStringBuilder);
Steps.Add(CloseStringBuilder);
}

private void SaveGameData()
Expand Down Expand Up @@ -134,7 +134,7 @@ private void CloseStringBuilder()
JsonUtil.GetLineBreak(sb, 1);
sb.Append("}");

bytes = Encoding.UTF8.GetBytes(sb.ToString());
Bytes = Encoding.UTF8.GetBytes(sb.ToString());

CurrentStep++;
}
Expand Down
8 changes: 4 additions & 4 deletions SDK/Editor/Exporters/SongExporter.cs
Expand Up @@ -66,10 +66,10 @@ public override void CalculateSteps()
{
base.CalculateSteps();

for (var i = 0; i < patterns.Length; i++) _steps.Add(ExportSong);
for (var i = 0; i < patterns.Length; i++) Steps.Add(ExportSong);

_steps.Add(MixdownAudioClips);
_steps.Add(CreateSongByteData);
Steps.Add(MixdownAudioClips);
Steps.Add(CreateSongByteData);
}

public void ExportSong()
Expand Down Expand Up @@ -205,7 +205,7 @@ private void MixdownAudioClips()
private void CreateSongByteData()
{
//TODO need to break this process up in to steps so it doesn't block the runner
bytes = result.GenerateWav();
Bytes = result.GenerateWav();
CurrentStep++;
}

Expand Down
8 changes: 4 additions & 4 deletions SDK/Editor/Exporters/SoundExporter.cs
Expand Up @@ -41,13 +41,13 @@ public override void CalculateSteps()
base.CalculateSteps();

// Create a new string builder
_steps.Add(CreateStringBuilder);
Steps.Add(CreateStringBuilder);


_steps.Add(SaveGameData);
Steps.Add(SaveGameData);

// Save the final string builder
_steps.Add(CloseStringBuilder);
Steps.Add(CloseStringBuilder);
}

private void SaveGameData()
Expand Down Expand Up @@ -131,7 +131,7 @@ private void CloseStringBuilder()
JsonUtil.GetLineBreak(sb, 1);
sb.Append("}");

bytes = Encoding.UTF8.GetBytes(sb.ToString());
Bytes = Encoding.UTF8.GetBytes(sb.ToString());

CurrentStep++;
}
Expand Down
9 changes: 4 additions & 5 deletions SDK/Editor/Exporters/SpriteBuilderExporter.cs
Expand Up @@ -19,7 +19,6 @@
//

using PixelVision8.Player;
using PixelVision8.Runner.Data;
using PixelVision8.Runner;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -94,16 +93,16 @@ public override void CalculateSteps()

spriteCount = 0;

_steps.Add(ConvertFilesToTextures);
Steps.Add(ConvertFilesToTextures);

maxTilesPerLoop = 10;
totalTiles = files.Count;

var loops = (int) Math.Ceiling((float) totalTiles / maxTilesPerLoop);

for (var i = 0; i < loops; i++) _steps.Add(ParseSpriteData);
for (var i = 0; i < loops; i++) Steps.Add(ParseSpriteData);

_steps.Add(GenerateSpriteJSON);
Steps.Add(GenerateSpriteJSON);
}


Expand Down Expand Up @@ -193,7 +192,7 @@ public void GenerateSpriteJSON()
sb.Append(endComment);
sb.AppendLine();

bytes = Encoding.UTF8.GetBytes(sb.ToString());
Bytes = Encoding.UTF8.GetBytes(sb.ToString());

CurrentStep++;
}
Expand Down
2 changes: 1 addition & 1 deletion SDK/Editor/Exporters/SpriteExporter.cs
Expand Up @@ -82,7 +82,7 @@ public void Dispose()
}

public Dictionary<string, object> Response => exporter.Response;
public byte[] bytes => exporter.bytes;
public byte[] Bytes => exporter.Bytes;

public string fileName => exporter.fileName;

Expand Down
24 changes: 12 additions & 12 deletions SDK/Editor/Exporters/SystemExporter.cs
Expand Up @@ -41,48 +41,48 @@ public override void CalculateSteps()
base.CalculateSteps();

// Create a new string builder
_steps.Add(CreateStringBuilder);
Steps.Add(CreateStringBuilder);

// TODO all chips should export

// Serialize Color Chip
if (engine.ColorChip != null)
_steps.Add(delegate { SerializeColorChip(engine.ColorChip); });
Steps.Add(delegate { SerializeColorChip(engine.ColorChip); });

// Serialize Display
if (engine.DisplayChip != null)
_steps.Add(delegate { SerializeDisplay(engine.DisplayChip); });
Steps.Add(delegate { SerializeDisplay(engine.DisplayChip); });

// Serialize Controller
if (engine.ControllerChip != null)
_steps.Add(delegate { SerializeControllerChip(engine.ControllerChip); });
Steps.Add(delegate { SerializeControllerChip(engine.ControllerChip); });

// Serialize Font
if (engine.FontChip != null)
_steps.Add(delegate { SerializeFontChip(engine.FontChip); });
Steps.Add(delegate { SerializeFontChip(engine.FontChip); });

// Serialize Game
if (engine.GameChip != null)
_steps.Add(delegate { SerializeGameChip(engine.GameChip); });
Steps.Add(delegate { SerializeGameChip(engine.GameChip); });

// Serialize Music
if (engine.MusicChip != null)
_steps.Add(delegate { SerializeMusicChip(engine.MusicChip); });
Steps.Add(delegate { SerializeMusicChip(engine.MusicChip); });

// Serialize Sound
if (engine.SoundChip != null /* && engine.SoundChip.export*/)
_steps.Add(delegate { SerializeSoundChip(engine.SoundChip as SfxrSoundChip); });
Steps.Add(delegate { SerializeSoundChip(engine.SoundChip as SfxrSoundChip); });

// Serialize Sprite
if (engine.SpriteChip != null)
_steps.Add(delegate { SerializeSpriteChip(engine.SpriteChip); });
Steps.Add(delegate { SerializeSpriteChip(engine.SpriteChip); });

// Serialize Tilemap
if (engine.TilemapChip != null)
_steps.Add(delegate { SerializeTilemapChip(engine.TilemapChip); });
Steps.Add(delegate { SerializeTilemapChip(engine.TilemapChip); });

// Save the final string builder
_steps.Add(CloseStringBuilder);
Steps.Add(CloseStringBuilder);
}

private void CreateStringBuilder()
Expand Down Expand Up @@ -111,7 +111,7 @@ private void CloseStringBuilder()
sb.Append("}");

// Debug.Log("Save bytes");
bytes = Encoding.UTF8.GetBytes(sb.ToString());
Bytes = Encoding.UTF8.GetBytes(sb.ToString());

CurrentStep++;
}
Expand Down

0 comments on commit c100fc1

Please sign in to comment.