Skip to content

Commit

Permalink
Fix #14
Browse files Browse the repository at this point in the history
  • Loading branch information
ghorsington committed Apr 13, 2019
1 parent 04bc076 commit 9eccc0d
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 69 deletions.
24 changes: 6 additions & 18 deletions Core/COM3D2.MaidFiddler.Plugin/Service/Service.GameMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ private Dictionary<string, string> 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";
});
}

Expand All @@ -103,15 +97,9 @@ private Dictionary<string, string> 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";
});
}

Expand Down
42 changes: 15 additions & 27 deletions Core/COM3D2.MaidFiddler.Plugin/Utils/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,25 @@ namespace COM3D2.MaidFiddler.Core.Utils
{
public static class Extensions
{
private static readonly HashSet<Type> FloatTypes = new HashSet<Type> {typeof(float), typeof(double), typeof(decimal)};

private static readonly HashSet<Type> IntegerTypes = new HashSet<Type>
private static readonly HashSet<Type> NativeFileTypes = new HashSet<Type>
{
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<Type> UnsignedIntegerTypes = new HashSet<Type>
{
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));
}
}
}
2 changes: 1 addition & 1 deletion GUI/app_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "1.0.4.3"
VERSION = "1.0.4.4"

CONTRIBUTORS = [
"@ghorsington -- original developer",
Expand Down
22 changes: 21 additions & 1 deletion GUI/maidfiddler/ui/qt_elements.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)

Expand Down
24 changes: 14 additions & 10 deletions GUI/maidfiddler/ui/tabs/maid_stats.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 14 additions & 10 deletions GUI/maidfiddler/ui/tabs/player.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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()
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion GUI/translations/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions Installer/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Installer/installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 9eccc0d

Please sign in to comment.