|
4 | 4 | ---@class InteractiveFunctionsParams |
5 | 5 | ---@field posFunc fun(target: MaterialProcessor, data: any, noEventSend: boolean | nil) |
6 | 6 | ---@field negFunc? fun(target: MaterialProcessor, data: any, noEventSend: boolean | nil) |
7 | | ----@field updateFunc? fun(target: MaterialProcessor): boolean | nil |
8 | | ----@field isBlockedFunc? fun(target: MaterialProcessor): boolean |
| 7 | +---@field updateFunc? fun(target: MaterialProcessor): boolean? |
| 8 | +---@field isBlockedFunc? fun(target: MaterialProcessor): boolean? |
9 | 9 |
|
10 | 10 | ---@class InteractiveControlExtension |
11 | 11 | InteractiveControlExtension = {} |
|
44 | 44 | function InteractiveControlExtension:registerConfigurationFunction(icf) |
45 | 45 | if icf.addFunction('PROCESSOR_CONTROL_PANEL', |
46 | 46 | { |
47 | | - posFunc = function (target) |
48 | | - ---@type MaterialProcessor_spec |
49 | | - local spec = target[MaterialProcessor.SPEC_NAME] |
| 47 | + posFunc = function (target, data, noEventSend) |
| 48 | + if noEventSend then |
| 49 | + return |
| 50 | + end |
50 | 51 |
|
51 | | - if spec ~= nil then |
| 52 | + if target.isClient and target[MaterialProcessor.SPEC_NAME] ~= nil then |
52 | 53 | MaterialProcessor.actionEventOpenDialog(target) |
53 | 54 | end |
54 | 55 | end, |
55 | 56 | isBlockedFunc = function (target) |
56 | | - ---@type MaterialProcessor_spec |
57 | | - local spec = target[MaterialProcessor.SPEC_NAME] |
| 57 | + if g_client ~= nil and target.getProcessor ~= nil then |
| 58 | + local processor = target:getProcessor() |
58 | 59 |
|
59 | | - if spec ~= nil then |
60 | | - return #spec.processor.configurations > 0 |
| 60 | + return #processor.configurations > 0 |
61 | 61 | end |
62 | 62 |
|
63 | | - return false |
| 63 | + return nil |
64 | 64 | end |
65 | 65 | } |
66 | 66 | ) then |
|
72 | 72 | function InteractiveControlExtension:registerToggleDischargeToGroundFunction(icf) |
73 | 73 | if icf.addFunction('PROCESSOR_TOGGLE_DISCHARGE_GROUND', |
74 | 74 | { |
75 | | - posFunc = function (target) |
76 | | - ---@type MaterialProcessor_spec |
77 | | - local spec = target[MaterialProcessor.SPEC_NAME] |
| 75 | + posFunc = function (target, data, noEventSend) |
| 76 | + if noEventSend then |
| 77 | + return |
| 78 | + end |
| 79 | + |
| 80 | + if target.getProcessor ~= nil then |
| 81 | + local processor = target:getProcessor() |
78 | 82 |
|
79 | | - if spec ~= nil and spec.processor.canToggleDischargeToGround then |
80 | | - MaterialProcessor.actionEventToggleDischargeToGround(target) |
| 83 | + if processor.canToggleDischargeToGround then |
| 84 | + MaterialProcessor.actionEventToggleDischargeToGround(target) |
| 85 | + end |
81 | 86 | end |
82 | 87 | end, |
83 | 88 | updateFunc = function (target) |
84 | | - ---@type MaterialProcessor_spec |
85 | | - local spec = target[MaterialProcessor.SPEC_NAME] |
| 89 | + if target.getProcessor ~= nil then |
| 90 | + local processor = target:getProcessor() |
86 | 91 |
|
87 | | - if spec ~= nil then |
88 | | - return spec.processor.canDischargeToGround |
| 92 | + return processor.canDischargeToGround |
89 | 93 | end |
| 94 | + |
| 95 | + return nil |
90 | 96 | end, |
91 | 97 | isBlockedFunc = function (target) |
92 | | - ---@type MaterialProcessor_spec |
93 | | - local spec = target[MaterialProcessor.SPEC_NAME] |
| 98 | + if target.getProcessor ~= nil then |
| 99 | + local processor = target:getProcessor() |
| 100 | + |
| 101 | + return processor.canToggleDischargeToGround |
| 102 | + end |
94 | 103 |
|
95 | | - return spec ~= nil and spec.processor.canToggleDischargeToGround |
| 104 | + return nil |
96 | 105 | end |
97 | 106 | } |
98 | 107 | ) then |
|
0 commit comments