fixed the probability spinbox look and refactored the code slightly
parent
e489737f5f
commit
ccf1b2b53f
|
@ -221,31 +221,31 @@ class SpawnEditWidget(QWidget):
|
|||
layout.addWidget(change_font_size(QLabel(text), 0.8), 0, i)
|
||||
|
||||
self.spawn = {"outpostcrewcabinet": {"label": QLabel("Outpost Crew Cabinet"),
|
||||
"float": ProbabilitySpinBox()},
|
||||
"value": ProbabilitySpinBox()},
|
||||
"wreckstorage": {"label": QLabel("Wreck Storage"),
|
||||
"float": ProbabilitySpinBox()},
|
||||
"value": ProbabilitySpinBox()},
|
||||
"abandonedcrewcab": {"label": QLabel("Abandoned Crew Cabinet"),
|
||||
"float": ProbabilitySpinBox()},
|
||||
"value": ProbabilitySpinBox()},
|
||||
"abandonedstoragecab": {"label": QLabel("Abandoned Storage Cabinet"),
|
||||
"float": ProbabilitySpinBox()}}
|
||||
"value": ProbabilitySpinBox()}}
|
||||
|
||||
for i, (location, editors) in enumerate(self.spawn.items()):
|
||||
layout.addWidget(editors["label"], int(i) + 1, 0)
|
||||
layout.addWidget(editors["float"], int(i) + 1, 1)
|
||||
layout.addWidget(editors["value"], int(i) + 1, 1)
|
||||
|
||||
self.load()
|
||||
|
||||
for i, (location, editors) in enumerate(self.spawn.items()):
|
||||
editors["float"].valueChanged.connect(self.save)
|
||||
editors["value"].valueChanged.connect(self.save)
|
||||
|
||||
def load(self):
|
||||
for locale in self.tape["spawn"]:
|
||||
self.spawn[locale["location"]]["float"].setValue(locale["probability"])
|
||||
self.spawn[locale["location"]]["value"].setValue(locale["probability"])
|
||||
|
||||
def save(self):
|
||||
self.tape["spawn"] = [{"location": location,
|
||||
"probability": editors["float"].value()} for location, editors in self.spawn.items() if
|
||||
editors["float"].value() > 0]
|
||||
"probability": editors["value"].value()} for location, editors in self.spawn.items() if
|
||||
editors["value"].value() > 0]
|
||||
|
||||
|
||||
# TODO: afflictions with shorter range for walkman songs.
|
||||
|
@ -329,4 +329,3 @@ class AfflictionsEditWidget(QWidget):
|
|||
def save(self):
|
||||
self.tape["afflictions"] = [{"name": affliction, "factor": editors["float"].value()} for affliction, editors in
|
||||
self.afflictions.items() if editors["cbox"].isChecked()]
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ class ProbabilitySpinBox(DoubleSpinBoxWithoutWheel):
|
|||
self.setSingleStep(0.01)
|
||||
self.valueChanged.connect(self.update_color)
|
||||
self.update_color()
|
||||
self.setMinimumWidth(75)
|
||||
|
||||
def update_color(self):
|
||||
if self.value() > 0:
|
||||
|
|
Loading…
Reference in New Issue