From 9eccc0d05295be606ee2bf75005073807e4287ab Mon Sep 17 00:00:00 2001 From: ghorsington Date: Sat, 13 Apr 2019 15:27:34 +0300 Subject: [PATCH] Fix #14 --- .../Service/Service.GameMain.cs | 24 +++-------- .../Utils/Extensions.cs | 42 +++++++------------ GUI/app_info.py | 2 +- GUI/maidfiddler/ui/qt_elements.py | 22 +++++++++- GUI/maidfiddler/ui/tabs/maid_stats.py | 24 ++++++----- GUI/maidfiddler/ui/tabs/player.py | 24 ++++++----- GUI/translations/english.json | 3 +- Installer/README.txt | 5 +++ Installer/installer.iss | 2 +- 9 files changed, 79 insertions(+), 69 deletions(-) diff --git a/Core/COM3D2.MaidFiddler.Plugin/Service/Service.GameMain.cs b/Core/COM3D2.MaidFiddler.Plugin/Service/Service.GameMain.cs index 415e4f8..8949564 100644 --- a/Core/COM3D2.MaidFiddler.Plugin/Service/Service.GameMain.cs +++ b/Core/COM3D2.MaidFiddler.Plugin/Service/Service.GameMain.cs @@ -69,15 +69,9 @@ private Dictionary GetLockableClubStatusInfo() p => { Type t = p.PropertyType; - if (t.IsFloat()) - return "double"; - if (t.IsSignedInteger()) - return "int"; - if (t.IsUnsignedInteger()) - return "uint"; - if (t == typeof(bool)) - return "bool"; - return "string"; + if (t.IsNativeType()) + return t.FullName; + return "System.String"; }); } @@ -103,15 +97,9 @@ private Dictionary GetLockableMaidStatusValueInfo() p => { Type t = p.PropertyType; - if (t.IsFloat()) - return "double"; - if (t.IsSignedInteger()) - return "int"; - if (t.IsUnsignedInteger()) - return "uint"; - if (t == typeof(bool)) - return "bool"; - return "string"; + if (t.IsNativeType()) + return t.FullName; + return "System.String"; }); } diff --git a/Core/COM3D2.MaidFiddler.Plugin/Utils/Extensions.cs b/Core/COM3D2.MaidFiddler.Plugin/Utils/Extensions.cs index f02f692..bef697b 100644 --- a/Core/COM3D2.MaidFiddler.Plugin/Utils/Extensions.cs +++ b/Core/COM3D2.MaidFiddler.Plugin/Utils/Extensions.cs @@ -5,37 +5,25 @@ namespace COM3D2.MaidFiddler.Core.Utils { public static class Extensions { - private static readonly HashSet FloatTypes = new HashSet {typeof(float), typeof(double), typeof(decimal)}; - - private static readonly HashSet IntegerTypes = new HashSet + private static readonly HashSet NativeFileTypes = new HashSet { - typeof(sbyte), - typeof(short), - typeof(int), - typeof(long), + typeof(sbyte), + typeof(short), + typeof(int), + typeof(long), + typeof(byte), + typeof(ushort), + typeof(uint), + typeof(ulong), + typeof(float), + typeof(double), + typeof(decimal), + typeof(bool) }; - private static readonly HashSet UnsignedIntegerTypes = new HashSet - { - typeof(byte), - typeof(ushort), - typeof(uint), - typeof(ulong) - }; - - public static bool IsSignedInteger(this Type self) - { - return IntegerTypes.Contains(self) || IntegerTypes.Contains(Nullable.GetUnderlyingType(self)); - } - - public static bool IsUnsignedInteger(this Type self) - { - return UnsignedIntegerTypes.Contains(self) || UnsignedIntegerTypes.Contains(Nullable.GetUnderlyingType(self)); - } - - public static bool IsFloat(this Type self) + public static bool IsNativeType(this Type self) { - return FloatTypes.Contains(self) || FloatTypes.Contains(Nullable.GetUnderlyingType(self)); + return NativeFileTypes.Contains(self) || NativeFileTypes.Contains(Nullable.GetUnderlyingType(self)); } } } \ No newline at end of file diff --git a/GUI/app_info.py b/GUI/app_info.py index 3231c68..f347b0a 100644 --- a/GUI/app_info.py +++ b/GUI/app_info.py @@ -1,4 +1,4 @@ -VERSION = "1.0.4.3" +VERSION = "1.0.4.4" CONTRIBUTORS = [ "@ghorsington -- original developer", diff --git a/GUI/maidfiddler/ui/qt_elements.py b/GUI/maidfiddler/ui/qt_elements.py index d9b64c1..24581ea 100644 --- a/GUI/maidfiddler/ui/qt_elements.py +++ b/GUI/maidfiddler/ui/qt_elements.py @@ -1,6 +1,23 @@ from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QWidget, QHBoxLayout +MIN_MAX_DICT = { + "System.SByte": (-128, 127), + "System.Byte": (0, 255), + "System.Int16": (-2**15, 2**15-1), + "System.UInt16": (0, 2**16-1), + "System.Int32": (-2**31, 2**31-1), + "System.UInt32": (0, 2**32-1), + "System.Int64": (-2**63, 2**63-1), + "System.UInt64": (0, 2**64-1) +} + +FLOAT_TYPES = set([ + "System.Single", + "System.Double", + "System.Decimal" +]) + class UiElement(object): def __init__(self, qt_element): @@ -39,9 +56,12 @@ def connect(self, edit_func): class NumberElement(UiElement): - def __init__(self, qt_element, minVal=-2**31, maxVal=2**31-1): + def __init__(self, qt_element, minVal=-2**31, maxVal=2**31-1, type=None): UiElement.__init__(self, qt_element) + if type is not None and type in MIN_MAX_DICT: + minVal, maxVal = MIN_MAX_DICT[type] + self.qt_element.setMaximum(maxVal) self.qt_element.setMinimum(minVal) diff --git a/GUI/maidfiddler/ui/tabs/maid_stats.py b/GUI/maidfiddler/ui/tabs/maid_stats.py index 9abb006..c0b5025 100644 --- a/GUI/maidfiddler/ui/tabs/maid_stats.py +++ b/GUI/maidfiddler/ui/tabs/maid_stats.py @@ -1,7 +1,7 @@ from PyQt5.QtWidgets import QHeaderView, QTableWidgetItem, QLineEdit, QDoubleSpinBox, QSpinBox, QCheckBox, QWidget, QHBoxLayout, QGroupBox from PyQt5.QtCore import Qt, pyqtSignal from .ui_tab import UiTab -from maidfiddler.ui.qt_elements import NumberElement, TextElement, CheckboxElement +from maidfiddler.ui.qt_elements import NumberElement, TextElement, CheckboxElement, MIN_MAX_DICT, FLOAT_TYPES from maidfiddler.util.translation import tr @@ -13,13 +13,17 @@ def __init__(self, ui): self.properties = {} self.bonus_properties = {} - self.type_generators = { - "uint": lambda: NumberElement(QSpinBox(), 0, 2**32), - "int": lambda: NumberElement(QSpinBox()), - "double": lambda: NumberElement(QDoubleSpinBox()), - "string": lambda: TextElement(QLineEdit()), - "bool": lambda: CheckboxElement(QCheckBox()) - } + + def create_line(self, t): + if t in MIN_MAX_DICT: + s = QDoubleSpinBox() + s.setDecimals(0) + return NumberElement(s, type=t) + if t in FLOAT_TYPES: + return NumberElement(QDoubleSpinBox()) + if t == "System.Boolean": + return CheckboxElement(QCheckBox()) + return TextElement(QLineEdit()) def update_ui(self): self.properties.clear() @@ -47,9 +51,9 @@ def update_ui(self): prop_type = self.game_data["maid_status_settable"][maid_prop] name = QTableWidgetItem(maid_prop) name.setWhatsThis(f"maid_props.{maid_prop}") - line = self.type_generators[prop_type]() + line = self.create_line(prop_type) - if prop_type != "bool": + if prop_type != "System.Boolean": line.qt_element.setStyleSheet("width: 15em;") else: line.checkbox.setProperty("prop_name", maid_prop) diff --git a/GUI/maidfiddler/ui/tabs/player.py b/GUI/maidfiddler/ui/tabs/player.py index c9aa9f9..0f9c3fb 100644 --- a/GUI/maidfiddler/ui/tabs/player.py +++ b/GUI/maidfiddler/ui/tabs/player.py @@ -1,7 +1,7 @@ from PyQt5.QtWidgets import QHeaderView, QTableWidgetItem, QCheckBox, QWidget, QHBoxLayout, QLineEdit, QSpinBox, QDoubleSpinBox, QGroupBox from PyQt5.QtCore import Qt, pyqtSignal from .ui_tab import UiTab -from maidfiddler.ui.qt_elements import NumberElement, TextElement, CheckboxElement +from maidfiddler.ui.qt_elements import NumberElement, TextElement, CheckboxElement, MIN_MAX_DICT, FLOAT_TYPES from maidfiddler.util.translation import tr, tr_str @@ -13,13 +13,17 @@ def __init__(self, ui): UiTab.__init__(self, ui) self.properties = {} - self.type_generators = { - "uint": lambda: NumberElement(QSpinBox(), 0, 2**32), - "int": lambda: NumberElement(QSpinBox()), - "double": lambda: NumberElement(QDoubleSpinBox()), - "string": lambda: TextElement(QLineEdit()), - "bool": lambda: CheckboxElement(QCheckBox()) - } + + def create_line(self, t): + if t in MIN_MAX_DICT: + s = QDoubleSpinBox() + s.setDecimals(0) + return NumberElement(s, type=t) + if t in FLOAT_TYPES: + return NumberElement(QDoubleSpinBox()) + if t == "System.Boolean": + return CheckboxElement(QCheckBox()) + return TextElement(QLineEdit()) def update_ui(self): self.properties.clear() @@ -40,10 +44,10 @@ def update_ui(self): prop_type = self.game_data["player_status_settable"][prop] name = QTableWidgetItem(prop) name.setWhatsThis(f"player_props.{prop}") - line = self.type_generators[prop_type]() + line = self.create_line(prop_type) line.qt_element.setProperty("prop_name", prop) - if prop_type != "bool": + if prop_type != "System.Boolean": line.qt_element.setStyleSheet("width: 15em;") else: line.checkbox.setProperty("prop_name", prop) diff --git a/GUI/translations/english.json b/GUI/translations/english.json index 42abe88..911d786 100644 --- a/GUI/translations/english.json +++ b/GUI/translations/english.json @@ -209,7 +209,8 @@ "totalEvaluations": "Total evaluations", "sales": "Sales", "totalSales": "Total sales", - "isNickNameCall": "Call by nickname" + "isNickNameCall": "Call by nickname", + "nockName": "Nickname" }, "maid_bonus_props": { "excite": "Excitement", diff --git a/Installer/README.txt b/Installer/README.txt index 4660ff5..8844d90 100644 --- a/Installer/README.txt +++ b/Installer/README.txt @@ -7,6 +7,11 @@ Maid Fiddler is a real-time game manipulation tool for COM3D2. Changelog: +* 1.0.4.4 + - Fix overflow error in some properties +* 1.0.4.3 + - Fix certain maid properties not being handled correctly by the GUI + - Update English UI for 1.28 * 1.0.4.2 - Fix some UI elements for non-negative integers permitting negative values - Fix crashing when personality is changed to Ladylike (for real this time) diff --git a/Installer/installer.iss b/Installer/installer.iss index ce0c51b..8c1e8d1 100644 --- a/Installer/installer.iss +++ b/Installer/installer.iss @@ -3,7 +3,7 @@ #define MyAppName "Maid Fiddler" #define MyAppPub "NeighTools" -#define MyAppVersion "1.0.4.2" +#define MyAppVersion "1.0.4.4" #define MyAppURL "https://github.com/denikson/COM3D2.MaidFiddler" #define MyAppExeName "maid_fiddler_qt.exe"