Debian Codegraph @

stylus.h

raw symbols SCIP
1 /*
2 * PROPRIETARY INFORMATION. This software is proprietary to POWDER
3 * Development, and is not to be reproduced, transmitted, or disclosed
4 * in any way without written permission.
5 *
6 * Produced by: Jeff Lait
7 *
8 * POWDER Development
9 *
10 * NAME: stylus.h ( POWDER Library, C++ )
11 *
12 * COMMENTS:
13 */
14
15 #ifndef __stylus__
16 #define __stylus__
17
18 #include <mygba.h>
19
20 class MOB;
21
22 enum STYLUSREGIONS
23 {
24 REGION_NONE = 0,
25 // The increasingly inaccurately named bottom buttons.
26 REGION_BOTTOMBUTTON = 1,
27 REGION_MAPTILES = 2,
28 REGION_INVENTORY = 4,
29 REGION_SLOTS = 8,
30 REGION_MENU = 16,
31 REGION_DISPLAYTEXT = 32,
32 REGION_TENDIR = 64,
33 REGION_FOURDIR = 128,
34 REGION_KEYBOARD = 256,
35 REGION_SIDEBUTTON = 512,
36 };
37
38 // Create this object at the start of a method that will query the
39 // stylus to ensure stylus processing is activated & cleared as
40 // expected.
41 class STYLUSLOCK
42 {
43 public:
44 explicit STYLUSLOCK(int regions = 0);
45 virtual ~STYLUSLOCK();
46
47 // You can only call this once and only if no region was specified
48 // in the constructor.
49 void setRegion(int regions);
50
51 // This is an *inclusive* range!
52 // Specified relative to GBA.
53 // Specified in *tile* coordinates - ie, everything is multiplied
54 // by 8.
55 // -1 means not to clip.
56 void setRange(int left, int top, int right, int bottom);
57
58 bool snap(int &x, int &y);
59
60 // Returns true if inside user specified range.
61 bool inRange(int x, int y);
62
63 // Processes the stylus, possibly drawing the sprite overlay if
64 // needed.
65 void update();
66
67 // Clears any pending stylus buttons
68 void clear();
69
70 // Waits for a proper stylus press on an inventory item, returning it.
71 bool selectinventoryitem(int &cx, int &cy);
72
73 // Waits for a proper click on an itemslot.
74 bool selectinventoryslot(int &slot);
75
76 // Queries for a menu choice in the given range.
77 bool selectmenu(int &menu, int x, int y, bool &inbounds);
78
79 // Performs any drag requests, updating the action strip accordingly
80 bool performDrags(int menuy, int startoflist, int endoflist,
81 const u8 *menu,
82 u8 *actionstrip);
83
84 // Perform inventory drags. We are returned the start & end slots
85 // if we return true.
86 // This doesn't use "locking" but rather soft touch.
87 // That sentence doesn't make any sense, does it?
88 // This is like stylus_queryinventory in that it is independent
89 // of normal menu options.
90 bool performInventoryDrag(int &sx, int &sy, int &ex, int &ey, MOB *owner, bool &dirty);
91
92 // Returns true if a click occured in the bottom
93 // row of buttons, each 16x16 and starting on y=160.
94 // buttonsel is which button was pressed.
95 // Nothing is consumed if the click is outside this range.
96 bool getbottombutton(int &buttonsel);
97
98 // Returns true if proper press. dy is set to +/-1 or 0.
99 bool getdisplaytext(int &dy);
100
101 // Sets the ten dir options, sets cancel if a valid click outside.
102 bool gettendir(int &dx, int &dy, int &dz, bool &cancel);
103
104 // Sets the ten dir options, sets cancel if a valid click outside.
105 bool getfourdir(int &dx, int &dy, bool &cancel);
106
107 // Returns which character tile was hit.
108 bool getchartile(int &cx, int &cy);
109
110 // Returns true if a click has occured.
111 // Cancel will be true if it was a cancel select
112 // mx & my will store the map coordinates of where the click occured.
113 bool getmaptile(int &mx, int &my, bool &cancel);
114
115 private:
116 STYLUSLOCK *myParent;
117 int myRegion;
118 int myLeft, myRight, myTop, myBottom;
119
120 // Flags controlling our current state.
121 bool myWaitForDown;
122 bool myStarted, myValid, myButton, myBadSnap;
123 bool myDragging;
124 int myStartX, myStartY;
125 int myLastDragX, myLastDragY;
126 };
127
128 // Sets cx/cy to inventory item if stylus is currently over them.
129 bool stylus_queryinventoryitem(int &cx, int &cy);
130
131 #endif
132