Add CON_DEBUG level con_printf's for basic events (not EVENT_IDLE or EVENT_DRAW though)

This commit is contained in:
Chris Taylor 2010-12-05 20:33:25 +08:00
parent 82053d1bd8
commit 84bf981a06
8 changed files with 49 additions and 43 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20101205
--------
arch/carbon/messagebox.c, arch/include/window.h, arch/linux/messagebox.c, arch/sdl/key.c, arch/sdl/mouse.c, arch/sdl/window.c, arch/win32/messagebox.c: Add CON_DEBUG level con_printf's for basic events (not EVENT_IDLE or EVENT_DRAW though)
20101204
--------
main/bmread.c, main/piggy.c: When setting a bogus sound in gamedata_read_tbl, don't let piggy_close free it. Fixes freeing of non-malloc'd pointer for PC shareware data

View file

@ -19,7 +19,7 @@
void display_mac_alert(char *message, int error)
{
window *wind;
d_event event = { EVENT_WINDOW_DEACTIVATED };
d_event event;
int fullscreen;
bool osX = FALSE;
uint response;
@ -27,8 +27,7 @@ void display_mac_alert(char *message, int error)
// Handle Descent's windows properly
if ((wind = window_get_front()))
window_send_event(window_get_front(), &event);
event.type = EVENT_WINDOW_ACTIVATED;
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED);
if ((fullscreen = gr_check_fullscreen()))
gr_toggle_fullscreen();
@ -48,14 +47,14 @@ void display_mac_alert(char *message, int error)
text = CFStringCreateWithCString(CFAllocatorGetDefault(), message, kCFStringEncodingMacRoman);
if (!text)
{
if (wind) window_send_event(window_get_front(), &event);
if (wind) WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
return;
}
if (CreateStandardAlert(error ? kAlertStopAlert : kAlertNoteAlert, error ? error_text : text, error ? text : NULL, 0, &alert) != noErr)
{
CFRelease(text);
if (wind) window_send_event(window_get_front(), &event);
if (wind) WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
return;
}
@ -74,8 +73,8 @@ void display_mac_alert(char *message, int error)
StandardAlert(error ? kAlertStopAlert : kAlertNoteAlert, error ? error_text : text, error ? text : NULL, 0, &itemHit);
}
if (wind)
window_send_event(window_get_front(), &event);
if ((wind = window_get_front()))
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
if (!error && fullscreen)
gr_toggle_fullscreen();

View file

@ -13,6 +13,7 @@
#include "event.h"
#include "gr.h"
#include "console.h"
typedef struct window window;
@ -28,4 +29,12 @@ extern void window_set_visible(window *wind, int visible);
extern int window_is_visible(window *wind);
extern grs_canvas *window_get_canvas(window *wind);
extern int window_send_event(window *wind, d_event *event);
#define WINDOW_SEND_EVENT(w, e) \
do { \
con_printf(CON_DEBUG, "Sending event %s to window of dimensions %dx%d\n", #e, window_get_canvas(w)->cv_bitmap.bm_w, window_get_canvas(w)->cv_bitmap.bm_h); \
event.type = e; \
window_send_event(w, &event); \
} while (0)
#endif

View file

@ -12,18 +12,17 @@
void display_linux_alert(char *message, int error)
{
d_event event = { EVENT_WINDOW_DEACTIVATED };
d_event event;
window *wind;
// Handle Descent's windows properly
if ((wind = window_get_front()))
window_send_event(window_get_front(), &event);
event.type = EVENT_WINDOW_ACTIVATED;
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED);
// TODO: insert messagebox code...
if (wind)
window_send_event(window_get_front(), &event);
if ((wind = window_get_front()))
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
}
void msgbox_warning(char *message)

View file

@ -16,6 +16,7 @@
#include "key.h"
#include "timer.h"
#include "window.h"
#include "console.h"
static unsigned char Installed = 0;
@ -435,6 +436,14 @@ void key_handler(SDL_KeyboardEvent *event, fix time)
event.keycode = key_command;
if ((wind = window_get_front()))
{
con_printf(CON_DEBUG, "Sending event EVENT_KEY_COMMAND: %s %s %s %s %s %s\n",
(key_command & KEY_METAED) ? "META" : "",
(key_command & KEY_DEBUGGED) ? "DEBUG" : "",
(key_command & KEY_CTRLED) ? "CTRL" : "",
(key_command & KEY_ALTED) ? "ALT" : "",
(key_command & KEY_SHIFTED) ? "SHIFT" : "",
key_properties[key_command & 0xff].key_text
);
if (!window_send_event(wind, (d_event *)&event))
call_default_handler((d_event *)&event);
}

View file

@ -103,6 +103,8 @@ void mouse_button_handler(SDL_MouseButtonEvent *mbe, fix time)
if ((wind = window_get_front()))
{
con_printf(CON_DEBUG, "Sending event %s, button %d, coords %d,%d,%d\n",
(mbe->state == SDL_PRESSED) ? "EVENT_MOUSE_BUTTON_DOWN" : "EVENT_MOUSE_BUTTON_UP", event.button, Mouse.x, Mouse.y, Mouse.z);
if (!window_send_event(wind, (d_event *)&event))
call_default_handler((d_event *)&event);
}

View file

@ -51,13 +51,9 @@ window *window_create(grs_canvas *src, int x, int y, int w, int h, int (*event_c
wind->next = NULL;
FrontWindow = wind;
if (prev)
{
event.type = EVENT_WINDOW_DEACTIVATED;
window_send_event(prev, &event);
}
WINDOW_SEND_EVENT(prev, EVENT_WINDOW_DEACTIVATED);
event.type = EVENT_WINDOW_ACTIVATED;
window_send_event(wind, &event);
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
return wind;
}
@ -69,20 +65,16 @@ int window_close(window *wind)
int (*w_callback)(window *wind, d_event *event, void *data) = wind->w_callback;
if (wind == window_get_front())
{
event.type = EVENT_WINDOW_DEACTIVATED; // Deactivate first
window_send_event(wind, &event);
}
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED); // Deactivate first
event.type = EVENT_WINDOW_CLOSE;
con_printf(CON_DEBUG, "Sending event EVENT_WINDOW_CLOSE to window of dimensions %dx%d\n",
(wind)->w_canv.cv_bitmap.bm_w, (wind)->w_canv.cv_bitmap.bm_h);
if (window_send_event(wind, &event))
{
// User 'handled' the event, cancelling close
if (wind == window_get_front())
{
event.type = EVENT_WINDOW_ACTIVATED; // Reactivate. May cause flashing of some sort, too bad
window_send_event(wind, &event);
}
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED); // Reactivate. May cause flashing of some sort, too bad
return 0;
}
@ -96,10 +88,7 @@ int window_close(window *wind)
wind->prev->next = wind->next;
if ((prev = window_get_front()))
{
event.type = EVENT_WINDOW_ACTIVATED;
window_send_event(prev, &event);
}
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED); // Reactivate. May cause flashing of some sort, too bad
d_free(wind);
@ -166,11 +155,9 @@ void window_select(window *wind)
if (window_is_visible(wind))
{
event.type = EVENT_WINDOW_DEACTIVATED;
if (prev)
window_send_event(prev, &event);
event.type = EVENT_WINDOW_ACTIVATED;
window_send_event(wind, &event);
WINDOW_SEND_EVENT(prev, EVENT_WINDOW_DEACTIVATED);
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
}
}
@ -184,13 +171,11 @@ void window_set_visible(window *wind, int visible)
if (wind == prev)
return;
event.type = EVENT_WINDOW_DEACTIVATED;
if (prev)
window_send_event(prev, &event);
WINDOW_SEND_EVENT(prev, EVENT_WINDOW_DEACTIVATED);
event.type = EVENT_WINDOW_ACTIVATED;
if (wind)
window_send_event(wind, &event);
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
}
int window_is_visible(window *wind)

View file

@ -13,21 +13,20 @@
void display_win32_alert(char *message, int error)
{
d_event event = { EVENT_WINDOW_DEACTIVATED };
d_event event;
window *wind;
// Handle Descent's windows properly
if ((wind = window_get_front()))
window_send_event(window_get_front(), &event);
event.type = EVENT_WINDOW_ACTIVATED;
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED);
if (gr_check_fullscreen())
gr_toggle_fullscreen();
MessageBox(NULL, message, error?"Sorry, a critical error has occurred.":"Attention!", error?MB_OK|MB_ICONERROR:MB_OK|MB_ICONWARNING);
if (wind)
window_send_event(window_get_front(), &event);
if ((wind = window_get_front()))
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
}
void msgbox_warning(char *message)