@ -770,6 +770,7 @@ public:
this - > CreateNestedTree ( ) ;
this - > vscroll = this - > GetScrollbar ( WID_O_SCROLLBAR ) ;
this - > GetWidget < NWidgetStacked > ( WID_O_SEL_OCCUPANCY ) - > SetDisplayedPlane ( SZSP_NONE ) ;
this - > FinishInitNested ( v - > index ) ;
if ( v - > owner = = _local_company ) {
this - > DisableWidget ( WID_O_EMPTY ) ;
@ -798,6 +799,12 @@ public:
virtual void UpdateWidgetSize ( int widget , Dimension * size , const Dimension & padding , Dimension * fill , Dimension * resize )
{
switch ( widget ) {
case WID_O_OCCUPANCY_LIST :
SetDParamMaxValue ( 0 , 100 ) ;
size - > width = WD_FRAMERECT_LEFT + GetStringBoundingBox ( STR_ORDERS_OCCUPANCY_PERCENT ) . width + 10 + WD_FRAMERECT_RIGHT ;
/* FALL THROUGH */
case WID_O_SEL_OCCUPANCY :
case WID_O_ORDER_LIST :
resize - > height = FONT_HEIGHT_NORMAL ;
size - > height = 6 * resize - > height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM ;
@ -1064,6 +1071,8 @@ public:
/* Disable list of vehicles with the same shared orders if there is no list */
this - > SetWidgetDisabledState ( WID_O_SHARED_ORDER_LIST , ! shared_orders ) ;
this - > GetWidget < NWidgetStacked > ( WID_O_SEL_OCCUPANCY ) - > SetDisplayedPlane ( IsWidgetLowered ( WID_O_OCCUPANCY_TOGGLE ) ? 0 : SZSP_NONE ) ;
this - > SetDirty ( ) ;
}
@ -1079,8 +1088,19 @@ public:
virtual void DrawWidget ( const Rect & r , int widget ) const
{
if ( widget ! = WID_O_ORDER_LIST ) return ;
switch ( widget ) {
case WID_O_ORDER_LIST :
DrawOrderListWidget ( r ) ;
break ;
case WID_O_OCCUPANCY_LIST :
DrawOccupancyListWidget ( r ) ;
break ;
}
}
void DrawOrderListWidget ( const Rect & r ) const
{
bool rtl = _current_text_dir = = TD_RTL ;
SetDParamMaxValue ( 0 , this - > vehicle - > GetNumOrders ( ) , 2 ) ;
int index_column_width = GetStringBoundingBox ( STR_ORDER_INDEX ) . width + 2 * GetSpriteSize ( rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT ) . width + 3 ;
@ -1135,6 +1155,30 @@ public:
}
}
void DrawOccupancyListWidget ( const Rect & r ) const
{
int y = r . top + WD_FRAMERECT_TOP ;
int line_height = this - > GetWidget < NWidgetBase > ( WID_O_ORDER_LIST ) - > resize_y ;
int i = this - > vscroll - > GetPosition ( ) ;
const Order * order = this - > vehicle - > GetOrder ( i ) ;
/* Draw the orders. */
while ( order ! = NULL ) {
/* Don't draw anything if it extends past the end of the window. */
if ( ! this - > vscroll - > IsVisible ( i ) ) break ;
uint8 occupancy = order - > GetOccupancy ( ) ;
if ( occupancy > 0 ) {
SetDParam ( 0 , occupancy - 1 ) ;
DrawString ( r . left + WD_FRAMETEXT_LEFT , r . right - WD_FRAMETEXT_RIGHT , y , STR_ORDERS_OCCUPANCY_PERCENT , ( i = = this - > selected_order ) ? TC_WHITE : TC_BLACK ) ;
}
y + = line_height ;
i + + ;
order = order - > next ;
}
}
virtual void SetStringParameters ( int widget ) const
{
switch ( widget ) {
@ -1318,6 +1362,12 @@ public:
case WID_O_SHARED_ORDER_LIST :
ShowVehicleListWindow ( this - > vehicle ) ;
break ;
case WID_O_OCCUPANCY_TOGGLE :
ToggleWidgetLoweredState ( WID_O_OCCUPANCY_TOGGLE ) ;
this - > UpdateButtonState ( ) ;
this - > ReInit ( ) ;
break ;
}
}
@ -1541,6 +1591,10 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , WID_O_ORDER_LIST ) , SetMinimalSize ( 372 , 62 ) , SetDataTip ( 0x0 , STR_ORDERS_LIST_TOOLTIP ) , SetResize ( 1 , 1 ) , SetScrollbar ( WID_O_SCROLLBAR ) , EndContainer ( ) ,
NWidget ( NWID_SELECTION , INVALID_COLOUR , WID_O_SEL_OCCUPANCY ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , WID_O_OCCUPANCY_LIST ) , SetMinimalSize ( 50 , 0 ) , SetFill ( 0 , 1 ) , SetDataTip ( STR_NULL , STR_ORDERS_OCCUPANCY_LIST_TOOLTIP ) ,
SetScrollbar ( WID_O_SCROLLBAR ) , EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_VSCROLLBAR , COLOUR_GREY , WID_O_SCROLLBAR ) ,
EndContainer ( ) ,
@ -1578,6 +1632,7 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
SetDataTip ( STR_BLACK_COMMA , STR_ORDER_CONDITIONAL_VALUE_TOOLTIP ) , SetResize ( 1 , 0 ) ,
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , WID_O_OCCUPANCY_TOGGLE ) , SetMinimalSize ( 12 , 12 ) , SetDataTip ( STR_ORDERS_OCCUPANCY_BUTTON , STR_ORDERS_OCCUPANCY_BUTTON_TOOLTIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , WID_O_SHARED_ORDER_LIST ) , SetMinimalSize ( 12 , 12 ) , SetDataTip ( SPR_SHARED_ORDERS_ICON , STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP ) ,
EndContainer ( ) ,
@ -1619,6 +1674,10 @@ static const NWidgetPart _nested_orders_widgets[] = {
EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , WID_O_ORDER_LIST ) , SetMinimalSize ( 372 , 62 ) , SetDataTip ( 0x0 , STR_ORDERS_LIST_TOOLTIP ) , SetResize ( 1 , 1 ) , SetScrollbar ( WID_O_SCROLLBAR ) , EndContainer ( ) ,
NWidget ( NWID_SELECTION , INVALID_COLOUR , WID_O_SEL_OCCUPANCY ) ,
NWidget ( WWT_PANEL , COLOUR_GREY , WID_O_OCCUPANCY_LIST ) , SetMinimalSize ( 50 , 0 ) , SetFill ( 0 , 1 ) , SetDataTip ( STR_NULL , STR_ORDERS_OCCUPANCY_LIST_TOOLTIP ) ,
SetScrollbar ( WID_O_SCROLLBAR ) , EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( NWID_VSCROLLBAR , COLOUR_GREY , WID_O_SCROLLBAR ) ,
EndContainer ( ) ,
@ -1653,6 +1712,7 @@ static const NWidgetPart _nested_orders_widgets[] = {
EndContainer ( ) ,
EndContainer ( ) ,
NWidget ( WWT_TEXTBTN , COLOUR_GREY , WID_O_OCCUPANCY_TOGGLE ) , SetMinimalSize ( 12 , 12 ) , SetDataTip ( STR_ORDERS_OCCUPANCY_BUTTON , STR_ORDERS_OCCUPANCY_BUTTON_TOOLTIP ) ,
NWidget ( WWT_PUSHIMGBTN , COLOUR_GREY , WID_O_SHARED_ORDER_LIST ) , SetMinimalSize ( 12 , 12 ) , SetDataTip ( SPR_SHARED_ORDERS_ICON , STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP ) ,
EndContainer ( ) ,