Skip to content

Commit 6a1eedf

Browse files
committed
feat: add warning property for unverified functionality and update color handling in material operations
1 parent 715ac6c commit 6a1eedf

3 files changed

Lines changed: 53 additions & 10 deletions

File tree

src/editors/smartprop_editor/objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@
211211
{'Translate': {'_class': "CSmartPropOperation_Translate", "m_vPosition": {"m_Components":[0,0,0]}}},
212212
{'SetTintColor': {'_class': "CSmartPropOperation_SetTintColor", "m_Mode": "MULTIPLY_OBJECT", "m_ColorChoices": []}},
213213
{'MaterialOverride': {'_class': "CSmartPropOperation_MaterialOverride", "m_bClearCurrentOverrides": False, "m_MaterialReplacements": []}},
214-
{'MaterialTint': {'_class': "CSmartPropOperation_MaterialTint", "m_Material": "", "m_SelectionMode": "SPECIFIC_COLOR", "m_Color": None, "m_ColorPosition": 0.0}},
214+
{'MaterialTint': {'_class': "CSmartPropOperation_MaterialTint", "m_Material": "", "m_SelectionMode": "SPECIFIC_COLOR", "m_Color": [255, 255, 255], "m_ColorPosition": 0.0}},
215215
{'RandomOffset': {'_class': "CSmartPropOperation_RandomOffset", "m_vRandomPositionMin": None, "m_vRandomPositionMax": None, "m_vSnapIncrement": None}},
216216
{'RandomScale': {'_class': "CSmartPropOperation_RandomScale", "m_flRandomScaleMin": 1.0, "m_flRandomScaleMax": 1.0, "m_flSnapIncrement": 0.0}},
217217
{'RandomRotation': {'_class': "CSmartPropOperation_RandomRotation", "m_vRandomRotationMin": None, "m_vRandomRotationMax": None, "m_vSnapIncrement": None}},
218-
{'RandomColorTintColor': {'_class': "CSmartPropOperation_RandomColorTintColor", "m_SelectionMode": "RANDOM", "m_ColorPosition": 0.0, "m_Mode": "MULTIPLY_OBJECT"}},
218+
{'RandomColorTintColor': {'_class': "CSmartPropOperation_RandomColorTintColor", "m_SelectionMode": "RANDOM", "m_Color": [255, 255, 255], "m_ColorPosition": 0.0, "m_Mode": "MULTIPLY_OBJECT"}},
219219
{'CreateSizer': {'_class': "CSmartPropOperation_CreateSizer", "m_Name": "", "m_bDisplayModel": False}},
220220
{'CreateRotator': {'_class': "CSmartPropOperation_CreateRotator", "m_Name": "", "m_vOffset": None, "m_vRotationAxis": None, "m_CoordinateSpace": "WORLD", "m_flDisplayRadius": 16.0, "m_DisplayColor": None, "m_bApplyToCurrentTransform": True, "m_flSnappingIncrement": 0.0, "m_flInitialAngle": 0.0, "m_bEnforceLimits": False, "m_flMinAngle": 0.0, "m_flMaxAngle": 0.0, "m_OutputVariable": ""}},
221221
{'CreateLocator': {'_class': "CSmartPropOperation_CreateLocator", "m_LocatorName": "", "m_vOffset": None, "m_flDisplayScale": 1.0, "m_bConfigurable": True, "m_bAllowTranslation": True, "m_bAllowRotation": True, "m_bAllowScale": True}},
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel
2+
from PySide6.QtCore import Qt, Signal
3+
from src.editors.smartprop_editor.property.base_pooled import PooledPropertyMixin
4+
5+
class PropertyWarning(QWidget, PooledPropertyMixin):
6+
edited = Signal()
7+
def __init__(self, parent=None, **kwargs):
8+
super().__init__(parent)
9+
self.layout = QHBoxLayout(self)
10+
self.layout.setContentsMargins(8, 4, 8, 4)
11+
12+
self.label = QLabel("This property is might not working in Cs2.")
13+
self.label.setStyleSheet("""
14+
color: #ffaa00;
15+
font-weight: bold;
16+
font-size: 9pt;
17+
background-color: rgba(255, 170, 0, 10);
18+
border: 1px solid rgba(255, 170, 0, 30);
19+
border-radius: 0px;
20+
padding: 4px;
21+
""")
22+
self.label.setAlignment(Qt.AlignCenter)
23+
self.layout.addWidget(self.label)
24+
25+
# Identity for consistency, though we don't emit 'edited'
26+
self.value = None
27+
28+
def reconfigure(self, **kwargs):
29+
# Nothing to change for a static warning, but we must implement it for pooling
30+
pass
31+
32+
@classmethod
33+
def _pool_key_from_kwargs(cls, **kwargs):
34+
return ("Warning",)
35+
36+
def _current_pool_key(self):
37+
return ("Warning",)

src/editors/smartprop_editor/property_frame.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from src.editors.smartprop_editor.property.set_variable import PropertyVariableValue
2727
from src.editors.smartprop_editor.property.comment import PropertyComment
2828
from src.editors.smartprop_editor.property.reference import PropertyReference
29+
from src.editors.smartprop_editor.property.warning import PropertyWarning
2930
from PySide6.QtGui import QCursor
3031
from src.widgets import HierarchyItemModel
3132
import uuid
@@ -71,27 +72,27 @@ class PropertyFrame(QWidget):
7172
'RandomOffset': ['m_bEnabled', 'm_vRandomPositionMin', 'm_vRandomPositionMax', 'm_vSnapIncrement'],
7273
'RandomScale': ['m_bEnabled', 'm_flRandomScaleMin', 'm_flRandomScaleMax', 'm_flSnapIncrement'],
7374
'RandomRotation': ['m_bEnabled', 'm_vRandomRotationMin', 'm_vRandomRotationMax', 'm_vSnapIncrement'],
74-
'RandomColorTintColor': ['m_bEnabled', 'm_SelectionMode', 'm_ColorPosition', 'm_Mode'],
75+
'RandomColorTintColor': ['_WARN_NOT_VERIFIED', 'm_bEnabled', 'm_SelectionMode', 'm_Color', 'm_ColorPosition', 'm_Mode'],
7576
'CreateSizer': ['m_bEnabled', 'm_Name', 'm_bDisplayModel'],
7677
'CreateRotator': ['m_bEnabled', 'm_Name', 'm_vOffset', 'm_vRotationAxis', 'm_CoordinateSpace', 'm_flDisplayRadius', 'm_DisplayColor', 'm_bApplyToCurrentTransform', 'm_flSnappingIncrement', 'm_flInitialAngle', 'm_bEnforceLimits', 'm_flMinAngle', 'm_flMaxAngle', 'm_OutputVariable'],
7778
'CreateLocator': ['m_bEnabled', 'm_LocatorName', 'm_vOffset', 'm_flDisplayScale', 'm_bConfigurable', 'm_bAllowTranslation', 'm_bAllowRotation', 'm_bAllowScale'],
7879
'RestoreState': ['m_bEnabled', 'm_bDiscardIfUknown'],
7980
'TraceInDirection': ['m_bEnabled', 'm_DirectionSpace', 'm_flSurfaceUpInfluence', 'm_nNoHitResult', 'm_flOriginOffset', 'm_flTraceLength'],
8081
'SaveState': ['m_bEnabled', 'm_StateName'],
8182
'SetVariable': ['m_bEnabled', 'm_VariableValue'],
82-
'RandomRotationSnapped': ['m_bEnabled', 'm_vMinAngles', 'm_vMaxAngles', 'm_flSnapIncrement', 'm_RotationAxes'],
83+
'RandomRotationSnapped': ['_WARN_NOT_VERIFIED','m_bEnabled', 'm_vMinAngles', 'm_vMaxAngles', 'm_flSnapIncrement', 'm_RotationAxes'],
8384
'ResetRotation': ['m_bEnabled', 'm_bIgnoreObjectRotation', 'm_bResetPitch', 'm_bResetYaw', 'm_bResetRoll'],
8485
'ResetScale': ['m_bEnabled', 'm_bIgnoreObjectScale'],
8586
'RotateTowards': ['m_bEnabled', 'm_vOriginPos', 'm_vTargetPos', 'm_vUpPos', 'm_flWeight', 'm_OriginSpace', 'm_TargetSpace', 'm_UpSpace'],
86-
'SaveColor': ['m_bEnabled', 'm_VariableName'],
87-
'SaveDirection': ['m_bEnabled', 'm_DirectionVector', 'm_CoordinateSpace', 'm_VariableName'],
88-
'SavePosition': ['m_bEnabled', 'm_CoordinateSpace', 'm_VariableName'],
87+
'SaveColor': ['_WARN_NOT_VERIFIED', 'm_bEnabled', 'm_VariableName'],
88+
'SaveDirection': ['_WARN_NOT_VERIFIED', 'm_bEnabled', 'm_DirectionVector', 'm_CoordinateSpace', 'm_VariableName'],
89+
'SavePosition': ['_WARN_NOT_VERIFIED', 'm_bEnabled', 'm_CoordinateSpace', 'm_VariableName'],
8990
'SaveScale': ['m_bEnabled', 'm_VariableName'],
90-
'SaveSurfaceNormal': ['m_bEnabled', 'm_CoordinateSpace', 'm_VariableName'],
91-
'SetMateraialGroupChoice': ['m_bEnabled', 'm_VariableName', 'm_SelectionMode', 'm_ChoiceSelection', 'm_MaterialGroupChoices'],
91+
'SaveSurfaceNormal': ['_WARN_NOT_VERIFIED', 'm_bEnabled', 'm_CoordinateSpace', 'm_VariableName'],
92+
'SetMateraialGroupChoice': ['_WARN_NOT_VERIFIED', 'm_bEnabled', 'm_VariableName', 'm_SelectionMode', 'm_ChoiceSelection', 'm_MaterialGroupChoices'],
9293
'SetOrientation': ['m_bEnabled', 'm_vForwardVector', 'm_ForwardDirectionSpace', 'm_vUpVector', 'm_UpDirectionSpace', 'm_bPrioritizeUp'],
9394
'SetPosition': ['m_bEnabled', 'm_vPosition', 'm_CoordinateSpace'],
94-
'Trace': ['m_bEnabled', 'm_Origin', 'm_OriginSpace', 'm_flOriginOffset', 'm_flSurfaceUpInfluence', 'm_nNoHitResult', 'm_bIgnoreToolMaterials', 'm_bIgnoreSky', 'm_bIgnoreNoDraw', 'm_bIgnoreTranslucent', 'm_bIgnoreModels', 'm_bIgnoreEntities', 'm_bIgnoreCables'],
95+
'Trace': ['_WARN_NOT_VERIFIED', 'm_bEnabled', 'm_Origin', 'm_OriginSpace', 'm_flOriginOffset', 'm_flSurfaceUpInfluence', 'm_nNoHitResult', 'm_bIgnoreToolMaterials', 'm_bIgnoreSky', 'm_bIgnoreNoDraw', 'm_bIgnoreTranslucent', 'm_bIgnoreModels', 'm_bIgnoreEntities', 'm_bIgnoreCables'],
9596
'Comment': ['m_bEnabled', 'm_Comment'],
9697
'Expression': ['m_bEnabled', 'm_Expression'],
9798
'Probability': ['m_bEnabled', 'm_flProbability'],
@@ -195,6 +196,9 @@ def _resolve_dispatch(cls):
195196
'm_MaterialReplacements': (PropertyMaterialReplacements, {}),
196197
'm_MaterialGroupChoices': (PropertyMaterialGroupChoices, {}),
197198
'm_ChoiceSelection': (PropertyFloat, {'int_bool': True}),
199+
'm_Color': (PropertyColor, {}),
200+
'm_ColorPosition': (PropertyFloat, {'slider_range': [0, 1]}),
201+
'm_Material': (PropertyString, {'expression_bool': False, 'placeholder': 'Material name (.vmat)', 'filter_types': ['String']}),
198202
'm_flBendPoint': (PropertyFloat, {'slider_range': [0, 1]}),
199203
'm_flWidth': (PropertyFloat, {'slider_range': [0, 4096]}),
200204
'm_flLength': (PropertyFloat, {'slider_range': [0, 4096]}),
@@ -213,6 +217,7 @@ def _resolve_dispatch(cls):
213217
'm_VariableName': (PropertyString, {'expression_bool': False, 'only_string': False, 'only_variable': True,
214218
'force_variable': True, 'placeholder': 'Variable name',
215219
'filter_types': ['String','Int','Float','Bool']}),
220+
'_WARN_NOT_VERIFIED': (PropertyWarning, {}),
216221
}
217222

218223
# Most frequent first; first matching substring wins after exact + combobox miss.
@@ -223,6 +228,7 @@ def _resolve_dispatch(cls):
223228
('m_v', PropertyVector3D, {}),
224229
('m_b', PropertyBool, {}),
225230
('m_s', PropertyString, {'expression_bool': False, 'placeholder': 'String'}),
231+
('m_', PropertyString, {'expression_bool': False, 'placeholder': 'String'}),
226232
]
227233

228234
cls._DISPATCH_RESOLVED = True

0 commit comments

Comments
 (0)