diff --git a/dist/ZlmData/zlmOps.txt b/dist/ZlmData/zlmOps.txt index 82dd9e6..d491105 100644 --- a/dist/ZlmData/zlmOps.txt +++ b/dist/ZlmData/zlmOps.txt @@ -122,8 +122,13 @@ , counter] [VarSet, currentSubToolIndex, [SubToolGetActiveIndex]] - [VarSet, subtoolLine, [StrMerge, "SubTools: ", #currentSubToolIndex, [StrFromAsc, 10]]] - [VarAdd, currentSize, [StrLength, subtoolLine]] + [VarSet, subtoolLine, [StrMerge, "SubTools: ", #currentSubToolIndex]] + [If, [IExists, "Tool:Geometry:SDiv"], + + [VarSet, subtoolLine, [StrMerge, #subtoolLine, " ", [IGet, "Tool:Geometry:SDiv"], " ", [IGetMax, "Tool:Geometry:SDiv"]]] + ] + [VarSet, subtoolLine, [StrMerge, #subtoolLine, [StrFromAsc, 10]]] + [VarAdd, currentSize, [StrLength, #subtoolLine]] // Check if memory is big enough // Resize it enough so we dont have to resize everytime [If, currentSize > [MemGetSize, layerNameMem], @@ -134,7 +139,12 @@ [VarSet, subToolCount, [SubToolGetCount]] [Loop, subToolCount, [SubToolSelect, #index] - [VarSet, subToolName, [StrMerge, #quote, [IGetTitle, "Tool:ItemInfo"], #quote]] + [VarSet, subToolFolder, [SubToolGetFolderName, #index]] + [If, [StrLength, subToolFolder], + [VarSet, subToolName, [StrMerge, #quote, subToolFolder, "/", [IGetTitle, "Tool:ItemInfo"], #quote]] + , + [VarSet, subToolName, [StrMerge, #quote, [IGetTitle, "Tool:ItemInfo"], #quote]] + ] [If, #index + 1 < subToolCount, [VarSet, subToolName, [StrMerge, #subToolName, [StrFromAsc, 10]]] ] diff --git a/src/zlm_core.py b/src/zlm_core.py index b53518f..873a151 100644 --- a/src/zlm_core.py +++ b/src/zlm_core.py @@ -93,6 +93,8 @@ def __init__(self): self.instances_list: List[ZlmLayer] = [] self.current_sub_tool: int = 0 + self.current_sub_tool_sdiv: int = 0 + self.current_sub_tool_sdiv_max: int = 0 self.subtools: List[ZlmSubTool] = [] self.recording_layer = None @@ -234,9 +236,16 @@ def _parse_subtool_line(self, lines: List[str]): if not lines: return - line = lines[0].strip() + splitted = lines[0].strip().split() # get current subtool - self.current_sub_tool = int(line.split(' ')[1]) + self.current_sub_tool = int(splitted[1]) + try: + self.current_sub_tool_sdiv = int(splitted[2]) + self.current_sub_tool_sdiv_max = int(splitted[3]) + except: + self.current_sub_tool_sdiv = 0 + self.current_sub_tool_sdiv_max = 0 + for index, line in enumerate(lines[1:]): self.subtools.append(ZlmSubTool.from_line(line, index)) diff --git a/src/zlm_to_zbrush.py b/src/zlm_to_zbrush.py index b2478d6..ccba983 100644 --- a/src/zlm_to_zbrush.py +++ b/src/zlm_to_zbrush.py @@ -368,3 +368,9 @@ def send_new_sub_tool(index: int, port: int): ] """) _send_script() + + +def send_sdiv_level(lvl: int): + with zsc.ZScript(zlm_info.SCRIPT_PATH): + zsc.SubdivSet(lvl) + _send_script() diff --git a/src/zlm_ui/main_ui.py b/src/zlm_ui/main_ui.py index 975dc34..0d07771 100644 --- a/src/zlm_ui/main_ui.py +++ b/src/zlm_ui/main_ui.py @@ -23,7 +23,8 @@ send_to_zbrush, send_update_request, send_new_layers_name, - send_new_sub_tool + send_new_sub_tool, + send_sdiv_level ) import zlm_app import version @@ -77,6 +78,42 @@ def stop_looking_for_update(self): return not self.cb_check_for_update.isChecked() +class SDivWidget(QtWidgets.QWidget): + + def __init__(self) -> None: + super().__init__() + self.sld = QtWidgets.QSlider(orientation=QtCore.Qt.Horizontal) + self.lbl = QtWidgets.QLabel("SDiv") + self.sld.valueChanged.connect(self.update_lbl_text) + self.sld.sliderReleased.connect(self.slider_released) + layout = QtWidgets.QVBoxLayout() + layout.setSpacing(0) + layout.addWidget(self.lbl) + layout.addWidget(self.sld) + layout.setContentsMargins(10, 0, 10, 0) + self.setLayout(layout) + + def slider_released(self): + value = self.sld.value() + send_sdiv_level(value) + + def update_lbl_text(self, index): + self.lbl.setText(f"SDiv {index}") + + def set_cur_max(self, current: int, pmax: int): + self.sld.blockSignals(True) + if pmax > 0: + self.update_lbl_text(current) + self.sld.setRange(1, pmax) + self.sld.setValue(current) + self.setEnabled(True) + else: + self.lbl.setText("SDiv") + self.sld.setRange(1, 1) + self.setEnabled(False) + self.sld.blockSignals(False) + + class ZlmMainUI(QtWidgets.QMainWindow): closing = QtCore.pyqtSignal() showing = QtCore.pyqtSignal() @@ -102,25 +139,15 @@ def __init__(self, file_path=None): self.tw_widget = ZlmLayerWidget(self) self.lbl_subtool = QtWidgets.QLabel("SubTool: ") - self.lbl_layer_count = QtWidgets.QLabel("0") - - pb_option = QtWidgets.QPushButton(QtGui.QIcon(':/gear.png'), '') - pb_option.clicked.connect(self.show_option) - - pb_help = QtWidgets.QPushButton(QtGui.QIcon(':/help.png'), '') - pb_help.clicked.connect(self.open_help_url) - self.cb_subtool = QtWidgets.QComboBox() self.cb_subtool.currentIndexChanged.connect(self.sub_tool_index_changed) + self.sdiv_widget = SDivWidget() + topLayout = QtWidgets.QHBoxLayout() topLayout.addWidget(self.lbl_subtool, 0) - topLayout.addWidget(self.cb_subtool, 1) - topLayout.addWidget(self.lbl_layer_count, 0, QtCore.Qt.AlignRight) - topLayout.addWidget(QtWidgets.QLabel("Layers"), 0, QtCore.Qt.AlignRight) - topLayout.addSpacing(20) - topLayout.addWidget(pb_option, 0) - topLayout.addWidget(pb_help, 0) + topLayout.addWidget(self.cb_subtool, 5) + topLayout.addWidget(self.sdiv_widget, 3) mainLayout = QtWidgets.QVBoxLayout() @@ -143,12 +170,21 @@ def __init__(self, file_path=None): bulk_rename = menu.addAction(QtGui.QIcon(':/rename.png'), "Rename all") bulk_rename.triggered.connect(self.bulk_rename) + menu.addSeparator() + + settings_act = menu.addAction(QtGui.QIcon(":/gear.png"), "Settings") + settings_act.triggered.connect(self.show_option) + + help_menu = menuBar.addMenu("Help") + pb_help = help_menu.addAction(QtGui.QIcon(':/help.png'), 'Open Documentation') + pb_help.triggered.connect(self.open_help_url) + + bug_action = help_menu.addAction("Flag bug") + bug_action.triggered.connect(self.flag_a_bug) + zlm_app.on_exception.append(self.on_error) zlm_app.on_port_not_set.append(self.on_port_not_set) - for i in range(3): - zlm_core.main_layers.add_callback(i, self.update_layer_count) - if file_path and os.path.exists(file_path): self.load_layers(file_path) @@ -220,6 +256,10 @@ def update_subtool_label(self): self.cb_subtool.addItems([st.name for st in zlm_core.main_layers.subtools]) self.cb_subtool.setCurrentIndex(zlm_core.main_layers.current_sub_tool) self.cb_subtool.blockSignals(signal_blocked) + self.sdiv_widget.set_cur_max( + zlm_core.main_layers.current_sub_tool_sdiv, + zlm_core.main_layers.current_sub_tool_sdiv_max + ) def _apply_custom_stylesheet(self): if getattr(sys, 'frozen', False): @@ -256,8 +296,11 @@ def open_help_url(self): except: pass - def update_layer_count(self, *args, **kwargs): - self.lbl_layer_count.setText(str(len(zlm_core.main_layers.instances_list))) + def flag_a_bug(self): + try: + webbrowser.open("https://github.com/JonasOuellet/zlayermanager/issues") + except: + pass def on_port_not_set(self, app): QtWidgets.QMessageBox.warning( diff --git a/src/zlm_ui/stylesheet.css b/src/zlm_ui/stylesheet.css index 13c0a4d..0f0198d 100644 --- a/src/zlm_ui/stylesheet.css +++ b/src/zlm_ui/stylesheet.css @@ -8,6 +8,10 @@ QLabel { background-color: rgba(0, 0, 0, 0); } +QLabel:disabled { + color: rgb(136, 136, 136); +} + QPushButton { border-style: solid; border-width: 1px; @@ -169,6 +173,14 @@ QSlider::groove{ stop:1 rgba(176, 176, 176, 50)); } +QSlider::groove:disabled { + background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, + stop:0 rgba(176, 176, 176, 23), + stop:0.5 rgba(176, 176, 176, 180), + stop:1 rgba(176, 176, 176, 23)); +} + + QSlider::handle { background-color: rgb(255, 144, 37); border-style: solid; @@ -177,6 +189,10 @@ QSlider::handle { border-color: rgb(0, 0, 0); } +QSlider::handle:disabled { + background-color: rgb(153, 107, 64); +} + QSlider::handle:hover { background-color: rgb(255, 160, 64); } diff --git a/src/zlm_ui/zlm_layerTree.py b/src/zlm_ui/zlm_layerTree.py index 18b57a2..db3bb6c 100644 --- a/src/zlm_ui/zlm_layerTree.py +++ b/src/zlm_ui/zlm_layerTree.py @@ -435,6 +435,7 @@ def build(self, text, mode): for layer in main_layers.instances_list: self.create_layer(layer) + self.updateColumnSize() def update_layer(self): column = self.sortColumn() @@ -445,7 +446,7 @@ def update_layer(self): for key, layers in self.itemDict.items(): for item in layers: item.update() - + if item.layer.mode == ZlmLayerMode.record: self.current_item_recording = item