1 Commits

Author SHA1 Message Date
dP
42e6f6b452 Fix polyrail endpoint update when removing 2024-05-10 22:36:32 +05:00
9 changed files with 219 additions and 781 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5,11 +5,6 @@ namespace citymania {
void ShowCommandsToolbar();
void ShowLoginWindow();
void CheckAdmin();
void ShowAdminCompanyButtons(int left, int top, int width, int company2, bool draw, bool redraw);
void JoinLastServer(int left, int top, int height);
bool GetAdmin();
} // namespace citymania

View File

@@ -49,12 +49,9 @@
#include "citymania/cm_hotkeys.hpp"
#include "citymania/cm_main.hpp"
#include "citymania/cm_commands_gui.hpp"
#include "safeguards.h"
/* Admin company buttons */
bool Show_ACB[15];
/** Company GUI constants. */
static void DoSelectCompanyManagerFace(Window *parent);
@@ -2199,10 +2196,6 @@ static constexpr NWidgetPart _nested_company_widgets[] = {
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_C_RELOCATE_HQ), SetDataTip(STR_COMPANY_VIEW_RELOCATE_HQ, STR_COMPANY_VIEW_RELOCATE_COMPANY_HEADQUARTERS),
NWidget(NWID_SPACER),
EndContainer(),
/* Admin company buttons */
NWidget(NWID_SELECTION, INVALID_COLOUR, CM_WID_C_SELECT_ADMINBUTTONS),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CM_WID_C_ADMINBUTTONS), SetDataTip(CM_STR_ACB_COMPANY_ADMIN_BUTTON, CM_STR_ACB_COMPANY_ADMIN_BUTTON_TOOLTIP),
EndContainer(),
EndContainer(),
EndContainer(),
@@ -2232,7 +2225,15 @@ static constexpr NWidgetPart _nested_company_widgets[] = {
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_COMPANY_PASSWORD), SetDataTip(STR_COMPANY_VIEW_PASSWORD, STR_COMPANY_VIEW_PASSWORD_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_COMPANY_JOIN), SetDataTip(STR_COMPANY_VIEW_JOIN, STR_COMPANY_VIEW_JOIN_TOOLTIP),
EndContainer(),
EndContainer(),
// NWidget(NWID_SELECTION, INVALID_COLOUR, WID_C_SELECT_MOD),
// NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
// NWidget(NWID_VERTICAL), SetPIP(4, 2, 4),
// NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_MOD_COMPANY_JOIN), SetFill(1, 0), SetDataTip(STR_MOD_COMPANY_JOIN_BUTTON, STR_NULL),
// NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_C_MOD_COMPANY_TOGGLE_LOCK), SetFill(1, 0), SetDataTip(STR_MOD_TOGGLE_LOCK_BUTTON, STR_NULL),
// NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_C_MOD_COMPANY_RESET), SetFill(1, 0), SetDataTip(STR_MOD_COMPANY_RESET_BUTTON, STR_NULL),
// EndContainer(),
// EndContainer(),
EndContainer(),
EndContainer(),
EndContainer(),
EndContainer(),
@@ -2256,6 +2257,14 @@ static const StringID _company_view_vehicle_count_strings[] = {
/**
* Window with general information about a company
*/
static void ResetCallback(Window *w, bool confirmed)
{
if (confirmed) {
CompanyID company2 = (CompanyID)w->window_number;
citymania::NetworkClientSendChatToServer(fmt::format("!reset {}", company2 + 1));
}
}
struct CompanyWindow : Window
{
CompanyWidgets query_widget;
@@ -2293,10 +2302,6 @@ struct CompanyWindow : Window
/* Button bar selection. */
reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_BUTTONS)->SetDisplayedPlane(local ? 0 : SZSP_NONE);
/* Admin company buttons: show/hide admin menue button from param of citymania.cfg */
citymania::CheckAdmin();
reinit |= this->GetWidget<NWidgetStacked>(CM_WID_C_SELECT_ADMINBUTTONS)->SetDisplayedPlane(citymania::GetAdmin() ? 0 : SZSP_NONE);
/* Build HQ button handling. */
reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_VIEW_BUILD_HQ)->SetDisplayedPlane((local && c->location_of_HQ == INVALID_TILE) ? CWP_VB_BUILD : CWP_VB_VIEW);
@@ -2316,13 +2321,17 @@ struct CompanyWindow : Window
if (reinit) {
this->ReInit();
/* Admin company buttons: recall buttons while join/leave company */
if (Show_ACB[this->window_number]) citymania::ShowAdminCompanyButtons(this->left, this->top, this->width, this->window_number + 1, Show_ACB[this->window_number], true);
return;
}
}
/* Admin company buttons: recall buttons while moving company window */
if (Show_ACB[this->window_number]) citymania::ShowAdminCompanyButtons(this->left, this->top, this->width, this->window_number + 1, Show_ACB[this->window_number], false);
// if(!_networking) {
// this->SetWidgetDisabledState(CW_WIDGET_COMPANY_RESUME, true);
// this->SetWidgetDisabledState(CW_WIDGET_COMPANY_SUSPEND, true);
// this->SetWidgetDisabledState(CW_WIDGET_COMPANY_RESET, true);
// this->SetWidgetDisabledState(CW_WIDGET_COMPANY_JOIN2, true);
// }
this->DrawWidgets();
}
@@ -2380,14 +2389,19 @@ struct CompanyWindow : Window
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_GIVE_MONEY_BUTTON).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_HOSTILE_TAKEOVER_BUTTON).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_PASSWORD).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_JOIN).width);
size->width += padding.width;
break;
/* Admin company buttons */
case CM_WID_C_ADMINBUTTONS:
size->width = std::max(size->width, GetStringBoundingBox(CM_STR_ACB_COMPANY_ADMIN_BUTTON).width);
// case CW_WIDGET_COMPANY_RESUME:
// case CW_WIDGET_COMPANY_SUSPEND:
// case CW_WIDGET_COMPANY_RESET:
// case CW_WIDGET_COMPANY_JOIN2:
// if(!_novarole){
// size->width = 0;
// size->height = 0;
// }
// break;
case WID_C_HAS_PASSWORD:
if (_networking) *size = maxdim(*size, GetSpriteSize(SPR_LOCK));
break;
@@ -2610,13 +2624,28 @@ struct CompanyWindow : Window
MarkWholeScreenDirty();
break;
}
/* Admin company buttons: show/hide buttons */
case CM_WID_C_ADMINBUTTONS: {
case WID_C_MOD_COMPANY_JOIN: {
if (!_novarole) return;
CompanyID company2 = (CompanyID)this->window_number;
if (!Show_ACB[company2]) Show_ACB[company2] = true;
else Show_ACB[company2] = false;
citymania::ShowAdminCompanyButtons(this->left, this->top, this->width,company2 + 1, Show_ACB[company2], false);
break;
// this->query_widget = WID_C_MOD_COMPANY_JOIN;
citymania::NetworkClientSendChatToServer(fmt::format("!move {}", company2 + 1));
MarkWholeScreenDirty();
break;
}
case WID_C_MOD_COMPANY_RESET: {
if (!_networking) return;
this->query_widget = WID_C_MOD_COMPANY_RESET;
ShowQuery(CM_STR_XI_RESET_CAPTION, CM_STR_XI_REALY_RESET, this, ResetCallback);
MarkWholeScreenDirty();
break;
}
case WID_C_MOD_COMPANY_TOGGLE_LOCK: {
if (!_novarole) return;
CompanyID company2 = (CompanyID)this->window_number;
citymania::NetworkClientSendChatToServer(fmt::format("!lockp {}", company2 + 1));
MarkWholeScreenDirty();
break;
}
}
}

View File

@@ -41,7 +41,6 @@
#include "table/sprites.h"
#include "citymania/cm_hotkeys.hpp"
#include "citymania/cm_commands_gui.hpp"
#include "safeguards.h"
@@ -298,8 +297,6 @@ struct SelectGameWindow : public Window {
DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
break;
}
/* last server widget */
citymania::JoinLastServer(this->left, this->top, this->height);
}
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override

View File

@@ -5951,8 +5951,6 @@ CM_STR_TOOLBAR_COMMANDS_HINT_CAPTION :{BLACK}CB Hint
CM_STR_TOOLBAR_COMMANDS_HINT_TOOLTIP :{BLACK}Send !hint command to server(Shows town demand in CB mode).
CM_STR_TOOLBAR_COMMANDS_LOGIN_CAPTION :{BLACK}Login
CM_STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP :{BLACK}Send !login command to server.
CM_STR_TOOLBAR_COMMANDS_LOGOUT_CAPTION :{BLACK}Logout
CM_STR_TOOLBAR_COMMANDS_LOGOUT_TOOLTIP :{BLACK}Send !logout command to server.
CM_STR_TOOLBAR_COMMANDS_TIMELEFT_CAPTION :{BLACK}Timeleft
CM_STR_TOOLBAR_COMMANDS_TIMELEFT_TOOLTIP :{BLACK}Send !timeleft command to server.
CM_STR_TOOLBAR_COMMANDS_NS_CAPTION :{BLACK}CM{NUM}
@@ -6206,11 +6204,8 @@ CM_STR_LOGIN_WINDOW_NICE :{BLACK}N-ice
CM_STR_LOGIN_WINDOW_BTPRO :{BLACK}BTPro
CM_STR_LOGIN_ERROR_SIGN_IN_FAILED :{WHITE}Failed to connect
CM_STR_LOGIN_ERROR_BAD_INPUT :{WHITE}Bad username or password
CM_STR_LOGIN_WINDOW_USERNAME :{WHITE}Username:
CM_STR_LOGIN_WINDOW_PASSWORD :{WHITE}Password:
CM_STR_LOGIN_WINDOW_ADMIN_LOGIN :{BLACK}A-Login
CM_STR_LOGIN_WINDOW_ADMIN_LOGOUT :{BLACK}A-Logout
CM_STR_LOGIN_WINDOW_ADMIN_PASSWORD :{WHITE}Admin:
CM_STR_LOGIN_WINDOW_USERNAME :{WHITE}Username
CM_STR_LOGIN_WINDOW_PASSWORD :{WHITE}Password
CM_STR_LOGIN_WINDOW_SET :{WHITE}Set
CM_STR_LOGIN_WINDOW_NOT_SET :{WHITE}Not Set
CM_STR_LOGIN_WINDOW_CHANGE_USERNAME :{WHITE}Change username
@@ -6220,7 +6215,6 @@ CM_STR_LOGIN_WINDOW_CHANGE_PASSWORD_HELPTEXT :{BLACK}Change p
CM_STR_LOGIN_WINDOW_SIGN_IN_HELPTEXT :{BLACK}Sign in (you must be on the correct community server)
CM_STR_LOGIN_WINDOW_USERNAME_DISPLAY :{WHITE}{RAW_STRING}
CM_STR_LOGIN_WINDOW_PASSWORD_DISPLAY :{WHITE}{STRING}
CM_STR_LOGIN_WINDOW_WELCOME :{BLACK}Welcome to {STRING} community !
CM_STR_NETWORK_COMPANY_LIST_NEW_COMPANY :New company
CM_STR_NETWORK_COMPANY_LIST_SPECTATE :Spectate
@@ -6303,7 +6297,7 @@ CM_STR_CONFIG_SETTING_TYPE_DROPDOWN_CITYMANIA :CityMania patch
CM_BUILDING_PREVIEW_COST_ENOUGH :Cost
CM_STR_NO_BLUEPRINT_IN_SLOT :{WHITE}No blueprint in slot {NUM}
CM_STR_ABOUT_MENU_LOGIN_WINDOW :Community tools
CM_STR_ABOUT_MENU_LOGIN_WINDOW :CityMania server login
CM_STR_BUILD_INFO_OVERLAY_COST_OK :{WHITE}Cost: {CURRENCY_LONG}
CM_STR_BUILD_INFO_OVERLAY_COST_NO_MONEY :{RED}Cost: {CURRENCY_LONG}
CM_STR_BUILD_INFO_OVERLAY_STATION_ACCEPTS :{WHITE}Accepts:
@@ -6318,58 +6312,7 @@ CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE :Toolbar dropdow
CM_STR_CONFIG_SETTING_TOOLBAR_DROPDOWN_CLOSE_HELPTEXT :Control whether the main toolbar dropdowns activate their default function when the mouse button is released. If not enabled then the dropdown menu will stay open so a selection can be made.
###length VEHICLE_TYPES
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN :{BLACK}Show hidden ({NUM})
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_ROAD_VEHICLE :{BLACK}Show hidden ({NUM})
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_SHIP :{BLACK}Show hidden ({NUM})
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT :{BLACK}Show hidden ({NUM})
### Admin Company Buttons ###
CM_STR_ACB_COMPANY_ADMIN_CAPTION :{WHITE}Admin buttons #{NUM}
CM_STR_ACB_COMPANY_ADMIN_BUTTON :{WHITE}Admin buttons
CM_STR_ACB_COMPANY_ADMIN_BUTTON_TOOLTIP :{BLACK}Show / hide the admin buttons.
CM_STR_ACB_LOCK :{BLACK}Lock
CM_STR_ACB_LOCK_TOOLTIP :{BLACK}Lock Company. All players on it will be sent to spectators.
CM_STR_ACB_UNLOCK :{BLACK}Unlock
CM_STR_ACB_UNLOCK_TOOLTIP :{BLACK}Unlock Company making possible player(s) joining it again.
CM_STR_ACB_KNOWN :{BLACK}Known
CM_STR_ACB_KNOWN_TOOLTIP :{BLACK}Show the known player(s) of company.
CM_STR_ACB_RESET_KNOWN :{BLACK}Reset Known
CM_STR_ACB_RESET_KNOWN_TOOLTIP :{BLACK}Reset list of known players of company.
CM_STR_ACB_MOVE_PLAYER_TO :{BLACK}Move to ...
CM_STR_ACB_MOVE_PLAYER_TO_TOOLTIP :{BLACK}Move a player (number #.. or name) to company
CM_STR_ACB_COMPANY_NEWSTICKET_BUTTON :{BLACK}News
CM_STR_ACB_COMPANY_NEWSTICKET_BUTTON_TOOLTIP :{BLACK}Open a Newspapper message directed to Company
CM_STR_ACB_COMPANY_NEWSTICKET_BUTTON_COMP :{BLACK}News (P. C.)
CM_STR_ACB_COMPANY_NEWSTICKET_BUTTON_COMP_TOOLTIP :{BLACK}Open a Newspapper message only showed to Company
CM_STR_ACB_SUSPEND :{BLACK}Suspend
CM_STR_ACB_SUSPEND_TOOLTIP :{BLACK}Suspend Company actions keeping player in the company.
CM_STR_ACB_UNSUSPEND :{BLACK}Unsuspend
CM_STR_ACB_UNSUSPEND_TOOLTIP :{BLACK}Unsuspend Company actions.
CM_STR_ACB_EMPTY :{BLACK}Empty
CM_STR_ACB_EMPTY_TOOLTIP :{BLACK}Send players in company to Spectators.
CM_STR_ACB_RESET :{BLACK}Reset
CM_STR_ACB_RESET_TOOLTIP :{BLACK}Reset the company. The company must be empty.
CM_STR_ACB_RESET_SPEC :{BLACK}Reset Spec
CM_STR_ACB_RESET_SPEC_TOOLTIP :{BLACK}Reset company and send player(s) to spectators.
CM_STR_ACB_RESET_KICK :{BLACK}Reset Kick
CM_STR_ACB_RESET_KICK_TOOLTIP :{BLACK}Reset company and Kick out of the game player(s) on it.
CM_STR_ACB_RESET_TIMER_120 :{BLACK}Reset T. 2m
CM_STR_ACB_RESET_TIMER_120_TOOLTIP :{BLACK}Starts a timer to reset company when after 2 minutes countdown.
CM_STR_ACB_RESET_TIMER :{BLACK}Reset T....
CM_STR_ACB_RESET_TIMER_TOOLTIP :{BLACK}Starts a timer to reset company when time expire (time is Admin input).
CM_STR_ACB_RESET_TIMER_VALUE :{BLACK}Time to Reset (seconds):
CM_STR_ACB_RESET_TIMER_CANCEL :{BLACK}Cancel Reset
CM_STR_ACB_RESET_TIMER_CANCEL_TOOLTIP :{BLACK}Cancel the Reset timer.
CM_STR_ACB_AWARNING :{BLACK}Warning
CM_STR_ACB_AWARNING_TOOLTIP :{BLACK}Sends a Warning to company that an admin is trying to contact.
CM_STR_ACB_RESET_COMP :{BLACK}RESET Company
CM_STR_ACB_RESET_COMP_SURE :{WHITE}Sure to RESET this company?
CM_STR_ACB_RESET_SPEC_SURE :{WHITE}Sure to RESET this company, send players to SPECTATORS?
CM_STR_ACB_RESET_KICK_SURE :{WHITE}Sure to RESET this company, and KICK players on it?
CM_STR_ACB_PLAYER_NEWSTICKET :{BLACK}Type message as newspapper ticket to this Player
CM_STR_ACB_COMPANY_NEWSTICKET :{BLACK}Type message as newspapper ticket to this Company
CM_STR_ACB_COMPANY_JOIN2 :{BLACK}A. Join
CM_STR_ACB_COMPANY_JOIN2_TOOLTIP :{BLACK}Join as an admin
### Several command strings ###
CM_STR_SCS_COMPANY_NEW_JOIN_TOOLTIP :Hold CTRL and click for joining with new company.
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN :{BLACK}Show hidden ({NUM})
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_ROAD_VEHICLE :{BLACK}Show hidden ({NUM})
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_SHIP :{BLACK}Show hidden ({NUM})
CM_STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT :{BLACK}Show hidden ({NUM})

View File

@@ -40,7 +40,6 @@
#include "../citymania/cm_client_list_gui.hpp"
#include "../citymania/cm_commands.hpp"
#include "../citymania/cm_newgrf_revisions.hpp"
#include "../citymania/cm_commands_gui.hpp" /* Admin company buttons */
#include "../safeguards.h"
@@ -1326,8 +1325,7 @@ void NetworkClientsToSpectators(CompanyID cid)
NetworkTextMessage(NETWORK_ACTION_COMPANY_SPECTATOR, CC_DEFAULT, false, ci->client_name);
ci->client_playas = COMPANY_SPECTATOR;
}
/* Admin company buttons: delete window */
citymania::ShowAdminCompanyButtons(0, 0, 0, cid+1, false, false);
cur_company.Restore();
}

View File

@@ -282,11 +282,6 @@ void ShowStatusBar()
}
void CM_RedrawStatusBar() {
Window *w = FindWindowById(WC_STATUS_BAR, 0);
if (w == nullptr) return;
StatusBarWindow *st = static_cast<StatusBarWindow*>(w);
st->ReInit();
StatusBarWindow *w = dynamic_cast<StatusBarWindow*>(FindWindowById(WC_STATUS_BAR, 0));
w->ReInit();
}

View File

@@ -52,8 +52,11 @@ enum CompanyWidgets : WidgetID {
WID_C_COMPANY_PASSWORD, ///< Button to set company password.
WID_C_COMPANY_JOIN, ///< Button to join company.
CM_WID_C_SELECT_ADMINBUTTONS,
CM_WID_C_ADMINBUTTONS,
WID_C_SELECT_MOD,
WID_C_SELECT_MOD_JOIN,
WID_C_MOD_COMPANY_JOIN,
WID_C_MOD_COMPANY_RESET,
WID_C_MOD_COMPANY_TOGGLE_LOCK,
};
/** Widgets of the #CompanyFinancesWindow class. */

View File

@@ -732,8 +732,6 @@ enum WindowClass {
CM_WC_COMMAND_TOOLBAR,
CM_WC_LOGIN_WINDOW,
CM_WC_CB_TOWN,
CM_WC_ADMIN_COMPANY_BUTTONS,
CM_LAST_SERVER,
WC_INVALID = 0xFFFF, ///< Invalid window.
};