Skip to content

Commit

Permalink
Feature: rework in-game Network GUI
Browse files Browse the repository at this point in the history
The GUI now more clearly shows some basic information about the
server you joined, your client name (and the ability to change it),
and what players are in which company.

It also contains useful buttons to press to join companies, chat
with other people, and for admins to kick/ban people.

Additionally, renamed "advertised" to "visibility"; this has to
do with future additions, but also because it is more clear in
wording.
  • Loading branch information
TrueBrain committed Apr 22, 2021
1 parent d4f0b6f commit b19e43d
Show file tree
Hide file tree
Showing 8 changed files with 547 additions and 160 deletions.
4 changes: 2 additions & 2 deletions src/company_cmd.cpp
Expand Up @@ -571,8 +571,8 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
GeneratePresidentName(c);

SetWindowDirty(WC_GRAPH_LEGEND, 0);
SetWindowClassesDirty(WC_CLIENT_LIST_POPUP);
SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowClassesData(WC_CLIENT_LIST_POPUP);
InvalidateWindowData(WC_CLIENT_LIST, 0);
InvalidateWindowData(WC_LINKGRAPH_LEGEND, 0);
BuildOwnerLegend();
InvalidateWindowData(WC_SMALLMAP, 0, 1);
Expand Down
43 changes: 34 additions & 9 deletions src/lang/english.txt
Expand Up @@ -1990,6 +1990,9 @@ STR_FACE_TIE :Tie:
STR_FACE_EARRING :Earring:
STR_FACE_TIE_EARRING_TOOLTIP :{BLACK}Change tie or earring

STR_NETWORK_SERVER_VISIBILITY_PRIVATE :Private
STR_NETWORK_SERVER_VISIBILITY_PUBLIC :Public

# Network server list
STR_NETWORK_SERVER_LIST_CAPTION :{WHITE}Multiplayer
STR_NETWORK_SERVER_LIST_PLAYER_NAME :{BLACK}Player name:
Expand Down Expand Up @@ -2052,10 +2055,8 @@ STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP :{BLACK}The game
STR_NETWORK_START_SERVER_SET_PASSWORD :{BLACK}Set password
STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP :{BLACK}Protect your game with a password if you don't want it to be publicly accessible

STR_NETWORK_START_SERVER_ADVERTISED_LABEL :{BLACK}Advertised
STR_NETWORK_START_SERVER_ADVERTISED_TOOLTIP :{BLACK}Choose between an advertised (internet) and a not advertised (Local Area Network, LAN) game
STR_NETWORK_START_SERVER_UNADVERTISED :No
STR_NETWORK_START_SERVER_ADVERTISED :Yes
STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibility
STR_NETWORK_START_SERVER_VISIBILITY_TOOLTIP :{BLACK}Whether other people can see your server in the public listing
STR_NETWORK_START_SERVER_CLIENTS_SELECT :{BLACK}{NUM} client{P "" s}
STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS :{BLACK}Maximum number of clients:
STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP :{BLACK}Choose the maximum number of clients. Not all slots need to be filled
Expand Down Expand Up @@ -2117,19 +2118,43 @@ STR_NETWORK_CONNECTION_DISCONNECT :{BLACK}Disconne

STR_NETWORK_NEED_GAME_PASSWORD_CAPTION :{WHITE}Server is protected. Enter password
STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION :{WHITE}Company is protected. Enter password
STR_NETWORK_COMPANY_LIST_CLIENT_LIST_CAPTION :{WHITE}Client list

# Network company list added strings
STR_NETWORK_COMPANY_LIST_CLIENT_LIST :Client list
STR_NETWORK_COMPANY_LIST_SPECTATE :Spectate
STR_NETWORK_COMPANY_LIST_NEW_COMPANY :New company

# Network client list
# Network client list popup for clients
STR_NETWORK_CLIENTLIST_KICK :Kick
STR_NETWORK_CLIENTLIST_BAN :Ban
STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL :Speak to all
STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY :Speak to company
STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT :Private message

# Network client list
STR_NETWORK_CLIENT_LIST_CAPTION :{WHITE}Multiplayer
STR_NETWORK_CLIENT_LIST_SERVER :{BLACK}Server
STR_NETWORK_CLIENT_LIST_SERVER_NAME :{BLACK}Name
STR_NETWORK_CLIENT_LIST_SERVER_NAME_TOOLTIP :{BLACK}Name of the server you are playing on
STR_NETWORK_CLIENT_LIST_SERVER_NAME_EDIT_TOOLTIP :{BLACK}Edit the name of your server
STR_NETWORK_CLIENT_LIST_SERVER_NAME_QUERY_CAPTION :Name of the server
STR_NETWORK_CLIENT_LIST_SERVER_VISIBILITY :{BLACK}Visibility
STR_NETWORK_CLIENT_LIST_SERVER_VISIBILITY_TOOLTIP :{BLACK}Whether other people can see your server in the public listing
STR_NETWORK_CLIENT_LIST_PLAYER :{BLACK}Player
STR_NETWORK_CLIENT_LIST_PLAYER_NAME :{BLACK}Name
STR_NETWORK_CLIENT_LIST_PLAYER_NAME_TOOLTIP :{BLACK}Your player name
STR_NETWORK_CLIENT_LIST_PLAYER_NAME_EDIT_TOOLTIP :{BLACK}Edit your player name
STR_NETWORK_CLIENT_LIST_PLAYER_NAME_QUERY_CAPTION :Your player name
STR_NETWORK_CLIENT_LIST_PLAYER_HOST :{WHITE}(host) {BLACK}{RAW_STRING}
STR_NETWORK_CLIENT_LIST_PLAYER_SELF :{WHITE}(you) {BLACK}{RAW_STRING}
STR_NETWORK_CLIENT_LIST_ADMIN :{WHITE}Admin
STR_NETWORK_CLIENT_LIST_ADMIN_TOOLTIP :{BLACK}Administrative actions to perform for this client
STR_NETWORK_CLIENT_LIST_JOIN :{BLACK}Join
STR_NETWORK_CLIENT_LIST_JOIN_TOOLTIP :{BLACK}Join this company
STR_NETWORK_CLIENT_LIST_CHAT :{BLACK}Chat
STR_NETWORK_CLIENT_LIST_CHAT_CLIENT_TOOLTIP :{BLACK}Send a message to this player
STR_NETWORK_CLIENT_LIST_CHAT_COMPANY_TOOLTIP :{BLACK}Send a message to all players of this company
STR_NETWORK_CLIENT_LIST_CHAT_SPECTATOR_TOOLTIP :{BLACK}Send a message to all spectators
STR_NETWORK_CLIENT_LIST_SPECTATORS :Spectators
STR_NETWORK_CLIENT_LIST_NO_PLAYERS :(no players)
STR_NETWORK_CLIENT_LIST_NO_SPECTATORS :(no spectators)

STR_NETWORK_SERVER :Server
STR_NETWORK_CLIENT :Client
Expand Down
10 changes: 8 additions & 2 deletions src/network/network.cpp
Expand Up @@ -521,9 +521,10 @@ void ParseGameConnectionString(const char **company, const char **port, char *co
/* Register the login */
_network_clients_connected++;

SetWindowDirty(WC_CLIENT_LIST, 0);
ServerNetworkGameSocketHandler *cs = new ServerNetworkGameSocketHandler(s);
cs->client_address = address; // Save the IP of the client

InvalidateWindowData(WC_CLIENT_LIST, 0);
}

/**
Expand Down Expand Up @@ -574,6 +575,11 @@ void NetworkClose(bool close_admins)
/* Initializes the network (cleans sockets and stuff) */
static void NetworkInitialize(bool close_admins = true)
{
/* Make sure we always have a name. */
if (StrEmpty(_settings_client.network.client_name)) {
strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));
}

InitializeNetworkPools(close_admins);
NetworkUDPInitialize();

Expand Down Expand Up @@ -710,7 +716,7 @@ void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const c
static void NetworkInitGameInfo()
{
if (StrEmpty(_settings_client.network.server_name)) {
seprintf(_settings_client.network.server_name, lastof(_settings_client.network.server_name), "Unnamed Server");
strecpy(_settings_client.network.server_name, "Unnamed Server", lastof(_settings_client.network.server_name));
}

/* The server is a client too */
Expand Down
10 changes: 5 additions & 5 deletions src/network/network_client.cpp
Expand Up @@ -641,7 +641,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(Pac
ci->client_playas = playas;
strecpy(ci->client_name, name, lastof(ci->client_name));

SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowData(WC_CLIENT_LIST, 0);

return NETWORK_RECV_STATUS_OKAY;
}
Expand All @@ -660,7 +660,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(Pac

strecpy(ci->client_name, name, lastof(ci->client_name));

SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowData(WC_CLIENT_LIST, 0);

return NETWORK_RECV_STATUS_OKAY;
}
Expand Down Expand Up @@ -1036,7 +1036,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT(Pack
delete ci;
}

SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowData(WC_CLIENT_LIST, 0);

return NETWORK_RECV_STATUS_OKAY;
}
Expand All @@ -1055,7 +1055,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(Packet *p)
DEBUG(net, 0, "Unknown client (%d) is leaving the game", client_id);
}

SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowData(WC_CLIENT_LIST, 0);

/* If we come here it means we could not locate the client.. strange :s */
return NETWORK_RECV_STATUS_OKAY;
Expand All @@ -1072,7 +1072,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_JOIN(Packet *p)
NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, ci->client_name);
}

SetWindowDirty(WC_CLIENT_LIST, 0);
InvalidateWindowData(WC_CLIENT_LIST, 0);

return NETWORK_RECV_STATUS_OKAY;
}
Expand Down

0 comments on commit b19e43d

Please sign in to comment.