Skip to content

Commit

Permalink
Removed more hard coded paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Wavesonics committed Nov 16, 2019
1 parent 9fa45e1 commit 43c7915
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 24 deletions.
49 changes: 37 additions & 12 deletions screens/lobby/Lobby.gd
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
extends PanelContainer

onready var playerListControl := $OuterContainer/CenterContainer/PlayersContainer/PlayersScrollContainer/PlayerList
onready var startGameButton := $OuterContainer/StartGameButton
onready var upnpButton := $OuterContainer/HBoxContainer/UPNPButton
onready var serverIpContainer := $OuterContainer/ServerIpContainer
onready var serverIpLabel := $OuterContainer/ServerIpContainer/ServerIpLabel
onready var seekerCountLabel := $OuterContainer/CenterContainer/PlayersContainer/SeekersCount
onready var hiderCountLabel := $OuterContainer/CenterContainer/PlayersContainer/HidersCount
onready var mapSelectButton := $OuterContainer/CenterContainer/OptionsContainer/MapSelectButton
export (NodePath) var playerListControlPath: NodePath
onready var playerListControl := get_node(playerListControlPath)

export (NodePath) var startGameButtonPath: NodePath
onready var startGameButton := get_node(startGameButtonPath)

export (NodePath) var upnpButtonPath: NodePath
onready var upnpButton := get_node(upnpButtonPath)

export (NodePath) var serverIpContainerPath: NodePath
onready var serverIpContainer : = get_node(serverIpContainerPath)

export (NodePath) var serverIpLabelPath: NodePath
onready var serverIpLabel := get_node(serverIpLabelPath)

export (NodePath) var serverPortLabelPath: NodePath
onready var serverPortLabel := get_node(serverPortLabelPath)

export (NodePath) var seekerCountLabelPath: NodePath
onready var seekerCountLabel := get_node(seekerCountLabelPath)

export (NodePath) var hiderCountLabelPath: NodePath
onready var hiderCountLabel := get_node(hiderCountLabelPath)

export (NodePath) var mapSelectButtonPath: NodePath
onready var mapSelectButton := get_node(mapSelectButtonPath)

export (NodePath) var mapInfoLabelPath: NodePath
onready var mapInfoLabel := get_node(mapInfoLabelPath)

export (NodePath) var gameNumberLabelPath: NodePath
onready var gameNumberLabel := get_node(gameNumberLabelPath)

export (NodePath) var winnerLabelPath: NodePath
onready var winnerLabel := get_node(winnerLabelPath)

# Production values:
const MIN_PLAYERS = 2
Expand Down Expand Up @@ -53,7 +80,7 @@ func _ready():
game_updated()
Network.request_lobby_state()

$OuterContainer/ServerIpContainer/PortLabel.text = "Port: %d" % Network.gameData.serverPort
serverPortLabel.text = "Port: %d" % Network.gameData.serverPort

# Update all clients to the server's network state
if get_tree().is_network_server():
Expand Down Expand Up @@ -100,7 +127,6 @@ func find_winner() -> PlayerLobbyData:
return playersByScore[0]

func update_winner():
var winnerLabel := $OuterContainer/WinnerLabel
if Network.gameData.numGames > 0:
var winner = find_winner()

Expand Down Expand Up @@ -349,7 +375,7 @@ func _on_MapSelectButton_item_selected(id):
remotesync func update_map_selection(id):
mapSelectButton.selected = id
var map = self.maps[id]
$OuterContainer/CenterContainer/OptionsContainer/MapInfoLabel.bbcode_text = '[u]Size:[/u] ' + map.size + "\n\n" + map.description
mapInfoLabel.bbcode_text = '[u]Size:[/u] ' + map.size + "\n\n" + map.description

func fetch_external_ip():
$HTTPRequest.request("https://api.ipify.org/?format=json")
Expand All @@ -369,7 +395,6 @@ func _on_HelpButton_pressed():
node.popup_centered()

func game_updated():
var gameNumberLabel := $OuterContainer/GameNumberLabel
gameNumberLabel.text = "Game: %d" % (Network.gameData.numGames+1)

func _on_CopyServerIpButton_pressed():
Expand Down
12 changes: 12 additions & 0 deletions screens/lobby/Lobby.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
playerListControlPath = NodePath("OuterContainer/CenterContainer/PlayersContainer/PlayersScrollContainer/PlayerList")
startGameButtonPath = NodePath("OuterContainer/StartGameButton")
upnpButtonPath = NodePath("OuterContainer/HBoxContainer/UPNPButton")
serverIpContainerPath = NodePath("OuterContainer/ServerIpContainer")
serverIpLabelPath = NodePath("OuterContainer/ServerIpContainer/ServerIpLabel")
serverPortLabelPath = NodePath("OuterContainer/ServerIpContainer/PortLabel")
seekerCountLabelPath = NodePath("OuterContainer/CenterContainer/PlayersContainer/SeekersCount")
hiderCountLabelPath = NodePath("OuterContainer/CenterContainer/PlayersContainer/HidersCount")
mapSelectButtonPath = NodePath("OuterContainer/CenterContainer/OptionsContainer/MapSelectButton")
mapInfoLabelPath = NodePath("OuterContainer/CenterContainer/OptionsContainer/MapInfoLabel")
gameNumberLabelPath = NodePath("OuterContainer/GameNumberLabel")
winnerLabelPath = NodePath("OuterContainer/WinnerLabel")

[node name="OuterContainer" type="VBoxContainer" parent="."]
margin_left = 14.0
Expand Down
39 changes: 27 additions & 12 deletions screens/mainmenu/MainMenu.gd
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
extends Node

export (NodePath) var joinDialogPath: NodePath
onready var joinDialog: WindowDialog = get_node(joinDialogPath)
onready var joinDialog := get_node(joinDialogPath)

export (NodePath) var serverIpEditTextPath: NodePath
onready var serverIpEditText: TextEdit = get_node(serverIpEditTextPath)
onready var serverIpEditText := get_node(serverIpEditTextPath)

export (NodePath) var serverListContainerPath: NodePath
onready var serverListContainer: PanelContainer = get_node(serverListContainerPath)
onready var serverListContainer := get_node(serverListContainerPath)

export (NodePath) var serverListPath: NodePath
onready var serverList: VBoxContainer
onready var serverList := get_node(serverListPath)

export (NodePath) var joiningDialogPath: NodePath
onready var joiningDialog: WindowDialog = get_node(joiningDialogPath)
onready var joiningDialog := get_node(joiningDialogPath)

export (NodePath) var joinFailedDialogPath: NodePath
onready var joinFailedDialog: AcceptDialog = get_node(joinFailedDialogPath)
onready var joinFailedDialog := get_node(joinFailedDialogPath)

export (NodePath) var hostFailedDialogPath: NodePath
onready var hostFailedDialog: AcceptDialog = get_node(hostFailedDialogPath)
onready var hostFailedDialog := get_node(hostFailedDialogPath)

export (NodePath) var playerNameEditTextPath: NodePath
onready var playerNameEditText := get_node(playerNameEditTextPath)

export (NodePath) var gameVersionLabelPath: NodePath
onready var gameVersionLabel := get_node(gameVersionLabelPath)

export (NodePath) var capturesLabelPath: NodePath
onready var capturesLabel := get_node(capturesLabelPath)

export (NodePath) var escapesLabelPath: NodePath
onready var escapesLabel := get_node(escapesLabelPath)

export (NodePath) var capturedLabelPath: NodePath
onready var capturedLabel := get_node(capturedLabelPath)

var playerName: String = ""

Expand Down Expand Up @@ -61,11 +76,11 @@ func _ready():

joiningDialog.get_close_button().hide()

$UiLayer/PanelContainer/VBoxContainer/PlayerNameTextEdit.text = playerName
$UiLayer/GameVersionLabel.text = "v%s" % UserData.GAME_VERSION
$UiLayer/PanelContainer/VBoxContainer/StatsReadoutContainer/GridContainer/LabelCaptures.text = str(UserData.data.lifetime_stats.seeker_captures)
$UiLayer/PanelContainer/VBoxContainer/StatsReadoutContainer/GridContainer/LabelEscapes.text = str(UserData.data.lifetime_stats.hider_escapes)
$UiLayer/PanelContainer/VBoxContainer/StatsReadoutContainer/GridContainer/LabelCaptured.text = str(UserData.data.lifetime_stats.hider_captures)
playerNameEditText.text = playerName
gameVersionLabel.text = "v%s" % UserData.GAME_VERSION
capturesLabel.text = str(UserData.data.lifetime_stats.seeker_captures)
escapesLabel.text = str(UserData.data.lifetime_stats.hider_escapes)
capturedLabel.text = str(UserData.data.lifetime_stats.hider_captures)

func _exit_tree():
# Save any user data that changed
Expand Down
5 changes: 5 additions & 0 deletions screens/mainmenu/MainMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ serverListPath = NodePath("UiLayer/ServerListContainer/VBoxContainer/ScrollConta
joiningDialogPath = NodePath("UiLayer/JoiningDialog")
joinFailedDialogPath = NodePath("UiLayer/JoinFailedDialog")
hostFailedDialogPath = NodePath("UiLayer/HostFailedDialog")
playerNameEditTextPath = NodePath("UiLayer/PanelContainer/VBoxContainer/PlayerNameTextEdit")
gameVersionLabelPath = NodePath("UiLayer/GameVersionLabel")
capturesLabelPath = NodePath("UiLayer/PanelContainer/VBoxContainer/StatsReadoutContainer/GridContainer/LabelCaptures")
escapesLabelPath = NodePath("UiLayer/PanelContainer/VBoxContainer/StatsReadoutContainer/GridContainer/LabelEscapes")
capturedLabelPath = NodePath("UiLayer/PanelContainer/VBoxContainer/StatsReadoutContainer/GridContainer/LabelCaptured")

[node name="Background" type="Node2D" parent="."]

Expand Down

0 comments on commit 43c7915

Please sign in to comment.