Compare commits
8 Commits
apm_crash/
...
origin_14.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdff0d37ec | ||
|
|
33b63dbd55 | ||
|
|
c5416bcd63 | ||
|
|
56defd5a4c | ||
| 24b93febeb | |||
|
|
991440009a | ||
| 740b6a4c4e | |||
|
|
c2dbe3923e |
@@ -37,6 +37,15 @@ int ACB_top = 0;
|
|||||||
int ACB_width = 0;
|
int ACB_width = 0;
|
||||||
int ACB_Location[3][15];
|
int ACB_Location[3][15];
|
||||||
|
|
||||||
|
/* server buttons */
|
||||||
|
std::string _server_list_text; // list from http
|
||||||
|
std::string _cc_address; // current adddress
|
||||||
|
std::string _cc_name; // current name
|
||||||
|
int _cc_porti; // current port
|
||||||
|
std::int8_t _fromlast = 0;
|
||||||
|
int _left, _top, _height;
|
||||||
|
int _servercount; // how many servers
|
||||||
|
|
||||||
static const int HTTPBUFLEN = 1024;
|
static const int HTTPBUFLEN = 1024;
|
||||||
static const int MAX_COMMUNITY_STRING_LEN = 128;
|
static const int MAX_COMMUNITY_STRING_LEN = 128;
|
||||||
|
|
||||||
@@ -199,6 +208,17 @@ enum LastServerWidgets {
|
|||||||
LSW_BUTTON,
|
LSW_BUTTON,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ServerButtonsWidgets {
|
||||||
|
WID_SB_SELECT_NICE,
|
||||||
|
WID_SB_SELECT_BTPRO,
|
||||||
|
WID_SB_SELECT_CITYMANIA,
|
||||||
|
WID_SB_SELECT_NONE,
|
||||||
|
AC_SERVERS,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ServerButtonsQueryWidgets {};
|
||||||
|
|
||||||
|
|
||||||
enum CommunityName {
|
enum CommunityName {
|
||||||
CITYMANIA,
|
CITYMANIA,
|
||||||
NICE,
|
NICE,
|
||||||
@@ -221,7 +241,9 @@ char _inilogindata[9][MAX_COMMUNITY_STRING_LEN];
|
|||||||
|
|
||||||
void AccountLogin(CommunityName community);
|
void AccountLogin(CommunityName community);
|
||||||
void IniReloadLogin();
|
void IniReloadLogin();
|
||||||
void ShowAdminCompanyButtons(int companyid = INVALID_COMPANY);
|
void ShowServerButtons(int left,int top, int height);
|
||||||
|
void ReloadServerButtons();
|
||||||
|
|
||||||
|
|
||||||
bool novahost() {
|
bool novahost() {
|
||||||
return _novahost;
|
return _novahost;
|
||||||
@@ -645,7 +667,125 @@ void ShowCommandsToolbar()
|
|||||||
// AllocateWindowDescFront<CommandsToolbarWindow>(&_commands_toolbar_desc, 0);
|
// AllocateWindowDescFront<CommandsToolbarWindow>(&_commands_toolbar_desc, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// login window
|
/* for server buttons */
|
||||||
|
/** To handle Community Server list */
|
||||||
|
class CommunityServerManager: public HTTPCallback {
|
||||||
|
public:
|
||||||
|
CommunityServerManager() {}
|
||||||
|
|
||||||
|
void initiateServerSequence(const std::string &uri) {
|
||||||
|
this->cursor = this->buf;
|
||||||
|
this->buf_last = lastof(buf);
|
||||||
|
NetworkHTTPSocketHandler::Connect(uri, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveServerString() const {
|
||||||
|
_server_list_text += this->buf;
|
||||||
|
//NetworkClientSendChatToServer("*** data has been saved.");
|
||||||
|
if (FindWindowByClass(CM_WC_LOGIN_WINDOW)) ReloadServerButtons();
|
||||||
|
if (FindWindowByClass(WC_SELECT_GAME)) ReloadServerButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
void inspectServerData() {
|
||||||
|
if (this->cursor - this->buf >= 4) this->SaveServerString();
|
||||||
|
else {
|
||||||
|
//NetworkClientSendChatToServer("*** no data has been received.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnFailure() override {
|
||||||
|
ShowErrorMessage(CM_STR_SB_SERVER_LIST_UNREACHABLE, INVALID_STRING_ID,WL_ERROR);
|
||||||
|
//NetworkClientSendChatToServer("*** connection failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsCancelled() const override { return false; }
|
||||||
|
|
||||||
|
void OnReceiveData(std::unique_ptr<char[]> data, size_t length) override
|
||||||
|
{
|
||||||
|
if (data.get() == nullptr)
|
||||||
|
{
|
||||||
|
this->inspectServerData();
|
||||||
|
this->cursor = nullptr;
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < length && this->cursor < this->buf_last; i++, this->cursor++) {
|
||||||
|
*(this->cursor) = data.get()[i];
|
||||||
|
}
|
||||||
|
*(this->cursor) = '\0';
|
||||||
|
//NetworkClientSendChatToServer("*** data received");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
char buf[4096]{};
|
||||||
|
char *buf_last{};
|
||||||
|
char *cursor{};
|
||||||
|
};
|
||||||
|
|
||||||
|
void CommunityServerManagerSend()
|
||||||
|
{
|
||||||
|
std::int8_t _community = stoi(GetServerItem(COMMUNITY));
|
||||||
|
std::string uri;
|
||||||
|
|
||||||
|
if (_community == 1) {
|
||||||
|
uri = fmt::format("http://n-ice.org/openttd/serverlist.txt");
|
||||||
|
} else if (_community == 2) {
|
||||||
|
uri = fmt::format("https://openttd.btpro.nl/btproservers.txt");
|
||||||
|
} else if (_community == 3) {
|
||||||
|
uri = fmt::format("http://altseehof.de/openttd/citymaniaservers.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
static CommunityServerManager servermgr{};
|
||||||
|
servermgr.initiateServerSequence(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetCommunityServerListText(){
|
||||||
|
std::int8_t _community = stoi(GetServerItem(COMMUNITY));
|
||||||
|
if(_fromlast == _community || _community == 0) return;
|
||||||
|
_fromlast = _community;
|
||||||
|
_server_list_text.clear();
|
||||||
|
CommunityServerManagerSend();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetCommunityServer(int number, bool findonly) {
|
||||||
|
|
||||||
|
if(_server_list_text.empty()) return false;
|
||||||
|
_cc_address = "";
|
||||||
|
_cc_name = "";
|
||||||
|
|
||||||
|
std::string server;
|
||||||
|
std::string port;
|
||||||
|
|
||||||
|
if(number < 10) {
|
||||||
|
server = fmt::format("SERVER0{}", number);
|
||||||
|
port = fmt::format("PORT0{}", number);
|
||||||
|
} else {
|
||||||
|
server = fmt::format("SERVER{}", number);
|
||||||
|
port = fmt::format("PORT{}", number);
|
||||||
|
}
|
||||||
|
size_t posaddress = _server_list_text.find(server);
|
||||||
|
size_t posport = _server_list_text.find(port);
|
||||||
|
|
||||||
|
if(posaddress != std::string::npos && posport != std::string::npos){
|
||||||
|
std::string saddress = _server_list_text.substr(posaddress + 10, _server_list_text.find(";", posaddress + 10) - posaddress - 10);
|
||||||
|
std::string sport = _server_list_text.substr(posport + 8, _server_list_text.find(";", posport + 8) - posport - 8);
|
||||||
|
|
||||||
|
if(saddress.compare("DISABLED") == 0) return false;
|
||||||
|
else if(findonly) return true;
|
||||||
|
|
||||||
|
_cc_address = saddress;
|
||||||
|
_cc_porti = std::stoi(sport);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(findonly) return false;
|
||||||
|
|
||||||
|
ShowErrorMessage(CM_STR_SB_SERVER_LIST_ERROR_FILE, INVALID_STRING_ID,WL_ERROR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* end of serverbuttons */
|
||||||
|
|
||||||
|
/* for login window */
|
||||||
class GetHTTPContent: public HTTPCallback {
|
class GetHTTPContent: public HTTPCallback {
|
||||||
public:
|
public:
|
||||||
GetHTTPContent() {
|
GetHTTPContent() {
|
||||||
@@ -693,15 +833,15 @@ public:
|
|||||||
virtual ~GetHTTPContent() {
|
virtual ~GetHTTPContent() {
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
char buf[HTTPBUFLEN];
|
char buf[HTTPBUFLEN]{};
|
||||||
char *buf_last;
|
char *buf_last{};
|
||||||
char *cursor;
|
char *cursor{};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string urlencode(const std::string &s) {
|
std::string urlencode(const std::string &s) {
|
||||||
static const char lookup[]= "0123456789abcdef";
|
static const char lookup[]= "0123456789abcdef";
|
||||||
std::stringstream e;
|
std::stringstream e;
|
||||||
for(int i=0, ix=s.length(); i<ix; i++)
|
for(int i=0, ix=(int)s.length(); i<ix; i++)
|
||||||
{
|
{
|
||||||
const char& c = s[i];
|
const char& c = s[i];
|
||||||
if ( (48 <= c && c <= 57) ||//0-9
|
if ( (48 <= c && c <= 57) ||//0-9
|
||||||
@@ -723,7 +863,7 @@ std::string urlencode(const std::string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string btpro_encode(const char *value) {
|
std::string btpro_encode(const char *value) {
|
||||||
return urlencode(base64_encode((const unsigned char *)value, strlen(value)));
|
return urlencode(base64_encode((const unsigned char *)value, (int)strlen(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//send login
|
//send login
|
||||||
@@ -748,9 +888,9 @@ void AccountLogin(CommunityName community){
|
|||||||
login.InitiateLoginSequence(uri);
|
login.InitiateLoginSequence(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
//login window
|
/* login window */
|
||||||
struct LoginWindow : Window {
|
struct LoginWindow : Window {
|
||||||
LoginWindowQueryWidgets query_widget;
|
LoginWindowQueryWidgets query_widget{};
|
||||||
|
|
||||||
std::int8_t _community = stoi(GetServerItem(COMMUNITY));
|
std::int8_t _community = stoi(GetServerItem(COMMUNITY));
|
||||||
|
|
||||||
@@ -764,8 +904,21 @@ struct LoginWindow : Window {
|
|||||||
this->DisableWidget(LWW_ADMIN_LOGOUT);
|
this->DisableWidget(LWW_ADMIN_LOGOUT);
|
||||||
this->DisableWidget(LWW_ADMIN_PW);
|
this->DisableWidget(LWW_ADMIN_PW);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Close([[maybe_unused]] int data) override {
|
||||||
|
CloseWindowByClass(CM_WC_SERVER_BUTTONS);
|
||||||
|
this->Window::Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||||
|
{
|
||||||
|
r; widget;
|
||||||
|
ShowServerButtons(this->left, this->top, this->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetStringParameters(int widget) const override
|
void SetStringParameters(int widget) const override
|
||||||
{
|
{
|
||||||
switch(widget){
|
switch(widget){
|
||||||
@@ -843,7 +996,6 @@ struct LoginWindow : Window {
|
|||||||
if(_networking) NetworkClientSendChatToServer(fmt::format("!alogin {} {}", _inilogindata[BTPROUSER], base64_decode(_inilogindata[BTPROADMINPW])));
|
if(_networking) NetworkClientSendChatToServer(fmt::format("!alogin {} {}", _inilogindata[BTPROUSER], base64_decode(_inilogindata[BTPROADMINPW])));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//case 3: if(/*_novahost && */_networking) AccountLogin(CITYMANIA); break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -890,9 +1042,8 @@ struct LoginWindow : Window {
|
|||||||
}
|
}
|
||||||
case LQW_ADMIN_PW: {
|
case LQW_ADMIN_PW: {
|
||||||
switch (_community) {
|
switch (_community) {
|
||||||
case 1: SetLoginItem(NICE_ADMIN_PW, base64_encode((const unsigned char *)str, strlen(str))); break;
|
case 1: SetLoginItem(NICE_ADMIN_PW, base64_encode((const unsigned char *)str, (int)strlen(str))); break;
|
||||||
case 2: SetLoginItem(BTPRO_ADMIN_PW, base64_encode((const unsigned char *)str, strlen(str))); break;
|
case 2: SetLoginItem(BTPRO_ADMIN_PW, base64_encode((const unsigned char *)str, (int)strlen(str))); break;
|
||||||
//case 3: SetLoginItem(NOVAPOLIS_PW, str); break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -903,8 +1054,7 @@ struct LoginWindow : Window {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct AdminCompanyButtonsWindow : Window {
|
struct AdminCompanyButtonsWindow : Window {
|
||||||
AdminCompanyButtonsQueryWidgets query_widget;
|
AdminCompanyButtonsQueryWidgets query_widget{};
|
||||||
//CompanyID company;
|
|
||||||
|
|
||||||
AdminCompanyButtonsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) {
|
AdminCompanyButtonsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) {
|
||||||
|
|
||||||
@@ -1065,7 +1215,6 @@ struct AdminCompanyButtonsWindow : Window {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct JoinLastServerWindow : Window {
|
struct JoinLastServerWindow : Window {
|
||||||
// CompanyID company;
|
|
||||||
|
|
||||||
JoinLastServerWindow(WindowDesc *desc, WindowNumber window_number)
|
JoinLastServerWindow(WindowDesc *desc, WindowNumber window_number)
|
||||||
: Window(desc) {
|
: Window(desc) {
|
||||||
@@ -1090,39 +1239,188 @@ struct JoinLastServerWindow : Window {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
void SetStringParameters(WidgetID widget) const override {
|
|
||||||
switch (widget) {
|
|
||||||
case LSW_BUTTON:
|
|
||||||
if (_server != "")
|
|
||||||
SetDParam(0, STR_JUST_NOTHING);
|
|
||||||
else {
|
|
||||||
SetDParam(0, STR_NETWORK_SERVER_LIST_CLICK_TO_SELECT_LAST);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ServerButtonsWindow : Window {
|
||||||
|
ServerButtonsQueryWidgets query_widget{};
|
||||||
|
|
||||||
|
std::int8_t _community = stoi(GetServerItem(COMMUNITY));
|
||||||
|
|
||||||
|
ServerButtonsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) {
|
||||||
|
|
||||||
|
this->InitNested(window_number);
|
||||||
|
|
||||||
|
if(_community == 1){
|
||||||
|
this->GetWidget<NWidgetCore>(WID_SB_SELECT_NICE)->colour = COLOUR_ORANGE;
|
||||||
|
}
|
||||||
|
else if(_community == 2){
|
||||||
|
this->GetWidget<NWidgetCore>(WID_SB_SELECT_BTPRO)->colour = COLOUR_ORANGE;
|
||||||
|
}
|
||||||
|
else if(_community == 3){
|
||||||
|
this->GetWidget<NWidgetCore>(WID_SB_SELECT_CITYMANIA)->colour = COLOUR_ORANGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count)
|
||||||
|
{
|
||||||
|
switch (widget) {
|
||||||
|
case WID_SB_SELECT_NICE:
|
||||||
|
SetServerItem(COMMUNITY, "1");
|
||||||
|
GetCommunityServerListText();
|
||||||
|
break;
|
||||||
|
case WID_SB_SELECT_BTPRO:
|
||||||
|
SetServerItem(COMMUNITY, "2");
|
||||||
|
GetCommunityServerListText();
|
||||||
|
break;
|
||||||
|
case WID_SB_SELECT_CITYMANIA:
|
||||||
|
SetServerItem(COMMUNITY, "3");
|
||||||
|
GetCommunityServerListText();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (widget >= AC_SERVERS) {
|
||||||
|
if (GetCommunityServer(widget - AC_SERVERS + 1,false)) {
|
||||||
|
if (_ctrl_pressed) {
|
||||||
|
NetworkClientConnectGame(fmt::format("{}:{}", _cc_address, _cc_porti), COMPANY_NEW_COMPANY);
|
||||||
|
} else {
|
||||||
|
NetworkClientConnectGame(fmt::format("{}:{}", _cc_address, _cc_porti), COMPANY_SPECTATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else ShowErrorMessage(CM_STR_SB_SERVER_DISABLED, INVALID_STRING_ID, WL_ERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GetServerName(int number)
|
||||||
|
{
|
||||||
|
size_t poscount = _server_list_text.find("servercount");
|
||||||
|
std::string scount = _server_list_text.substr(poscount + 12, 3);
|
||||||
|
_servercount = std::stoi(scount);
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
if (number < 10){
|
||||||
|
name = fmt::format("NAME0{}",number);
|
||||||
|
} else {
|
||||||
|
name = fmt::format("NAME{}",number);
|
||||||
|
}
|
||||||
|
std::string server;
|
||||||
|
if (number < 10){
|
||||||
|
server = fmt::format("SERVER0{}",number);
|
||||||
|
} else {
|
||||||
|
server = fmt::format("SERVER{}",number);
|
||||||
|
}
|
||||||
|
size_t posname = _server_list_text.find(name);
|
||||||
|
std::string sname = _server_list_text.substr(posname + 8, _server_list_text.find(";", posname + 8) - posname - 8);
|
||||||
|
|
||||||
|
if (number > _servercount)
|
||||||
|
_cc_name = "-";
|
||||||
|
else
|
||||||
|
_cc_name = sname;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void DrawWidget(const Rect &r, int widget) const override
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
switch (widget) {
|
||||||
|
case AC_SERVERS:
|
||||||
|
default:
|
||||||
|
if(widget >= AC_SERVERS){
|
||||||
|
if(widget - AC_SERVERS + 1 < 10){
|
||||||
|
name = fmt::format("NAME0{}",widget - AC_SERVERS +1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
name = fmt::format("NAME{}",widget - AC_SERVERS +1);
|
||||||
|
}
|
||||||
|
size_t posname = _server_list_text.find(name);
|
||||||
|
std::string sname = _server_list_text.substr(posname + 8, _server_list_text.find(";", posname + 8) - posname - 8);
|
||||||
|
_cc_name = sname;
|
||||||
|
|
||||||
|
SetDParamStr(0, _cc_name);
|
||||||
|
DrawString(r.left, r.right, r.top + 3, CM_STR_SB_NETWORK_DIRECT_JOIN_GAME, TC_FROMSTRING, SA_CENTER);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* fix me */
|
||||||
|
std::unique_ptr<NWidgetBase> MakeServerButtons()
|
||||||
|
{
|
||||||
|
std::int8_t _community = stoi(GetServerItem(COMMUNITY));
|
||||||
|
auto ver = std::make_unique<NWidgetVertical>();
|
||||||
|
|
||||||
|
if(_community == 0 || _server_list_text.empty()){
|
||||||
|
auto leaf = std::make_unique<NWidgetBackground>(WWT_PANEL, COLOUR_GREY, AC_SERVERS);
|
||||||
|
ver->Add(std::move(leaf));
|
||||||
|
return ver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for disabled server from serverlist file */
|
||||||
|
int active = 0, aactive[50]{}, s_max = 0;
|
||||||
|
if (_community == 1) s_max = 50; //for n-ice
|
||||||
|
if (_community == 2) s_max = 30; //for btpro
|
||||||
|
if (_community == 3) s_max = 10; //for citymania
|
||||||
|
for (int i = 0; i < s_max; i++) {
|
||||||
|
aactive[i] = GetCommunityServer(i + 1, true) ? (i + 1) : 0; //server disabled?
|
||||||
|
active++;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto hor = std::make_unique<NWidgetHorizontal>();
|
||||||
|
int i1 = 0, i2 = 0;
|
||||||
|
for (int i = 0; i < s_max; i++) {
|
||||||
|
if ((aactive[i] == 0) && (_community == 1)) continue; //hide button if disabled - for n-ice only
|
||||||
|
i2++;
|
||||||
|
if ((i1 == 5) || (i1 == 10) || (i1 == 15) || (i1 == 20) || (i1 == 25) || (i1 == 30) || (i1 == 35) || (i1 == 40) || (i1 == 45) || (i1 == 50)) {
|
||||||
|
i2=0;
|
||||||
|
auto spce = std::make_unique<NWidgetSpacer>(3, 0);
|
||||||
|
spce->SetFill(1, 0);
|
||||||
|
hor->Add(std::move(spce));
|
||||||
|
ver->Add(std::move(hor));
|
||||||
|
auto spc = std::make_unique<NWidgetSpacer>(0, 4);
|
||||||
|
spc->SetFill(1, 0);
|
||||||
|
ver->Add(std::move(spc));
|
||||||
|
hor = std::make_unique<NWidgetHorizontal>();
|
||||||
|
}
|
||||||
|
auto spce = std::make_unique<NWidgetSpacer>(4, 0);
|
||||||
|
spce->SetFill(1, 0);
|
||||||
|
hor->Add(std::move(spce));
|
||||||
|
auto leaf = std::make_unique<NWidgetBackground>(WWT_PANEL, COLOUR_ORANGE, AC_SERVERS + i);
|
||||||
|
if(aactive[i] == 0) leaf->SetDisabled(true);
|
||||||
|
leaf->SetDataTip(CM_STR_SB_NETWORK_DIRECT_JOIN_GAME, CM_STR_SB_NETWORK_DIRECT_JOIN_TOOLTIP);
|
||||||
|
leaf->SetMinimalSize(79, 15);
|
||||||
|
hor->Add(std::move(leaf));
|
||||||
|
i1++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* arrange buttons @ last line */
|
||||||
|
if (i2==0) i2=375;
|
||||||
|
if (i2==1) i2=282;
|
||||||
|
if (i2==2) i2=189;
|
||||||
|
if (i2==3) i2=96;
|
||||||
|
if (i2==4) i2=3;
|
||||||
|
auto spce = std::make_unique<NWidgetSpacer>(i2, 0);
|
||||||
|
spce->SetFill(1, 0);
|
||||||
|
hor->Add(std::move(spce));
|
||||||
|
ver->Add(std::move(hor));
|
||||||
|
return ver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const NWidgetPart _nested_login_window_widgets[] = {
|
static const NWidgetPart _nested_login_window_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
NWidget(WWT_CLOSEBOX, COLOUR_ORANGE),
|
||||||
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(CM_STR_LOGIN_WINDOW_CAPTION, 0),
|
NWidget(WWT_CAPTION, COLOUR_ORANGE), SetDataTip(CM_STR_LOGIN_WINDOW_CAPTION, 0),
|
||||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0),
|
NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0),
|
||||||
NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPadding(10),
|
NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPadding(10),
|
||||||
//welcome
|
//welcome
|
||||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
NWidget(WWT_TEXT, COLOUR_BROWN, LWW_COMMUNITY), SetMinimalSize(100, 20), SetAlignment(SA_CENTER), SetDataTip(CM_STR_LOGIN_WINDOW_WELCOME, 0), SetFill(1, 1),
|
NWidget(WWT_TEXT, COLOUR_BROWN, LWW_COMMUNITY), SetMinimalSize(403, 20), SetAlignment(SA_CENTER), SetDataTip(CM_STR_LOGIN_WINDOW_WELCOME, 0), SetFill(1, 1),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(0, 10),
|
NWidget(NWID_SPACER), SetMinimalSize(0, 10),
|
||||||
//username and pw
|
//username and pw
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(55, 0),
|
||||||
NWidget(WWT_TEXT, COLOUR_BROWN, LWW_USERNAME), SetDataTip(CM_STR_LOGIN_WINDOW_USERNAME, 0),
|
NWidget(WWT_TEXT, COLOUR_BROWN, LWW_USERNAME), SetDataTip(CM_STR_LOGIN_WINDOW_USERNAME, 0),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, LWW_USER_NAME), SetMinimalSize(100, 15), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, LWW_USER_NAME), SetMinimalSize(100, 15), SetFill(1, 1),
|
||||||
@@ -1132,18 +1430,18 @@ static const NWidgetPart _nested_login_window_widgets[] = {
|
|||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, LWW_USER_PW), SetMinimalSize(50, 15), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, LWW_USER_PW), SetMinimalSize(50, 15), SetFill(1, 1),
|
||||||
SetDataTip(CM_STR_LOGIN_WINDOW_PASSWORD_DISPLAY, CM_STR_LOGIN_WINDOW_CHANGE_PASSWORD_HELPTEXT),
|
SetDataTip(CM_STR_LOGIN_WINDOW_PASSWORD_DISPLAY, CM_STR_LOGIN_WINDOW_CHANGE_PASSWORD_HELPTEXT),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(55, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(0, 20),
|
NWidget(NWID_SPACER), SetMinimalSize(0, 20),
|
||||||
//login and logout
|
//login and logout
|
||||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(85, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGIN), SetMinimalSize(40, 30), SetAlignment(SA_CENTER), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGIN), SetMinimalSize(40, 20), SetAlignment(SA_CENTER), SetFill(1, 1),
|
||||||
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGIN_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP),
|
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGIN_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGOUT), SetMinimalSize(40, 30), SetAlignment(SA_CENTER), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGOUT), SetMinimalSize(40, 20), SetAlignment(SA_CENTER), SetFill(1, 1),
|
||||||
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGOUT_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGOUT_TOOLTIP),
|
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGOUT_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGOUT_TOOLTIP),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(85, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(0, 10),
|
NWidget(NWID_SPACER), SetMinimalSize(0, 10),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
@@ -1152,11 +1450,10 @@ static const NWidgetPart _nested_login_window_widgets[] = {
|
|||||||
|
|
||||||
static const NWidgetPart _nested_admin_window_widgets[] = {
|
static const NWidgetPart _nested_admin_window_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
NWidget(WWT_CLOSEBOX, COLOUR_ORANGE),
|
||||||
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(CM_STR_LOGIN_WINDOW_CAPTION, 0),
|
NWidget(WWT_CAPTION, COLOUR_ORANGE), SetDataTip(CM_STR_LOGIN_WINDOW_CAPTION, 0),
|
||||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0),
|
NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0),
|
||||||
NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPadding(10),
|
NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPadding(10),
|
||||||
//welcome
|
//welcome
|
||||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
@@ -1186,16 +1483,16 @@ static const NWidgetPart _nested_admin_window_widgets[] = {
|
|||||||
//login and logout
|
//login and logout
|
||||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGIN), SetMinimalSize(40, 30), SetAlignment(SA_CENTER), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGIN), SetMinimalSize(40, 20), SetAlignment(SA_CENTER), SetFill(1, 1),
|
||||||
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGIN_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP),
|
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGIN_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGOUT), SetMinimalSize(40, 30), SetAlignment(SA_CENTER), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_USER_LOGOUT), SetMinimalSize(40, 20), SetAlignment(SA_CENTER), SetFill(1, 1),
|
||||||
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGOUT_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGOUT_TOOLTIP),
|
SetDataTip(CM_STR_TOOLBAR_COMMANDS_LOGOUT_CAPTION, CM_STR_TOOLBAR_COMMANDS_LOGOUT_TOOLTIP),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_ADMIN_LOGIN), SetMinimalSize(40, 30), SetAlignment(SA_CENTER), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_ADMIN_LOGIN), SetMinimalSize(40, 20), SetAlignment(SA_CENTER), SetFill(1, 1),
|
||||||
SetDataTip(CM_STR_LOGIN_WINDOW_ADMIN_LOGIN, CM_STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP),
|
SetDataTip(CM_STR_LOGIN_WINDOW_ADMIN_LOGIN, CM_STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_ADMIN_LOGOUT), SetMinimalSize(40, 30), SetAlignment(SA_CENTER), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LWW_ADMIN_LOGOUT), SetMinimalSize(40, 20), SetAlignment(SA_CENTER), SetFill(1, 1),
|
||||||
SetDataTip(CM_STR_LOGIN_WINDOW_ADMIN_LOGOUT, CM_STR_TOOLBAR_COMMANDS_LOGOUT_TOOLTIP),
|
SetDataTip(CM_STR_LOGIN_WINDOW_ADMIN_LOGOUT, CM_STR_TOOLBAR_COMMANDS_LOGOUT_TOOLTIP),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(5, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
@@ -1244,49 +1541,29 @@ static const NWidgetPart _nested_admin_company_window_widgets[] = {
|
|||||||
|
|
||||||
static const NWidgetPart _nested_last_server_widgets[] = {
|
static const NWidgetPart _nested_last_server_widgets[] = {
|
||||||
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(0, 1),
|
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(0, 1),
|
||||||
//NWidget(NWID_HORIZONTAL),
|
|
||||||
// NWidget(WWT_CAPTION, COLOUR_BROWN, LSW_CAPTION), SetMinimalSize(322, 20), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_SERVER_LIST_LAST_JOINED_SERVER, 0), SetFill(1, 1),
|
|
||||||
//EndContainer(),
|
|
||||||
NWidget(NWID_HORIZONTAL), SetPadding(4),
|
NWidget(NWID_HORIZONTAL), SetPadding(4),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LSW_BUTTON), SetMinimalSize(322, 20), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_SERVER_LIST_CLICK_TO_SELECT_LAST, CM_STR_SCS_COMPANY_NEW_JOIN_TOOLTIP), SetFill(1, 1),
|
NWidget(NWID_SPACER), SetMinimalSize(87, 0), SetFill(1, 0),
|
||||||
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, LSW_BUTTON), SetMinimalSize(241, 15), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_SERVER_LIST_CLICK_TO_SELECT_LAST, CM_STR_SB_NETWORK_DIRECT_JOIN_TOOLTIP), SetFill(1, 1),
|
||||||
|
NWidget(NWID_SPACER), SetMinimalSize(87, 0), SetFill(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Identify the current community */
|
static const NWidgetPart _nested_server_buttons_window_widgets[] = {
|
||||||
void CheckCommunity() {
|
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(0, 1),
|
||||||
if (_network_server_name.find("n-ice.org") != std::string::npos) {
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(4), SetPIP(0, 7, 0),
|
||||||
if (GetServerItem(COMMUNITY) != "1") {
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SB_SELECT_NICE), SetMinimalSize(134, 13), SetDataTip(CM_STR_SB_SELECT_NICE, 0),
|
||||||
SetServerItem(COMMUNITY, "1");
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SB_SELECT_BTPRO), SetMinimalSize(134, 13), SetDataTip(CM_STR_SB_SELECT_BTPRO, 0),
|
||||||
// GetCommunityServerListText();
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SB_SELECT_CITYMANIA), SetMinimalSize(134, 13), SetDataTip(CM_STR_SB_SELECT_CITYMANIA, 0),
|
||||||
}
|
EndContainer(),
|
||||||
} else if (_network_server_name.find("BTPro.nl") != std::string::npos) {
|
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
|
||||||
if (GetServerItem(COMMUNITY) != "2") {
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||||
SetServerItem(COMMUNITY, "2");
|
NWidgetFunction(MakeServerButtons),
|
||||||
// GetCommunityServerListText();
|
EndContainer(),
|
||||||
}
|
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
|
||||||
} else if (_network_server_name.find("CityMania.org") != std::string::npos) {
|
EndContainer(),
|
||||||
if (GetServerItem(COMMUNITY) != "3") {
|
|
||||||
SetServerItem(COMMUNITY, "3");
|
|
||||||
// GetCommunityServerListText();
|
|
||||||
}
|
|
||||||
} else if (_network_server_name.find("reddit.com") != std::string::npos) {
|
|
||||||
if (GetServerItem(COMMUNITY) != "4") {
|
|
||||||
SetServerItem(COMMUNITY, "4");
|
|
||||||
// GetCommunityServerListText();
|
|
||||||
}
|
|
||||||
} else { // Unknown Server
|
|
||||||
SetServerItem(COMMUNITY, "0");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void CheckAdmin(){
|
|
||||||
IniInitiate();
|
|
||||||
if (GetLoginItem(ADMIN) == "1")
|
|
||||||
_admin = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static WindowDesc _login_window_desc(__FILE__, __LINE__,
|
static WindowDesc _login_window_desc(__FILE__, __LINE__,
|
||||||
WDP_CENTER, "cm_login", 0, 0,
|
WDP_CENTER, "cm_login", 0, 0,
|
||||||
CM_WC_LOGIN_WINDOW, WC_NONE,
|
CM_WC_LOGIN_WINDOW, WC_NONE,
|
||||||
@@ -1311,8 +1588,55 @@ static WindowDesc _admin_company_buttons_desc(__FILE__, __LINE__,
|
|||||||
static WindowDesc _last_server_desc(__FILE__, __LINE__,
|
static WindowDesc _last_server_desc(__FILE__, __LINE__,
|
||||||
WDP_AUTO, NULL, 0, 0,
|
WDP_AUTO, NULL, 0, 0,
|
||||||
CM_LAST_SERVER,
|
CM_LAST_SERVER,
|
||||||
WC_NONE, WDF_CONSTRUCTION, std::begin(_nested_last_server_widgets),
|
WC_NONE, WDF_CONSTRUCTION,
|
||||||
std::end(_nested_last_server_widgets));
|
std::begin(_nested_last_server_widgets), std::end(_nested_last_server_widgets));
|
||||||
|
|
||||||
|
static WindowDesc _server_buttons_desc(__FILE__, __LINE__,
|
||||||
|
WDP_AUTO, NULL, 0, 0,
|
||||||
|
CM_WC_SERVER_BUTTONS, WC_NONE,
|
||||||
|
WDF_CONSTRUCTION,
|
||||||
|
std::begin(_nested_server_buttons_window_widgets), std::end(_nested_server_buttons_window_widgets)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Identify the current community */
|
||||||
|
void CheckCommunity() {
|
||||||
|
if (_networking) {
|
||||||
|
if (_network_server_name.find("n-ice.org") != std::string::npos) {
|
||||||
|
if (GetServerItem(COMMUNITY) != "1") {
|
||||||
|
SetServerItem(COMMUNITY, "1");
|
||||||
|
GetCommunityServerListText();
|
||||||
|
}
|
||||||
|
} else if (_network_server_name.find("BTPro.nl") != std::string::npos) {
|
||||||
|
if (GetServerItem(COMMUNITY) != "2") {
|
||||||
|
SetServerItem(COMMUNITY, "2");
|
||||||
|
GetCommunityServerListText();
|
||||||
|
}
|
||||||
|
} else if (_network_server_name.find("CityMania.org") !=
|
||||||
|
std::string::npos) {
|
||||||
|
if (GetServerItem(COMMUNITY) != "3") {
|
||||||
|
SetServerItem(COMMUNITY, "3");
|
||||||
|
GetCommunityServerListText();
|
||||||
|
}
|
||||||
|
} else if (_network_server_name.find("reddit.com") !=
|
||||||
|
std::string::npos) {
|
||||||
|
if (GetServerItem(COMMUNITY) != "4") {
|
||||||
|
SetServerItem(COMMUNITY, "4");
|
||||||
|
// GetCommunityServerListText();
|
||||||
|
}
|
||||||
|
} else { // Unknown Server
|
||||||
|
SetServerItem(COMMUNITY, "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* for intro menue */
|
||||||
|
if ((GetServerItem(COMMUNITY) == "1") || (GetServerItem(COMMUNITY) == "2") || (GetServerItem(COMMUNITY) == "3"))
|
||||||
|
GetCommunityServerListText();
|
||||||
|
};
|
||||||
|
|
||||||
|
void CheckAdmin() {
|
||||||
|
IniInitiate();
|
||||||
|
if (GetLoginItem(ADMIN) == "1")
|
||||||
|
_admin = true;
|
||||||
|
};
|
||||||
|
|
||||||
void ShowLoginWindow() {
|
void ShowLoginWindow() {
|
||||||
IniInitiate();
|
IniInitiate();
|
||||||
@@ -1323,10 +1647,35 @@ void ShowLoginWindow() {
|
|||||||
else AllocateWindowDescFront<LoginWindow>(&_admin_window_desc, 0);
|
else AllocateWindowDescFront<LoginWindow>(&_admin_window_desc, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ShowServerButtons(int left, int top, int height) {
|
||||||
|
|
||||||
|
_left = left;
|
||||||
|
_top = top;
|
||||||
|
_height = height;
|
||||||
|
|
||||||
|
IniInitiate();
|
||||||
|
if (_server_list_text.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* create window at coordinates */
|
||||||
|
Window *b;
|
||||||
|
CloseWindowByClass(CM_WC_SERVER_BUTTONS);
|
||||||
|
b = new ServerButtonsWindow(&_server_buttons_desc, 0);
|
||||||
|
b->top = top+height;
|
||||||
|
b->left = left;
|
||||||
|
b->SetDirty();
|
||||||
|
};
|
||||||
|
|
||||||
|
void ReloadServerButtons() {
|
||||||
|
ShowServerButtons(_left, _top, _height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateCommunityServerList() {
|
||||||
|
IniInitiate();
|
||||||
|
CheckCommunity();
|
||||||
|
};
|
||||||
|
|
||||||
void ShowAdminCompanyButtons(int left, int top, int width, int company2, bool draw, bool redraw) {
|
void ShowAdminCompanyButtons(int left, int top, int width, int company2, bool draw, bool redraw) {
|
||||||
//IniInitiate();
|
|
||||||
//CheckCommunity();
|
|
||||||
if (!draw) {
|
if (!draw) {
|
||||||
CloseWindowById(CM_WC_ADMIN_COMPANY_BUTTONS, company2);
|
CloseWindowById(CM_WC_ADMIN_COMPANY_BUTTONS, company2);
|
||||||
/* clear for company */
|
/* clear for company */
|
||||||
@@ -1342,7 +1691,7 @@ void ShowAdminCompanyButtons(int left, int top, int width, int company2, bool dr
|
|||||||
(!redraw))
|
(!redraw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* set for company */
|
/* save position of company window */
|
||||||
ACB_Location[company2 - 1][0] = left;
|
ACB_Location[company2 - 1][0] = left;
|
||||||
ACB_Location[company2 - 1][1] = top;
|
ACB_Location[company2 - 1][1] = top;
|
||||||
ACB_Location[company2 - 1][2] = width;
|
ACB_Location[company2 - 1][2] = width;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ void ShowLoginWindow();
|
|||||||
void CheckAdmin();
|
void CheckAdmin();
|
||||||
void ShowAdminCompanyButtons(int left, int top, int width, int company2, bool draw, bool redraw);
|
void ShowAdminCompanyButtons(int left, int top, int width, int company2, bool draw, bool redraw);
|
||||||
void JoinLastServer(int left, int top, int height);
|
void JoinLastServer(int left, int top, int height);
|
||||||
|
void CreateCommunityServerList();
|
||||||
|
void ShowServerButtons(int left, int top, int height);
|
||||||
|
|
||||||
bool GetAdmin();
|
bool GetAdmin();
|
||||||
|
|
||||||
|
|||||||
@@ -678,4 +678,15 @@ std::string GetStationCoverageProductionText(TileIndex tile, int w, int h, int r
|
|||||||
return s.str();
|
return s.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* enable/disable catchment area with ctrl+click on a station */
|
||||||
|
void ShowCatchmentByClick(StationID station)
|
||||||
|
{
|
||||||
|
if (_viewport_highlight_station != nullptr) {
|
||||||
|
if (_viewport_highlight_station == Station::Get(station))
|
||||||
|
SetViewportCatchmentStation(Station::Get(station), false);
|
||||||
|
else SetViewportCatchmentStation(Station::Get(station), true);
|
||||||
|
}
|
||||||
|
else SetViewportCatchmentStation(Station::Get(station), true);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace citymania
|
} // namespace citymania
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ void SelectStationToJoin(const Station *station);
|
|||||||
void MarkCoverageHighlightDirty();
|
void MarkCoverageHighlightDirty();
|
||||||
bool CheckRedrawStationCoverage();
|
bool CheckRedrawStationCoverage();
|
||||||
void AbortStationPlacement();
|
void AbortStationPlacement();
|
||||||
|
void ShowCatchmentByClick(StationID station);
|
||||||
|
|
||||||
std::string GetStationCoverageProductionText(TileIndex tile, int w, int h, int rad, StationCoverageType sct);
|
std::string GetStationCoverageProductionText(TileIndex tile, int w, int h, int rad, StationCoverageType sct);
|
||||||
|
|
||||||
|
|||||||
@@ -2673,6 +2673,14 @@ struct CompanyWindow : Window
|
|||||||
OnResize();
|
OnResize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Admin company buttons: close window */
|
||||||
|
void Close([[maybe_unused]] int data) override
|
||||||
|
{
|
||||||
|
if (FindWindowById(CM_WC_ADMIN_COMPANY_BUTTONS,this->window_number+1))
|
||||||
|
CloseWindowById(CM_WC_ADMIN_COMPANY_BUTTONS,this->window_number+1);
|
||||||
|
this->Window::Close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static WindowDesc _company_desc(__FILE__, __LINE__,
|
static WindowDesc _company_desc(__FILE__, __LINE__,
|
||||||
|
|||||||
@@ -299,7 +299,9 @@ struct SelectGameWindow : public Window {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* last server widget */
|
/* last server widget */
|
||||||
|
citymania::CreateCommunityServerList();
|
||||||
citymania::JoinLastServer(this->left, this->top, this->height);
|
citymania::JoinLastServer(this->left, this->top, this->height);
|
||||||
|
citymania::ShowServerButtons(this->left, this->top, this->height + 28);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||||
@@ -455,7 +457,9 @@ static constexpr NWidgetPart _nested_select_game_widgets[] = {
|
|||||||
|
|
||||||
/* 'Exit' button */
|
/* 'Exit' button */
|
||||||
NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
|
NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
|
||||||
|
NWidget(NWID_SPACER), SetMinimalSize(138, 0), SetFill(1, 0),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EXIT), SetMinimalSize(128, 0), SetDataTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_SGI_EXIT), SetMinimalSize(128, 0), SetDataTip(STR_INTRO_QUIT, STR_INTRO_TOOLTIP_QUIT),
|
||||||
|
NWidget(NWID_SPACER), SetMinimalSize(138, 0), SetFill(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
|||||||
@@ -6200,7 +6200,7 @@ CM_STR_CONFIG_SETTING_GRAPH_BACKGROUND_BLACK :Black
|
|||||||
CM_STR_CONFIG_SETTING_GRAPH_BACKGROUND_GREY :Light grey
|
CM_STR_CONFIG_SETTING_GRAPH_BACKGROUND_GREY :Light grey
|
||||||
|
|
||||||
# Community login window
|
# Community login window
|
||||||
CM_STR_LOGIN_WINDOW_CAPTION :{WHITE}Login Window
|
CM_STR_LOGIN_WINDOW_CAPTION :{BLACK}Login Window
|
||||||
CM_STR_LOGIN_WINDOW_CITYMANIA :{BLACK}CityMania
|
CM_STR_LOGIN_WINDOW_CITYMANIA :{BLACK}CityMania
|
||||||
CM_STR_LOGIN_WINDOW_NICE :{BLACK}N-ice
|
CM_STR_LOGIN_WINDOW_NICE :{BLACK}N-ice
|
||||||
CM_STR_LOGIN_WINDOW_BTPRO :{BLACK}BTPro
|
CM_STR_LOGIN_WINDOW_BTPRO :{BLACK}BTPro
|
||||||
@@ -6371,5 +6371,12 @@ CM_STR_ACB_COMPANY_NEWSTICKET :{BLACK}Type mes
|
|||||||
CM_STR_ACB_COMPANY_JOIN2 :{BLACK}A. Join
|
CM_STR_ACB_COMPANY_JOIN2 :{BLACK}A. Join
|
||||||
CM_STR_ACB_COMPANY_JOIN2_TOOLTIP :{BLACK}Join as an admin
|
CM_STR_ACB_COMPANY_JOIN2_TOOLTIP :{BLACK}Join as an admin
|
||||||
|
|
||||||
### Several command strings ###
|
### Server buttons ###
|
||||||
CM_STR_SCS_COMPANY_NEW_JOIN_TOOLTIP :Hold CTRL and click for joining with new company.
|
CM_STR_SB_SELECT_NICE :{BLACK}N-ice
|
||||||
|
CM_STR_SB_SELECT_BTPRO :{BLACK}BTPro
|
||||||
|
CM_STR_SB_SELECT_CITYMANIA :{BLACK}Citymania
|
||||||
|
CM_STR_SB_SERVER_LIST_UNREACHABLE :{WHITE}Couldn't get server details
|
||||||
|
CM_STR_SB_SERVER_DISABLED :{WHITE}Server is Disabled / Offline
|
||||||
|
CM_STR_SB_SERVER_LIST_ERROR_FILE :{WHITE}Error on getting servers file
|
||||||
|
CM_STR_SB_NETWORK_DIRECT_JOIN_GAME :{BLACK}{RAW_STRING}
|
||||||
|
CM_STR_SB_NETWORK_DIRECT_JOIN_TOOLTIP :{BLACK}Hold CTRL and click for joining with new company.
|
||||||
|
|||||||
@@ -1228,7 +1228,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(P
|
|||||||
_network_server_max_companies = p.Recv_uint8();
|
_network_server_max_companies = p.Recv_uint8();
|
||||||
_network_server_name = p.Recv_string(NETWORK_NAME_LENGTH);
|
_network_server_name = p.Recv_string(NETWORK_NAME_LENGTH);
|
||||||
SetWindowClassesDirty(WC_CLIENT_LIST);
|
SetWindowClassesDirty(WC_CLIENT_LIST);
|
||||||
|
citymania::CreateCommunityServerList(); //@cm_commands_gui.cpp
|
||||||
Debug(net, 9, "Client::Receive_SERVER_CONFIG_UPDATE(): max_companies={}", _network_server_max_companies);
|
Debug(net, 9, "Client::Receive_SERVER_CONFIG_UPDATE(): max_companies={}", _network_server_max_companies);
|
||||||
|
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
|
|||||||
@@ -2202,6 +2202,7 @@ static WindowDesc _station_view_desc(__FILE__, __LINE__,
|
|||||||
*/
|
*/
|
||||||
void ShowStationViewWindow(StationID station)
|
void ShowStationViewWindow(StationID station)
|
||||||
{
|
{
|
||||||
|
if (_ctrl_pressed) citymania::ShowCatchmentByClick(station); else
|
||||||
AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
|
AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,6 +282,11 @@ void ShowStatusBar()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CM_RedrawStatusBar() {
|
void CM_RedrawStatusBar() {
|
||||||
StatusBarWindow *w = dynamic_cast<StatusBarWindow*>(FindWindowById(WC_STATUS_BAR, 0));
|
Window *w = FindWindowById(WC_STATUS_BAR, 0);
|
||||||
w->ReInit();
|
|
||||||
|
if (w == nullptr) return;
|
||||||
|
|
||||||
|
StatusBarWindow *st = static_cast<StatusBarWindow*>(w);
|
||||||
|
|
||||||
|
st->ReInit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,6 +733,7 @@ enum WindowClass {
|
|||||||
CM_WC_LOGIN_WINDOW,
|
CM_WC_LOGIN_WINDOW,
|
||||||
CM_WC_CB_TOWN,
|
CM_WC_CB_TOWN,
|
||||||
CM_WC_ADMIN_COMPANY_BUTTONS,
|
CM_WC_ADMIN_COMPANY_BUTTONS,
|
||||||
|
CM_WC_SERVER_BUTTONS,
|
||||||
CM_LAST_SERVER,
|
CM_LAST_SERVER,
|
||||||
|
|
||||||
WC_INVALID = 0xFFFF, ///< Invalid window.
|
WC_INVALID = 0xFFFF, ///< Invalid window.
|
||||||
|
|||||||
Reference in New Issue
Block a user