Skip to content

Commit

Permalink
Server IP address is now shown in the "Connecting..." panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrettin committed Oct 31, 2015
1 parent f8f2f50 commit 85b9c07
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ https://github.com/Andrettin/Wyrmsun

* Miscellaneous
- Maps are now saved directly as SMP and SMS files, instead of being saved within a compressed GZ file.
- Fixed a bug which caused a health bar to be shown for decoration units.

* Multiplayer
- Fix to IP address validation code (to prevent the game from repeatedly trying to connect to an invalid IP address).
- The IP address to which the player is trying to connect is now shown while in the "Connecting..." panel.

-----------------------------------------------------------------------
- 1.5.0
Expand Down
54 changes: 27 additions & 27 deletions scripts/menus/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ function RunJoiningMapMenu(s)
menu:run()
end

function RunJoiningGameMenu(s)
function RunJoiningGameMenu(server_address, s)
local menu = WarMenu(nil, panel(4), false)
menu:setSize(288, 128)
menu:setPosition((Video.Width - 288) / 2, (Video.Height - 128) / 2)
menu:setDrawMenusUnder(true)

menu:addLabel("Connecting to server", 144, 11)
menu:addLabel("Connecting to " .. server_address, 144, 11)

local percent = 0

Expand Down Expand Up @@ -291,32 +291,32 @@ function RunJoiningGameMenu(s)
end

function RunJoinIpMenu()
local menu = WarMenu(nil, panel(4), false)
menu:setSize(288, 128)
menu:setPosition((Video.Width - 288) / 2, (Video.Height - 128) / 2)
menu:setDrawMenusUnder(true)

menu:addLabel("Enter server IP-address:", 144, 11)
local server = menu:addTextInputField("localhost", 40, 38, 212)

menu:addHalfButton("~!OK", "o", 24, 80,
function(s)
-- FIXME: allow port ("localhost:1234")
if (NetworkSetupServerAddress(server:getText()) ~= 0) then
ErrorMenu("Invalid server name")
return
end
NetworkInitClientConnect()
if (RunJoiningGameMenu() ~= 0) then
-- connect failed, don't leave this menu
return
end
menu:stop()
end
)
menu:addHalfButton(_("~!Cancel"), "c", 154, 80, function() menu:stop() end)
local menu = WarMenu(nil, panel(4), false)
menu:setSize(288, 128)
menu:setPosition((Video.Width - 288) / 2, (Video.Height - 128) / 2)
menu:setDrawMenusUnder(true)

menu:addLabel("Enter server IP-address:", 144, 11)
local server = menu:addTextInputField("localhost", 40, 38, 212)

menu:addHalfButton("~!OK", "o", 24, 80,
function(s)
-- FIXME: allow port ("localhost:1234")
if (NetworkSetupServerAddress(server:getText()) ~= 0) then
ErrorMenu("Invalid address")
return
end
NetworkInitClientConnect()
if (RunJoiningGameMenu(server:getText()) ~= 0) then
-- connect failed, don't leave this menu
return
end
menu:stop()
end
)
menu:addHalfButton(_("~!Cancel"), "c", 154, 80, function() menu:stop() end)

menu:run()
menu:run()
end

function RunServerMultiGameMenu(map, description, numplayers)
Expand Down
2 changes: 1 addition & 1 deletion scripts/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if not (ui_loaded_first_time) then
if (CanAccessFile("ui/health2.png")) then
DefineSprites({Name = "sprite-health", File = "ui/health2.png", Offset = {0, -4}, Size = {31, 4}})

DefineDecorations({Index = "HitPoints", HideNeutral = false, CenterX = true, ShowOpponent=true,
DefineDecorations({Index = "HitPoints", HideNeutral = false, CenterX = true, ShowOpponent = true,
OffsetPercent = {50, 100}, Method = {"sprite", {"sprite-health"}}})
end

Expand Down

0 comments on commit 85b9c07

Please sign in to comment.