root/trunk/src/osx/osx_tables.h

Revision 958, 6.8 kB (checked in by takkaria, 6 months ago)

A bunch of fixes by Rowan Beentje:

  • Remove the now useless arg_fiddle, as discussed in #angband-dev
  • Remove arg_sound (no longer used)

OS X only:

  • Removes the Fiddle and (non-functional) Wizard mode and non-[V] 54x54 graphics tile menu entries.
  • Removal of more unused/disabled menu items: Page Setup and Print, and the Edit menu.
  • Corrects the Sound menu entry to update use_sound instead of the old arg_sound.
  • Final mac cleanup as part of r538, replacing game_in_progress with cmd.command checks.
  • Reshuffle of Open Recent menu redraw into a function with far fewer calls, add comment to validate_menus() to indicate it is called on every use of the menubar.
  • Complete rewrite of the sound code. Add support for the sound.cfg file, and at the same time replace the Carbon SoundManager? code with Cocoa NSSound-based code.
  • Cleanup of event handler definitions in osx-tables.h (just to make my life easier tying to track down: )
  • Fix to unhiding application being broken on some Intel machines. I believe the functions intended to flush input events were flushing setup/update events.
  • (#511) Fix to unhiding application not refreshing all windows
  • Improvement to release build rules to build a 20% smaller compressed file.
Line 
1 /*
2  * Maximum menu ID.
3  * IMPORTANT: see note in main-crb.c if you wish to add menus.
4  */
5 #ifndef INCLUDED_OSX_TABLES_H
6 #define INCLUDED_OSX_TABLES_H
7
8 #define MAX_MENU_ID (150)
9
10 /* These numbers must agree with the corresponding Menu ID in the nib. */
11 enum MenuID {
12         kAngbandMenu    = 100,
13         kFileMenu               = 101,
14         kEditMenu               = 102,
15         kStyleMenu              = 103,
16         /* deleted */
17         kWindowMenu             = 105,
18         kSpecialMenu    = 106,
19
20         kTileWidMenu    = 107,
21         kTileHgtMenu    = 108,
22        
23         kOpenRecentMenu = 109
24 };
25
26 // Edit menu
27 enum {
28         kCopy                   = 1,    /* C, 'copy' */
29         kSelectAll              = 2,    /* A, 'sall' */
30         kUndo                   = 3             /* Z, 'undo' */
31 };
32
33 // File Menu
34 enum {
35         kNew                    = 1,    /* N, 'new' */
36         kOpen                   = 2,    /* O, 'open' */
37         kOpenRecent             = 3,
38         kImport                 = 4,    /* I, 'impo' */
39         /* \-p */
40         kSave                   = 6,    /* S, 'save' */
41         kClose                  = 7,    /* W, 'clos' */
42         /* \-p
43          setup
44           print
45          \-p */
46 };
47
48
49 // Window menu
50 enum {
51         kMinimize                       = 1, /* Not used */
52         kMinimizeAll            = 2, /* Not used */
53         kAngbandTerm            = 4,
54         kTerminal1                      = 5,  /* Terminal ids are relative to Terminal 1 */
55         /* ... */
56         kBringToFront           = 13
57 };
58
59 // Special Menu
60 enum {
61         kSound                          = 1, /* Toggle sound */
62 };
63
64
65
66 // Styles menu
67 enum {
68         kFonts                          = 1,
69         kAntialias                      = 2,
70         kGrafNone                       = 4,
71         kGraf8x8                        = 5,
72         kGraf16x16                      = 6,
73         kGraf32x32                      = 7,
74         kInterpolate            = 9,
75         kBigTile                        = 10,
76         kTileWidth                      = 11,
77         kTileHeight                     = 12,
78 };
79
80
81 enum {
82         // Event target are windows, not a menu.
83         kWINDOW = -1
84 };
85
86
87 /* References to HIViews in the dialog window */
88 static const HIViewID aboutDialogIcon = { 'DLOG', 1 };
89 static const HIViewID aboutDialogName = { 'DLOG', 2 };
90 static const HIViewID aboutDialogCopyright = { 'DLOG', 4 };
91
92
93 /* Specifications for graphics modes.  */
94 /* graf_mode variable is index of current mode */
95 static const struct {
96         int menuItem;           // Index in Graphics Menu
97         cptr file;                      // Base name of png file (if any)
98         cptr name;                      // Value of ANGBAND_GRAF variable
99         int size;                       // Tile size (in pixels)
100         bool trans;                     // Use transparent foreground tiles
101 } graphics_modes [] = {
102         { kGrafNone,    NULL,           NULL,           0,                      false },
103         { kGraf8x8,             "8x8",          "old",          8,                      false },
104         { kGraf16x16,   "16x16",        "new",          16,                     true },
105         { kGraf32x32,   "32x32",        "david",        32,                     true },
106 };
107
108
109 /* Event handler specification */
110 struct CommandDef {
111         int                             evtClass; // Eventspec class - char-style constant eg 'quit'
112         int                             evtType;  // Eventspec type - enumeration
113         EventHandlerUPP handler;
114         UInt32                  targetID; // Menu target (0 if no target)
115         void              * userData; // Event user data (Not used currently)
116 };
117 typedef struct CommandDef CommandDef;
118
119
120 #define HANDLERDEF(func) \
121                 static OSStatus func(EventHandlerCallRef inHandlerCallRef, \
122                                                          EventRef inEvent, \
123                                                      void * inUserData )
124
125 HANDLERDEF(CloseCommand);
126 HANDLERDEF(QuitCommand);
127 HANDLERDEF(TileSizeCommand);
128 HANDLERDEF(FontCommand);
129 HANDLERDEF(RestoreCommand);
130 HANDLERDEF(ToggleCommand);
131 HANDLERDEF(TerminalCommand);
132 HANDLERDEF(GraphicsCommand);
133 HANDLERDEF(KeyboardCommand);
134 HANDLERDEF(MouseCommand);
135 HANDLERDEF(ResizeCommand);
136 HANDLERDEF(UpdateCommand);
137 HANDLERDEF(AboutCommand);
138 HANDLERDEF(ValidateMenuCommand);
139 HANDLERDEF(OpenRecentCommand);
140 HANDLERDEF(ResumeCommand);
141 HANDLERDEF(CommandCommand);
142 HANDLERDEF(AngbandGame);
143 HANDLERDEF(SoundCommand);
144
145
146
147
148 /* WARNING: This list must be grouped by (func, userData) pairs */
149
150 const CommandDef event_defs [] =
151 {
152
153         /*
154          * Start game event - posted into the event queue after
155          * any potential open game events from the Finder
156          */
157         { 'Play', 'Band', AngbandGame, 0, NULL },
158
159
160
161         /* Quit the game */
162         { 'appl', kEventAppQuit, QuitCommand, 0, NULL },
163        
164         /* Reactivate the game after it's been in the background */
165         { 'appl', kEventAppActivated, ResumeCommand, 0, NULL },
166
167
168
169         /* "About Angband" command */
170         { 'cmds', kEventProcessCommand, AboutCommand, kAngbandMenu, NULL },
171
172         /* Execute "boring" commands - "Save", "Open", and "Show Fonts" */
173         { 'cmds', kEventProcessCommand, CommandCommand, 0, NULL },
174        
175         /* Menu item within the "Open Recent" submenu */
176         { 'cmds', kEventProcessCommand, OpenRecentCommand, kOpenRecentMenu, NULL },
177        
178         /* Selection of a terminal within the Window menu */
179         { 'cmds', kEventProcessCommand, TerminalCommand, kWindowMenu, NULL },
180        
181         /* Toggling a menu option - bigtile, interpolate, antialias */
182         { 'cmds', kEventProcessCommand, ToggleCommand, kSpecialMenu, NULL },
183         { 'cmds', kEventProcessCommand, ToggleCommand, kStyleMenu, NULL },
184
185         /* "Use Sound" command */
186         { 'cmds', kEventProcessCommand, SoundCommand, kSpecialMenu, NULL},
187
188         /* Alter tile width and height */
189         { 'cmds', kEventProcessCommand, TileSizeCommand, kTileWidMenu, NULL },
190         { 'cmds', kEventProcessCommand, TileSizeCommand, kTileHgtMenu, NULL },
191
192         /* Switch between graphics modes */
193         { 'cmds', kEventProcessCommand, GraphicsCommand, kStyleMenu, NULL },
194
195
196
197         /* Font panel - selection of a new font */
198         { 'font', kEventFontSelection, FontCommand, 0, NULL },
199        
200         /* Font panel closed */
201         { 'font', kEventFontPanelClosed, FontCommand, 0, NULL },
202        
203         /* Application window focus changes (update font focus status) */
204         { 'appl', kEventAppActiveWindowChanged, FontCommand, 0, NULL },
205
206
207
208         /* Update seldom-changed menu item statuses on each menu open */
209         { 'menu', kEventMenuEnableItems, ValidateMenuCommand, 0, NULL },
210
211
212
213         /* Keyboard keydown event */
214         { 'keyb', kEventRawKeyDown, KeyboardCommand, 0, NULL },
215        
216         /* Keyboard key repeat event */
217         { 'keyb', kEventRawKeyRepeat, KeyboardCommand, 0, NULL },
218        
219         /* Mouse click in a term */
220         { 'wind', kEventWindowHandleContentClick, MouseCommand, kWINDOW, NULL },
221
222
223
224         /* Close a term */
225         { 'wind', kEventWindowClose, CloseCommand, kWINDOW, NULL },
226        
227         /* Activate a term (term brought to front) */
228         { 'wind', kEventWindowActivated, RestoreCommand, kWINDOW, NULL },
229        
230         /* A term requires redrawing */
231         { 'wind', kEventWindowUpdate, UpdateCommand, kWINDOW, NULL },
232
233         /* Resize and move of a term, update term positions and sizes */
234         { 'wind', kEventWindowResizeCompleted, ResizeCommand, kWINDOW, NULL },
235         { 'wind', kEventWindowDragCompleted, ResizeCommand, kWINDOW, NULL },
236 };
237
238
239
240 /*
241  * Construct a list of events that should be flushed in order to flush input
242  */
243 static EventTypeSpec input_event_types[] = {
244         { 'keyb', kEventRawKeyDown },
245         { 'keyb', kEventRawKeyRepeat },
246         { 'wind', kEventWindowHandleContentClick },
247 };
248
249 /*
250  * Interpolate images when rescaling them
251  */
252 static bool interpolate = 0;
253
254 /*
255  * Use antialiasing.  Without image differencing from
256  * OSX  10.4 features, you won't want to use this.
257  */
258
259 static bool antialias = 0;
260
261 static struct {
262         bool *var;                              // Value to toggle (*var = !*var)
263         int menuID;                             // Menu for this action (MenuRef would be better)
264         int menuItem;                   // Index of menu item for this acton
265         bool refresh;                   // Change requires graphics refresh of main window.
266 } toggle_defs [] = {
267         { &use_bigtile, kStyleMenu,  kBigTile,  true},
268         { &interpolate, kStyleMenu,  kInterpolate, true},
269         { &antialias,   kStyleMenu,     kAntialias,     true}
270 };
271
272 #endif /* !INCLUDED_OSX_TABLES_H */
Note: See TracBrowser for help on using the browser.