From 5057b717a0f46cc7db63a1f67122ebd57860d728 Mon Sep 17 00:00:00 2001 From: eaxvac <4586194+lastbattle@users.noreply.github.com> Date: Sun, 31 Jan 2021 17:44:38 +0800 Subject: [PATCH] [HaRepacker] Fix - truncation of negative numbers in WzIntProperty field https://github.com/lastbattle/Harepacker-resurrected/issues/102 --- HaRepacker/GUI/Panels/MainPanel.xaml.cs | 50 +++++++++++++++---------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/HaRepacker/GUI/Panels/MainPanel.xaml.cs b/HaRepacker/GUI/Panels/MainPanel.xaml.cs index f8c25837..8e503a76 100644 --- a/HaRepacker/GUI/Panels/MainPanel.xaml.cs +++ b/HaRepacker/GUI/Panels/MainPanel.xaml.cs @@ -1496,37 +1496,47 @@ private void ShowObjectValue(WzObject obj) textPropBox.AcceptsReturn = false; textPropBox.ApplyButtonEnabled = false; // reset to disabled mode when changed - ulong value_ = 0; - if (bIsWzLongProperty) - { - value_ = (ulong)((WzLongProperty)obj).GetLong(); - } - else if (bIsWzIntProperty) - { - value_ = (ulong)((WzIntProperty)obj).GetLong(); - } else if (bIsWzShortProperty) - { - value_ = (ulong)((WzShortProperty)obj).GetLong(); - } - // field limit UI if (obj.Name == FIELD_LIMIT_OBJ_NAME) // fieldLimit { isSelectingWzMapFieldLimit = true; + ulong value_ = 0; + if (bIsWzLongProperty) // use uLong for field limit + { + value_ = (ulong)((WzLongProperty)obj).GetLong(); + } + else if (bIsWzIntProperty) + { + value_ = (ulong)((WzIntProperty)obj).GetLong(); + } + else if (bIsWzShortProperty) + { + value_ = (ulong)((WzShortProperty)obj).GetLong(); + } + fieldLimitPanel1.UpdateFieldLimitCheckboxes(value_); // Set visibility fieldLimitPanelHost.Visibility = Visibility.Visible; - } - else if (obj.Name == FIELD_TYPE_OBJ_NAME) // fieldType + } + else { - fieldTypePanel.SetFieldTypeIndex(value_); - - // Set visibility - fieldTypePanel.Visibility = Visibility.Visible; + long value_ = 0; // long for others, in the case of negative value + if (bIsWzLongProperty) + { + value_ = ((WzLongProperty)obj).GetLong(); + } + else if (bIsWzIntProperty) + { + value_ = ((WzIntProperty)obj).GetLong(); + } + else if (bIsWzShortProperty) + { + value_ = ((WzShortProperty)obj).GetLong(); + } + textPropBox.Text = value_.ToString(); } - textPropBox.Text = value_.ToString(); } else if (bIsWzDoubleProperty || bIsWzFloatProperty) {