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

Commit

Permalink
Added new display partial classes for MonoGame and MonoVision and mod…
Browse files Browse the repository at this point in the history
…ified PV8 Lite project to support change.
  • Loading branch information
jessefreeman committed Mar 16, 2021
1 parent 8c36859 commit 4e64795
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 308 deletions.
1 change: 1 addition & 0 deletions PixelVision8.CoreDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
<Compile Include="SDK\Lua\Debugger\VariableInspector.cs" />
<Compile Include="SDK\Lua\Parsers\ScriptParser.cs" />
<Compile Include="SDK\Lua\Services\LuaService.cs" />
<Compile Include="SDK\Runner\Data\DisplayTarget.MonoVision.cs" />
<Compile Include="SDK\Runner\Data\ShaderDisplayTarget.cs" />
<Compile Include="SDK\Runner\Data\DisplayTarget.cs" />
<Compile Include="SDK\Player\Data\ImageData.cs" />
Expand Down
9 changes: 6 additions & 3 deletions Projects/PixelVision8Lite/PixelVision8Lite.CoreDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@

<!-- Parser -->
<ItemGroup>
<Compile Include="..\..\SDK\Runner\Data\DisplayTarget.MonoGame.cs">
<Link>SDK\Runner\Data\DisplayTarget.MonoGame.cs</Link>
</Compile>
<Compile Include="..\..\SDK\Runner\Parsers\AbstractParser.cs">
<Link>SDK/Runner/Parsers/AbstractParser.cs</Link>
</Compile>
Expand Down Expand Up @@ -216,13 +219,13 @@
<Compile Include="../../SDK/Player/Chips/Input/ControllerChip.cs">
<Link>SDK/Player/Chips/Input/ControllerChip.cs</Link>
</Compile>
<Compile Include="..\..\SDK\Player\Chips\Input\InputMap.cs" >
<Compile Include="..\..\SDK\Player\Chips\Input\InputMap.cs">
<Link>SDK/Player/Chips/Input/InputMap.cs</Link>
</Compile>
<Compile Include="..\..\SDK\Player\Chips\Input\KeyboardInputChip.cs" >
<Compile Include="..\..\SDK\Player\Chips\Input\KeyboardInputChip.cs">
<Link>SDK/Player/Chips/Input/KeyboardInputChip.cs</Link>
</Compile>
<Compile Include="..\..\SDK\Player\Chips\Input\MouseInputChip.cs" >
<Compile Include="..\..\SDK\Player\Chips\Input\MouseInputChip.cs">
<Link>SDK/Player/Chips/Input/MouseInputChip.cs</Link>
</Compile>

Expand Down
28 changes: 28 additions & 0 deletions SDK/Runner/Data/DisplayTarget.MonoGame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PixelVision8.Runner
{
public partial class DisplayTarget
{
public virtual void Render(int[] pixels, int defaultColor)
{

// We can only update the display if the pixel lengths match up
if (pixels.Length != _totalPixels)
return;

SpriteBatch.Begin(SpriteSortMode.Immediate, null, SamplerState.PointClamp);

for (_i = 0; _i < _totalPixels; _i++)
{
_colorId = pixels[_i];
_pixelData[_i] = CachedColors[_colorId < 0 ? defaultColor : _colorId];
}

RenderTexture.SetData(_pixelData);
SpriteBatch.Draw(RenderTexture, Offset, VisibleRect, Color.White, 0f, Vector2.Zero, Scale, SpriteEffects.None, 1f);
SpriteBatch.End();
}
}
}
26 changes: 26 additions & 0 deletions SDK/Runner/Data/DisplayTarget.MonoVision.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.Xna.Framework;
namespace PixelVision8.Runner
{
public partial class DisplayTarget
{
public virtual void Render(int[] pixels, int defaultColor)
{

// We can only update the display if the pixel lengths match up
if (pixels.Length != _totalPixels)
return;

SpriteBatch.Begin(); //SpriteSortMode.Immediate

for (_i = 0; _i < _totalPixels; _i++)
{
_colorId = pixels[_i];
_pixelData[_i] = CachedColors[_colorId < 0 ? defaultColor : _colorId];
}

RenderTexture.SetData(_pixelData);
SpriteBatch.Draw(RenderTexture, Offset, VisibleRect, Color.White, Vector2.Zero, Scale);
SpriteBatch.End();
}
}
}
40 changes: 20 additions & 20 deletions SDK/Runner/Data/DisplayTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace PixelVision8.Runner
{
public class DisplayTarget
public partial class DisplayTarget
{

public static Color HexToColor(string hex)
Expand Down Expand Up @@ -221,24 +221,24 @@ public virtual void RebuildColorPalette(string[] hexColors, int bgColorId = 0, s

}

public virtual void Render(int[] pixels, int defaultColor)
{

// We can only update the display if the pixel lengths match up
if (pixels.Length != _totalPixels)
return;

SpriteBatch.Begin(); //SpriteSortMode.Immediate

for (_i = 0; _i < _totalPixels; _i++)
{
_colorId = pixels[_i];
_pixelData[_i] = CachedColors[_colorId < 0 ? defaultColor : _colorId];
}

RenderTexture.SetData(_pixelData);
SpriteBatch.Draw(RenderTexture, Offset, VisibleRect, Color.White, Vector2.Zero, Scale);
SpriteBatch.End();
}
// public virtual void Render(int[] pixels, int defaultColor)
// {
//
// // We can only update the display if the pixel lengths match up
// if (pixels.Length != _totalPixels)
// return;
//
// SpriteBatch.Begin(); //SpriteSortMode.Immediate
//
// for (_i = 0; _i < _totalPixels; _i++)
// {
// _colorId = pixels[_i];
// _pixelData[_i] = CachedColors[_colorId < 0 ? defaultColor : _colorId];
// }
//
// RenderTexture.SetData(_pixelData);
// SpriteBatch.Draw(RenderTexture, Offset, VisibleRect, Color.White, Vector2.Zero, Scale);
// SpriteBatch.End();
// }
}
}
2 changes: 1 addition & 1 deletion SDK/Runner/DesktopRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ public override void RunGame()
ignoreExtension = metaData["runnerType"] == "csharp" ? ".lua" : ".cs";
}
// Read the game's meta file to see if the runner is defined there
else if (Array.IndexOf(GameFiles, "/Game/info.json") != -1)
else if (Array.IndexOf(GameFiles, "/Game/info.json") != -1) // TODO this are is throwing a random issue
{
var json = workspaceService.ReadTextFromFile(
WorkspacePath.Parse(GameFiles[Array.IndexOf(GameFiles, "/Game/info.json")]));
Expand Down

0 comments on commit 4e64795

Please sign in to comment.