diff --git a/gui/HP_AppearanceBindingsScreen.xml b/gui/HP_AppearanceBindingsScreen.xml
index 4959bbe..5164835 100644
--- a/gui/HP_AppearanceBindingsScreen.xml
+++ b/gui/HP_AppearanceBindingsScreen.xml
@@ -16,6 +16,9 @@
+
diff --git a/gui/HP_RosterManagerScreen.xml b/gui/HP_RosterManagerScreen.xml
index 0a8c805..66d4bbc 100644
--- a/gui/HP_RosterManagerScreen.xml
+++ b/gui/HP_RosterManagerScreen.xml
@@ -16,6 +16,9 @@
+
diff --git a/gui/HP_WorldWorkerScreen.xml b/gui/HP_WorldWorkerScreen.xml
new file mode 100644
index 0000000..a3b0dc8
--- /dev/null
+++ b/gui/HP_WorldWorkerScreen.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/scripts/HP_SlotRegistry.lua b/scripts/HP_SlotRegistry.lua
index 29e9feb..d2e6917 100644
--- a/scripts/HP_SlotRegistry.lua
+++ b/scripts/HP_SlotRegistry.lua
@@ -143,16 +143,14 @@ if HP_RosterState == nil and source ~= nil then
source((g_currentModDirectory or "") .. "scripts/HP_RosterState.lua")
end
--- Install the shared two-tab management controller early. It waits until both
+-- Install the shared management controller early. It waits until the three
-- GUI screen classes are available before applying its lightweight wrappers.
if HP_TabbedManagement == nil and source ~= nil then
source((g_currentModDirectory or "") .. "scripts/HP_TabbedManagement.lua")
end
--- Alpha world-worker services are deliberately sourced from the stable slot
--- registry so the permanent A-T identity model is available before they load.
--- The runtime manager waits until the helper roster and appearance bridge are
--- ready before it restores any persisted world representations.
+-- World-worker services are sourced from the stable slot registry so the
+-- permanent A-T identity model is available before they load.
if HP_WorldState == nil and source ~= nil then
source((g_currentModDirectory or "") .. "scripts/HP_WorldState.lua")
end
@@ -162,3 +160,9 @@ end
if HP_WorldWorkerPlayerAccess == nil and source ~= nil then
source((g_currentModDirectory or "") .. "scripts/HP_WorldWorkerPlayerAccess.lua")
end
+if HP_WorldWorkerScreen == nil and source ~= nil then
+ source((g_currentModDirectory or "") .. "scripts/HP_WorldWorkerScreen.lua")
+end
+if HP_WorldWorkerInput == nil and source ~= nil then
+ source((g_currentModDirectory or "") .. "scripts/HP_WorldWorkerInput.lua")
+end
diff --git a/scripts/HP_TabbedManagement.lua b/scripts/HP_TabbedManagement.lua
index 7a55c7c..5d0316d 100644
--- a/scripts/HP_TabbedManagement.lua
+++ b/scripts/HP_TabbedManagement.lua
@@ -1,6 +1,6 @@
-- HP_TabbedManagement.lua (FS25_HelperProfiles)
--- Presents the appearance-binding and roster-management dialogs as one
--- two-tab management workflow while preserving staged changes between tabs.
+-- Presents appearance, roster and world-worker management dialogs as one
+-- three-tab management workflow while preserving staged changes between tabs.
if HP_TabbedManagement ~= nil then return end
@@ -9,7 +9,8 @@ HP_TabbedManagement = {
sessionId = 0,
openFromTab = {
appearance = false,
- roster = false
+ roster = false,
+ world = false
}
}
@@ -26,11 +27,8 @@ local function configureTabs(screen, activeIndex)
local background = tab.getDescendantByName ~= nil
and tab:getDescendantByName("background") or nil
- if background ~= nil then
- background.getIsSelected = function() return selected end
- end
+ if background ~= nil then background.getIsSelected = function() return selected end end
tab.getIsSelected = function() return selected end
-
if tab.invalidateLayout ~= nil then tab:invalidateLayout() end
end
end
@@ -43,16 +41,13 @@ end
local function beginOpen(tabName, fromTab)
local isTabSwitch = fromTab == true
- if not isTabSwitch then
- HP_TabbedManagement.sessionId = HP_TabbedManagement.sessionId + 1
- end
+ if not isTabSwitch then HP_TabbedManagement.sessionId = HP_TabbedManagement.sessionId + 1 end
HP_TabbedManagement.openFromTab[tabName] = isTabSwitch
end
local function shouldResume(screen, tabName)
local fromTab = HP_TabbedManagement.openFromTab[tabName] == true
HP_TabbedManagement.openFromTab[tabName] = false
-
return fromTab
and screen._hpTabbedDataLoaded == true
and screen._hpTabbedSessionId == HP_TabbedManagement.sessionId
@@ -63,6 +58,24 @@ local function markLoaded(screen)
screen._hpTabbedSessionId = HP_TabbedManagement.sessionId
end
+local function openAppearance(screen)
+ if HP_AppearanceBindingsGui == nil or HP_AppearanceBindingsGui.open == nil then return end
+ screen:close()
+ HP_AppearanceBindingsGui:open(true)
+end
+
+local function openRoster(screen)
+ if HP_RosterManagerGui == nil or HP_RosterManagerGui.open == nil then return end
+ screen:close()
+ HP_RosterManagerGui:open(true)
+end
+
+local function openWorld(screen)
+ if HP_WorldWorkerGui == nil or HP_WorldWorkerGui.open == nil then return end
+ screen:close()
+ HP_WorldWorkerGui:open(true)
+end
+
local function patchAppearanceScreen()
local screenClass = HP_AppearanceBindingsScreen
if screenClass == nil or screenClass._hpTabbedManagementPatched == true then return false end
@@ -81,26 +94,18 @@ local function patchAppearanceScreen()
self.reloadData = function() end
originalOpen(self, ...)
self.reloadData = originalReloadData
-
if self.reloadLists ~= nil then self:reloadLists() end
if self.updateDetailText ~= nil then self:updateDetailText() end
else
originalOpen(self, ...)
end
-
markLoaded(self)
configureTabs(self, 1)
end
- function screenClass:onClickAppearanceTab(sender)
- configureTabs(self, 1)
- end
-
- function screenClass:onClickOpenRosterManager(sender)
- if HP_RosterManagerGui == nil or HP_RosterManagerGui.open == nil then return end
- self:close()
- HP_RosterManagerGui:open(true)
- end
+ function screenClass:onClickAppearanceTab(sender) configureTabs(self, 1) end
+ function screenClass:onClickOpenRosterManager(sender) openRoster(self) end
+ function screenClass:onClickOpenWorldManager(sender) openWorld(self) end
screenClass._hpTabbedManagementPatched = true
return true
@@ -124,27 +129,44 @@ local function patchRosterScreen()
self.reloadData = function() end
originalOpen(self, ...)
self.reloadData = originalReloadData
-
if self.rosterTable ~= nil then self.rosterTable:reloadData() end
if self.updateDetailText ~= nil then self:updateDetailText() end
else
originalOpen(self, ...)
end
-
markLoaded(self)
configureTabs(self, 2)
end
- function screenClass:onClickRosterTab(sender)
- configureTabs(self, 2)
+ function screenClass:onClickRosterTab(sender) configureTabs(self, 2) end
+ function screenClass:onClickAppearances(sender) openAppearance(self) end
+ function screenClass:onClickOpenWorldManager(sender) openWorld(self) end
+
+ screenClass._hpTabbedManagementPatched = true
+ return true
+end
+
+local function patchWorldScreen()
+ local screenClass = HP_WorldWorkerScreen
+ if screenClass == nil or screenClass._hpTabbedManagementPatched == true then return false end
+
+ local originalSetup = screenClass.onGuiSetupFinished
+ function screenClass:onGuiSetupFinished(...)
+ originalSetup(self, ...)
+ configureTabs(self, 3)
end
- function screenClass:onClickAppearances(sender)
- if HP_AppearanceBindingsGui == nil or HP_AppearanceBindingsGui.open == nil then return end
- self:close()
- HP_AppearanceBindingsGui:open(true)
+ local originalOpen = screenClass.onOpen
+ function screenClass:onOpen(...)
+ originalOpen(self, ...)
+ markLoaded(self)
+ configureTabs(self, 3)
end
+ function screenClass:onClickWorldTab(sender) configureTabs(self, 3) end
+ function screenClass:onClickAppearances(sender) openAppearance(self) end
+ function screenClass:onClickRoster(sender) openRoster(self) end
+
screenClass._hpTabbedManagementPatched = true
return true
end
@@ -172,26 +194,36 @@ local function patchGuiManagers()
HP_RosterManagerGui._hpTabbedManagementPatched = true
end
- return HP_AppearanceBindingsGui ~= nil
- and HP_AppearanceBindingsGui._hpTabbedManagementPatched == true
- and HP_RosterManagerGui ~= nil
- and HP_RosterManagerGui._hpTabbedManagementPatched == true
+ if HP_WorldWorkerGui ~= nil
+ and HP_WorldWorkerGui._hpTabbedManagementPatched ~= true
+ and type(HP_WorldWorkerGui.open) == "function" then
+ local originalOpen = HP_WorldWorkerGui.open
+ function HP_WorldWorkerGui:open(fromTab)
+ beginOpen("world", fromTab)
+ return originalOpen(self)
+ end
+ HP_WorldWorkerGui._hpTabbedManagementPatched = true
+ end
+
+ return HP_AppearanceBindingsGui ~= nil and HP_AppearanceBindingsGui._hpTabbedManagementPatched == true
+ and HP_RosterManagerGui ~= nil and HP_RosterManagerGui._hpTabbedManagementPatched == true
+ and HP_WorldWorkerGui ~= nil and HP_WorldWorkerGui._hpTabbedManagementPatched == true
end
function HP_TabbedManagement:update(dt)
if self.installed then return end
local appearanceReady = patchAppearanceScreen()
- or (HP_AppearanceBindingsScreen ~= nil
- and HP_AppearanceBindingsScreen._hpTabbedManagementPatched == true)
+ or (HP_AppearanceBindingsScreen ~= nil and HP_AppearanceBindingsScreen._hpTabbedManagementPatched == true)
local rosterReady = patchRosterScreen()
- or (HP_RosterManagerScreen ~= nil
- and HP_RosterManagerScreen._hpTabbedManagementPatched == true)
+ or (HP_RosterManagerScreen ~= nil and HP_RosterManagerScreen._hpTabbedManagementPatched == true)
+ local worldReady = patchWorldScreen()
+ or (HP_WorldWorkerScreen ~= nil and HP_WorldWorkerScreen._hpTabbedManagementPatched == true)
local managersReady = patchGuiManagers()
- if appearanceReady and rosterReady and managersReady then
+ if appearanceReady and rosterReady and worldReady and managersReady then
self.installed = true
- hpPrint("Two-tab helper management workflow installed")
+ hpPrint("Three-tab helper management workflow installed")
end
end
diff --git a/scripts/HP_WorldWorkerInput.lua b/scripts/HP_WorldWorkerInput.lua
new file mode 100644
index 0000000..ceba020
--- /dev/null
+++ b/scripts/HP_WorldWorkerInput.lua
@@ -0,0 +1,87 @@
+-- HP_WorldWorkerInput.lua (FS25_HelperProfiles)
+-- 2.2.0.0-alpha2: register the custom A-key menu action while the World dialog is open.
+
+if HP_WorldWorkerInput ~= nil then return end
+HP_WorldWorkerInput = { installed = false }
+
+local LOG = "[FS25_HelperProfiles/WorldWorkerInput] "
+
+local function isPress(inputValue, callbackState)
+ if type(inputValue) == "number" then
+ return inputValue > 0
+ elseif type(inputValue) == "boolean" then
+ return inputValue == true
+ end
+ local value = tonumber(callbackState)
+ return value ~= nil and value > 0
+end
+
+local function removeMoveAction(screen)
+ local id = screen ~= nil and screen._hpWorldMoveActionEventId or nil
+ if id ~= nil and g_inputBinding ~= nil and g_inputBinding.removeActionEvent ~= nil then
+ pcall(function() g_inputBinding:removeActionEvent(id) end)
+ end
+ if screen ~= nil then screen._hpWorldMoveActionEventId = nil end
+end
+
+local function onMoveAction(screen, actionName, inputValue, callbackState, isAnalog)
+ if screen == nil or not isPress(inputValue, callbackState) then return end
+ if screen.onClickMoveHere ~= nil then screen:onClickMoveHere(nil) end
+end
+
+local function registerMoveAction(screen)
+ removeMoveAction(screen)
+
+ local inputAction = InputAction ~= nil and InputAction.HP_CLEAR_ALL_BINDINGS or nil
+ if screen == nil or g_inputBinding == nil or g_inputBinding.registerActionEvent == nil or inputAction == nil then
+ print(LOG .. "Failed to register MOVE HERE action: input action unavailable")
+ return
+ end
+
+ local callOk, registered, id = pcall(function()
+ return g_inputBinding:registerActionEvent(
+ inputAction,
+ screen,
+ onMoveAction,
+ false,
+ true,
+ false,
+ true
+ )
+ end)
+
+ if callOk and registered == true and id ~= nil then
+ screen._hpWorldMoveActionEventId = id
+ if g_inputBinding.setActionEventTextPriority ~= nil then
+ g_inputBinding:setActionEventTextPriority(id, GS_PRIO_VERY_LOW)
+ end
+ if g_inputBinding.setActionEventTextVisibility ~= nil then
+ g_inputBinding:setActionEventTextVisibility(id, false)
+ end
+ if g_inputBinding.setActionEventActive ~= nil then
+ g_inputBinding:setActionEventActive(id, true)
+ end
+ print(LOG .. "Registered A -> MOVE HERE (World dialog)")
+ else
+ print(LOG .. "Failed to register A -> MOVE HERE (World dialog)")
+ end
+end
+
+if HP_WorldWorkerScreen ~= nil and HP_WorldWorkerScreen._hpWorldMoveInputPatched ~= true then
+ local originalOpen = HP_WorldWorkerScreen.onOpen
+ local originalClose = HP_WorldWorkerScreen.onClose
+
+ function HP_WorldWorkerScreen:onOpen(...)
+ originalOpen(self, ...)
+ registerMoveAction(self)
+ end
+
+ function HP_WorldWorkerScreen:onClose(...)
+ removeMoveAction(self)
+ return originalClose(self, ...)
+ end
+
+ HP_WorldWorkerScreen._hpWorldMoveInputPatched = true
+ HP_WorldWorkerInput.installed = true
+ print(LOG .. "World MOVE HERE input wrapper installed")
+end
diff --git a/scripts/HP_WorldWorkerScreen.lua b/scripts/HP_WorldWorkerScreen.lua
new file mode 100644
index 0000000..7c5ffaf
--- /dev/null
+++ b/scripts/HP_WorldWorkerScreen.lua
@@ -0,0 +1,291 @@
+-- HP_WorldWorkerScreen.lua (FS25_HelperProfiles)
+-- 2.2.0.0-alpha2: fullscreen management UI for static world-worker placement.
+
+if HP_WorldWorkerScreen ~= nil then return end
+
+HP_WorldWorkerScreen = {}
+local HP_WorldWorkerScreen_mt = Class(HP_WorldWorkerScreen, MessageDialog)
+local LOG = "[FS25_HelperProfiles/WorldWorkerUI] "
+local MOD_DIR = g_currentModDirectory or ""
+
+local function hpPrint(message) print(LOG .. tostring(message)) end
+
+local function clamp(value, minimum, maximum)
+ value = math.floor(tonumber(value) or minimum)
+ if value < minimum then return minimum end
+ if value > maximum then return maximum end
+ return value
+end
+
+local function getDisplayName(helper, stableIndex)
+ if HelperProfiles ~= nil and HelperProfiles.getDisplayNameForHelper ~= nil then
+ local ok, value = pcall(HelperProfiles.getDisplayNameForHelper, HelperProfiles, helper, stableIndex)
+ if ok and value ~= nil and tostring(value) ~= "" then return tostring(value) end
+ end
+ return tostring(helper ~= nil and helper.name or ("Helper " .. tostring(stableIndex)))
+end
+
+local function isActive(helper)
+ if helper == nil then return false end
+ if HelperProfiles ~= nil and HelperProfiles.isHelperActive ~= nil then
+ local ok, value = pcall(HelperProfiles.isHelperActive, HelperProfiles, helper)
+ if ok then return value == true end
+ end
+ return helper.inUse == true
+end
+
+local function isRosterEnabled(helper, stableIndex)
+ if HP_RosterState == nil then return true end
+ return HP_RosterState:isEnabled(helper, stableIndex)
+end
+
+local function getPlacement(stableIndex)
+ if HP_WorldState == nil then return nil end
+ return HP_WorldState:getPlacement(stableIndex)
+end
+
+local function isSpawned(stableIndex)
+ if HP_WorldWorkerManager == nil or HP_WorldWorkerManager.instancesByCanonicalId == nil then return false end
+ local id = HP_SlotRegistry ~= nil and HP_SlotRegistry:canonicalId(stableIndex) or nil
+ return id ~= nil and HP_WorldWorkerManager.instancesByCanonicalId[id] ~= nil
+end
+
+function HP_WorldWorkerScreen.new(target, customMt)
+ local self = MessageDialog.new(target, customMt or HP_WorldWorkerScreen_mt)
+ self.rows = {}
+ self.selectedIndex = 1
+ self.actionMessage = nil
+ return self
+end
+
+function HP_WorldWorkerScreen:onGuiSetupFinished()
+ HP_WorldWorkerScreen:superClass().onGuiSetupFinished(self)
+ if self.worldTable ~= nil then
+ self.worldTable:setDataSource(self)
+ self.worldTable:setDelegate(self)
+ end
+end
+
+function HP_WorldWorkerScreen:onCreate()
+ HP_WorldWorkerScreen:superClass().onCreate(self)
+end
+
+function HP_WorldWorkerScreen:onOpen()
+ HP_WorldWorkerScreen:superClass().onOpen(self)
+ self:reloadData()
+ if FocusManager ~= nil and self.worldTable ~= nil then
+ self:setSoundSuppressed(true)
+ FocusManager:setFocus(self.worldTable)
+ self:setSoundSuppressed(false)
+ end
+end
+
+function HP_WorldWorkerScreen:onClose()
+ HP_WorldWorkerScreen:superClass().onClose(self)
+ if HP_WorldWorkerGui ~= nil then HP_WorldWorkerGui.dialog = nil end
+end
+
+function HP_WorldWorkerScreen:reloadData()
+ self.rows = {}
+ if HP_WorldState ~= nil and not HP_WorldState.initialized then HP_WorldState:init() end
+
+ local allProfiles = HelperProfiles ~= nil and HelperProfiles.getAllProfiles ~= nil
+ and HelperProfiles:getAllProfiles() or {}
+ local target = HP_SlotRegistry ~= nil and HP_SlotRegistry.TARGET_COUNT or #allProfiles
+
+ for stableIndex = 1, target do
+ local helper = allProfiles[stableIndex]
+ local slot = HP_SlotRegistry ~= nil and HP_SlotRegistry:indexToSlot(stableIndex) or tostring(stableIndex)
+ local canonicalId = HP_SlotRegistry ~= nil and HP_SlotRegistry:canonicalId(stableIndex) or tostring(stableIndex)
+ self.rows[#self.rows + 1] = {
+ stableIndex = stableIndex,
+ slot = slot,
+ canonicalId = canonicalId,
+ helper = helper,
+ displayName = getDisplayName(helper, stableIndex)
+ }
+ end
+
+ self.selectedIndex = clamp(self.selectedIndex, 1, math.max(1, #self.rows))
+ self.actionMessage = nil
+ if self.worldTable ~= nil then self.worldTable:reloadData() end
+ self:updateDetailText()
+end
+
+function HP_WorldWorkerScreen:getSelectedRow()
+ return self.rows[clamp(self.selectedIndex, 1, math.max(1, #self.rows))]
+end
+
+function HP_WorldWorkerScreen:getNumberOfSections() return 1 end
+function HP_WorldWorkerScreen:getNumberOfItemsInSection() return #(self.rows or {}) end
+
+function HP_WorldWorkerScreen:populateCellForItemInSection(list, section, index, cell)
+ local row = self.rows[index]
+ if row == nil or cell == nil then return end
+
+ local placement = getPlacement(row.stableIndex)
+ local active = isActive(row.helper)
+ local spawned = isSpawned(row.stableIndex)
+ local rostered = isRosterEnabled(row.helper, row.stableIndex)
+
+ local worldState = "NOT PLACED"
+ if placement ~= nil then
+ if active then worldState = "PLACED / WORKING"
+ elseif spawned then worldState = "PLACED"
+ else worldState = "PLACED / HIDDEN" end
+ end
+
+ local position = "-"
+ if placement ~= nil then
+ position = string.format("%.1f, %.1f", tonumber(placement.x) or 0, tonumber(placement.z) or 0)
+ end
+
+ cell:getAttribute("Slot"):setText(tostring(row.slot or "?"))
+ cell:getAttribute("Worker"):setText(tostring(row.displayName or "-"))
+ cell:getAttribute("RosterState"):setText(rostered and "ON ROSTER" or "OFF ROSTER")
+ cell:getAttribute("WorkState"):setText(active and "ACTIVE" or "AVAILABLE")
+ cell:getAttribute("WorldState"):setText(worldState)
+ cell:getAttribute("Position"):setText(position)
+end
+
+function HP_WorldWorkerScreen:onListSelectionChanged(list, section, index)
+ self.selectedIndex = clamp(index or 1, 1, math.max(1, #self.rows))
+ self:updateDetailText()
+end
+
+function HP_WorldWorkerScreen:setStatus(message)
+ self.actionMessage = tostring(message or "")
+ self:updateDetailText()
+end
+
+function HP_WorldWorkerScreen:updateDetailText()
+ local row = self:getSelectedRow()
+ local placedCount, spawnedCount = 0, 0
+ for _, candidate in ipairs(self.rows or {}) do
+ if getPlacement(candidate.stableIndex) ~= nil then placedCount = placedCount + 1 end
+ if isSpawned(candidate.stableIndex) then spawnedCount = spawnedCount + 1 end
+ end
+
+ local detail = "Select a worker to place, move or remove their independent world presence."
+ if row ~= nil then
+ local placement = getPlacement(row.stableIndex)
+ local active = isActive(row.helper)
+ local rostered = isRosterEnabled(row.helper, row.stableIndex)
+ detail = string.format("%s (%s / %s) | %s | %s | %s",
+ tostring(row.displayName), tostring(row.slot), tostring(row.canonicalId),
+ rostered and "ON ROSTER" or "OFF ROSTER",
+ active and "ACTIVE" or "AVAILABLE",
+ placement ~= nil and "WORLD PLACEMENT SAVED" or "NOT PLACED")
+ end
+ if self.detailText ~= nil then self.detailText:setText(detail) end
+
+ local status = self.actionMessage or string.format("World placements: %d | Currently visible: %d", placedCount, spawnedCount)
+ if self.statusText ~= nil then self.statusText:setText(status) end
+end
+
+function HP_WorldWorkerScreen:runWorldAction(actionName)
+ local row = self:getSelectedRow()
+ if row == nil then return end
+ if HP_WorldWorkerManager == nil then
+ self:setStatus("World worker manager unavailable.")
+ return
+ end
+
+ local ok, err
+ if actionName == "place" or actionName == "move" then
+ ok, err = HP_WorldWorkerManager:placeAtPlayer(row.stableIndex)
+ elseif actionName == "remove" then
+ ok, err = HP_WorldWorkerManager:removePlacement(row.stableIndex)
+ else
+ return
+ end
+
+ if ok then
+ if actionName == "place" then
+ self.actionMessage = string.format("Placed %s at your current location.", tostring(row.displayName))
+ elseif actionName == "move" then
+ self.actionMessage = string.format("Moved %s to your current location.", tostring(row.displayName))
+ else
+ self.actionMessage = string.format("Removed %s from the world.", tostring(row.displayName))
+ end
+ else
+ self.actionMessage = string.format("%s failed for %s: %s", string.upper(actionName), tostring(row.displayName), tostring(err or "unknown"))
+ end
+
+ if self.worldTable ~= nil then self.worldTable:reloadData() end
+ self:updateDetailText()
+end
+
+function HP_WorldWorkerScreen:onClickPlaceHere(sender)
+ local row = self:getSelectedRow()
+ if row ~= nil and getPlacement(row.stableIndex) ~= nil then
+ return self:runWorldAction("move")
+ end
+ return self:runWorldAction("place")
+end
+
+function HP_WorldWorkerScreen:onClickMoveHere(sender)
+ return self:runWorldAction("move")
+end
+
+function HP_WorldWorkerScreen:onClickRemove(sender)
+ return self:runWorldAction("remove")
+end
+
+function HP_WorldWorkerScreen:onClickBack(sender)
+ self:close()
+end
+
+HP_WorldWorkerGui = HP_WorldWorkerGui or {
+ dialog = nil,
+ loaded = false,
+ failed = false,
+ modDirectory = MOD_DIR,
+ version = "2.2.0.0-alpha2-world-ui-1"
+}
+
+function HP_WorldWorkerGui:loadMap()
+ self.modDirectory = MOD_DIR ~= "" and MOD_DIR or (g_currentModDirectory or self.modDirectory or "")
+ hpPrint("Loaded " .. tostring(self.version))
+end
+
+function HP_WorldWorkerGui:deleteMap()
+ self.dialog = nil
+ self.loaded = false
+ self.failed = false
+end
+
+function HP_WorldWorkerGui:loadDialog()
+ if self.loaded or self.failed then return self.loaded end
+ if g_gui == nil then return false end
+
+ local modDir = self.modDirectory or MOD_DIR or g_currentModDirectory or ""
+ local ok, err = pcall(function()
+ if g_gui.loadProfiles ~= nil then g_gui:loadProfiles(modDir .. "gui/guiProfiles.xml") end
+ local frame = HP_WorldWorkerScreen.new(g_i18n)
+ g_gui:loadGui(modDir .. "gui/HP_WorldWorkerScreen.xml", "HP_WorldWorkerDialog", frame)
+ self.loaded = true
+ end)
+
+ if not ok then
+ self.failed = true
+ hpPrint("Failed to load world worker manager: " .. tostring(err))
+ end
+ return self.loaded
+end
+
+function HP_WorldWorkerGui:open()
+ if HP_Compatibility ~= nil and HP_Compatibility:isBlocked() then return false end
+ if not self.loaded then self:loadDialog() end
+ if self.loaded and g_gui ~= nil then
+ self.dialog = g_gui:showDialog("HP_WorldWorkerDialog")
+ return self.dialog ~= nil
+ end
+ return false
+end
+
+if addConsoleCommand ~= nil then
+ addConsoleCommand("hpWorldManage", "Open the HelperProfiles world worker manager", "open", HP_WorldWorkerGui)
+end
+
+addModEventListener(HP_WorldWorkerGui)