mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Change display rotation to long?
This commit is contained in:
@@ -357,11 +357,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "display":
|
case "display":
|
||||||
datItems.Add(new Display
|
var display = new Display
|
||||||
{
|
{
|
||||||
Tag = reader.GetAttribute("tag"),
|
Tag = reader.GetAttribute("tag"),
|
||||||
DisplayType = reader.GetAttribute("type").AsDisplayType(),
|
DisplayType = reader.GetAttribute("type").AsDisplayType(),
|
||||||
Rotate = reader.GetAttribute("rotate"),
|
|
||||||
FlipX = reader.GetAttribute("flipx").AsYesNo(),
|
FlipX = reader.GetAttribute("flipx").AsYesNo(),
|
||||||
Width = reader.GetAttribute("width"),
|
Width = reader.GetAttribute("width"),
|
||||||
Height = reader.GetAttribute("height"),
|
Height = reader.GetAttribute("height"),
|
||||||
@@ -379,7 +378,16 @@ namespace SabreTools.Library.DatFiles
|
|||||||
Index = indexId,
|
Index = indexId,
|
||||||
Name = filename,
|
Name = filename,
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Set the rotation
|
||||||
|
if (reader.GetAttribute("rotate") != null)
|
||||||
|
{
|
||||||
|
if (Int64.TryParse(reader.GetAttribute("rotate"), out long rotate))
|
||||||
|
display.Rotate = rotate;
|
||||||
|
}
|
||||||
|
|
||||||
|
datItems.Add(display);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -1531,7 +1539,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
xtw.WriteStartElement("display");
|
xtw.WriteStartElement("display");
|
||||||
xtw.WriteOptionalAttributeString("tag", display.Tag);
|
xtw.WriteOptionalAttributeString("tag", display.Tag);
|
||||||
xtw.WriteOptionalAttributeString("type", display.DisplayType.FromDisplayType());
|
xtw.WriteOptionalAttributeString("type", display.DisplayType.FromDisplayType());
|
||||||
xtw.WriteOptionalAttributeString("rotate", display.Rotate);
|
xtw.WriteOptionalAttributeString("rotate", display.Rotate?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("flipx", display.FlipX.FromYesNo());
|
xtw.WriteOptionalAttributeString("flipx", display.FlipX.FromYesNo());
|
||||||
xtw.WriteOptionalAttributeString("width", display.Width);
|
xtw.WriteOptionalAttributeString("width", display.Width);
|
||||||
xtw.WriteOptionalAttributeString("height", display.Height);
|
xtw.WriteOptionalAttributeString("height", display.Height);
|
||||||
|
|||||||
@@ -1437,7 +1437,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
xtw.WriteAttributeString("type", "display");
|
xtw.WriteAttributeString("type", "display");
|
||||||
xtw.WriteOptionalAttributeString("tag", display.Tag);
|
xtw.WriteOptionalAttributeString("tag", display.Tag);
|
||||||
xtw.WriteOptionalAttributeString("type", display.DisplayType.FromDisplayType());
|
xtw.WriteOptionalAttributeString("type", display.DisplayType.FromDisplayType());
|
||||||
xtw.WriteOptionalAttributeString("rotate", display.Rotate);
|
xtw.WriteOptionalAttributeString("rotate", display.Rotate?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("flipx", display.FlipX.FromYesNo());
|
xtw.WriteOptionalAttributeString("flipx", display.FlipX.FromYesNo());
|
||||||
xtw.WriteOptionalAttributeString("width", display.Width);
|
xtw.WriteOptionalAttributeString("width", display.Width);
|
||||||
xtw.WriteOptionalAttributeString("height", display.Height);
|
xtw.WriteOptionalAttributeString("height", display.Height);
|
||||||
|
|||||||
@@ -359,23 +359,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
switch (reader.Name)
|
switch (reader.Name)
|
||||||
{
|
{
|
||||||
case "rom":
|
case "rom":
|
||||||
// If the rom is continue or ignore, add the size to the previous rom
|
var rom = new Rom
|
||||||
if (reader.GetAttribute("loadflag") == "continue" || reader.GetAttribute("loadflag") == "ignore")
|
|
||||||
{
|
|
||||||
int index = Items[key].Count - 1;
|
|
||||||
DatItem lastrom = Items[key][index];
|
|
||||||
if (lastrom.ItemType == ItemType.Rom)
|
|
||||||
{
|
|
||||||
((Rom)lastrom).Size += Sanitizer.CleanSize(reader.GetAttribute("size"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Items[key].RemoveAt(index);
|
|
||||||
Items[key].Add(lastrom);
|
|
||||||
reader.Read();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DatItem rom = new Rom
|
|
||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Size = Sanitizer.CleanSize(reader.GetAttribute("size")),
|
Size = Sanitizer.CleanSize(reader.GetAttribute("size")),
|
||||||
@@ -389,6 +373,24 @@ namespace SabreTools.Library.DatFiles
|
|||||||
DataArea = dataArea,
|
DataArea = dataArea,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If the rom is continue or ignore, add the size to the previous rom
|
||||||
|
// TODO: Can this be done on write? We technically lose information this way.
|
||||||
|
// Order is not guaranteed, and since these don't tend to have any way
|
||||||
|
// of determining what the "previous" item was after this, that info would
|
||||||
|
// have to be stored *with* the item somehow
|
||||||
|
if (rom.LoadFlag == LoadFlag.Continue || rom.LoadFlag == LoadFlag.Ignore)
|
||||||
|
{
|
||||||
|
int index = Items[key].Count - 1;
|
||||||
|
DatItem lastrom = Items[key][index];
|
||||||
|
if (lastrom.ItemType == ItemType.Rom)
|
||||||
|
(lastrom as Rom).Size += rom.Size;
|
||||||
|
|
||||||
|
Items[key].RemoveAt(index);
|
||||||
|
Items[key].Add(lastrom);
|
||||||
|
reader.Read();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
items.Add(rom);
|
items.Add(rom);
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ namespace SabreTools.Library.DatItems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the devices is mandatory
|
/// Determines if the devices is mandatory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>Only value used seems to be 1. Used like bool, but actually int</remarks>
|
||||||
[JsonProperty("mandatory", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("mandatory", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public string Mandatory { get; set; } // TODO: bool?
|
public string Mandatory { get; set; } // TODO: long?
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Device interface
|
/// Device interface
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Library.Filtering;
|
using SabreTools.Library.Filtering;
|
||||||
@@ -33,7 +34,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
/// Display rotation
|
/// Display rotation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("rotate", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("rotate", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public string Rotate { get; set; } // TODO: (0|90|180|270) Int32?
|
public long? Rotate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if display is flipped in the X-coordinates
|
/// Determines if display is flipped in the X-coordinates
|
||||||
@@ -122,7 +123,10 @@ namespace SabreTools.Library.DatItems
|
|||||||
DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType();
|
DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Rotate))
|
if (mappings.Keys.Contains(Field.DatItem_Rotate))
|
||||||
Rotate = mappings[Field.DatItem_Rotate];
|
{
|
||||||
|
if (Int64.TryParse(mappings[Field.DatItem_Rotate], out long rotate))
|
||||||
|
Rotate = rotate;
|
||||||
|
}
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_FlipX))
|
if (mappings.Keys.Contains(Field.DatItem_FlipX))
|
||||||
FlipX = mappings[Field.DatItem_FlipX].AsYesNo();
|
FlipX = mappings[Field.DatItem_FlipX].AsYesNo();
|
||||||
@@ -260,9 +264,9 @@ namespace SabreTools.Library.DatItems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on rotation
|
// Filter on rotation
|
||||||
if (filter.DatItem_Rotate.MatchesPositiveSet(Rotate) == false)
|
if (filter.DatItem_Rotate.MatchesPositive(null, Rotate) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Rotate.MatchesNegativeSet(Rotate) == true)
|
if (filter.DatItem_Rotate.MatchesNegative(null, Rotate) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on flipx
|
// Filter on flipx
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Byte size of the rom
|
/// Byte size of the rom
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// TODO: Can this be made optional instead of concrete long? Use `null` instead of `-1`?
|
||||||
[JsonProperty("size", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("size", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long Size { get; set; }
|
public long Size { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace SabreTools.Library.Filtering
|
|||||||
|
|
||||||
// Display
|
// Display
|
||||||
public FilterItem<DisplayType> DatItem_DisplayType { get; private set; } = new FilterItem<DisplayType>() { Positive = DisplayType.NULL, Negative = DisplayType.NULL };
|
public FilterItem<DisplayType> DatItem_DisplayType { get; private set; } = new FilterItem<DisplayType>() { Positive = DisplayType.NULL, Negative = DisplayType.NULL };
|
||||||
public FilterItem<string> DatItem_Rotate { get; private set; } = new FilterItem<string>();
|
public FilterItem<long?> DatItem_Rotate { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||||
public FilterItem<bool?> DatItem_FlipX { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
public FilterItem<bool?> DatItem_FlipX { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||||
public FilterItem<string> DatItem_Width { get; private set; } = new FilterItem<string>();
|
public FilterItem<string> DatItem_Width { get; private set; } = new FilterItem<string>();
|
||||||
public FilterItem<string> DatItem_Height { get; private set; } = new FilterItem<string>();
|
public FilterItem<string> DatItem_Height { get; private set; } = new FilterItem<string>();
|
||||||
@@ -839,7 +839,7 @@ namespace SabreTools.Library.Filtering
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Field.DatItem_Rotate:
|
case Field.DatItem_Rotate:
|
||||||
SetStringFilter(DatItem_Rotate, value, negate);
|
SetOptionalLongFilter(DatItem_Rotate, value, negate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Field.DatItem_FlipX:
|
case Field.DatItem_FlipX:
|
||||||
|
|||||||
Reference in New Issue
Block a user