diff --git a/src/ui/mainwin.ts b/src/ui/mainwin.ts index 88737fd..bfd63d9 100644 --- a/src/ui/mainwin.ts +++ b/src/ui/mainwin.ts @@ -14,62 +14,68 @@ const userActions = { } }; -const widgets: WidgetDesc[] | undefined = []; +function Widgets(): WidgetDesc[] { -widgets.push({ - type: "checkbox", - x: 5, y: 20, width: 60, height: 15, - isChecked: storage.sharedStorage.get("enabled"), - text: "Enabled", - onChange: userActions.enabled -}); - -widgets.push({ - type: "label", - x: 5, y: 45, width: 190, height: 40, - textAlign: "centred", - text: "Only mechanics are able to repair\nbroken additions." -}); - -if (globals.isDebug) { + const widgets: WidgetDesc[] = []; widgets.push({ - type: "button", - x: 5, y: 70, width: 190, height: 20, - text: "log", - onClick: function () { - console.log(workers.data); - console.log(occupiedTiles.data); - } + type: "checkbox", + x: 5, y: 20, width: 60, height: 15, + isChecked: storage.sharedStorage.get("enabled"), + text: "Enabled", + onChange: userActions.enabled }); widgets.push({ - type: "button", - x: 5, y: 90, width: 190, height: 20, - text: "clear", - onClick: function () { - workers.data = {}; - occupiedTiles.data = {}; - UpdateWorkersData(); - } + type: "label", + x: 5, y: 45, width: 190, height: 40, + textAlign: "centred", + text: "Only mechanics are able to repair\nbroken additions." }); -} + if (globals.isDebug) { -const winDesc: WindowDesc = { - classification: "animated_vandalism_repairing", - width: 200, height: globals.isDebug ? 115 : 70, - title: "Animated vandalism repairing", - widgets: widgets -}; + widgets.push({ + type: "button", + x: 5, y: 70, width: 190, height: 20, + text: "log", + onClick: () => { + console.log(workers.data); + console.log(occupiedTiles.data); + } + }); + + widgets.push({ + type: "button", + x: 5, y: 90, width: 190, height: 20, + text: "clear", + onClick: () => { + workers.data = {}; + occupiedTiles.data = {}; + UpdateWorkersData(); + } + }); + + } + + return widgets; +} export const mainWin = { open(): void { - const win: Window = ui.getWindow("animated_vandalism_repairing") + const win: Window = ui.getWindow("animated_vandalism_repairing"); if (win) { win.bringToFront(); return; } + let winDesc: WindowDesc = { + classification: "animated_vandalism_repairing", + width: 200, height: globals.isDebug ? 115 : 70, + title: "Animated vandalism repairing", + widgets: Widgets() + }; ui.openWindow(winDesc); } -}; \ No newline at end of file +}; + +