@@ -38,7 +38,7 @@ short smoothHiliteGradient(const short currentXValue, const short maxXValue) {
38
38
// Text is white, but can use color escapes.
39
39
// Hovering highlight augments fore and back colors with buttonHoverColor by 20%.
40
40
// Pressed darkens the middle color (or turns it the hover color if the button is black).
41
- void drawButton (brogueButton * button , enum buttonDrawStates highlight , cellDisplayBuffer dbuf [ COLS ][ ROWS ] ) {
41
+ void drawButton (brogueButton * button , enum buttonDrawStates highlight , screenDisplayBuffer * dbuf ) {
42
42
if (!(button -> flags & B_DRAW )) {
43
43
return ;
44
44
}
@@ -114,7 +114,7 @@ void drawButton(brogueButton *button, enum buttonDrawStates highlight, cellDispl
114
114
plotCharToBuffer (displayCharacter , (windowpos ){ button -> x + i , button -> y }, & fColor , & bColor , dbuf );
115
115
if (dbuf ) {
116
116
// Only buffers can have opacity set.
117
- dbuf [button -> x + i ][button -> y ].opacity = opacity ;
117
+ dbuf -> cells [button -> x + i ][button -> y ].opacity = opacity ;
118
118
}
119
119
}
120
120
}
@@ -160,7 +160,7 @@ void drawButtonsInState(buttonState *state) {
160
160
// Draw the buttons to the dbuf:
161
161
for (int i = 0 ; i < state -> buttonCount ; i ++ ) {
162
162
if (state -> buttons [i ].flags & B_DRAW ) {
163
- drawButton (& (state -> buttons [i ]), BUTTON_NORMAL , state -> dbuf );
163
+ drawButton (& (state -> buttons [i ]), BUTTON_NORMAL , & state -> dbuf );
164
164
}
165
165
}
166
166
}
@@ -182,15 +182,15 @@ void initializeButtonState(buttonState *state,
182
182
for (int i = 0 ; i < state -> buttonCount ; i ++ ) {
183
183
state -> buttons [i ] = buttons [i ];
184
184
}
185
- copyDisplayBuffer (state -> rbuf , displayBuffer );
186
- clearDisplayBuffer (state -> dbuf );
185
+ copyDisplayBuffer (& state -> rbuf , & displayBuffer );
186
+ clearDisplayBuffer (& state -> dbuf );
187
187
188
188
drawButtonsInState (state );
189
189
190
190
// Clear the rbuf so that it resets only those parts of the screen in which buttons are drawn in the first place:
191
191
for (int i = 0 ; i < COLS ; i ++ ) {
192
192
for (int j = 0 ; j < ROWS ; j ++ ) {
193
- state -> rbuf [i ][j ].opacity = (state -> dbuf [i ][j ].opacity ? 100 : 0 );
193
+ state -> rbuf . cells [i ][j ].opacity = (state -> dbuf . cells [i ][j ].opacity ? 100 : 0 );
194
194
}
195
195
}
196
196
}
@@ -216,7 +216,7 @@ short processButtonInput(buttonState *state, boolean *canceled, rogueEvent *even
216
216
217
217
// Revert the button with old focus, if any.
218
218
if (state -> buttonFocused >= 0 ) {
219
- drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_NORMAL , state -> dbuf );
219
+ drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_NORMAL , & state -> dbuf );
220
220
state -> buttonFocused = -1 ;
221
221
}
222
222
@@ -242,11 +242,11 @@ short processButtonInput(buttonState *state, boolean *canceled, rogueEvent *even
242
242
243
243
if (state -> buttonDepressed >= 0 ) {
244
244
if (state -> buttonDepressed == state -> buttonFocused ) {
245
- drawButton (& (state -> buttons [state -> buttonDepressed ]), BUTTON_PRESSED , state -> dbuf );
245
+ drawButton (& (state -> buttons [state -> buttonDepressed ]), BUTTON_PRESSED , & state -> dbuf );
246
246
}
247
247
} else if (state -> buttonFocused >= 0 ) {
248
248
// If no button is depressed, then update the appearance of the button with the new focus, if any.
249
- drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_HOVER , state -> dbuf );
249
+ drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_HOVER , & state -> dbuf );
250
250
}
251
251
252
252
// Mouseup:
@@ -257,7 +257,7 @@ short processButtonInput(buttonState *state, boolean *canceled, rogueEvent *even
257
257
} else {
258
258
// Otherwise, no button is depressed. If one was previously depressed, redraw it.
259
259
if (state -> buttonDepressed >= 0 ) {
260
- drawButton (& (state -> buttons [state -> buttonDepressed ]), BUTTON_NORMAL , state -> dbuf );
260
+ drawButton (& (state -> buttons [state -> buttonDepressed ]), BUTTON_NORMAL , & state -> dbuf );
261
261
} else if (!(x >= state -> winX && x < state -> winX + state -> winWidth
262
262
&& y >= state -> winY && y < state -> winY + state -> winHeight )) {
263
263
// Clicking outside of a button means canceling.
@@ -268,7 +268,7 @@ short processButtonInput(buttonState *state, boolean *canceled, rogueEvent *even
268
268
269
269
if (state -> buttonFocused >= 0 ) {
270
270
// Buttons don't hover-highlight when one is depressed, so we have to fix that when the mouse is up.
271
- drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_HOVER , state -> dbuf );
271
+ drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_HOVER , & state -> dbuf );
272
272
}
273
273
state -> buttonDepressed = -1 ;
274
274
}
@@ -287,20 +287,20 @@ short processButtonInput(buttonState *state, boolean *canceled, rogueEvent *even
287
287
if (state -> buttons [i ].flags & B_DRAW ) {
288
288
// Restore the depressed and focused buttons.
289
289
if (state -> buttonDepressed >= 0 ) {
290
- drawButton (& (state -> buttons [state -> buttonDepressed ]), BUTTON_NORMAL , state -> dbuf );
290
+ drawButton (& (state -> buttons [state -> buttonDepressed ]), BUTTON_NORMAL , & state -> dbuf );
291
291
}
292
292
if (state -> buttonFocused >= 0 ) {
293
- drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_NORMAL , state -> dbuf );
293
+ drawButton (& (state -> buttons [state -> buttonFocused ]), BUTTON_NORMAL , & state -> dbuf );
294
294
}
295
295
296
296
// If the button likes to flash when keypressed:
297
297
if (state -> buttons [i ].flags & B_KEYPRESS_HIGHLIGHT ) {
298
298
// Depress the chosen button.
299
- drawButton (& (state -> buttons [i ]), BUTTON_PRESSED , state -> dbuf );
299
+ drawButton (& (state -> buttons [i ]), BUTTON_PRESSED , & state -> dbuf );
300
300
301
301
// Update the display.
302
- overlayDisplayBuffer (state -> rbuf , NULL );
303
- overlayDisplayBuffer (state -> dbuf , NULL );
302
+ overlayDisplayBuffer (& state -> rbuf , NULL );
303
+ overlayDisplayBuffer (& state -> dbuf , NULL );
304
304
305
305
if (!rogue .playbackMode || rogue .playbackPaused ) {
306
306
// Wait for a little; then we're done.
@@ -359,7 +359,7 @@ short buttonInputLoop(brogueButton *buttons,
359
359
360
360
do {
361
361
// Update the display.
362
- overlayDisplayBuffer (state .dbuf , NULL );
362
+ overlayDisplayBuffer (& state .dbuf , NULL );
363
363
364
364
// Get input.
365
365
nextBrogueEvent (& theEvent , true, false, false);
@@ -368,7 +368,7 @@ short buttonInputLoop(brogueButton *buttons,
368
368
button = processButtonInput (& state , & canceled , & theEvent );
369
369
370
370
// Revert the display.
371
- overlayDisplayBuffer (state .rbuf , NULL );
371
+ overlayDisplayBuffer (& state .rbuf , NULL );
372
372
373
373
} while (button == -1 && !canceled );
374
374
0 commit comments