Skip to content

Commit c166437

Browse files
committed
Checkbox
1 parent 0115ac6 commit c166437

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

editor/inspector.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ def load(self, hierarchyItem):
7474

7575
name_input = main_section.add_value("name", self.props[0], self.gameObject.name)
7676
name_input.edited.connect(hierarchyItem.rename)
77-
tag_input = main_section.add_value("tag", self.props[2], self.gameObject.tag.tag)
77+
tag_input = main_section.add_value("tag", self.props[1], self.gameObject.tag.tag)
7878
tag_input.prevent_modify = True # temporarily until i implement tag dropdowns
7979

80+
enabled_input = main_section.add_value("enabled", pyu.ShowInInspector(bool, True, "enabled"), True)
81+
8082
for component in self.gameObject.components:
8183
section = self.add_section(component)
8284
for name, val in component.shown.items():
@@ -175,6 +177,36 @@ def check(self, string):
175177
if match is not None and match.group(0) == string:
176178
return re.sub(regex, replace, string, 1)
177179

180+
class InspectorBoolEdit(QCheckBox, InspectorInput):
181+
edited = pyqtSignal(object)
182+
def __init__(self, parent, prop, orig):
183+
super(InspectorBoolEdit, self).__init__(parent)
184+
self.setStyleSheet("QCheckBox{color: rgba(0,0,0,0);}")
185+
self.prop = prop
186+
self.orig = orig
187+
self.value = True
188+
self.label = None
189+
self.setChecked(True)
190+
191+
def on_edit(self, value):
192+
if value != self.value:
193+
self.modified = True
194+
font = self.label.font()
195+
font.setBold(self.modified)
196+
self.label.setFont(font)
197+
self.value = value
198+
self.setChecked(self.value)
199+
self.edited.emit(self)
200+
201+
def reset_bold(self):
202+
self.modified = False
203+
font = self.label.font()
204+
font.setBold(self.modified)
205+
self.label.setFont(font)
206+
207+
def get(self):
208+
return self.value
209+
178210
class InspectorVector3Edit(InspectorInput):
179211
edited = pyqtSignal(object)
180212
def __init__(self, parent, prop, orig):
@@ -377,6 +409,7 @@ def add_value(self, orig, prop, value=None):
377409
str: InspectorTextEdit,
378410
int: InspectorIntEdit,
379411
float: InspectorFloatEdit,
412+
bool: InspectorBoolEdit,
380413
pyu.Vector3: InspectorVector3Edit,
381414
pyu.Quaternion: InspectorQuaternionEdit,
382415
}

0 commit comments

Comments
 (0)