mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-05-13 15:56:18 -05:00
support |z suffix for arguments in script reference files
This commit is contained in:
parent
e65644a236
commit
ccbdca51f3
|
|
@ -1229,14 +1229,17 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
|
|||
return "<> <`xse`> <`bse`> <`ase`> <`tse`> <\"\"> <`mart`> <`decor`> <`move`> <`oam`> : .".Split(' ').Any(token.Contains);
|
||||
}
|
||||
|
||||
public string Convert(IDataModel model, int value) {
|
||||
public string Convert(IDataModel model, int value, int bytes) {
|
||||
var preferHex = EnumTableName?.EndsWith("|h") ?? false;
|
||||
var preferSign = EnumTableName?.EndsWith("|z") ?? false;
|
||||
var enumName = EnumTableName?.Split('|')[0];
|
||||
var table = string.IsNullOrEmpty(enumName) ? null : model.GetOptions(enumName);
|
||||
if (table == null || value - EnumOffset < 0 || table.Count <= value - EnumOffset || string.IsNullOrEmpty(table[value])) {
|
||||
if (preferHex || value == int.MinValue || Math.Abs(value) >= 0x4000) {
|
||||
return "0x" + ((uint)value).ToString($"X{length * 2}");
|
||||
} else {
|
||||
if (bytes == 1 && preferSign) value = (sbyte)value;
|
||||
if (bytes == 2 && preferSign) value = (short)value;
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1257,9 +1260,9 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
|
|||
|
||||
public bool Build(bool allFillerIsZero, IDataModel data, int start, StringBuilder builder, List<string> streamContent) {
|
||||
if (allFillerIsZero && Name == "filler") return true;
|
||||
if (Type == ArgType.Byte) builder.Append(Convert(data, data[start]));
|
||||
if (Type == ArgType.Short) builder.Append(Convert(data, data.ReadMultiByteValue(start, 2)));
|
||||
if (Type == ArgType.Word) builder.Append(Convert(data, data.ReadMultiByteValue(start, 4)));
|
||||
if (Type == ArgType.Byte) builder.Append(Convert(data, data[start], 1));
|
||||
if (Type == ArgType.Short) builder.Append(Convert(data, data.ReadMultiByteValue(start, 2), 2));
|
||||
if (Type == ArgType.Word) builder.Append(Convert(data, data.ReadMultiByteValue(start, 4), 4));
|
||||
if (Type == ArgType.Pointer) {
|
||||
var address = data.ReadMultiByteValue(start, 4);
|
||||
if (address < 0x8000000) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
01 if_random_greater_than percent. ptr<`tse`>
|
||||
02 if_random_equal percent. ptr<`tse`>
|
||||
03 if_random_not_equal percent. ptr<`tse`>
|
||||
04 score score.
|
||||
04 score score.|z
|
||||
05 if_hp_less_than battler. percent. ptr<`tse`>
|
||||
06 if_hp_more_than battler. percent. ptr<`tse`>
|
||||
07 if_hp_equal battler. percent. ptr<`tse`>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user