mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 08:23:12 +09:00
Add 2.0 support to player_auth
This commit is contained in:
1 file changed
+11
-2
@@ -1,6 +1,12 @@
|
|||||||
local clusterio_api = require("modules/clusterio/api")
|
local clusterio_api = require("modules/clusterio/api")
|
||||||
|
local compat = require("modules/clusterio/compat")
|
||||||
local auth = {}
|
local auth = {}
|
||||||
|
|
||||||
|
local v2_styles = compat.version_ge("2.0.0")
|
||||||
|
|
||||||
|
--- @param player LuaPlayer
|
||||||
|
--- @param url string
|
||||||
|
--- @param code string
|
||||||
local function open_dialog(player, url, code)
|
local function open_dialog(player, url, code)
|
||||||
if player.gui.screen.player_auth_dialog then
|
if player.gui.screen.player_auth_dialog then
|
||||||
player.gui.screen.player_auth_dialog.destroy()
|
player.gui.screen.player_auth_dialog.destroy()
|
||||||
@@ -28,7 +34,7 @@ local function open_dialog(player, url, code)
|
|||||||
type = "empty-widget",
|
type = "empty-widget",
|
||||||
style = "draggable_space_header",
|
style = "draggable_space_header",
|
||||||
}
|
}
|
||||||
filler.style.horizontally_stretchable = "on"
|
filler.style.horizontally_stretchable = true
|
||||||
filler.style.right_margin = 4
|
filler.style.right_margin = 4
|
||||||
filler.style.height = 24
|
filler.style.height = 24
|
||||||
filler.drag_target = frame
|
filler.drag_target = frame
|
||||||
@@ -36,7 +42,7 @@ local function open_dialog(player, url, code)
|
|||||||
titlebar.add {
|
titlebar.add {
|
||||||
name = "player_auth_dialog_close_button",
|
name = "player_auth_dialog_close_button",
|
||||||
type = "sprite-button",
|
type = "sprite-button",
|
||||||
sprite = "utility/close_white",
|
sprite = v2_styles and "utility/close" or "utility/close_white",
|
||||||
hovered_sprite = "utility/close_black",
|
hovered_sprite = "utility/close_black",
|
||||||
clicked_sprite = "utility/close_black",
|
clicked_sprite = "utility/close_black",
|
||||||
style = "frame_action_button",
|
style = "frame_action_button",
|
||||||
@@ -178,6 +184,8 @@ function auth.add_commands()
|
|||||||
end
|
end
|
||||||
|
|
||||||
auth.events = {}
|
auth.events = {}
|
||||||
|
|
||||||
|
--- @param event EventData.on_gui_click
|
||||||
auth.events[defines.events.on_gui_click] = function(event)
|
auth.events[defines.events.on_gui_click] = function(event)
|
||||||
if not event.element or not event.element.valid then
|
if not event.element or not event.element.valid then
|
||||||
return
|
return
|
||||||
@@ -197,6 +205,7 @@ auth.events[defines.events.on_gui_click] = function(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param event EventData.on_gui_closed
|
||||||
auth.events[defines.events.on_gui_closed] = function(event)
|
auth.events[defines.events.on_gui_closed] = function(event)
|
||||||
if
|
if
|
||||||
event.element
|
event.element
|
||||||
|
|||||||
Reference in new issue
Block a user