c3adde741274d5409dbaa14cab9c76c9dbed0bef
[openitg.git] / src / CodeDetector.h
1 /* CodeDetector - Uses InputQueue to detect input of codes. */
2
3 #ifndef CODE_DETECTOR_H
4 #define CODE_DETECTOR_H
5
6 #include "GameInput.h"
7
8 enum Code {
9 CODE_EASIER1,
10 CODE_EASIER2,
11 CODE_HARDER1,
12 CODE_HARDER2,
13 CODE_NEXT_SORT1,
14 CODE_NEXT_SORT2,
15 CODE_NEXT_SORT3,
16 CODE_NEXT_SORT4,
17 CODE_MODE_MENU1,
18 CODE_MODE_MENU2,
19 CODE_MIRROR,
20 CODE_LEFT,
21 CODE_RIGHT,
22 CODE_SHUFFLE,
23 CODE_SUPER_SHUFFLE,
24 CODE_NEXT_TRANSFORM,
25 CODE_NEXT_SCROLL_SPEED,
26 CODE_PREVIOUS_SCROLL_SPEED,
27 CODE_NEXT_ACCEL,
28 CODE_NEXT_EFFECT,
29 CODE_NEXT_APPEARANCE,
30 CODE_NEXT_TURN,
31 CODE_REVERSE,
32 CODE_HOLDS,
33 CODE_MINES,
34 CODE_DARK,
35 CODE_HIDDEN,
36 CODE_RANDOMVANISH,
37 CODE_CANCEL_ALL,
38 CODE_NEXT_THEME,
39 CODE_NEXT_THEME2,
40 CODE_NEXT_ANNOUNCER,
41 CODE_NEXT_ANNOUNCER2,
42 CODE_NEXT_GAME,
43 CODE_NEXT_GAME2,
44 CODE_BW_NEXT_GROUP,
45 CODE_BW_NEXT_GROUP2,
46 CODE_SAVE_SCREENSHOT1,
47 CODE_SAVE_SCREENSHOT2,
48 CODE_CANCEL_ALL_PLAYER_OPTIONS,
49 CODE_BACK_IN_EVENT_MODE,
50 CODE_OPTIONS_LIST_OPEN1,
51 CODE_OPTIONS_LIST_OPEN2,
52 CODE_LINKED_MENU_SWITCH1,
53 CODE_LINKED_MENU_SWITCH2,
54 NUM_CODES // leave this at the end
55 };
56 #define FOREACH_Code( c ) FOREACH_ENUM( Code, NUM_CODES, c )
57
58 struct CodeItem
59 {
60 public:
61 bool Load( CString sButtonsNames );
62 bool EnteredCode( GameController controller ) const;
63
64 private:
65 vector<GameButton> buttons;
66 enum Type
67 {
68 sequence, // press the buttons in sequence
69 hold_and_press, // hold the first iNumButtons-1 buttons, then press the last
70 tap // press all buttons simultaneously
71 };
72 Type m_Type;
73 float fMaxSecondsBack;
74 };
75
76 class CodeDetector
77 {
78 public:
79 static void RefreshCacheItems( CString sClass="" ); // call this before checking codes, but call infrequently
80 static bool EnteredEasierDifficulty( GameController controller );
81 static bool EnteredHarderDifficulty( GameController controller );
82 static bool EnteredNextSort( GameController controller );
83 static bool EnteredModeMenu( GameController controller );
84 static bool DetectAndAdjustMusicOptions( GameController controller );
85 static bool EnteredCode( GameController controller, Code code );
86 static bool EnteredNextBannerGroup( GameController controller );
87 };
88
89 #endif
90
91 /*
92 * (c) 2001-2004 Chris Danford
93 * All rights reserved.
94 *
95 * Permission is hereby granted, free of charge, to any person obtaining a
96 * copy of this software and associated documentation files (the
97 * "Software"), to deal in the Software without restriction, including
98 * without limitation the rights to use, copy, modify, merge, publish,
99 * distribute, and/or sell copies of the Software, and to permit persons to
100 * whom the Software is furnished to do so, provided that the above
101 * copyright notice(s) and this permission notice appear in all copies of
102 * the Software and that both the above copyright notice(s) and this
103 * permission notice appear in supporting documentation.
104 *
105 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
106 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
107 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
108 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
109 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
110 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
111 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
112 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
113 * PERFORMANCE OF THIS SOFTWARE.
114 */