Merge branch 'enhanced_viewport_overlay' into jgrpp
# Conflicts: # src/command.cpp # src/saveload/extended_ver_sl.cpp
This commit is contained in:
@@ -253,6 +253,7 @@ CommandProc CmdAddPlanLine;
|
||||
CommandProc CmdRemovePlan;
|
||||
CommandProc CmdRemovePlanLine;
|
||||
CommandProc CmdChangePlanVisibility;
|
||||
CommandProc CmdRenamePlan;
|
||||
|
||||
CommandProc CmdDesyncCheck;
|
||||
|
||||
@@ -466,6 +467,7 @@ static const Command _command_proc_table[] = {
|
||||
DEF_CMD(CmdRemovePlan, CMD_NO_TEST, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_PLAN
|
||||
DEF_CMD(CmdRemovePlanLine, CMD_NO_TEST, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_PLAN_LINE
|
||||
DEF_CMD(CmdChangePlanVisibility, CMD_NO_TEST, CMDT_OTHER_MANAGEMENT ), // CMD_CHANGE_PLAN_VISIBILITY
|
||||
DEF_CMD(CmdRenamePlan, CMD_NO_TEST, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_PLAN
|
||||
|
||||
DEF_CMD(CmdDesyncCheck, CMD_SERVER, CMDT_SERVER_SETTING ), // CMD_DESYNC_CHECK
|
||||
};
|
||||
|
@@ -398,6 +398,7 @@ enum Commands {
|
||||
CMD_REMOVE_PLAN,
|
||||
CMD_REMOVE_PLAN_LINE,
|
||||
CMD_CHANGE_PLAN_VISIBILITY,
|
||||
CMD_RENAME_PLAN,
|
||||
|
||||
CMD_DESYNC_CHECK, ///< Force desync checks to be run
|
||||
|
||||
|
@@ -4894,8 +4894,10 @@ STR_PLANS_VISIBILITY_TOOLTIP :{BLACK}Toggle t
|
||||
STR_PLANS_DELETE :{BLACK}Delete
|
||||
STR_PLANS_DELETE_TOOLTIP :{BLACK}Delete the selected item in the list
|
||||
STR_PLANS_LIST_ITEM_PLAN :Plan #{NUM}: {NUM} line{P "" s} ({DATE_SHORT})
|
||||
STR_PLANS_LIST_ITEM_NAMED_PLAN :{RAW_STRING}: {NUM} line{P "" s} ({DATE_SHORT})
|
||||
STR_PLANS_LIST_ITEM_LINE : -- Line #{NUM}: {NUM} segment{P "" s}
|
||||
STR_PLANS_LIST_TOOLTIP :{BLACK}Double click any item in the list to (un)fold the related plan.{}Ctrl+Click to scroll to.
|
||||
STR_PLANS_QUERY_RENAME_PLAN :{WHITE}Rename plan
|
||||
|
||||
# Vehicle loading indicators
|
||||
STR_PERCENT_UP_SMALL :{TINY_FONT}{WHITE}{NUM}%{UP_ARROW}
|
||||
@@ -5346,6 +5348,7 @@ STR_ERROR_CAN_T_DELETE_SIGN :{WHITE}Can't de
|
||||
STR_ERROR_TOO_MANY_PLANS :{WHITE}... too many plans
|
||||
STR_ERROR_TOO_MANY_NODES :{WHITE}... too many nodes in plan line
|
||||
STR_ERROR_NO_MORE_SPACE_FOR_LINES :{WHITE}No more space for lines
|
||||
STR_ERROR_CAN_T_RENAME_PLAN :{WHITE}Can't rename plan...
|
||||
|
||||
# Translatable comment for OpenTTD's desktop shortcut
|
||||
STR_DESKTOP_SHORTCUT_COMMENT :A simulation game based on Transport Tycoon Deluxe
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "date_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "core/endian_func.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
typedef Pool<Plan, PlanID, 16, 64000> PlanPool;
|
||||
@@ -164,6 +165,7 @@ struct Plan : PlanPool::PoolItem<&_plan_pool> {
|
||||
bool visible_by_all;
|
||||
bool show_lines;
|
||||
Date creation_date;
|
||||
std::string name;
|
||||
|
||||
Plan(Owner owner = INVALID_OWNER)
|
||||
{
|
||||
@@ -247,12 +249,22 @@ struct Plan : PlanPool::PoolItem<&_plan_pool> {
|
||||
return this->visible;
|
||||
}
|
||||
|
||||
bool HasName() const
|
||||
{
|
||||
return !this->name.empty();
|
||||
}
|
||||
|
||||
bool ToggleVisibilityByAll()
|
||||
{
|
||||
if (_current_plan->owner == _local_company) DoCommandP(0, _current_plan->index, !this->visible_by_all, CMD_CHANGE_PLAN_VISIBILITY);
|
||||
return this->visible_by_all;
|
||||
}
|
||||
|
||||
const std::string &GetName() const
|
||||
{
|
||||
return this->name;
|
||||
}
|
||||
|
||||
TileIndex CalculateCentreTile() const
|
||||
{
|
||||
uint64 x = 0;
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "plans_func.h"
|
||||
#include "window_func.h"
|
||||
#include "company_func.h"
|
||||
#include "string_func.h"
|
||||
#include "window_gui.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
@@ -157,3 +158,31 @@ CommandCost CmdRemovePlanLine(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Give a custom name to your plan
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 ID of plan to name
|
||||
* @param p2 unused
|
||||
* @param text the new name
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenamePlan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (text == NULL) return CMD_ERROR;
|
||||
|
||||
Plan *p = Plan::GetIfValid(p1);
|
||||
if (p == NULL) return CMD_ERROR;
|
||||
CommandCost ret = CheckOwnership(p->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (Utf8StringLength(text) >= MAX_LENGTH_PLAN_NAME_CHARS) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
p->name = text;
|
||||
InvalidateWindowClassesData(WC_PLANS);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "window_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "gfx_func.h"
|
||||
#include "textbuf_gui.h"
|
||||
#include "tilehighlight_func.h"
|
||||
#include "strings_func.h"
|
||||
#include "core/pool_func.hpp"
|
||||
@@ -56,6 +57,7 @@ static const NWidgetPart _nested_plans_widgets[] = {
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_SHOW_ALL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_SHOW_ALL, STR_PLANS_SHOW_ALL_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_DELETE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_DELETE, STR_PLANS_DELETE_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_RENAME), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_NULL),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
@@ -126,6 +128,16 @@ struct PlansWindow : Window {
|
||||
this->SetWidgetDirty(WID_PLN_LIST);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_PLN_RENAME: {
|
||||
if (_current_plan) {
|
||||
SetDParamStr(0, _current_plan->GetName().c_str());
|
||||
ShowQueryString(STR_JUST_RAW_STRING, STR_PLANS_QUERY_RENAME_PLAN,
|
||||
MAX_LENGTH_PLAN_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_PLN_SHOW_ALL: {
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
@@ -187,6 +199,13 @@ struct PlansWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnQueryTextFinished(char *str)
|
||||
{
|
||||
if (_current_plan == nullptr || str == nullptr) return;
|
||||
|
||||
DoCommandP(0, _current_plan->index, 0, CMD_RENAME_PLAN | CMD_MSG(STR_ERROR_CAN_T_RENAME_PLAN), NULL, str);
|
||||
}
|
||||
|
||||
bool AllPlansHidden() const
|
||||
{
|
||||
Plan *p;
|
||||
@@ -202,10 +221,10 @@ struct PlansWindow : Window {
|
||||
this->SetWidgetDisabledState(WID_PLN_SHOW_ALL, this->vscroll->GetCount() == 0);
|
||||
this->hide_all_sel->SetDisplayedPlane(this->vscroll->GetCount() != 0 && this->AllPlansHidden() ? 1 : 0);
|
||||
if (_current_plan) {
|
||||
this->SetWidgetsDisabledState(_current_plan->owner != _local_company, WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_DELETE, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(_current_plan->owner != _local_company, WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_DELETE, WID_PLN_RENAME, WIDGET_LIST_END);
|
||||
this->GetWidget<NWidgetCore>(WID_PLN_VISIBILITY)->widget_data = _current_plan->visible_by_all ? STR_PLANS_VISIBILITY_PRIVATE : STR_PLANS_VISIBILITY_PUBLIC;
|
||||
} else {
|
||||
this->SetWidgetsDisabledState(true, WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_DELETE, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(true, WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_DELETE, WID_PLN_RENAME, WIDGET_LIST_END);
|
||||
}
|
||||
this->DrawWidgets();
|
||||
}
|
||||
@@ -235,10 +254,14 @@ struct PlansWindow : Window {
|
||||
if (list[i].is_plan) {
|
||||
DrawCompanyIcon(p->owner, icon_left, y + (this->resize.step_height - this->company_icon_spr_dim.height) / 2);
|
||||
DrawBoolButton(btn_left, y + (this->resize.step_height - SETTING_BUTTON_HEIGHT) / 2, p->visible, true);
|
||||
SetDParam(0, list[i].plan_id + 1);
|
||||
if (p->HasName()) {
|
||||
SetDParamStr(0, p->GetName().c_str());
|
||||
} else {
|
||||
SetDParam(0, list[i].plan_id + 1);
|
||||
}
|
||||
SetDParam(1, p->lines.size());
|
||||
SetDParam(2, p->creation_date);
|
||||
DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, STR_PLANS_LIST_ITEM_PLAN, p->visible_by_all ? TC_LIGHT_BLUE : TC_YELLOW);
|
||||
DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, p->HasName() ? STR_PLANS_LIST_ITEM_NAMED_PLAN : STR_PLANS_LIST_ITEM_PLAN, p->visible_by_all ? TC_LIGHT_BLUE : TC_YELLOW);
|
||||
} else {
|
||||
PlanLine *pl = p->lines[list[i].line_id];
|
||||
DrawBoolButton(btn_left, y + (this->resize.step_height - SETTING_BUTTON_HEIGHT) / 2, pl->visible, true);
|
||||
|
@@ -20,6 +20,8 @@ typedef uint16 PlanID;
|
||||
struct PlanLine;
|
||||
struct Plan;
|
||||
|
||||
static const uint MAX_LENGTH_PLAN_NAME_CHARS = 128; ///< The maximum length of a plan name in characters including '\0'
|
||||
|
||||
static const PlanID INVALID_PLAN = 0xFFFF; ///< Sentinel for an invalid plan.
|
||||
|
||||
#endif /* PLANS_TYPE_H */
|
||||
|
@@ -61,7 +61,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL },
|
||||
{ XSLFI_AUTO_TIMETABLE, XSCF_NULL, 4, 4, "auto_timetables", NULL, NULL, NULL },
|
||||
{ XSLFI_VEHICLE_REPAIR_COST, XSCF_NULL, 2, 2, "vehicle_repair_cost", NULL, NULL, NULL },
|
||||
{ XSLFI_ENH_VIEWPORT_PLANS, XSCF_IGNORABLE_ALL, 2, 2, "enh_viewport_plans", NULL, NULL, "PLAN" },
|
||||
{ XSLFI_ENH_VIEWPORT_PLANS, XSCF_IGNORABLE_ALL, 3, 3, "enh_viewport_plans", NULL, NULL, "PLAN" },
|
||||
{ XSLFI_INFRA_SHARING, XSCF_NULL, 2, 2, "infra_sharing", NULL, NULL, "CPDP" },
|
||||
{ XSLFI_VARIABLE_DAY_LENGTH, XSCF_NULL, 2, 2, "variable_day_length", NULL, NULL, NULL },
|
||||
{ XSLFI_ORDER_OCCUPANCY, XSCF_NULL, 2, 2, "order_occupancy", NULL, NULL, NULL },
|
||||
|
@@ -21,6 +21,7 @@ static const SaveLoad _plan_desc[] = {
|
||||
SLE_VAR(Plan, visible, SLE_BOOL),
|
||||
SLE_VAR(Plan, visible_by_all, SLE_BOOL),
|
||||
SLE_VAR(Plan, creation_date, SLE_INT32),
|
||||
SLE_CONDSTDSTR_X(Plan, name, 0, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ENH_VIEWPORT_PLANS, 3)),
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
|
@@ -24,6 +24,7 @@ enum PlansWidgets {
|
||||
WID_PLN_SHOW_ALL,
|
||||
WID_PLN_DELETE,
|
||||
WID_PLN_HIDE_ALL_SEL,
|
||||
WID_PLN_RENAME,
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_PLANS_WIDGET_H */
|
||||
|
Reference in New Issue
Block a user