summaryrefslogtreecommitdiff
path: root/train_gui.c
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2006-10-02 00:28:31 +0000
committerbelugas <belugas@openttd.org>2006-10-02 00:28:31 +0000
commitf5ee5bdb0e06c9492ae65949c1c0b09c13fa5c10 (patch)
tree824c32c54efb62eb8db1cd43c94dbe8c28a30b9a /train_gui.c
parent33e8c26c38ac228a22868a27687e0a92d1ec9a29 (diff)
downloadopenttd-f5ee5bdb0e06c9492ae65949c1c0b09c13fa5c10.tar.xz
(svn r6612) -Codechange: Use accessors for hidden_state.
Another step toward merging XTDwidget. The only two files not converted (window.h and widget.c) will be done at the very last commit)
Diffstat (limited to 'train_gui.c')
-rw-r--r--train_gui.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/train_gui.c b/train_gui.c
index 5f3e7b93f..9e5a6986f 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -564,12 +564,17 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP: {
const Vehicle *v = GetVehicle(w->window_number);
- uint32 h;
-
- assert(v->type == VEH_Train);
- h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13);
- if (h != w->hidden_state) {
- w->hidden_state = h;
+ bool train_stopped = CheckTrainStoppedInDepot(v) >= 0;
+
+ /* Widget 7 (send to depot) must be hidden if the train is already stopped in hangar.
+ * Widget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
+ * This sytem allows to have two buttons, on top of each other.
+ * The same system applies to widget 9 and 12, reverse direction and refit*/
+ if (train_stopped != IsWindowWidgetHidden(w, 7) || train_stopped == IsWindowWidgetHidden(w, 13)) {
+ SetWindowWidgetHiddenState(w, 7, train_stopped); // send to depot
+ SetWindowWidgetHiddenState(w, 9, train_stopped); // reverse direction
+ SetWindowWidgetHiddenState(w, 12, !train_stopped); // refit
+ SetWindowWidgetHiddenState(w, 13, !train_stopped); // clone
SetWindowDirty(w);
}
break;