Update to 13.0-beta1
This commit is contained in:
+39
-31
@@ -36,6 +36,7 @@
|
||||
#include "../zoom_func.h"
|
||||
#include "../sprite.h"
|
||||
#include "../settings_internal.h"
|
||||
#include "../company_cmd.h"
|
||||
|
||||
#include "../widgets/network_widget.h"
|
||||
|
||||
@@ -102,8 +103,7 @@ public:
|
||||
|
||||
leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
|
||||
leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK, nullptr, ZOOM_LVL_OUT_4X).width
|
||||
+ GetSpriteSize(SPR_BLOT, nullptr, ZOOM_LVL_OUT_4X).width
|
||||
+ GetSpriteSize(SPR_FLAGS_BASE, nullptr, ZOOM_LVL_OUT_4X).width, 12);
|
||||
+ GetSpriteSize(SPR_BLOT, nullptr, ZOOM_LVL_OUT_4X).width, 12);
|
||||
leaf->SetFill(0, 1);
|
||||
this->Add(leaf);
|
||||
|
||||
@@ -1335,15 +1335,17 @@ static const NWidgetPart _nested_client_list_widgets[] = {
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_CL_CLIENT_NAME_EDIT), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_EDIT_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_MATRIX, COLOUR_GREY, WID_CL_MATRIX), SetMinimalSize(180, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_CL_SCROLLBAR),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_MATRIX, COLOUR_GREY, WID_CL_MATRIX), SetMinimalSize(180, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_CL_SCROLLBAR),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_CLIENT_COMPANY_COUNT), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetPadding(2, 1, 2, 1), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT, STR_NULL),
|
||||
EndContainer(),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_CL_SCROLLBAR),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_CL_SCROLLBAR),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
};
|
||||
@@ -1395,7 +1397,7 @@ static void AdminCompanyResetCallback(Window *w, bool confirmed)
|
||||
{
|
||||
if (confirmed) {
|
||||
if (NetworkCompanyHasClients(_admin_company_id)) return;
|
||||
DoCommandP(0, CCA_DELETE | _admin_company_id << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL);
|
||||
Command<CMD_COMPANY_CTRL>::Post(CCA_DELETE, _admin_company_id, CRR_MANUAL, INVALID_CLIENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1535,9 +1537,9 @@ private:
|
||||
static void OnClickCompanyNew(NetworkClientListWindow *w, Point pt, CompanyID company_id)
|
||||
{
|
||||
if (_network_server) {
|
||||
DoCommandP(0, CCA_NEW, _network_own_client_id, CMD_COMPANY_CTRL);
|
||||
Command<CMD_COMPANY_CTRL>::Post(CCA_NEW, INVALID_COMPANY, CRR_NONE, _network_own_client_id);
|
||||
} else {
|
||||
NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, nullptr, {}, _local_company);
|
||||
Command<CMD_COMPANY_CTRL>::SendNet(STR_NULL, _local_company, CCA_NEW, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1713,6 +1715,11 @@ public:
|
||||
this->FinishInitNested(window_number);
|
||||
}
|
||||
|
||||
void OnInit() override
|
||||
{
|
||||
RebuildList();
|
||||
}
|
||||
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
this->RebuildList();
|
||||
@@ -1771,9 +1778,11 @@ public:
|
||||
SetDParam(0, STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE_UNKNOWN + _network_server_connection_type);
|
||||
break;
|
||||
|
||||
case WID_CL_CLIENT_NAME:
|
||||
SetDParamStr(0, _settings_client.network.client_name);
|
||||
case WID_CL_CLIENT_NAME: {
|
||||
const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
|
||||
SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CL_CLIENT_COMPANY_COUNT:
|
||||
SetDParam(0, NetworkClientInfo::GetNumItems());
|
||||
@@ -1793,12 +1802,13 @@ public:
|
||||
ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_NAME_QUERY_CAPTION, NETWORK_NAME_LENGTH, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
|
||||
break;
|
||||
|
||||
case WID_CL_CLIENT_NAME_EDIT:
|
||||
case WID_CL_CLIENT_NAME_EDIT: {
|
||||
const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
|
||||
this->query_widget = WID_CL_CLIENT_NAME_EDIT;
|
||||
SetDParamStr(0, _settings_client.network.client_name);
|
||||
SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name);
|
||||
ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_QUERY_CAPTION, NETWORK_CLIENT_NAME_LENGTH, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
|
||||
break;
|
||||
|
||||
}
|
||||
case WID_CL_SERVER_VISIBILITY:
|
||||
if (!_network_server) break;
|
||||
|
||||
@@ -2106,21 +2116,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnMouseLoop() override
|
||||
void OnMouseOver(Point pt, int widget) override
|
||||
{
|
||||
if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) != WID_CL_MATRIX) {
|
||||
this->hover_index = -1;
|
||||
this->SetDirty();
|
||||
return;
|
||||
}
|
||||
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_CL_MATRIX);
|
||||
int y = _cursor.pos.y - this->top - nwi->pos_y - 2;
|
||||
int index = y / this->line_height;
|
||||
|
||||
if (index != this->hover_index) {
|
||||
this->hover_index = index;
|
||||
this->SetDirty();
|
||||
if (widget != WID_CL_MATRIX) {
|
||||
if (this->hover_index != -1) {
|
||||
this->hover_index = -1;
|
||||
this->SetWidgetDirty(WID_CL_MATRIX);
|
||||
}
|
||||
} else {
|
||||
int index = this->GetRowFromWidget(pt.y, widget, 0, -1);
|
||||
if (index != this->hover_index) {
|
||||
this->hover_index = index;
|
||||
this->SetWidgetDirty(WID_CL_MATRIX);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user