Skip to content

Commit

Permalink
Dock is correctly responsive now. Added dialog functions for user fee…
Browse files Browse the repository at this point in the history
…dback. Updates to readme. Added license
  • Loading branch information
p-hennessy committed Mar 27, 2024
1 parent 09efb2f commit 2a1b1b8
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 67 deletions.
20 changes: 20 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2012-2024 Scott Chacon and others

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# VTF Exporter for Substance 3D Designer

![Static Badge](https://img.shields.io/badge/Compatible_Versions-%3E2022.2-blue?style=flat-square&logo=adobe)
![GitHub License](https://img.shields.io/github/license/p-hennessy/Substance-VTF-Exporter-Plugin?style=flat-square)


> [!WARNING]
> This plugin is still in very early alpha / active development. I made no gaurentees of stability or reverse compatibility.
> This plugin is still in very early alpha / active development. I make no gaurentees of stability or reverse compatibility.
A plugin for Substance 3D Designer that allows one to do bulk exporting of materials into the Source Engine's VTF format

Expand Down
6 changes: 3 additions & 3 deletions pluginInfo.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"metadata_format_version": "1",
"name": "vtf_exporter",
"version": "0.2.0",
"version": "0.2.1",
"author": "Patrick 'Zeus' Hennessy",
"email": "https://tf2maps.net/members/zeus.28272/",
"min_designer_version": "2019.2",
"platform": "windows"
"min_designer_version": "2022.2",
"platform": "any"
}
14 changes: 7 additions & 7 deletions vtf_exporter/actions/export_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,36 @@ def export_presets():
logger.info("Running error checking before export...")

if not global_config.get("vtex_location"):
dialogs.notify("You need to configure your VTEX location to run this function.")
dialogs.critical("You need to configure your VTEX location to run this function.")
return

vtex_location = Path(global_config.get("vtex_location"))
vtex_exe = vtex_location / "vtex.exe"
if not vtex_exe.exists():
dialogs.notify(f"vtex.exe could not be found at {vtex_location}")
dialogs.critical(f"vtex.exe could not be found at {vtex_location}")
return

if not graph:
dialogs.notify("Please select a graph to run this function on")
dialogs.critical("Please select a graph to run this function on")
return

graph_uuid = get_graph_uuid()
graph_config = config.get_graph_config(graph_uuid)

if not graph_config:
dialogs.notify("You must setup and / or save your graph configuration to run this function")
dialogs.critical("You must setup and / or save your graph configuration to run this function")
return

if not graph_config.get("export_location"):
dialogs.notify("You must have a valid export location")
dialogs.critical("You must have a valid export location")
retur

if len(graph.getOutputNodes()) == 0:
dialogs.notify("You need graph outputs to run this function")
dialogs.critical("You need graph outputs to run this function")
return

if len(graph.getPresets()) == 0:
dialogs.notify("You need to set up graph presets to run this function")
dialogs.critical("You need to set up graph presets to run this function")
return

logger.info("Saving current graph input settings...")
Expand Down
2 changes: 1 addition & 1 deletion vtf_exporter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def get_config_base_path():
CONFIG_DIR = SUBSTANCE_DIR / "vtf_exporter"
GLOBAL_CONFIG_FILE = CONFIG_DIR / "global_configuration.json"

PLUGIN_VERSION = "0.2.0"
PLUGIN_VERSION = "0.2.1"
9 changes: 6 additions & 3 deletions vtf_exporter/ui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sd
from PySide2 import QtWidgets
from PySide2 import QtCore, QtWidgets, QtUiTools
from PySide2.QtWidgets import QApplication, QFileDialog

Expand All @@ -16,11 +15,15 @@ def create_panel():
ui_manager = app.getQtForPythonUIMgr()
DOCK = ui_manager.newDockWidget(identifier="vtf_exporter", title="VTF Exporter")

layout = QtWidgets.QVBoxLayout()
DOCK.setLayout(layout)

widget = load_ui_file("panel.ui", parent=DOCK)
load_global_settings(widget)
setup_event_handlers(ui_manager, widget)
layout.addWidget(widget)
widget.show()


def destroy_panel():
global DOCK
Expand All @@ -34,7 +37,7 @@ def load_ui_file(filename, parent=None):
path = os.path.join(current_directory, filename)

loader = QtUiTools.QUiLoader()
uifile = QtCore.QFile(path)
uifile = QtCore.QFile(filename)
uifile.open(QtCore.QFile.ReadOnly)
ui = loader.load(uifile, parent)
uifile.close()
Expand Down
20 changes: 15 additions & 5 deletions vtf_exporter/ui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ def get_directory(prompt="Select a folder"):
return directory


def notify(message):
def notify(msgbox_type, message):
app = sd.getContext().getSDApplication()
uiMgr = app.getQtForPythonUIMgr()
mainWindow = uiMgr.getMainWindow()

dialog = QtWidgets.QMessageBox(parent=mainWindow)
dialog.setWindowTitle("VTF Exporter")
dialog.setText(message)
dialog.show()
dialog = msgbox_type(mainWindow, "VTF Exporter", message)
dialog.show()


def critical(message):
notify(QtWidgets.QMessageBox.critical, message)


def informational(message):
notify(QtWidgets.QMessageBox.informational, message)


def warning(message):
notify(QtWidgets.QMessageBox.warning, message)
6 changes: 3 additions & 3 deletions vtf_exporter/ui/event_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def on_btn_save_global_config(widget):
vtex_location_path = pathlib.Path(vtex_location) / "vtex.exe"

if not vtex_location_path.exists():
dialogs.notify(f"vtex.exe could not be found at {vtex_location}")
dialogs.critical(f"vtex.exe could not be found at {vtex_location}")
return

config_data = {
Expand All @@ -42,7 +42,7 @@ def on_btn_save_global_config(widget):
try:
config.save_global_config(config_data)
except Exception as e:
dialogs.notify(f"Failed to save global config.\n {e}")
dialogs.critical(f"Failed to save global config.\n {e}")

set_saved(widget.lbl_global_config)

Expand Down Expand Up @@ -76,7 +76,7 @@ def on_btn_save_graph_config(widget):
try:
config.save_graph_config(graph_uuid, config_data)
except Exception as e:
dialogs.notify(f"Failed to graph config.\n {e}")
dialogs.critical(f"Failed to save graph config.\n {e}")

set_saved(widget.lbl_graph_config)

Expand Down
57 changes: 13 additions & 44 deletions vtf_exporter/ui/panel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,12 @@
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>410</width>
<height>651</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>10</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="lbl_global_config">
<property name="font">
Expand Down Expand Up @@ -509,6 +465,19 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
Expand Down

0 comments on commit 2a1b1b8

Please sign in to comment.