Mercurial > hg > openttd
changeset 11084:e07c7d3925c8 draft
(svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 09 Feb 2009 02:33:10 +0000 |
parents | ccdc108edbc5 |
children | 8da1855e9f14 |
files | src/autoreplace_gui.cpp src/build_vehicle_gui.cpp src/company_gui.cpp src/depot_gui.cpp src/group_gui.cpp src/order_gui.cpp src/station_gui.cpp src/timetable_gui.cpp src/vehicle_gui.cpp src/waypoint_gui.cpp src/widget.cpp src/window.cpp src/window_gui.h |
diffstat | 13 files changed, 28 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -236,7 +236,7 @@ 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
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -803,7 +803,7 @@ 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;
--- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -228,7 +228,7 @@ 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; @@ -458,7 +458,7 @@ 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); @@ -848,7 +848,7 @@ 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; @@ -1254,7 +1254,7 @@ 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); }
--- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -243,7 +243,7 @@ this->sel = INVALID_VEHICLE; this->generate_list = true; - this->caption_color = GetTileOwner(tile); + this->owner = GetTileOwner(tile); this->CreateDepotListWindow(type); this->FindWindowPlacementAndResize(desc);
--- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -173,7 +173,7 @@ 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) {
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -623,7 +623,7 @@ 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;
--- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -233,7 +233,7 @@ 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 @@ -711,7 +711,7 @@ 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;
--- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -51,7 +51,7 @@ 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;
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -271,7 +271,7 @@ 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; @@ -801,7 +801,7 @@ 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 */ @@ -930,7 +930,7 @@ 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); @@ -1094,9 +1094,8 @@ 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(); } } @@ -1327,7 +1326,7 @@ } this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << 8) + 1; - this->caption_color = v->owner; + this->owner = v->owner; this->tab = 0; @@ -1671,7 +1670,7 @@ { 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]);
--- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -36,7 +36,7 @@ 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);
--- a/src/widget.cpp +++ b/src/widget.cpp @@ -468,10 +468,10 @@ 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);
--- a/src/window.cpp +++ b/src/window.cpp @@ -608,7 +608,7 @@ * 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; } @@ -627,7 +627,7 @@ { 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: @@ -642,7 +642,7 @@ continue; default: - w->caption_color = new_owner; + w->owner = new_owner; break; } } @@ -768,7 +768,7 @@ /* 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;
--- a/src/window_gui.h +++ b/src/window_gui.h @@ -150,9 +150,9 @@ 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