Added Custom Blueprint Background
This commit is contained in:
parent
9214a73b83
commit
2c2ea67775
BIN
Modules/__pycache__/graph_gradient_style.cpython-312.pyc
Normal file
BIN
Modules/__pycache__/graph_gradient_style.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/borealis_graph_style.cpython-312.pyc
Normal file
BIN
__pycache__/borealis_graph_style.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/myscene.cpython-312.pyc
Normal file
BIN
__pycache__/myscene.cpython-312.pyc
Normal file
Binary file not shown.
94
borealis.py
94
borealis.py
@ -1,36 +1,39 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# --- Patch QGraphicsScene.setSelectionArea to handle selection arguments ---
|
|
||||||
from Qt import QtWidgets, QtCore, QtGui
|
from Qt import QtWidgets, QtCore, QtGui
|
||||||
|
|
||||||
_original_setSelectionArea = QtWidgets.QGraphicsScene.setSelectionArea
|
|
||||||
|
|
||||||
def _patched_setSelectionArea(self, *args, **kwargs):
|
|
||||||
try:
|
|
||||||
return _original_setSelectionArea(self, *args, **kwargs)
|
|
||||||
except TypeError as e:
|
|
||||||
# If only a QPainterPath is provided, supply default mode and transform.
|
|
||||||
if len(args) == 1:
|
|
||||||
painterPath = args[0]
|
|
||||||
return _original_setSelectionArea(self, painterPath,
|
|
||||||
QtCore.Qt.ReplaceSelection,
|
|
||||||
QtGui.QTransform())
|
|
||||||
raise e
|
|
||||||
|
|
||||||
# Monkey-patch the setSelectionArea method.
|
|
||||||
QtWidgets.QGraphicsScene.setSelectionArea = _patched_setSelectionArea
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import importlib
|
import importlib
|
||||||
import inspect
|
import inspect
|
||||||
from Qt import QtWidgets, QtCore, QtGui
|
|
||||||
|
# Patch QGraphicsScene.setSelectionArea to handle selection arguments
|
||||||
|
_original_setSelectionArea = QtWidgets.QGraphicsScene.setSelectionArea
|
||||||
|
|
||||||
|
def _patched_setSelectionArea(self, painterPath, second_arg, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
# Try calling the original method with the provided arguments.
|
||||||
|
return _original_setSelectionArea(self, painterPath, second_arg, *args, **kwargs)
|
||||||
|
except TypeError:
|
||||||
|
# If a TypeError is raised, assume the call was made with only a QPainterPath
|
||||||
|
# and an ItemSelectionMode, and patch it by supplying defaults.
|
||||||
|
# Default operation: ReplaceSelection, default transform: QTransform()
|
||||||
|
return _original_setSelectionArea(
|
||||||
|
self,
|
||||||
|
painterPath,
|
||||||
|
QtCore.Qt.ReplaceSelection,
|
||||||
|
second_arg,
|
||||||
|
QtGui.QTransform()
|
||||||
|
)
|
||||||
|
|
||||||
|
QtWidgets.QGraphicsScene.setSelectionArea = _patched_setSelectionArea
|
||||||
|
|
||||||
from OdenGraphQt import NodeGraph, BaseNode
|
from OdenGraphQt import NodeGraph, BaseNode
|
||||||
|
|
||||||
def import_nodes_from_folder(package_name):
|
def import_nodes_from_folder(package_name):
|
||||||
"""
|
"""
|
||||||
Dynamically import all modules from the given package and return a list of
|
Dynamically import all modules from the given package
|
||||||
classes that subclass BaseNode.
|
and return a list of classes that subclass BaseNode.
|
||||||
"""
|
"""
|
||||||
imported_nodes = []
|
imported_nodes = []
|
||||||
package = importlib.import_module(package_name)
|
package = importlib.import_module(package_name)
|
||||||
@ -41,23 +44,19 @@ def import_nodes_from_folder(package_name):
|
|||||||
imported_nodes.append(obj)
|
imported_nodes.append(obj)
|
||||||
return imported_nodes
|
return imported_nodes
|
||||||
|
|
||||||
def make_node_command(graph, nt):
|
def make_node_command(graph, node_type_str):
|
||||||
"""
|
"""
|
||||||
Given a NodeGraph instance and a node type string nt, return a command
|
Return a function that creates a node of the given type at the current cursor position.
|
||||||
function that creates a node of that type at the current mouse location.
|
|
||||||
"""
|
"""
|
||||||
def command():
|
def command():
|
||||||
try:
|
try:
|
||||||
# Get the current cursor position in scene coordinates
|
|
||||||
pos = graph.cursor_pos()
|
pos = graph.cursor_pos()
|
||||||
# Create the node with the current cursor position.
|
graph.create_node(node_type_str, pos=pos)
|
||||||
node = graph.create_node(nt, pos=pos)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error creating node of type {nt}: {e}")
|
print("Error creating node of type {}: {}".format(node_type_str, e))
|
||||||
return command
|
return command
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
|
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
|
|
||||||
# Create the NodeGraph controller.
|
# Create the NodeGraph controller.
|
||||||
@ -65,18 +64,17 @@ if __name__ == '__main__':
|
|||||||
graph.widget.setWindowTitle("Project Borealis - Flyff Information Overlay")
|
graph.widget.setWindowTitle("Project Borealis - Flyff Information Overlay")
|
||||||
|
|
||||||
# Dynamically import custom node classes from the 'Nodes' package.
|
# Dynamically import custom node classes from the 'Nodes' package.
|
||||||
custom_nodes = import_nodes_from_folder('Nodes')
|
custom_nodes = import_nodes_from_folder("Nodes")
|
||||||
for node_class in custom_nodes:
|
for node_class in custom_nodes:
|
||||||
graph.register_node(node_class)
|
graph.register_node(node_class)
|
||||||
|
|
||||||
# Add context menu commands for dynamic node creation.
|
# Add context menu commands for dynamic node creation.
|
||||||
graph_context_menu = graph.get_context_menu('graph')
|
graph_context_menu = graph.get_context_menu("graph")
|
||||||
for node_class in custom_nodes:
|
for node_class in custom_nodes:
|
||||||
# Build the node type string: "<__identifier__>.<ClassName>"
|
node_type = "{}.{}".format(node_class.__identifier__, node_class.__name__)
|
||||||
node_type = f"{node_class.__identifier__}.{node_class.__name__}"
|
|
||||||
node_name = node_class.NODE_NAME
|
node_name = node_class.NODE_NAME
|
||||||
graph_context_menu.add_command(
|
graph_context_menu.add_command(
|
||||||
f"Add {node_name}",
|
"Add {}".format(node_name),
|
||||||
make_node_command(graph, node_type)
|
make_node_command(graph, node_type)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -86,11 +84,28 @@ if __name__ == '__main__':
|
|||||||
lambda: [graph.remove_node(node) for node in graph.selected_nodes()] if graph.selected_nodes() else None
|
lambda: [graph.remove_node(node) for node in graph.selected_nodes()] if graph.selected_nodes() else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Grid styling changes
|
||||||
|
# 1) Dark background color
|
||||||
|
graph.set_background_color(20, 20, 20) # Dark gray
|
||||||
|
# 2) Subdued grid color
|
||||||
|
graph.set_grid_color(60, 60, 60) # Gray grid lines
|
||||||
|
|
||||||
|
# Optionally, create a subtle gradient in the scene:
|
||||||
|
scene = graph.scene()
|
||||||
|
|
||||||
|
# A QLinearGradient that uses ObjectBoundingMode so it stretches to fill the scene.
|
||||||
|
gradient = QtGui.QLinearGradient(0, 0, 0, 1)
|
||||||
|
gradient.setCoordinateMode(QtGui.QGradient.ObjectBoundingMode)
|
||||||
|
gradient.setColorAt(0.0, QtGui.QColor(9, 44, 68)) # Very Top Gradient
|
||||||
|
gradient.setColorAt(0.3, QtGui.QColor(30, 30, 30)) # Middle Gradient
|
||||||
|
gradient.setColorAt(0.7, QtGui.QColor(30, 30, 30)) # Middle Gradient
|
||||||
|
gradient.setColorAt(1.0, QtGui.QColor(9, 44, 68)) # Very Bottom Gradient
|
||||||
|
scene.setBackgroundBrush(QtGui.QBrush(gradient))
|
||||||
|
|
||||||
# Resize and show the graph widget.
|
# Resize and show the graph widget.
|
||||||
graph.widget.resize(1920, 1080)
|
graph.widget.resize(1600, 900)
|
||||||
graph.widget.show()
|
graph.widget.show()
|
||||||
|
|
||||||
# Global update timer:
|
|
||||||
def global_update():
|
def global_update():
|
||||||
for node in graph.all_nodes():
|
for node in graph.all_nodes():
|
||||||
if hasattr(node, "process_input"):
|
if hasattr(node, "process_input"):
|
||||||
@ -98,8 +113,9 @@ if __name__ == '__main__':
|
|||||||
node.process_input()
|
node.process_input()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error updating node", node, e)
|
print("Error updating node", node, e)
|
||||||
|
|
||||||
timer = QtCore.QTimer()
|
timer = QtCore.QTimer()
|
||||||
timer.timeout.connect(global_update)
|
timer.timeout.connect(global_update)
|
||||||
timer.start(500)
|
timer.start(500)
|
||||||
|
|
||||||
sys.exit(app.exec())
|
sys.exit(app.exec_())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user