annotate src/waypoint_gui.cpp @ 20729:ea20edff1862 draft default tip master

(svn r25643) -Fix (r25480): [OSX] Define version constants before they're used
author planetmaker <planetmaker@openttd.org>
date Wed, 31 Jul 2013 18:50:01 +0000 (2013-07-31)
parents 63dba929ba42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
1 /* $Id$ */
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
9
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
10 /** @file waypoint_gui.cpp Handling of waypoints gui. */
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
11
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
12 #include "stdafx.h"
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
13 #include "window_gui.h"
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
14 #include "gui.h"
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
15 #include "textbuf_gui.h"
16079
f961c962db5d (svn r20772) -Codechange: use packed VehicleListIdentifiers as window numbers
rubidium <rubidium@openttd.org>
parents: 15349
diff changeset
16 #include "vehiclelist.h"
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
17 #include "vehicle_gui.h"
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
18 #include "viewport_func.h"
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
19 #include "strings_func.h"
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
20 #include "command_func.h"
11058
f68131a5cf7e (svn r15398) -Fix (r14135): _current_company shouldn't be used in GUI code (Swallow)
smatz <smatz@openttd.org>
parents: 10960
diff changeset
21 #include "company_func.h"
15315
ae1f7a2f6ce3 (svn r19956) -Fix: close list of vehicles with given oil rig in orders when the oil rig is deleted
smatz <smatz@openttd.org>
parents: 15314
diff changeset
22 #include "company_base.h"
10120
e429d7f88beb (svn r14304) -Fix (r14104): waypoint train list wasn't closed with the waypoint window (crashes since r14296)
smatz <smatz@openttd.org>
parents: 9986
diff changeset
23 #include "window_func.h"
12475
c133b51890f4 (svn r16912) -Codechange: split waypoint.h in waypoint_base.h and waypoint_func.h
rubidium <rubidium@openttd.org>
parents: 12472
diff changeset
24 #include "waypoint_base.h"
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
25
18680
e87c7c30e606 (svn r23528) -Codechange: move widget enums to widgets/NNN_type.h
truebrain <truebrain@openttd.org>
parents: 18677
diff changeset
26 #include "widgets/waypoint_widget.h"
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
27
18680
e87c7c30e606 (svn r23528) -Codechange: move widget enums to widgets/NNN_type.h
truebrain <truebrain@openttd.org>
parents: 18677
diff changeset
28 #include "table/strings.h"
11492
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
29
16312
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
30 /** GUI for accessing waypoints and buoys. */
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
31 struct WaypointWindow : Window {
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
32 private:
16312
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
33 VehicleType vt; ///< Vehicle type using the waypoint.
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
34 Waypoint *wp; ///< Waypoint displayed by the window.
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
35
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
36 /**
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
37 * Get the center tile of the waypoint.
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
38 * @return The center tile if the waypoint exists, otherwise the tile with the waypoint name.
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
39 */
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
40 TileIndex GetCenterTile() const
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
41 {
16327
3835bbe059fe (svn r21035) -Fix [FS#4181] (r21020): crash when opening the buoy's viewport. Based on a patch by Krille.
rubidium <rubidium@openttd.org>
parents: 16313
diff changeset
42 if (!this->wp->IsInUse()) return this->wp->xy;
3835bbe059fe (svn r21035) -Fix [FS#4181] (r21020): crash when opening the buoy's viewport. Based on a patch by Krille.
rubidium <rubidium@openttd.org>
parents: 16313
diff changeset
43
3835bbe059fe (svn r21035) -Fix [FS#4181] (r21020): crash when opening the buoy's viewport. Based on a patch by Krille.
rubidium <rubidium@openttd.org>
parents: 16313
diff changeset
44 TileArea ta;
3835bbe059fe (svn r21035) -Fix [FS#4181] (r21020): crash when opening the buoy's viewport. Based on a patch by Krille.
rubidium <rubidium@openttd.org>
parents: 16313
diff changeset
45 this->wp->GetTileArea(&ta, this->vt == VEH_TRAIN ? STATION_WAYPOINT : STATION_BUOY);
3835bbe059fe (svn r21035) -Fix [FS#4181] (r21020): crash when opening the buoy's viewport. Based on a patch by Krille.
rubidium <rubidium@openttd.org>
parents: 16313
diff changeset
46 return ta.GetCenterTile();
16312
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
47 }
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
48
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
49 public:
17635
41ea7460de25 (svn r22406) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17634
diff changeset
50 /**
41ea7460de25 (svn r22406) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17634
diff changeset
51 * Construct the window.
41ea7460de25 (svn r22406) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17634
diff changeset
52 * @param desc The description of the window.
41ea7460de25 (svn r22406) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17634
diff changeset
53 * @param window_number The window number, in this case the waypoint's ID.
41ea7460de25 (svn r22406) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17634
diff changeset
54 */
20335
cadf6aaa0573 (svn r25287) -Codechange: Keep a reference to the WindowDesc in the Window after construction.
frosch <frosch@openttd.org>
parents: 19767
diff changeset
55 WaypointWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
56 {
12585
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
57 this->wp = Waypoint::Get(window_number);
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12466
diff changeset
58 this->vt = (wp->string_id == STR_SV_STNAME_WAYPOINT) ? VEH_TRAIN : VEH_SHIP;
12466
2093135e028e (svn r16900) -Codechange: prepare the waypoint window for buoys
rubidium <rubidium@openttd.org>
parents: 12452
diff changeset
59
20335
cadf6aaa0573 (svn r25287) -Codechange: Keep a reference to the WindowDesc in the Window after construction.
frosch <frosch@openttd.org>
parents: 19767
diff changeset
60 this->CreateNestedTree();
12590
f725939721be (svn r17030) -Codechange: Better descriptions for buoys.
alberth <alberth@openttd.org>
parents: 12585
diff changeset
61 if (this->vt == VEH_TRAIN) {
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
62 this->GetWidget<NWidgetCore>(WID_W_SHOW_VEHICLES)->SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP);
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
63 this->GetWidget<NWidgetCore>(WID_W_CENTER_VIEW)->tool_tip = STR_WAYPOINT_VIEW_CENTER_TOOLTIP;
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
64 this->GetWidget<NWidgetCore>(WID_W_RENAME)->tool_tip = STR_WAYPOINT_VIEW_CHANGE_WAYPOINT_NAME;
12590
f725939721be (svn r17030) -Codechange: Better descriptions for buoys.
alberth <alberth@openttd.org>
parents: 12585
diff changeset
65 }
20335
cadf6aaa0573 (svn r25287) -Codechange: Keep a reference to the WindowDesc in the Window after construction.
frosch <frosch@openttd.org>
parents: 19767
diff changeset
66 this->FinishInitNested(window_number);
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
67
15349
9e7152647fb1 (svn r19990) -Fix: owner of the Waypoint View window wasn't properly set
smatz <smatz@openttd.org>
parents: 15316
diff changeset
68 if (this->wp->owner != OWNER_NONE) this->owner = this->wp->owner;
18677
7077d1f6763b (svn r23525) -Codechange: make Window::flags4 WindowFlags instead of uint16, with only values known in WindowFlags (and move out 2 timers to their own variable)
truebrain <truebrain@openttd.org>
parents: 18477
diff changeset
69 this->flags |= WF_DISABLE_VP_SCROLL;
15349
9e7152647fb1 (svn r19990) -Fix: owner of the Waypoint View window wasn't properly set
smatz <smatz@openttd.org>
parents: 15316
diff changeset
70
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
71 NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_W_VIEWPORT);
18477
45def1e34fa6 (svn r23321) -Fix (r23316): Extra viewports and waypoint detail opened up at wrong zoom level.
peter1138 <peter1138@openttd.org>
parents: 17635
diff changeset
72 nvp->InitializeViewport(this, this->GetCenterTile(), ZOOM_LVL_VIEWPORT);
12466
2093135e028e (svn r16900) -Codechange: prepare the waypoint window for buoys
rubidium <rubidium@openttd.org>
parents: 12452
diff changeset
73
12585
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
74 this->OnInvalidateData(0);
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
75 }
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
76
15315
ae1f7a2f6ce3 (svn r19956) -Fix: close list of vehicles with given oil rig in orders when the oil rig is deleted
smatz <smatz@openttd.org>
parents: 15314
diff changeset
77 ~WaypointWindow()
ae1f7a2f6ce3 (svn r19956) -Fix: close list of vehicles with given oil rig in orders when the oil rig is deleted
smatz <smatz@openttd.org>
parents: 15314
diff changeset
78 {
ae1f7a2f6ce3 (svn r19956) -Fix: close list of vehicles with given oil rig in orders when the oil rig is deleted
smatz <smatz@openttd.org>
parents: 15314
diff changeset
79 Owner owner = this->owner;
17385
dad1b676ebac (svn r22131) -Fix: Spectators had trouble closing buoy windows. (Terkhen)
frosch <frosch@openttd.org>
parents: 16684
diff changeset
80
dad1b676ebac (svn r22131) -Fix: Spectators had trouble closing buoy windows. (Terkhen)
frosch <frosch@openttd.org>
parents: 16684
diff changeset
81 /* Buoys have no owner and can be used by everyone. Show only 'our' vehicles */
15315
ae1f7a2f6ce3 (svn r19956) -Fix: close list of vehicles with given oil rig in orders when the oil rig is deleted
smatz <smatz@openttd.org>
parents: 15314
diff changeset
82 if (!Company::IsValidID(owner)) owner = _local_company;
17385
dad1b676ebac (svn r22131) -Fix: Spectators had trouble closing buoy windows. (Terkhen)
frosch <frosch@openttd.org>
parents: 16684
diff changeset
83
dad1b676ebac (svn r22131) -Fix: Spectators had trouble closing buoy windows. (Terkhen)
frosch <frosch@openttd.org>
parents: 16684
diff changeset
84 /* Well, spectators otoh */
dad1b676ebac (svn r22131) -Fix: Spectators had trouble closing buoy windows. (Terkhen)
frosch <frosch@openttd.org>
parents: 16684
diff changeset
85 if (Company::IsValidID(owner)) DeleteWindowById(GetWindowClassForVehicleType(this->vt), VehicleListIdentifier(VL_STATION_LIST, this->vt, owner, this->window_number).Pack(), false);
15315
ae1f7a2f6ce3 (svn r19956) -Fix: close list of vehicles with given oil rig in orders when the oil rig is deleted
smatz <smatz@openttd.org>
parents: 15314
diff changeset
86 }
ae1f7a2f6ce3 (svn r19956) -Fix: close list of vehicles with given oil rig in orders when the oil rig is deleted
smatz <smatz@openttd.org>
parents: 15314
diff changeset
87
12585
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
88 virtual void SetStringParameters(int widget) const
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
89 {
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
90 if (widget == WID_W_CAPTION) SetDParam(0, this->wp->index);
12585
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
91 }
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
92
14409
1eaefde497fd (svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents: 14258
diff changeset
93 virtual void OnClick(Point pt, int widget, int click_count)
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
94 {
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
95 switch (widget) {
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
96 case WID_W_CENTER_VIEW: // scroll to location
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
97 if (_ctrl_pressed) {
16312
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
98 ShowExtraViewPortWindow(this->GetCenterTile());
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
99 } else {
16312
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
100 ScrollMainWindowToTile(this->GetCenterTile());
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
101 }
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
102 break;
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
103
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
104 case WID_W_RENAME: // rename
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
105 SetDParam(0, this->wp->index);
17579
105b4e4eb168 (svn r22343) -Change: Remove pixel limiter for query strings.
terkhen <terkhen@openttd.org>
parents: 17486
diff changeset
106 ShowQueryString(STR_WAYPOINT_NAME, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_STATION_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
107 break;
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
108
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
109 case WID_W_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
19667
eaf0fcf9aae8 (svn r24576) -Fix [FS#5319] (r24260): Vehicle list at buoys did no longer work. (Juanjo)
frosch <frosch@openttd.org>
parents: 18682
diff changeset
110 ShowVehicleListWindow(this->wp->owner, this->vt, this->wp->index);
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
111 break;
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
112 }
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
113 }
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
114
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17385
diff changeset
115 /**
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17385
diff changeset
116 * Some data on this window has become invalid.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17385
diff changeset
117 * @param data Information about the changed data.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17385
diff changeset
118 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17385
diff changeset
119 */
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17385
diff changeset
120 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
9986
c218d2656349 (svn r14143) -Codechange: Recenter viewport of waypoint window when relocating the waypoint.
frosch <frosch@openttd.org>
parents: 9978
diff changeset
121 {
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17385
diff changeset
122 if (!gui_scope) return;
12585
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
123 /* You can only change your own waypoints */
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
124 this->SetWidgetDisabledState(WID_W_RENAME, !this->wp->IsInUse() || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE));
12585
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
125 /* Disable the widget for waypoints with no use */
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
126 this->SetWidgetDisabledState(WID_W_SHOW_VEHICLES, !this->wp->IsInUse());
12585
25900cef760d (svn r17025) -Codechange: Waypoint window using all the new goodies (based on work by Rubidium).
alberth <alberth@openttd.org>
parents: 12538
diff changeset
127
16312
e19d6bb9ff88 (svn r21020) -Add: Use center of waypoint in waypoint gui, if available.
alberth <alberth@openttd.org>
parents: 16117
diff changeset
128 ScrollWindowToTile(this->GetCenterTile(), this, true);
9986
c218d2656349 (svn r14143) -Codechange: Recenter viewport of waypoint window when relocating the waypoint.
frosch <frosch@openttd.org>
parents: 9978
diff changeset
129 }
c218d2656349 (svn r14143) -Codechange: Recenter viewport of waypoint window when relocating the waypoint.
frosch <frosch@openttd.org>
parents: 9978
diff changeset
130
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
131 virtual void OnResize()
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
132 {
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
133 if (this->viewport != NULL) {
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
134 NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_W_VIEWPORT);
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
135 nvp->UpdateViewportCoordinates(this);
16117
4a2b464d3f87 (svn r20813) -Fix: make the waypoint viewport keep centered around the waypoint when resizing the window (Krille)
rubidium <rubidium@openttd.org>
parents: 16079
diff changeset
136 this->wp->UpdateVirtCoord();
16313
a09e9e494674 (svn r21021) -Add [FS#4171]: Center industry gui and waypoint gui after resize (partly by Krille).
alberth <alberth@openttd.org>
parents: 16312
diff changeset
137
a09e9e494674 (svn r21021) -Add [FS#4171]: Center industry gui and waypoint gui after resize (partly by Krille).
alberth <alberth@openttd.org>
parents: 16312
diff changeset
138 ScrollWindowToTile(this->GetCenterTile(), this, true); // Re-center viewport.
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
139 }
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
140 }
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
141
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
142 virtual void OnQueryTextFinished(char *str)
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
143 {
10148
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
144 if (str == NULL) return;
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
145
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12590
diff changeset
146 DoCommandP(0, this->window_number, 0, CMD_RENAME_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME), NULL, str);
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
147 }
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
148
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
149 };
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
150
17634
5117fc12b816 (svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17579
diff changeset
151 /** The widgets of the waypoint view. */
11492
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
152 static const NWidgetPart _nested_waypoint_view_widgets[] = {
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
153 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
154 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
155 NWidget(WWT_CAPTION, COLOUR_GREY, WID_W_CAPTION), SetDataTip(STR_WAYPOINT_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
14045
68fabdc82f5b (svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents: 13796
diff changeset
156 NWidget(WWT_SHADEBOX, COLOUR_GREY),
20342
63dba929ba42 (svn r25294) -Feature: Add another button to window title bars to resize the window to its default size.
frosch <frosch@openttd.org>
parents: 20338
diff changeset
157 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
158 NWidget(WWT_STICKYBOX, COLOUR_GREY),
11492
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
159 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
160 NWidget(WWT_PANEL, COLOUR_GREY),
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
161 NWidget(WWT_INSET, COLOUR_GREY), SetPadding(2, 2, 2, 2),
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
162 NWidget(NWID_VIEWPORT, COLOUR_GREY, WID_W_VIEWPORT), SetMinimalSize(256, 88), SetPadding(1, 1, 1, 1), SetResize(1, 1),
11492
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
163 EndContainer(),
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
164 EndContainer(),
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
165 NWidget(NWID_HORIZONTAL),
18682
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
166 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_CENTER_VIEW), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_BUOY_VIEW_CENTER_TOOLTIP),
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
167 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_RENAME), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_BUOY_VIEW_CHANGE_BUOY_NAME),
2e811972ef2b (svn r23530) -Codechange: begin unify the naming of widgets and add comments to them, in this case the waypoint view widgets
rubidium <rubidium@openttd.org>
parents: 18680
diff changeset
168 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_SHOW_VEHICLES), SetMinimalSize(15, 12), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
169 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
11492
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
170 EndContainer(),
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
171 };
d5991b4040ea (svn r15853) -Codechange: New widgets for the waypoint gui.
yexo <yexo@openttd.org>
parents: 11375
diff changeset
172
17634
5117fc12b816 (svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17579
diff changeset
173 /** The description of the waypoint view. */
20335
cadf6aaa0573 (svn r25287) -Codechange: Keep a reference to the WindowDesc in the Window after construction.
frosch <frosch@openttd.org>
parents: 19767
diff changeset
174 static WindowDesc _waypoint_view_desc(
20338
491ddf49f744 (svn r25290) -Add: Assign string names to notable windows.
frosch <frosch@openttd.org>
parents: 20335
diff changeset
175 WDP_AUTO, "view_waypoint", 260, 118,
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
176 WC_WAYPOINT_VIEW, WC_NONE,
19767
2a11204038e3 (svn r24700) -Cleanup: Remove WDF_UNCLICK_BUTTONS and make it the default.
frosch <frosch@openttd.org>
parents: 19667
diff changeset
177 0,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13072
diff changeset
178 _nested_waypoint_view_widgets, lengthof(_nested_waypoint_view_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
179 );
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
180
17634
5117fc12b816 (svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17579
diff changeset
181 /**
5117fc12b816 (svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17579
diff changeset
182 * Show the window for the given waypoint.
5117fc12b816 (svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17579
diff changeset
183 * @param wp The waypoint to show the window for.
5117fc12b816 (svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents: 17579
diff changeset
184 */
9953
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
185 void ShowWaypointWindow(const Waypoint *wp)
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
186 {
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
187 AllocateWindowDescFront<WaypointWindow>(&_waypoint_view_desc, wp->index);
9f5e3b4f4caf (svn r14108) -Fix(r14104): Give a more consistent naming of the new gui file
belugas <belugas@openttd.org>
parents:
diff changeset
188 }