print("Loaded game_forge module!")

forgeWindow = nil

function init()
  print("[Forge] Init called.")

  local ui = g_ui.loadUI('game_forge')
  if not ui then
    print("[Forge] Failed to load UI file with loadUI.")
    return
  end

  forgeWindow = ui:recursiveGetChildById('Exaltation_Forge_GunzodusOT')
  local sliverActionButton = forgeWindow:recursiveGetChildById('sliver_action')
  if not forgeWindow then
    print("[Forge] Failed to find Forge Window in UI.")
    return
  end

  print("[Forge] Showing forge window.")
  modules.game_interface.getRootPanel():addChild(forgeWindow)
  forgeWindow:show()
  forgeWindow:breakAnchors()
  forgeWindow:move(
    (g_window.getWidth() - forgeWindow:getWidth()) / 2,
    (g_window.getHeight() - forgeWindow:getHeight()) / 2
  )

  sliverActionButton.onClick = function()
      print("Hello World")
    end
  end


function terminate()
  if forgeWindow then
    forgeWindow:destroy()
    forgeWindow = nil
  end
end

