Skip to content

Commit

Permalink
Merge pull request #207 from Oarcinae/206-spawn-controls-get-disabled…
Browse files Browse the repository at this point in the history
…-on-mod-update-on-gui-rebuild

206 spawn controls get disabled on mod update on gui rebuild
  • Loading branch information
Oarcinae authored Oct 23, 2024
2 parents 354e3a4 + 4e7c9c6 commit 1fc8312
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 2.1.2
Date: 2024-10-23
Bugfixes:
- Fix spawn controls tab in custom GUI not being re-enabled when GUI is recreated (on mod update for example).
Info:
- Add a warning note explanation when the custom respawn feature is not available.
---------------------------------------------------------------------------------------------------
Version: 2.1.1
Date: 2024-10-23
Bugfixes:
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oarc-mod",
"version": "2.1.1",
"version": "2.1.2",
"factorio_version": "2.0",
"title": "Oarc Multiplayer Spawn",
"author": "Oarcinae",
Expand Down
5 changes: 4 additions & 1 deletion lib/gui_tabs/spawn_controls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function CreateSetRespawnLocationButton(player, container)
local respawn_info = storage.player_respawns[player.name][player.surface.name]

if (respawn_info == nil) then
log("ERROR: No respawn info for player: " .. player.name)
AddLabel(container, nil, { "oarc-no-respawn-this-surface" }, my_warning_style)
return
end

Expand Down Expand Up @@ -325,6 +325,9 @@ function SpawnCtrlTabGuiClick(event)
elseif (tags.setting == "teleport_home") then
local surface_name = tags.surface --[[@as string]]
local position = tags.position --[[@as MapPosition]]

--TODO Verify player is still on the same surface, if they leave the GUI open, they can teleport back from any surface.

SafeTeleport(player, game.surfaces[surface_name], position)

-- Accept or reject pending player join requests to a shared base
Expand Down
7 changes: 5 additions & 2 deletions lib/oarc_gui_tabs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ function InitOarcGuiTabs(player)
AddOarcGuiTab(player, OARC_SERVER_INFO_TAB_NAME)
SetOarcGuiTabEnabled(player, OARC_SERVER_INFO_TAB_NAME, true)

-- Spawn control tab, disabled by default
-- Spawn control tab, enable if player is already spawned
AddOarcGuiTab(player, OARC_SPAWN_CTRL_TAB_NAME)
local player_respawns = storage.player_respawns[player.name]
local spawn_enabled = (player_respawns ~= nil) and (next(player_respawns) ~= nil) -- TODO: Maybe make a specific state flag or something more explicit?
SetOarcGuiTabEnabled(player, OARC_SPAWN_CTRL_TAB_NAME, spawn_enabled)

-- Regrowth control tab
AddOarcGuiTab(player, OARC_MOD_INFO_CTRL_TAB_NAME)
Expand Down Expand Up @@ -419,7 +422,7 @@ function AddRemoveOarcGuiTabForAllPlayers(tab_name, add, enable)
AddOarcGuiTab(player, tab_name)
SetOarcGuiTabEnabled(player, tab_name, true)
elseif (not add and DoesOarcGuiTabExist(player, tab_name)) then
-- RemoveOarcGuiTab(player, tab_name) -- SEE https://forums.factorio.com/viewtopic.php?f=7&t=115901
-- RemoveOarcGuiTab(player, tab_name) -- TODO: SEE https://forums.factorio.com/viewtopic.php?f=7&t=115901
RecreateOarcGui(player) -- Assumes a ocfg setting change, so just recreate the whole thing.
end
end
Expand Down
1 change: 1 addition & 0 deletions locale/en/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ oarc-shared-spawn-allow-joiners=Allow others to join your base.
oarc-shared-spawn-full=Your base is full! No more players can join.

oarc-set-respawn-loc-header=Respawn Location
oarc-no-respawn-this-surface=You cannot set a custom respawn location on this surface.
oarc-set-respawn-loc-info-surface-label=Current Surface Respawn: __1__ (x=__2__, y=__3__)
oarc-set-respawn-loc=Set Respawn Location
oarc-set-respawn-loc-tooltip=This will set your respawn point to your current location. There is a cooldown before you can change it again. You can only set this on supported surfaces.
Expand Down

0 comments on commit 1fc8312

Please sign in to comment.