-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui-workshop.js
More file actions
84 lines (69 loc) · 3.53 KB
/
Copy pathui-workshop.js
File metadata and controls
84 lines (69 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// ============================================================================
// UI-WORKSHOP.JS : AUTOMATION WORKSHOP INTERFACE BINDINGS
// ============================================================================
/**
* Update the selectable script list in the Automation Workshop sidebar.
*/
window.updateWorkshopScriptList = function() {
const wsSelect = document.getElementById('scriptSelect');
const VM = window.Game.Automation || (typeof AutomationVM !== 'undefined' ? AutomationVM : (typeof AutomationWorkshop !== 'undefined' ? AutomationWorkshop : null));
if (wsSelect && VM && VM.scripts) {
wsSelect.replaceChildren();
const createNew = document.createElement('option');
createNew.value = 'new';
createNew.textContent = '+ Create New Script';
wsSelect.appendChild(createNew);
// ... (rest of function inside the if)
const builtInsGroup = document.createElement('optgroup');
builtInsGroup.label = 'Built-ins';
const myScriptsGroup = document.createElement('optgroup');
myScriptsGroup.label = 'My Automations';
const sharedScriptsGroup = document.createElement('optgroup');
sharedScriptsGroup.label = 'Shared with Me';
let currentPlayer = Registry.playerName || window.Game.Storage.get(window.Game.Keys.PLAYER, 'Pilot 1');
const reachedRound = Math.max(Registry.highestUnlockedRound || 1, Registry.stats.round || 1);
const isZoningUnlocked = Config.debugMode || reachedRound >= 14;
VM.scripts.forEach(s => {
if (s.serviceZone && !isZoningUnlocked) return;
const opt = document.createElement('option');
opt.value = `custom_${s.id}`;
const zoneLabel = s.serviceZone ? ` [${VM.getServiceZoneLabel?.(s.serviceZone, Config.numFloors) || 'zoned'}]` : '';
if (s.author === 'System') {
opt.textContent = `${s.name}${zoneLabel}`;
builtInsGroup.appendChild(opt);
} else if (s.author === currentPlayer) {
opt.textContent = `${s.name}${zoneLabel}`;
myScriptsGroup.appendChild(opt);
} else {
opt.textContent = `${s.name}${zoneLabel} (by ${s.author})`;
sharedScriptsGroup.appendChild(opt);
}
});
if (builtInsGroup.children.length > 0) wsSelect.appendChild(builtInsGroup);
if (myScriptsGroup.children.length > 0) wsSelect.appendChild(myScriptsGroup);
if (sharedScriptsGroup.children.length > 0) wsSelect.appendChild(sharedScriptsGroup);
}
};
/**
* Open the Automation Workshop modal and initialize Blockly if needed.
*/
window.openWorkshopModal = function() {
const engine = (typeof GameEngine === 'function') ? GameEngine() : (window.Game && window.Game.Engine);
const overlay = document.getElementById('workshopOverlay');
if (overlay && overlay.style.display === 'flex') {
overlay.style.display = 'none';
window.Game.Audio?.setContext('gameplay');
engine?.resume?.();
return;
}
if (engine && typeof engine.pause === 'function') engine.pause();
window.Game.Audio?.setContext('menu');
window.openModalExclusive('workshopOverlay');
if (typeof AutomationWorkshop !== 'undefined') {
AutomationWorkshop.show();
}
};
// API Registration
window.UI = window.UI || {};
window.UI.updateWorkshopScriptList = window.updateWorkshopScriptList;
window.UI.openWorkshopModal = window.openWorkshopModal;