@ -70,9 +70,9 @@ static const uint32 _cargo_type_unload_order_drowdown_hidden_mask = 0x8; // 0100
DropDownList GetSlotDropDownList ( Owner owner , TraceRestrictSlotID slot_id , int & selected , VehicleType vehtype , bool show_other_types ) ;
DropDownList GetCounterDropDownList ( Owner owner , TraceRestrictCounterID ctr_id , int & selected ) ;
static bool ModifyOrder ( const Vehicle * v , VehicleOrderID order_id , uint32 p2 , bool error_msg = true )
static bool ModifyOrder ( const Vehicle * v , VehicleOrderID order_id , uint32 p2 , bool error_msg = true , const char * text = nullptr )
{
return DoCommandPEx ( v - > tile , v - > index , p2 , order_id , CMD_MODIFY_ORDER | ( error_msg ? CMD_MSG ( STR_ERROR_CAN_T_MODIFY_THIS_ORDER ) : 0 ) , nullptr , nullptr , 0 ) ;
return DoCommandPEx ( v - > tile , v - > index , p2 , order_id , CMD_MODIFY_ORDER | ( error_msg ? CMD_MSG ( STR_ERROR_CAN_T_MODIFY_THIS_ORDER ) : 0 ) , nullptr , text , nullptr ) ;
}
struct CargoTypeOrdersWindow : public Window {
@ -626,6 +626,8 @@ static const StringID _order_goto_dropdown[] = {
STR_ORDER_SHARE ,
STR_ORDER_RELEASE_SLOT_BUTTON ,
STR_ORDER_CHANGE_COUNTER_BUTTON ,
STR_ORDER_TEXT_LABEL_BUTTON ,
STR_ORDER_DEPARTURES_VIA_LABEL_BUTTON ,
INVALID_STRING_ID
} ;
@ -636,6 +638,8 @@ static const StringID _order_goto_dropdown_aircraft[] = {
STR_ORDER_SHARE ,
STR_ORDER_RELEASE_SLOT_BUTTON ,
STR_ORDER_CHANGE_COUNTER_BUTTON ,
STR_ORDER_TEXT_LABEL_BUTTON ,
STR_ORDER_DEPARTURES_VIA_LABEL_BUTTON ,
INVALID_STRING_ID
} ;
@ -1160,6 +1164,31 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
SetDParam ( 3 , order - > GetXData ( ) ) ;
break ;
case OT_LABEL :
switch ( order - > GetLabelSubType ( ) ) {
case OLST_TEXT : {
SetDParam ( 0 , STR_TRACE_RESTRICT_LABEL_TEXT ) ;
const char * text = order - > GetLabelText ( ) ;
SetDParamStr ( 1 , StrEmpty ( text ) ? " " : text ) ;
break ;
}
case OLST_DEPARTURES_VIA :
SetDParam ( 0 , STR_TRACE_RESTRICT_LABEL_DEPARTURES_VIA ) ;
if ( Waypoint : : IsValidID ( order - > GetDestination ( ) ) ) {
SetDParam ( 1 , STR_WAYPOINT_NAME ) ;
} else {
SetDParam ( 1 , STR_STATION_NAME ) ;
}
SetDParam ( 2 , order - > GetDestination ( ) ) ;
break ;
default :
SetDParam ( 0 , STR_TRACE_RESTRICT_VARIABLE_UNDEFINED_RED ) ;
break ;
}
break ;
default : NOT_REACHED ( ) ;
}
@ -1339,6 +1368,7 @@ private:
OPOS_SHARE ,
OPOS_COND_VIA ,
OPOS_CONDITIONAL_RETARGET ,
OPOS_DEPARTURE_VIA ,
OPOS_END ,
} ;
@ -1349,6 +1379,8 @@ private:
DP_GROUNDVEHICLE_ROW_CONDITIONAL = 1 , ///< Display the row for conditional orders in the top row of the train/rv order window.
DP_GROUNDVEHICLE_ROW_SLOT = 2 , ///< Display the row for release slot orders in the top row of the train/rv order window.
DP_GROUNDVEHICLE_ROW_COUNTER = 3 , ///< Display the row for change counter orders in the top row of the train/rv order window.
DP_GROUNDVEHICLE_ROW_TEXT_LABEL = 4 , ///< Display the row for text label orders in the top row of the train/rv order window.
DP_GROUNDVEHICLE_ROW_EMPTY = 5 , ///< Display the row for no buttons in the top row of the train/rv order window.
/* WID_O_SEL_TOP_LEFT */
DP_LEFT_LOAD = 0 , ///< Display 'load' in the left button of the top row of the train/rv order window.
@ -1369,6 +1401,8 @@ private:
DP_ROW_CONDITIONAL = 2 , ///< Display the conditional order buttons in the top row of the ship/airplane order window.
DP_ROW_SLOT = 3 , ///< Display the release slot buttons in the top row of the ship/airplane order window.
DP_ROW_COUNTER = 4 , ///< Display the change counter buttons in the top row of the ship/airplane order window.
DP_ROW_TEXT_LABEL = 5 , ///< Display the text label buttons in the top row of the ship/airplane order window.
DP_ROW_EMPTY = 6 , ///< Display no buttons in the top row of the ship/airplane order window.
/* WID_O_SEL_COND_VALUE */
DP_COND_VALUE_NUMBER = 0 , ///< Display number widget
@ -1482,9 +1516,9 @@ private:
return DoCommandPEx ( this - > vehicle - > tile , this - > vehicle - > index , this - > OrderGetSel ( ) , order_pack , CMD_INSERT_ORDER | CMD_MSG ( STR_ERROR_CAN_T_INSERT_NEW_ORDER ) , nullptr , nullptr , 0 ) ;
}
bool ModifyOrder ( VehicleOrderID sel_ord , uint32 p2 , bool error_msg = true )
bool ModifyOrder ( VehicleOrderID sel_ord , uint32 p2 , bool error_msg = true , const char * text = nullptr )
{
return : : ModifyOrder ( this - > vehicle , sel_ord , p2 , error_msg );
return : : ModifyOrder ( this - > vehicle , sel_ord , p2 , error_msg , text );
}
/**
@ -1500,6 +1534,7 @@ private:
HT_VEHICLE , // OPOS_SHARE
HT_RECT , // OPOS_COND_VIA
HT_NONE , // OPOS_CONDITIONAL_RETARGET
HT_RECT , // OPOS_DEPARTURE_VIA
} ;
SetObjectToPlaceWnd ( ANIMCURSOR_PICKSTATION , PAL_NONE , goto_place_style [ type - 1 ] , this ) ;
this - > goto_type = type ;
@ -1586,6 +1621,19 @@ private:
this - > InsertNewOrder ( order . Pack ( ) ) ;
}
/**
* Handle the click on the text label button .
*/
void OrderClick_TextLabel ( )
{
Order order ;
order . next = nullptr ;
order . index = 0 ;
order . MakeLabel ( OLST_TEXT ) ;
this - > InsertNewOrder ( order . Pack ( ) ) ;
}
/**
* Handle the click on the unload button .
* @ param unload_type Unload flag to apply . If matches existing unload type , toggles to default of ' unload if possible ' .
@ -2195,6 +2243,15 @@ public:
break ;
}
case OT_LABEL : {
if ( row_sel ! = nullptr ) {
row_sel - > SetDisplayedPlane ( order - > GetLabelSubType ( ) = = OLST_TEXT ? DP_ROW_TEXT_LABEL : DP_ROW_EMPTY ) ;
} else {
train_row_sel - > SetDisplayedPlane ( order - > GetLabelSubType ( ) = = OLST_TEXT ? DP_GROUNDVEHICLE_ROW_TEXT_LABEL : DP_GROUNDVEHICLE_ROW_EMPTY ) ;
}
break ;
}
default : // every other order
if ( row_sel ! = nullptr ) {
row_sel - > SetDisplayedPlane ( DP_ROW_LOAD ) ;
@ -2938,6 +2995,14 @@ public:
break ;
}
case WID_O_TEXT_LABEL : {
const Order * order = this - > vehicle - > GetOrder ( this - > OrderGetSel ( ) ) ;
this - > query_text_widget = widget ;
SetDParamStr ( 0 , order - > GetLabelText ( ) ) ;
ShowQueryString ( STR_JUST_RAW_STRING , STR_ORDER_TEXT_LABEL_CAPTION , NUM_CARGO - 1 , this , CS_ALPHANUMERAL , QSF_NONE ) ;
break ;
}
case WID_O_TOGGLE_SIZE : {
_settings_client . gui . show_order_management_button = ! _settings_client . gui . show_order_management_button ;
InvalidateWindowClassesData ( WC_VEHICLE_ORDERS ) ;
@ -2994,6 +3059,10 @@ public:
if ( this - > query_text_widget = = WID_O_ADD_VEH_GROUP ) {
DoCommandP ( 0 , VehicleListIdentifier ( VL_SINGLE_VEH , this - > vehicle - > type , this - > vehicle - > owner , this - > vehicle - > index ) . Pack ( ) , CF_ANY , CMD_CREATE_GROUP_FROM_LIST | CMD_MSG ( STR_ERROR_GROUP_CAN_T_CREATE ) , nullptr , str ) ;
}
if ( this - > query_text_widget = = WID_O_TEXT_LABEL & & str ! = nullptr ) {
this - > ModifyOrder ( this - > OrderGetSel ( ) , MOF_LABEL_TEXT , true , str ) ;
}
}
void OnDropdownSelect ( int widget , int index ) override
@ -3019,6 +3088,8 @@ public:
case 3 : this - > OrderClick_Goto ( OPOS_SHARE ) ; break ;
case 4 : this - > OrderClick_ReleaseSlot ( ) ; break ;
case 5 : this - > OrderClick_ChangeCounter ( ) ; break ;
case 6 : this - > OrderClick_TextLabel ( ) ; break ;
case 7 : this - > OrderClick_Goto ( OPOS_DEPARTURE_VIA ) ; break ;
default : NOT_REACHED ( ) ;
}
break ;
@ -3209,6 +3280,28 @@ public:
}
}
}
} else if ( this - > goto_type = = OPOS_DEPARTURE_VIA ) {
if ( IsTileType ( tile , MP_STATION ) | | IsTileType ( tile , MP_INDUSTRY ) ) {
const BaseStation * st = nullptr ;
if ( IsTileType ( tile , MP_STATION ) ) {
st = BaseStation : : GetByTile ( tile ) ;
} else {
const Industry * in = Industry : : GetByTile ( tile ) ;
st = in - > neutral_station ;
}
if ( st ! = nullptr & & IsInfraUsageAllowed ( this - > vehicle - > type , this - > vehicle - > owner , st - > owner ) ) {
Order order ;
order . next = nullptr ;
order . index = 0 ;
order . MakeLabel ( OLST_DEPARTURES_VIA ) ;
order . SetDestination ( st - > index ) ;
if ( this - > InsertNewOrder ( order . Pack ( ) ) ) {
ResetObjectToPlace ( ) ;
}
}
}
}
}
@ -3446,6 +3539,13 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , WID_O_COUNTER_VALUE ) , SetMinimalSize ( 124 , 12 ) , SetFill ( 1 , 0 ) ,
SetDataTip ( STR_BLACK_COMMA , STR_TRACE_RESTRICT_COND_VALUE_TOOLTIP ) , SetResize ( 1 , 0 ) ,
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL , NC_EQUALSIZE ) ,
NWidget ( WWT_PANEL , COLOUR_GREY ) , EndContainer ( ) ,
NWidget ( WWT_PANEL , COLOUR_GREY ) , EndContainer ( ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , WID_O_TEXT_LABEL ) , SetMinimalSize ( 124 , 12 ) , SetFill ( 1 , 0 ) ,
SetDataTip ( STR_ORDER_TEXT_LABEL_BUTTON , STR_ORDER_TEXT_LABEL_BUTTON_TOOLTIP ) , SetResize ( 1 , 0 ) ,
EndContainer ( ) ,
NWidget ( WWT_PANEL , COLOUR_GREY ) , SetFill ( 1 , 0 ) , SetResize ( 1 , 0 ) , EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , WID_O_OCCUPANCY_TOGGLE ) , SetMinimalSize ( 36 , 12 ) , SetDataTip ( STR_ORDERS_OCCUPANCY_BUTTON , STR_ORDERS_OCCUPANCY_BUTTON_TOOLTIP ) ,
NWidget ( NWID_SELECTION , INVALID_COLOUR , WID_O_SEL_SHARED ) ,
@ -3581,6 +3681,17 @@ static const NWidgetPart _nested_orders_widgets[] = {
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , WID_O_COUNTER_VALUE ) , SetMinimalSize ( 124 , 12 ) , SetFill ( 1 , 0 ) ,
SetDataTip ( STR_BLACK_COMMA , STR_TRACE_RESTRICT_COND_VALUE_TOOLTIP ) , SetResize ( 1 , 0 ) ,
EndContainer ( ) ,
/* Buttons for changing a text label */
NWidget ( NWID_HORIZONTAL , NC_EQUALSIZE ) ,
NWidget ( WWT_PANEL , COLOUR_GREY ) , EndContainer ( ) ,
NWidget ( WWT_PANEL , COLOUR_GREY ) , EndContainer ( ) ,
NWidget ( WWT_PUSHTXTBTN , COLOUR_GREY , WID_O_TEXT_LABEL ) , SetMinimalSize ( 124 , 12 ) , SetFill ( 1 , 0 ) ,
SetDataTip ( STR_ORDER_TEXT_LABEL_BUTTON , STR_ORDER_TEXT_LABEL_BUTTON_TOOLTIP ) , SetResize ( 1 , 0 ) ,
EndContainer ( ) ,
/* No buttons */
NWidget ( WWT_PANEL , COLOUR_GREY ) , SetFill ( 1 , 0 ) , SetResize ( 1 , 0 ) , EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , WID_O_OCCUPANCY_TOGGLE ) , SetMinimalSize ( 36 , 12 ) , SetDataTip ( STR_ORDERS_OCCUPANCY_BUTTON , STR_ORDERS_OCCUPANCY_BUTTON_TOOLTIP ) ,