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