Changeset - r11815:174e81d06883
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2009-05-03 10:34:47
alberth@openttd.org
(svn r16210) -Codechange: Make panels non-overlapping in company stations window.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/station_gui.cpp
Show inline comments
 
@@ -526,193 +526,193 @@ public:
 

	
 
						SetBit(this->cargo_filter, c);
 
						this->LowerWidget(widget);
 
					}
 
					this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty);
 
					this->stations.ForceRebuild();
 
					this->SetDirty();
 
				}
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		if (this->stations.SortType() != index) {
 
			this->stations.SetSortType(index);
 

	
 
			/* Display the current sort variant */
 
			this->widget[SLW_SORTDROPBTN].data = this->sorter_names[this->stations.SortType()];
 

	
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	virtual void OnTick()
 
	{
 
		if (_pause_game != 0) return;
 
		if (this->stations.NeedResort()) {
 
			DEBUG(misc, 3, "Periodic rebuild station list company %d", this->window_number);
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		this->RaiseWidget(SLW_SORTBY);
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnResize(Point delta)
 
	{
 
		this->vscroll.cap += delta.y / 10;
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		if (data == 0) {
 
			this->stations.ForceRebuild();
 
		} else {
 
			this->stations.ForceResort();
 
		}
 
	}
 
};
 

	
 
Listing CompanyStationsWindow::last_sorting = {false, 0};
 
byte CompanyStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
 
bool CompanyStationsWindow::include_empty = true;
 
const uint32 CompanyStationsWindow::cargo_filter_max = UINT32_MAX;
 
uint32 CompanyStationsWindow::cargo_filter = UINT32_MAX;
 
const Station *CompanyStationsWindow::last_station = NULL;
 

	
 
/* Availible station sorting functions */
 
GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = {
 
	&StationNameSorter,
 
	&StationTypeSorter,
 
	&StationWaitingSorter,
 
	&StationRatingMaxSorter,
 
	&StationRatingMinSorter
 
};
 

	
 
/* Names of the sorting functions */
 
const StringID CompanyStationsWindow::sorter_names[] = {
 
	STR_SORT_BY_DROPDOWN_NAME,
 
	STR_SORT_BY_FACILITY,
 
	STR_SORT_BY_WAITING,
 
	STR_SORT_BY_RATING_MAX,
 
	STR_SORT_BY_RATING_MIN,
 
	INVALID_STRING_ID
 
};
 

	
 

	
 
static const Widget _company_stations_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_BLACK_CROSS,   STR_TOOLTIP_CLOSE_WINDOW},         // SLW_CLOSEBOX
 
{    WWT_CAPTION,  RESIZE_RIGHT,  COLOUR_GREY,    11,   345,     0,    13, STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},  // SLW_CAPTION
 
{  WWT_STICKYBOX,     RESIZE_LR,  COLOUR_GREY,   346,   357,     0,    13, 0x0,               STR_STICKY_BUTTON},                // SLW_STICKY
 
{      WWT_PANEL,     RESIZE_RB,  COLOUR_GREY,     0,   345,    37,   161, 0x0,               STR_STATION_LIST_TOOLTIP},         // SLW_LIST
 
{  WWT_SCROLLBAR,    RESIZE_LRB,  COLOUR_GREY,   346,   357,    37,   149, 0x0,               STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST}, // SLW_SCROLLBAR
 
{  WWT_RESIZEBOX,   RESIZE_LRTB,  COLOUR_GREY,   346,   357,   150,   161, 0x0,               STR_RESIZE_BUTTON},                // SLW_RESIZE
 

	
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,    13,    14,    24, STR_TRAIN,         STR_USE_CTRL_TO_SELECT_MORE},      // SLW_TRAIN
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    14,    27,    14,    24, STR_LORRY,         STR_USE_CTRL_TO_SELECT_MORE},      // SLW_TRUCK
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    28,    41,    14,    24, STR_BUS,           STR_USE_CTRL_TO_SELECT_MORE},      // SLW_BUS
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    42,    55,    14,    24, STR_PLANE,         STR_USE_CTRL_TO_SELECT_MORE},      // SLW_AIRPLANE
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    56,    69,    14,    24, STR_SHIP,          STR_USE_CTRL_TO_SELECT_MORE},      // SLW_SHIP
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,    70,    83,    14,    24, 0x0,               STR_SELECT_ALL_FACILITIES},        // SLW_FACILALL
 

	
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,    83,    88,    14,    24, 0x0,               STR_NULL},                         // SLW_PAN_BETWEEN
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,    84,    88,    14,    24, 0x0,               STR_NULL},                         // SLW_PAN_BETWEEN
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,    89,   102,    14,    24, 0x0,               STR_NO_WAITING_CARGO},             // SLW_NOCARGOWAITING
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,   103,   116,    14,    24, 0x0,               STR_SELECT_ALL_TYPES},             // SLW_CARGOALL
 
{      WWT_PANEL,  RESIZE_RIGHT,  COLOUR_GREY,   117,   357,    14,    24, 0x0,               STR_NULL},                         // SLW_PAN_RIGHT
 

	
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,    80,    25,    36, STR_SORT_BY,       STR_SORT_ORDER_TIP},               // SLW_SORTBY
 
{   WWT_DROPDOWN,   RESIZE_NONE,  COLOUR_GREY,    81,   243,    25,    36, 0x0,               STR_SORT_CRITERIA_TIP},            // SLW_SORTDROPBTN
 
{      WWT_PANEL,  RESIZE_RIGHT,  COLOUR_GREY,   244,   357,    25,    36, 0x0,               STR_NULL},                         // SLW_PAN_SORT_RIGHT
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _company_stations_desc(
 
	WDP_AUTO, WDP_AUTO, 358, 162, 358, 162,
 
	WC_STATION_LIST, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 
	_company_stations_widgets
 
);
 

	
 
/**
 
 * Opens window with list of company's stations
 
 *
 
 * @param company whose stations' list show
 
 */
 
void ShowCompanyStations(CompanyID company)
 
{
 
	if (!IsValidCompanyID(company)) return;
 

	
 
	AllocateWindowDescFront<CompanyStationsWindow>(&_company_stations_desc, company);
 
}
 

	
 
static const Widget _station_view_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_BLACK_CROSS,                 STR_TOOLTIP_CLOSE_WINDOW},             // SVW_CLOSEBOX
 
{    WWT_CAPTION,  RESIZE_RIGHT,  COLOUR_GREY,    11,   236,     0,    13, STR_STATION_VIEW_CAPTION,        STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
 
{  WWT_STICKYBOX,     RESIZE_LR,  COLOUR_GREY,   237,   248,     0,    13, 0x0,                             STR_STICKY_BUTTON},
 
{      WWT_PANEL,     RESIZE_RB,  COLOUR_GREY,     0,   236,    14,    65, 0x0,                             STR_NULL},                             // SVW_WAITING
 
{  WWT_SCROLLBAR,    RESIZE_LRB,  COLOUR_GREY,   237,   248,    14,    65, 0x0,                             STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST},
 
{      WWT_PANEL,    RESIZE_RTB,  COLOUR_GREY,     0,   248,    66,    97, 0x0,                             STR_NULL},                             // SVW_ACCEPTLIST / SVW_RATINGLIST
 
{ WWT_PUSHTXTBTN,     RESIZE_TB,  COLOUR_GREY,     0,    59,    98,   109, STR_BUTTON_LOCATION,             STR_STATION_VIEW_CENTER_TOOLTIP},      // SVW_LOCATION
 
{ WWT_PUSHTXTBTN,     RESIZE_TB,  COLOUR_GREY,    60,   120,    98,   109, STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP},     // SVW_RATINGS / SVW_ACCEPTS
 
{ WWT_PUSHTXTBTN,    RESIZE_RTB,  COLOUR_GREY,   121,   180,    98,   109, STR_QUERY_RENAME,                STR_STATION_VIEW_RENAME_TOOLTIP},      // SVW_RENAME
 
{ WWT_PUSHTXTBTN,   RESIZE_LRTB,  COLOUR_GREY,   181,   194,    98,   109, STR_TRAIN,                       STR_SCHEDULED_TRAINS_TIP },            // SVW_TRAINS
 
{ WWT_PUSHTXTBTN,   RESIZE_LRTB,  COLOUR_GREY,   195,   208,    98,   109, STR_LORRY,                       STR_SCHEDULED_ROAD_VEHICLES_TIP },     // SVW_ROADVEHS
 
{ WWT_PUSHTXTBTN,   RESIZE_LRTB,  COLOUR_GREY,   209,   222,    98,   109, STR_PLANE,                       STR_SCHEDULED_AIRCRAFT_TIP },          // SVW_PLANES
 
{ WWT_PUSHTXTBTN,   RESIZE_LRTB,  COLOUR_GREY,   223,   236,    98,   109, STR_SHIP,                        STR_SCHEDULED_SHIPS_TIP },             // SVW_SHIPS
 
{  WWT_RESIZEBOX,   RESIZE_LRTB,  COLOUR_GREY,   237,   248,    98,   109, 0x0,                             STR_RESIZE_BUTTON},
 
{   WIDGETS_END},
 
};
 

	
 
SpriteID GetCargoSprite(CargoID i)
 
{
 
	const CargoSpec *cs = GetCargo(i);
 
	SpriteID sprite;
 

	
 
	if (cs->sprite == 0xFFFF) {
 
		/* A value of 0xFFFF indicates we should draw a custom icon */
 
		sprite = GetCustomCargoSprite(cs);
 
	} else {
 
		sprite = cs->sprite;
 
	}
 

	
 
	if (sprite == 0) sprite = SPR_CARGO_GOODS;
 

	
 
	return sprite;
 
}
 

	
 
/**
 
 * Draws icons of waiting cargo in the StationView window
 
 *
 
 * @param i type of cargo
 
 * @param waiting number of waiting units
 
 * @param x x on-screen coordinate where to start with drawing icons
 
 * @param y y coordinate
 
 */
 
static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width)
 
{
 
	uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow
 
	if (num == 0) return;
 

	
 
	SpriteID sprite = GetCargoSprite(i);
 

	
 
	do {
 
		DrawSprite(sprite, PAL_NONE, x, y);
 
		x += 10;
 
	} while (--num);
 
}
 

	
 
struct CargoData {
 
	CargoID cargo;
 
	StationID source;
 
	uint count;
 

	
 
	CargoData(CargoID cargo, StationID source, uint count) :
 
		cargo(cargo),
 
		source(source),
 
		count(count)
 
	{ }
 
};
0 comments (0 inline, 0 general)