ScummVM API documentation
taskbar.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NANCY_UI_TASKBAR_H
23 #define NANCY_UI_TASKBAR_H
24 
25 #include "engines/nancy/renderobject.h"
26 
27 namespace Nancy {
28 
29 struct NancyInput;
30 
31 namespace UI {
32 
33 // Always-on bottom-of-screen strip introduced in Nancy 10.
34 // Holds 5 buttons (MENU / inventory / notebook / cellphone / HELP) that
35 // open the various popup UIs handled by Scene.
36 class Taskbar : public RenderObject {
37 public:
38  Taskbar();
39  virtual ~Taskbar() = default;
40 
41  void init() override;
42  void registerGraphics() override;
43  void handleInput(NancyInput &input);
44 
45  // Enable / disable a taskbar button. A disabled button is rendered
46  // in its disabled sprite and ignores clicks.
47  void toggleButton(uint index, bool enabled);
48 
49  // Disable override: keep the disabled sprite active while the current
50  // scene is in [startScene, endScene]. Driven by AR 29 (ControlUIItems,
51  // _flagB != 0).
52  void setDisabledRange(uint buttonIndex, int16 startScene, int16 endScene);
53  void clearButtonOverride(uint buttonIndex);
54 
55  // Notification badge: each button has up to 3 independent notification
56  // sub-categories. The badge shows when any sub-category is set; it
57  // persists across scene changes until cleared (or all sub-cats are
58  // cleared individually). Disabled state takes precedence over the badge.
59  void setNotification(uint buttonIndex, uint subCategory);
60  void clearNotification(uint buttonIndex, uint subCategory);
61  void clearAllNotifications(uint buttonIndex);
62 
63  // Re-evaluate which buttons should currently show their override
64  // sprite. Call after a scene change so the range check kicks in.
65  void updateNotificationStates(int16 currentSceneID);
66 
67  // Returns the index of the button that was clicked this frame, or -1
68  // if none. Cleared on the next call to handleInput().
69  int getClickedButton() const { return _clickedButton; }
70 
71 private:
72  enum ButtonState {
73  kButtonIdle = 0,
74  kButtonHover = 1,
75  kButtonPressed = 2,
76  kButtonDisabled = 3, // not clickable
77  kButtonNotification = 4 // popup has new content (badge sprite)
78  };
79 
80  // A scene-ranged disable override for one button. While active and the
81  // current scene is within [startScene, endScene] the button renders in
82  // the disabled state.
83  struct ButtonOverride {
84  bool active = false;
85  int16 startScene = -1;
86  int16 endScene = -1;
87  };
88 
89  static const uint kNumNotificationSubCategories = 3;
90 
91  void drawButton(uint index, ButtonState state);
92  ButtonState restingState(uint index) const;
93  // True when the button currently accepts hover/click (not disabled).
94  bool isButtonActive(uint index) const;
95 
96  Graphics::ManagedSurface _backgroundImage; // TASK::imageName (e.g. "Frame")
97  Graphics::ManagedSurface _buttonImage; // buttons' primaryImageName (e.g. "UIShared_OVL")
98  int _hoveredButton;
99  int _clickedButton;
100  int16 _currentScene;
101  bool _enabled[5];
102  ButtonState _buttonStates[5];
103  ButtonOverride _overrides[5];
104  bool _notifications[5][kNumNotificationSubCategories];
105 };
106 
107 } // End of namespace UI
108 } // End of namespace Nancy
109 
110 #endif // NANCY_UI_TASKBAR_H
Definition: managed_surface.h:51
Definition: taskbar.h:36
Definition: input.h:41
Definition: soundequalizerpuzzle.h:27
Definition: renderobject.h:36
Definition: actionmanager.h:32