ScummVM API documentation
cursors.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 MEDIASTATION_CURSORS_H
23 #define MEDIASTATION_CURSORS_H
24 
25 #include "common/platform.h"
26 #include "common/scummsys.h"
27 #include "common/hashmap.h"
28 #include "common/str.h"
29 #include "common/macresman.h"
30 #include "common/formats/winexe.h"
31 #include "graphics/wincursor.h"
32 #include "graphics/maccursor.h"
33 
34 #include "mediastation/clients.h"
35 #include "mediastation/datafile.h"
36 
37 namespace MediaStation {
38 
39 enum CursorManagerCommandType {
40  kCursorManagerInit = 0x0c,
41  kCursorManagerNewCursor = 0x15,
42  kCursorManagerDisposeCursor = 0x16,
43 };
44 
45 enum CursorType {
46  kPlatformCursor = 0,
47  kResourceCursor = 1,
48 };
49 
50 // Media Station stores cursors in the executable as named resources.
52 public:
53  CursorManager(const Common::Path &appName) : _appName(appName) {}
54  virtual ~CursorManager();
55 
56  virtual bool attemptToReadFromStream(Chunk &chunk, uint param) override;
57  void init(Chunk &chunk);
58  void newCursor(Chunk &chunk);
59  void disposeCursor(Chunk &chunk);
60 
61  void newPlatformCursor(uint16 platformCursorId, uint16 cursorId);
62  void newResourceCursor(uint16 cursorId, const Common::String &resourceName);
63  // Some engine versions also have newBufferCursor that seems to be unused.
64 
65  void showCursor();
66  void hideCursor();
67 
68  virtual void resetCurrent();
69  void registerAsPermanent(uint16 id);
70  void setAsPermanent(uint16 id);
71  void setAsTemporary(uint16 id);
72  void unsetPermanent();
73  void unsetTemporary();
74 
75 protected:
76  Common::Path _appName;
77 
78  uint16 _baseCursorId = 0;
79  uint16 _maxCursorId = 0;
80  uint16 _currentCursorId = 0;
81  uint16 _permanentCursorId = 0;
82 
83  // The original used an array with computed indices, but we use a hashmap for simplicity.
85 
86  virtual Graphics::Cursor *loadResourceCursor(const Common::String &name) = 0;
87  void setDefaultCursor();
88 };
89 
91 public:
92  WindowsCursorManager(const Common::Path &appName);
93  ~WindowsCursorManager() override;
94 
95  virtual Graphics::Cursor *loadResourceCursor(const Common::String &name) override;
96 
97 private:
99 };
100 
102 public:
103  explicit MacCursorManager(const Common::Path &appName);
104  ~MacCursorManager() override;
105 
106  virtual Graphics::Cursor *loadResourceCursor(const Common::String &name) override;
107 
108 private:
109  Common::MacResManager *_resFork;
110 };
111 
112 } // End of namespace MediaStation
113 
114 #endif
Definition: cursors.h:101
Definition: macresman.h:126
Definition: str.h:59
Definition: actor.h:33
Definition: datafile.h:102
Definition: path.h:52
Definition: cursors.h:51
Definition: clients.h:29
Definition: hashmap.h:85
Definition: cursors.h:90
Definition: cursor.h:42