Changeset - r11084:003adceca07c
[Not reviewed]
master
0 13 0
rubidium - 16 years ago 2009-02-09 02:33:10
rubidium@openttd.org
(svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
13 files changed with 28 insertions and 29 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -233,13 +233,13 @@ public:
 
		ResizeWindow(this, 0, this->resize.step_height * this->vscroll.cap);
 

	
 
		/* Set the minimum window size to the current window size */
 
		this->resize.width  = this->width;
 
		this->resize.height = this->height;
 

	
 
		this->caption_color = _local_company;
 
		this->owner = _local_company;
 
		this->sel_group = id_g;
 
		this->vscroll2.cap = this->vscroll.cap;   // these two are always the same
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -800,13 +800,13 @@ struct BuildVehicleWindow : Window {
 
		this->vscroll.cap = 1;
 
		this->widget[BUILD_VEHICLE_WIDGET_LIST].data = 0x101;
 

	
 
		this->resize.width  = this->width;
 
		this->resize.height = this->height;
 

	
 
		this->caption_color = (tile != INVALID_TILE) ? GetTileOwner(tile) : _local_company;
 
		this->owner = (tile != INVALID_TILE) ? GetTileOwner(tile) : _local_company;
 

	
 
		this->sel_engine      = INVALID_ENGINE;
 
		this->regenerate_list = false;
 

	
 
		this->sort_criteria         = _last_sort_criteria[type];
 
		this->descending_sort_order = _last_sort_order[type];
src/company_gui.cpp
Show inline comments
 
@@ -225,13 +225,13 @@ struct CompanyFinancesWindow : Window {
 

	
 
	CompanyFinancesWindow(const WindowDesc *desc, CompanyID company, bool show_small,
 
					bool show_stickied, int top, int left) :
 
			Window(desc, company),
 
			small(show_small)
 
	{
 
		this->caption_color = this->window_number;
 
		this->owner = (Owner)this->window_number;
 

	
 
		if (show_stickied) this->flags4 |= WF_STICKY;
 

	
 
		/* Check if repositioning from default is required */
 
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
 
			this->top = top;
 
@@ -455,13 +455,13 @@ private:
 
		ShowDropDownList(this, list, widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget);
 
	}
 

	
 
public:
 
	SelectCompanyLiveryWindow(const WindowDesc *desc, CompanyID company) : Window(desc, company)
 
	{
 
		this->caption_color = company;
 
		this->owner = company;
 
		this->livery_class = LC_OTHER;
 
		this->sel = 1;
 
		this->LowerWidget(SCLW_WIDGET_CLASS_GENERAL);
 
		this->OnInvalidateData(_loaded_newgrf_features.has_2CC);
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 
@@ -845,13 +845,13 @@ class SelectCompanyManagerFaceWindow : p
 
	}
 

	
 
public:
 
	SelectCompanyManagerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number)
 
	{
 
		this->parent = parent;
 
		this->caption_color = this->window_number;
 
		this->owner = (Owner)this->window_number;
 
		this->face = GetCompany((CompanyID)this->window_number)->face;
 
		this->advanced = advanced;
 

	
 
		this->UpdateData();
 

	
 
		/* Check if repositioning from default is required */
 
@@ -1251,13 +1251,13 @@ static void DrawCompanyOwnerText(const C
 
struct CompanyWindow : Window
 
{
 
	CompanyWindowWidgets query_widget;
 

	
 
	CompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->caption_color = this->window_number;
 
		this->owner = (Owner)this->window_number;
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		const Company *c = GetCompany((CompanyID)this->window_number);
src/depot_gui.cpp
Show inline comments
 
@@ -240,13 +240,13 @@ struct DepotWindow : Window {
 

	
 
	DepotWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, tile)
 
	{
 
		this->sel = INVALID_VEHICLE;
 
		this->generate_list = true;
 

	
 
		this->caption_color = GetTileOwner(tile);
 
		this->owner = GetTileOwner(tile);
 
		this->CreateDepotListWindow(type);
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~DepotWindow()
src/group_gui.cpp
Show inline comments
 
@@ -170,13 +170,13 @@ private:
 
public:
 
	VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number)
 
	{
 
		const Owner owner = (Owner)GB(this->window_number, 0, 8);
 
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
 

	
 
		this->caption_color = owner;
 
		this->owner = owner;
 
		this->resize.step_width = 1;
 

	
 
		switch (this->vehicle_type) {
 
			default: NOT_REACHED();
 
			case VEH_TRAIN:
 
			case VEH_ROAD:
src/order_gui.cpp
Show inline comments
 
@@ -620,13 +620,13 @@ private:
 
		Handler *proc;
 
	};
 

	
 
public:
 
	OrdersWindow(const WindowDesc *desc, const Vehicle *v) : Window(desc, v->index)
 
	{
 
		this->caption_color = v->owner;
 
		this->owner = v->owner;
 
		this->vscroll.cap = 6;
 
		this->resize.step_height = 10;
 
		this->selected_order = -1;
 
		this->vehicle = v;
 

	
 
		if (_settings_client.gui.quick_goto && v->owner == _local_company) {
src/station_gui.cpp
Show inline comments
 
@@ -230,13 +230,13 @@ protected:
 
		this->InvalidateWidget(SLW_LIST);
 
	}
 

	
 
public:
 
	CompanyStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->caption_color = (byte)this->window_number;
 
		this->owner = (Owner)this->window_number;
 
		this->vscroll.cap = 12;
 
		this->resize.step_height = 10;
 
		this->resize.height = this->height - 10 * 7; // minimum if 5 in the list
 

	
 
		/* Add cargo filter buttons */
 
		uint num_active = 0;
 
@@ -708,13 +708,13 @@ struct StationViewWindow : public Window
 
	uint32 cargo;                 ///< Bitmask of cargo types to expand
 
	uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type
 

	
 
	StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		Owner owner = GetStation(window_number)->owner;
 
		if (owner != OWNER_NONE) this->caption_color = owner;
 
		if (owner != OWNER_NONE) this->owner = owner;
 
		this->vscroll.cap = 5;
 
		this->resize.step_height = 10;
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
src/timetable_gui.cpp
Show inline comments
 
@@ -48,13 +48,13 @@ struct TimetableWindow : Window {
 
	int sel_index;
 
	const Vehicle *vehicle;
 

	
 
	TimetableWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->vehicle = GetVehicle(window_number);
 
		this->caption_color = this->vehicle->owner;
 
		this->owner = this->vehicle->owner;
 
		this->vscroll.cap = 8;
 
		this->resize.step_height = 10;
 
		this->sel_index = -1;
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
src/vehicle_gui.cpp
Show inline comments
 
@@ -268,13 +268,13 @@ struct RefitWindow : public Window {
 
	RefitList *list;
 
	uint length;
 
	VehicleOrderID order;
 

	
 
	RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order) : Window(desc, v->index)
 
	{
 
		this->caption_color = v->owner;
 
		this->owner = v->owner;
 
		this->vscroll.cap = 8;
 
		this->resize.step_height = 14;
 

	
 
		this->order = order;
 
		this->sel  = -1;
 
		this->list = BuildRefitList(v);
 
@@ -798,13 +798,13 @@ struct VehicleListWindow : public BaseVe
 
	VehicleListWindow(const WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number)
 
	{
 
		uint16 window_type = this->window_number & VLW_MASK;
 
		CompanyID company = (CompanyID)GB(this->window_number, 0, 8);
 

	
 
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
 
		this->caption_color = company;
 
		this->owner = company;
 

	
 
		/* Hide the widgets that we will not use in this window
 
		* Some windows contains actions only fit for the owner */
 
		if (company == _local_company) {
 
			this->HideWidget(VLW_WIDGET_OTHER_COMPANY_FILLER);
 
			this->SetWidgetDisabledState(VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
 
@@ -927,13 +927,13 @@ struct VehicleListWindow : public BaseVe
 
		*this->sorting = this->vehicles.GetListing();
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		int x = 2;
 
		const Owner owner = (Owner)this->caption_color;
 
		const Owner owner = this->owner;
 
		const uint16 window_type = this->window_number & VLW_MASK;
 
		const uint16 index = GB(this->window_number, 16, 16);
 

	
 
		this->BuildVehicleList(owner, index, window_type);
 
		this->SortVehicleList();
 
		SetVScrollCount(this, this->vehicles.Length());
 
@@ -1091,15 +1091,14 @@ struct VehicleListWindow : public BaseVe
 

	
 
	virtual void OnTick()
 
	{
 
		if (_pause_game != 0) return;
 
		if (this->vehicles.NeedResort()) {
 
			StationID station = ((this->window_number & VLW_MASK) == VLW_STATION_LIST) ? GB(this->window_number, 16, 16) : INVALID_STATION;
 
			Owner owner = (Owner)this->caption_color;
 

	
 
			DEBUG(misc, 3, "Periodic resort %d list company %d at station %d", this->vehicle_type, owner, station);
 
			DEBUG(misc, 3, "Periodic resort %d list company %d at station %d", this->vehicle_type, this->owner, station);
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	virtual void OnResize(Point new_size, Point delta)
 
	{
 
@@ -1324,13 +1323,13 @@ struct VehicleDetailsWindow : Window {
 
		if (v->type != VEH_TRAIN) {
 
			this->vscroll.cap = 1;
 
			this->widget[VLD_WIDGET_MIDDLE_DETAILS].right += 12;
 
		}
 

	
 
		this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << 8) + 1;
 
		this->caption_color = v->owner;
 
		this->owner = v->owner;
 

	
 
		this->tab = 0;
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
@@ -1668,13 +1667,13 @@ static bool IsVehicleRefitable(const Veh
 

	
 
struct VehicleViewWindow : Window {
 
	VehicleViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		const Vehicle *v = GetVehicle(this->window_number);
 

	
 
		this->caption_color = v->owner;
 
		this->owner = v->owner;
 
		InitializeWindowViewport(this, VV_VIEWPORT_X, VV_VIEWPORT_Y, VV_INITIAL_VIEWPORT_WIDTH,
 
												 (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT,
 
												 this->window_number | (1 << 31), _vehicle_view_zoom_levels[v->type]);
 

	
 
		/*
 
		 * fill in data and tooltip codes for the widgets and
src/waypoint_gui.cpp
Show inline comments
 
@@ -33,13 +33,13 @@ private:
 
	};
 

	
 
public:
 
	WaypointWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->wp = GetWaypoint(this->window_number);
 
		this->caption_color = this->wp->owner;
 
		this->owner = this->wp->owner;
 

	
 
		this->flags4 |= WF_DISABLE_VP_SCROLL;
 
		InitializeWindowViewport(this, 3, 17, 254, 86, this->wp->xy, ZOOM_LVL_MIN);
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
src/widget.cpp
Show inline comments
 
@@ -465,16 +465,16 @@ void Window::DrawWidgets() const
 
			break;
 
		}
 

	
 
		case WWT_CAPTION:
 
			assert(r.bottom - r.top == 13); // To ensure the same sizes are used everywhere!
 
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, FR_BORDERONLY);
 
			DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->colour, (this->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
 
			DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->colour, (this->owner == INVALID_OWNER) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
 

	
 
			if (this->caption_color != 0xFF) {
 
				GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[this->caption_color]][4]);
 
			if (this->owner != INVALID_OWNER) {
 
				GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[this->owner]][4]);
 
			}
 

	
 
			DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top + 2, wi->data, TC_FROMSTRING);
 
			break;
 

	
 
		case WWT_DROPDOWN: {
src/window.cpp
Show inline comments
 
@@ -605,13 +605,13 @@ void DeleteCompanyWindows(CompanyID id)
 

	
 
restart_search:
 
	/* When we find the window to delete, we need to restart the search
 
	 * as deleting this window could cascade in deleting (many) others
 
	 * anywhere in the z-array */
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->caption_color == id) {
 
		if (w->owner == id) {
 
			delete w;
 
			goto restart_search;
 
		}
 
	}
 

	
 
	/* Also delete the company specific windows, that don't have a company-colour */
 
@@ -624,13 +624,13 @@ restart_search:
 
 * @param old_owner original owner of the window
 
 * @param new_owner the new owner of the window */
 
void ChangeWindowOwner(Owner old_owner, Owner new_owner)
 
{
 
	Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->caption_color != old_owner) continue;
 
		if (w->owner != old_owner) continue;
 

	
 
		switch (w->window_class) {
 
			case WC_COMPANY_COLOR:
 
			case WC_FINANCES:
 
			case WC_STATION_LIST:
 
			case WC_TRAINS_LIST:
 
@@ -639,13 +639,13 @@ void ChangeWindowOwner(Owner old_owner, 
 
			case WC_AIRCRAFT_LIST:
 
			case WC_BUY_COMPANY:
 
			case WC_COMPANY:
 
				continue;
 

	
 
			default:
 
				w->caption_color = new_owner;
 
				w->owner = new_owner;
 
				break;
 
		}
 
	}
 
}
 

	
 
static void BringWindowToFront(Window *w);
 
@@ -765,13 +765,13 @@ static void AssignWidgetToWindow(Window 
 
void Window::Initialize(int x, int y, int min_width, int min_height,
 
				WindowClass cls, const Widget *widget, int window_number)
 
{
 
	/* Set up window properties */
 
	this->window_class = cls;
 
	this->flags4 = WF_WHITE_BORDER_MASK; // just opened windows have a white border
 
	this->caption_color = 0xFF;
 
	this->owner = INVALID_OWNER;
 
	this->left = x;
 
	this->top = y;
 
	this->width = min_width;
 
	this->height = min_height;
 
	AssignWidgetToWindow(this, widget);
 
	this->focused_widget = 0;
src/window_gui.h
Show inline comments
 
@@ -147,15 +147,15 @@ public:
 

	
 
	Scrollbar hscroll;  ///< Horizontal scroll bar
 
	Scrollbar vscroll;  ///< First vertical scroll bar
 
	Scrollbar vscroll2; ///< Second vertical scroll bar
 
	ResizeInfo resize;  ///< Resize information
 

	
 
	byte caption_color; ///< Background color of the window caption, contains CompanyID
 
	Owner owner;        ///< The owner of the content shown in this window. Company colour is acquired from this variable.
 

	
 
	ViewportData *viewport;      ///< Pointer to viewport data, if present
 
	ViewportData *viewport;///< Pointer to viewport data, if present
 
	Widget *widget;        ///< Widgets of the window
 
	uint widget_count;     ///< Number of widgets of the window
 
	uint32 desc_flags;     ///< Window/widgets default flags setting, @see WindowDefaultFlag
 
	const Widget *focused_widget; ///< Currently focused widget or NULL, if no widget has focus
 

	
 
	Window *parent;        ///< Parent window
0 comments (0 inline, 0 general)