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

Commit 3a11351

Browse files
committed
Moved BG Color and Mask to GameChip, refactored Clear into Fill (#489), and refactored color id to color offset (#490).
1 parent fdc1dee commit 3a11351

35 files changed

+220
-198
lines changed

Disks/APIExamples/BackgroundColor/code.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function Init()
2020
DrawText("Default Color " .. defaultColor, 1, 4, DrawMode.Tile, "large", 15)
2121

2222
-- Here we are manually changing the background color
23-
local newColor = BackgroundColor(2)
23+
local newColor = BackgroundColor(1)
2424

2525
-- Draw the new color ID to the display
2626
DrawText("New Color " .. newColor, 1, 6, DrawMode.Tile, "large", 15)

Disks/PixelVisionOS/System/Tools/ChipTool/Src/code-chip-selector-panel.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ function ChipEditorTool:ReplaceChip(chipData, chipID)
388388

389389
self.invalidateColorMap = true
390390

391-
gameEditor:ReindexSprites()
391+
-- gameEditor:ReindexSprites()
392392

393393
for i = 1, #chipData.palette do
394394
-- Find the palette start index

Disks/PixelVisionOS/System/Tools/WorkspaceTool/Src/code-icon-button.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function PixelVisionOS:CreateIconButtonStates(data, spriteName, text, bgColor)
8484
-- if(bgColor ~= nil) then
8585
-- data.bgDrawArgs[5] = bgColor
8686
-- end
87-
print("bgColor", bgColor)
87+
-- print("bgColor", bgColor)
8888
if(spriteName == "none") then
8989

9090
DrawRect(

SDK/Editor/Editors/GameEditor.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -365,29 +365,29 @@ public string Color(int id, string value = null)
365365
return value;
366366
}
367367

368-
public void ClearColors(string color = null)
369-
{
370-
colorChip.Clear(color);
371-
}
368+
public void ClearColors() => colorChip.Clear(_gameChip.MaskColor());
369+
// {
370+
// colorChip.Clear();
371+
// }
372372

373-
public void ClearSprites()
374-
{
375-
spriteChip.Clear();
376-
}
373+
public void ClearSprites() => spriteChip.Clear();
374+
// {
375+
// spriteChip.Clear();
376+
// }
377377

378378
/// <summary>
379379
/// Get the TotalDisks colors or change the limit for how many colors the color chip can store.
380380
/// </summary>
381381
/// <param name="ignoreEmpty"></param>
382382
/// <param name="total"></param>
383383
/// <returns></returns>
384-
public int TotalColors(bool ignoreEmpty = false)
385-
{
384+
public int TotalColors(bool ignoreEmpty = false) => _gameChip.TotalColors(ignoreEmpty);
385+
// {
386386
// if (TotalDisks.HasValue)
387387
// activeColorChip.maxColors = TotalDisks.Value;
388388

389-
return ignoreEmpty ? colorChip.TotalUsedColors : colorChip.Total;
390-
}
389+
// return ignoreEmpty ? colorChip.TotalUsedColors : colorChip.Total;
390+
// }
391391

392392
// Since we want to be able to edit this value but the interface doesn't allow it, we hide it in lua and use the overload instead
393393
// [MoonSharpHidden]
@@ -757,12 +757,12 @@ public int ChannelType(int id, int? typeID = null)
757757
/// </summary>
758758
/// <param name="value"></param>
759759
/// <returns></returns>
760-
public string MaskColor(string value = null)
761-
{
762-
if (value != null) colorChip.MaskColor = value;
760+
public string MaskColor(string value = null) => _gameChip.MaskColor(value);
761+
// {
762+
// if (value != null) _gameChip.MaskColor(value);
763763

764-
return colorChip.MaskColor;
765-
}
764+
// return _gameChip.MaskColor();
765+
// }
766766

767767
#endregion
768768

SDK/Editor/Exporters/ColorPaletteExporter.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ public class ColorPaletteExporter : IExporter
4040
protected int total;
4141
protected int width;
4242

43-
public ColorPaletteExporter(string fileName, ColorChip colorChip, IImageExporter imageExporter)
43+
protected string _maskColor;
44+
45+
public ColorPaletteExporter(string fileName, ColorChip colorChip, IImageExporter imageExporter, string maskColor)
4446
{
4547
fullFileName = fileName;
4648

4749
this.colorChip = colorChip;
4850

4951
this.imageExporter = imageExporter;
52+
53+
_maskColor = maskColor;
5054
}
5155

5256
protected ColorChip colorChip { get; set; }
@@ -70,8 +74,7 @@ public void CalculateSteps()
7074
BuildPixelData();
7175

7276
// Create Pixel Data Exporter
73-
exporter = new PixelDataExporter(fullFileName, pixels, width, height, colors, imageExporter,
74-
colorChip.MaskColor);
77+
exporter = new PixelDataExporter(fullFileName, pixels, width, height, colors, imageExporter, _maskColor);
7578

7679
// calculate steps for exporter
7780
exporter.CalculateSteps();

SDK/Editor/Exporters/FontExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public override void ConfigurePixelData()
7373
// TODO use the colors from the sprite parser this class extends?
7474

7575
exporter = new PixelDataExporter(fullFileName, textureData.Pixels, width, height, colors, imageExporter,
76-
engine.ColorChip.MaskColor);
76+
engine.GameChip.MaskColor());
7777
}
7878
}
7979
}

SDK/Editor/Exporters/GifExporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public ColorData[] VisiblePixels()
103103
var pixels = DisplayChip.Pixels;
104104

105105
var cachedColors = ColorUtils.ConvertColors(engine.ColorChip.HexColors, /*engine.ColorChip.MaskColor,
106-
engine.ColorChip.DebugMode, */engine.ColorChip.BackgroundColor).Select(c=> new ColorData(c.R, c.G, c.B)).ToArray();
106+
engine.ColorChip.DebugMode, */engine.GameChip.BGColorOffset).Select(c=> new ColorData(c.R, c.G, c.B)).ToArray();
107107

108108
// TODO need to replace the first color with the bg?
109109

@@ -120,7 +120,7 @@ public ColorData[] VisiblePixels()
120120
var totalPixels = pixels.Length;
121121
var newTotalPixels = newPixels.Length;
122122

123-
var index = 0;
123+
// var index = 0;
124124

125125
for (var i = 0; i < totalPixels; i++)
126126
{

SDK/Editor/Exporters/SpriteExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public virtual void ConfigurePixelData()
102102
// spriteChip.texture.CopyPixels(ref pixelData, 0, 0, width, height);
103103

104104
exporter = new PixelDataExporter(fullFileName, pixelData, width, height, colors, imageExporter,
105-
engine.ColorChip.MaskColor);
105+
engine.GameChip.MaskColor());
106106
}
107107
}
108108
}

SDK/Editor/Exporters/SystemExporter.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,12 @@ private void SerializeColorChip(ColorChip colorChip)
179179
// sb.Append(",");
180180
// JsonUtil.GetLineBreak(sb, 1);
181181

182-
sb.Append("\"backgroundColor\":");
183-
sb.Append(colorChip.BackgroundColor);
184-
sb.Append(",");
185-
JsonUtil.GetLineBreak(sb, 1);
182+
// sb.Append("\"backgroundColor\":");
183+
// sb.Append(colorChip.BackgroundColor);
184+
// sb.Append(",");
185+
// JsonUtil.GetLineBreak(sb, 1);
186186

187-
sb.Append("\"maskColor\":\"");
188-
sb.Append(colorChip.MaskColor);
189-
sb.Append("\"");
190-
sb.Append(",");
191-
JsonUtil.GetLineBreak(sb, 1);
187+
192188

193189
// sb.Append("\"unique\":");
194190
// sb.Append(colorChip.unique.ToString().ToLower());
@@ -274,6 +270,19 @@ private void SerializeGameChip(GameChip gameChip)
274270
sb.Append(",");
275271
JsonUtil.GetLineBreak(sb, 1);
276272

273+
// Mask color
274+
sb.Append("\"maskColor\":\"");
275+
sb.Append(gameChip.MaskColor());
276+
sb.Append("\"");
277+
sb.Append(",");
278+
JsonUtil.GetLineBreak(sb, 1);
279+
280+
// Background color
281+
sb.Append("\"backgroundColor\":");
282+
sb.Append(gameChip.BackgroundColor());
283+
sb.Append(",");
284+
JsonUtil.GetLineBreak(sb, 1);
285+
277286
// Save Slots
278287
sb.Append("\"saveSlots\":");
279288
sb.Append(gameChip.SaveSlots);

SDK/Editor/Exporters/TilemapJsonExporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private void SaveMapDataV1()
281281

282282
// background color
283283
sb.Append("\"backgroundcolor\":");
284-
sb.Append("\"" + colorChip.MaskColor + "\"");
284+
sb.Append("\"" + gameChip.MaskColor() + "\"");
285285
sb.Append(",");
286286
JsonUtil.GetLineBreak(sb, 1);
287287

@@ -374,7 +374,7 @@ private void SaveMapDataV1()
374374

375375
// transparentcolor
376376
sb.Append("\"transparentcolor\":");
377-
sb.Append("\"" + targetEngine.ColorChip.MaskColor + "\"");
377+
sb.Append("\"" + targetEngine.GameChip.MaskColor() + "\"");
378378
JsonUtil.GetLineBreak(sb, 2);
379379

380380
// tilesets end

0 commit comments

Comments
 (0)
X Tutup