2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
2010-12-24 04:34:30 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Windowing functions and controller.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
2010-12-22 14:14:46 +00:00
|
|
|
|
|
|
|
#include "window.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "u_mem.h"
|
2012-07-01 02:54:33 +00:00
|
|
|
#include "maths.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "pstypes.h"
|
|
|
|
#include "gr.h"
|
|
|
|
#include "ui.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "mouse.h"
|
2010-12-24 04:34:30 +00:00
|
|
|
#include "timer.h"
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-09-07 18:06:09 +00:00
|
|
|
#include "compiler-make_unique.h"
|
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
#define D_X (dlg->x)
|
|
|
|
#define D_Y (dlg->y)
|
|
|
|
#define D_WIDTH (dlg->width)
|
|
|
|
#define D_HEIGHT (dlg->height)
|
|
|
|
#define D_GADGET (dlg->gadget)
|
|
|
|
#define D_TEXT_X (dlg->text_x)
|
|
|
|
#define D_TEXT_Y (dlg->text_y)
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2010-12-24 04:34:30 +00:00
|
|
|
#ifndef __MSDOS__
|
|
|
|
#define _disable()
|
|
|
|
#define _enable()
|
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
#define BORDER_WIDTH 8
|
|
|
|
|
|
|
|
static unsigned int FrameCount = 0;
|
|
|
|
unsigned int ui_event_counter = 0;
|
|
|
|
unsigned int ui_number_of_events = 0;
|
|
|
|
static UI_EVENT * EventBuffer = NULL;
|
|
|
|
static int Record = 0;
|
|
|
|
static int RecordFlags = 0;
|
|
|
|
|
2015-04-19 04:18:49 +00:00
|
|
|
static array<uint8_t, 256> SavedState;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
static int PlaybackSpeed = 1;
|
|
|
|
|
|
|
|
// 1=1x faster, 2=2x faster, etc
|
|
|
|
void ui_set_playback_speed( int speed )
|
|
|
|
{
|
|
|
|
PlaybackSpeed = speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ui_record_events( int NumberOfEvents, UI_EVENT * buffer, int Flags )
|
|
|
|
{
|
|
|
|
if ( Record > 0 || buffer==NULL ) return 1;
|
|
|
|
|
|
|
|
RecordFlags = Flags;
|
|
|
|
EventBuffer = buffer;
|
|
|
|
ui_event_counter = 0;
|
|
|
|
FrameCount = 0;
|
|
|
|
ui_number_of_events = NumberOfEvents;
|
|
|
|
Record = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ui_play_events_realtime( int NumberOfEvents, UI_EVENT * buffer )
|
|
|
|
{ int i;
|
|
|
|
if ( buffer == NULL ) return 1;
|
|
|
|
|
|
|
|
EventBuffer = buffer;
|
|
|
|
FrameCount = 0;
|
|
|
|
ui_event_counter = 0;
|
|
|
|
ui_number_of_events = NumberOfEvents;
|
|
|
|
Record = 2;
|
|
|
|
_disable();
|
|
|
|
keyd_last_released= 0;
|
|
|
|
keyd_last_pressed= 0;
|
|
|
|
for (i=0; i<256; i++ )
|
|
|
|
SavedState[i] = keyd_pressed[i];
|
|
|
|
_enable();
|
|
|
|
key_flush();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ui_play_events_fast( int NumberOfEvents, UI_EVENT * buffer )
|
|
|
|
{
|
|
|
|
if ( buffer == NULL ) return 1;
|
|
|
|
|
|
|
|
EventBuffer = buffer;
|
|
|
|
FrameCount = 0;
|
|
|
|
ui_event_counter = 0;
|
|
|
|
ui_number_of_events = NumberOfEvents;
|
|
|
|
Record = 3;
|
|
|
|
_disable();
|
|
|
|
keyd_last_released= 0;
|
|
|
|
keyd_last_pressed= 0;
|
|
|
|
|
2014-09-26 02:42:15 +00:00
|
|
|
for (int i=0; i<256; i++ )
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
SavedState[i] = keyd_pressed[i];
|
|
|
|
}
|
|
|
|
_enable();
|
|
|
|
key_flush();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns: 0=Normal, 1=Recording, 2=Playback normal, 3=Playback fast
|
|
|
|
int ui_recorder_status()
|
|
|
|
{
|
|
|
|
return Record;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void ui_dialog_draw(UI_DIALOG *dlg)
|
2011-01-17 14:42:18 +00:00
|
|
|
{
|
2012-03-31 10:36:07 +00:00
|
|
|
int x, y, w, h;
|
|
|
|
int req_w, req_h;
|
|
|
|
|
|
|
|
x = D_X;
|
|
|
|
y = D_Y;
|
|
|
|
w = D_WIDTH;
|
|
|
|
h = D_HEIGHT;
|
|
|
|
|
2012-04-09 09:30:40 +00:00
|
|
|
req_w = w;
|
|
|
|
req_h = h;
|
2012-03-31 10:36:07 +00:00
|
|
|
|
|
|
|
if (dlg->flags & DF_BORDER)
|
|
|
|
{
|
2012-04-09 09:30:40 +00:00
|
|
|
req_w -= 2*BORDER_WIDTH;
|
|
|
|
req_h -= 2*BORDER_WIDTH;
|
|
|
|
|
2012-03-31 10:36:07 +00:00
|
|
|
gr_set_current_canvas( NULL );
|
|
|
|
ui_draw_frame( x, y, x+w-1, y+h-1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_dialog_set_current_canvas(dlg);
|
|
|
|
|
|
|
|
if (dlg->flags & DF_FILLED)
|
|
|
|
ui_draw_box_out( 0, 0, req_w-1, req_h-1 );
|
|
|
|
|
|
|
|
gr_set_fontcolor( CBLACK, CWHITE );
|
|
|
|
|
|
|
|
D_TEXT_X = 0;
|
|
|
|
D_TEXT_Y = 0;
|
2011-01-17 14:42:18 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
// The dialog handler borrows heavily from the newmenu_handler
|
2014-10-04 21:47:13 +00:00
|
|
|
static window_event_result ui_dialog_handler(window *wind,const d_event &event, UI_DIALOG *dlg)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_WINDOW_CLOSED ||
|
|
|
|
event.type == EVENT_WINDOW_ACTIVATED ||
|
|
|
|
event.type == EVENT_WINDOW_DEACTIVATED)
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::ignored;
|
2011-10-09 12:31:39 +00:00
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
if (dlg->callback)
|
|
|
|
if ((*dlg->callback)(dlg, event, dlg->userdata))
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::handled; // event handled
|
2012-03-18 10:03:29 +00:00
|
|
|
|
|
|
|
if (!window_exists(wind))
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::handled;
|
2011-01-17 14:42:18 +00:00
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
switch (event.type)
|
2011-01-17 14:42:18 +00:00
|
|
|
{
|
|
|
|
case EVENT_MOUSE_BUTTON_DOWN:
|
|
|
|
case EVENT_MOUSE_BUTTON_UP:
|
2011-11-06 03:06:38 +00:00
|
|
|
case EVENT_MOUSE_MOVED:
|
2011-10-30 11:09:11 +00:00
|
|
|
/*return*/ ui_dialog_do_gadgets(dlg, event);
|
2012-03-17 09:39:24 +00:00
|
|
|
if (!window_exists(wind))
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::handled;
|
|
|
|
return mouse_in_window(dlg->wind);
|
2011-01-17 14:42:18 +00:00
|
|
|
case EVENT_KEY_COMMAND:
|
2011-11-05 09:08:17 +00:00
|
|
|
case EVENT_KEY_RELEASE:
|
2014-08-06 02:10:49 +00:00
|
|
|
return ui_dialog_do_gadgets(dlg, event);
|
2011-01-17 14:42:18 +00:00
|
|
|
case EVENT_IDLE:
|
|
|
|
timer_delay2(50);
|
2014-08-06 02:10:49 +00:00
|
|
|
return ui_dialog_do_gadgets(dlg, event);
|
2011-01-17 14:42:18 +00:00
|
|
|
case EVENT_WINDOW_DRAW:
|
2012-03-24 09:19:30 +00:00
|
|
|
{
|
2012-03-31 10:36:07 +00:00
|
|
|
ui_dialog_draw(dlg);
|
2014-08-06 02:10:49 +00:00
|
|
|
window_event_result rval = ui_dialog_do_gadgets(dlg, event);
|
|
|
|
if (rval != window_event_result::close)
|
2014-10-04 21:47:13 +00:00
|
|
|
{
|
|
|
|
d_event event2 = { EVENT_UI_DIALOG_DRAW };
|
2015-01-17 18:31:40 +00:00
|
|
|
window_send_event(*wind, event2);
|
2014-10-04 21:47:13 +00:00
|
|
|
}
|
2014-08-06 02:10:49 +00:00
|
|
|
return rval;
|
2012-03-24 09:19:30 +00:00
|
|
|
}
|
2011-01-17 14:42:18 +00:00
|
|
|
|
|
|
|
case EVENT_WINDOW_CLOSE:
|
2012-04-09 12:41:47 +00:00
|
|
|
ui_gadget_delete_all(dlg);
|
|
|
|
selected_gadget = NULL;
|
2014-09-07 18:06:09 +00:00
|
|
|
delete dlg;
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::ignored;
|
2011-01-17 14:42:18 +00:00
|
|
|
default:
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::ignored;
|
2011-01-17 14:42:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 02:36:52 +00:00
|
|
|
UI_DIALOG *untyped_ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, ui_subfunction_t<void>::type callback, void *userdata, const void *createdata)
|
2011-01-17 14:42:18 +00:00
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
int sw, sh, req_w, req_h;
|
|
|
|
|
2014-09-07 18:06:09 +00:00
|
|
|
auto dlg = make_unique<UI_DIALOG>();
|
2015-03-22 18:49:21 +00:00
|
|
|
sw = grd_curscreen->get_screen_width();
|
|
|
|
sh = grd_curscreen->get_screen_height();
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//mouse_set_limits(0, 0, sw - 1, sh - 1);
|
|
|
|
|
|
|
|
req_w = w;
|
|
|
|
req_h = h;
|
2011-10-09 10:32:53 +00:00
|
|
|
|
|
|
|
dlg->flags = flags;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
if (flags & DF_BORDER)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
x -= BORDER_WIDTH;
|
|
|
|
y -= BORDER_WIDTH;
|
|
|
|
w += 2*BORDER_WIDTH;
|
|
|
|
h += 2*BORDER_WIDTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( x < 0 ) x = 0;
|
|
|
|
if ( (x+w-1) >= sw ) x = sw - w;
|
|
|
|
if ( y < 0 ) y = 0;
|
|
|
|
if ( (y+h-1) >= sh ) y = sh - h;
|
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
D_X = x;
|
|
|
|
D_Y = y;
|
|
|
|
D_WIDTH = w;
|
|
|
|
D_HEIGHT = h;
|
|
|
|
D_GADGET = NULL;
|
|
|
|
dlg->keyboard_focus_gadget = NULL;
|
2012-04-09 12:41:47 +00:00
|
|
|
selected_gadget = NULL;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
dlg->callback = callback;
|
|
|
|
dlg->userdata = userdata;
|
|
|
|
dlg->wind = window_create(&grd_curscreen->sc_canvas,
|
|
|
|
x + ((flags & DF_BORDER) ? BORDER_WIDTH : 0),
|
|
|
|
y + ((flags & DF_BORDER) ? BORDER_WIDTH : 0),
|
2014-12-20 04:36:09 +00:00
|
|
|
req_w, req_h, ui_dialog_handler, dlg.get(), createdata);
|
2011-12-18 12:41:31 +00:00
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
if (!dlg->wind)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2011-10-09 10:32:53 +00:00
|
|
|
if (!(flags & DF_MODAL))
|
|
|
|
window_set_modal(dlg->wind, 0); // make this window modeless, allowing events to propogate through the window stack
|
2014-09-07 18:06:09 +00:00
|
|
|
return dlg.release();
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 12:41:31 +00:00
|
|
|
window *ui_dialog_get_window(UI_DIALOG *dlg)
|
|
|
|
{
|
|
|
|
return dlg->wind;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_dialog_set_current_canvas(UI_DIALOG *dlg)
|
|
|
|
{
|
2015-01-17 18:31:40 +00:00
|
|
|
gr_set_current_canvas(window_get_canvas(*dlg->wind));
|
2011-12-18 12:41:31 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
void ui_close_dialog( UI_DIALOG * dlg )
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2012-04-09 12:41:47 +00:00
|
|
|
window_close(dlg->wind);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2012-11-11 19:22:51 +00:00
|
|
|
#if 0
|
2006-03-20 17:12:09 +00:00
|
|
|
void restore_state()
|
|
|
|
{
|
|
|
|
_disable();
|
2014-09-26 02:42:15 +00:00
|
|
|
for (int i=0; i<256; i++ )
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
keyd_pressed[i] = SavedState[i];
|
|
|
|
}
|
|
|
|
_enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ui_mega_process()
|
|
|
|
{
|
2007-05-21 10:55:43 +00:00
|
|
|
int mx, my, mz;
|
2006-03-20 17:12:09 +00:00
|
|
|
unsigned char k;
|
|
|
|
|
2010-12-22 14:14:46 +00:00
|
|
|
event_process();
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
switch( Record )
|
|
|
|
{
|
|
|
|
case 0:
|
2007-05-21 10:55:43 +00:00
|
|
|
mouse_get_delta( &mx, &my, &mz );
|
2006-03-20 17:12:09 +00:00
|
|
|
Mouse.new_dx = mx;
|
|
|
|
Mouse.new_dy = my;
|
|
|
|
Mouse.new_buttons = mouse_get_btns();
|
|
|
|
last_keypress = key_inkey();
|
|
|
|
|
|
|
|
if ( Mouse.new_buttons || last_keypress || Mouse.new_dx || Mouse.new_dy ) {
|
2010-12-10 23:18:17 +00:00
|
|
|
last_event = timer_query();
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
if (ui_event_counter==0 )
|
|
|
|
{
|
|
|
|
EventBuffer[ui_event_counter].frame = 0;
|
|
|
|
EventBuffer[ui_event_counter].type = 7;
|
|
|
|
EventBuffer[ui_event_counter].data = ui_number_of_events;
|
|
|
|
ui_event_counter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ui_event_counter==1 && (RecordFlags & UI_RECORD_MOUSE) )
|
|
|
|
{
|
|
|
|
Mouse.new_buttons = 0;
|
|
|
|
EventBuffer[ui_event_counter].frame = FrameCount;
|
|
|
|
EventBuffer[ui_event_counter].type = 6;
|
|
|
|
EventBuffer[ui_event_counter].data = ((Mouse.y & 0xFFFF) << 16) | (Mouse.x & 0xFFFF);
|
|
|
|
ui_event_counter++;
|
|
|
|
}
|
|
|
|
|
2007-05-21 10:55:43 +00:00
|
|
|
mouse_get_delta( &mx, &my, &mz );
|
2006-03-20 17:12:09 +00:00
|
|
|
MouseDX = mx;
|
|
|
|
MouseDY = my;
|
|
|
|
MouseButtons = mouse_get_btns();
|
|
|
|
|
|
|
|
Mouse.new_dx = MouseDX;
|
|
|
|
Mouse.new_dy = MouseDY;
|
|
|
|
|
|
|
|
if ((MouseDX != 0 || MouseDY != 0) && (RecordFlags & UI_RECORD_MOUSE) )
|
|
|
|
{
|
|
|
|
if (ui_event_counter < ui_number_of_events-1 )
|
|
|
|
{
|
|
|
|
EventBuffer[ui_event_counter].frame = FrameCount;
|
|
|
|
EventBuffer[ui_event_counter].type = 1;
|
|
|
|
EventBuffer[ui_event_counter].data = ((MouseDY & 0xFFFF) << 16) | (MouseDX & 0xFFFF);
|
|
|
|
ui_event_counter++;
|
|
|
|
} else {
|
|
|
|
Record = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (MouseButtons != Mouse.new_buttons) && (RecordFlags & UI_RECORD_MOUSE) )
|
|
|
|
{
|
|
|
|
Mouse.new_buttons = MouseButtons;
|
|
|
|
|
|
|
|
if (ui_event_counter < ui_number_of_events-1 )
|
|
|
|
{
|
|
|
|
EventBuffer[ui_event_counter].frame = FrameCount;
|
|
|
|
EventBuffer[ui_event_counter].type = 2;
|
|
|
|
EventBuffer[ui_event_counter].data = MouseButtons;
|
|
|
|
ui_event_counter++;
|
|
|
|
} else {
|
|
|
|
Record = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( keyd_last_pressed && (RecordFlags & UI_RECORD_KEYS) )
|
|
|
|
{
|
|
|
|
_disable();
|
|
|
|
k = keyd_last_pressed;
|
|
|
|
keyd_last_pressed= 0;
|
|
|
|
_enable();
|
|
|
|
|
|
|
|
if (ui_event_counter < ui_number_of_events-1 )
|
|
|
|
{
|
|
|
|
EventBuffer[ui_event_counter].frame = FrameCount;
|
|
|
|
EventBuffer[ui_event_counter].type = 3;
|
|
|
|
EventBuffer[ui_event_counter].data = k;
|
|
|
|
ui_event_counter++;
|
|
|
|
} else {
|
|
|
|
Record = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( keyd_last_released && (RecordFlags & UI_RECORD_KEYS) )
|
|
|
|
{
|
|
|
|
_disable();
|
|
|
|
k = keyd_last_released;
|
|
|
|
keyd_last_released= 0;
|
|
|
|
_enable();
|
|
|
|
|
|
|
|
if (ui_event_counter < ui_number_of_events-1 )
|
|
|
|
{
|
|
|
|
EventBuffer[ui_event_counter].frame = FrameCount;
|
|
|
|
EventBuffer[ui_event_counter].type = 4;
|
|
|
|
EventBuffer[ui_event_counter].data = k;
|
|
|
|
ui_event_counter++;
|
|
|
|
} else {
|
|
|
|
Record = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
last_keypress = key_inkey();
|
|
|
|
|
|
|
|
if (last_keypress == KEY_F12 )
|
|
|
|
{
|
|
|
|
ui_number_of_events = ui_event_counter;
|
|
|
|
last_keypress = 0;
|
|
|
|
Record = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((last_keypress != 0) && (RecordFlags & UI_RECORD_KEYS) )
|
|
|
|
{
|
|
|
|
if (ui_event_counter < ui_number_of_events-1 )
|
|
|
|
{
|
|
|
|
EventBuffer[ui_event_counter].frame = FrameCount;
|
|
|
|
EventBuffer[ui_event_counter].type = 5;
|
|
|
|
EventBuffer[ui_event_counter].data = last_keypress;
|
|
|
|
ui_event_counter++;
|
|
|
|
} else {
|
|
|
|
Record = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameCount++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
Mouse.new_dx = 0;
|
|
|
|
Mouse.new_dy = 0;
|
|
|
|
Mouse.new_buttons = 0;
|
|
|
|
last_keypress = 0;
|
|
|
|
|
|
|
|
if ( keyd_last_pressed ) {
|
|
|
|
_disable();
|
|
|
|
k = keyd_last_pressed;
|
|
|
|
keyd_last_pressed = 0;
|
|
|
|
_disable();
|
|
|
|
SavedState[k] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( keyd_last_released )
|
|
|
|
{
|
|
|
|
_disable();
|
|
|
|
k = keyd_last_released;
|
|
|
|
keyd_last_released = 0;
|
|
|
|
_disable();
|
|
|
|
SavedState[k] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_inkey() == KEY_F12 )
|
|
|
|
{
|
|
|
|
restore_state();
|
|
|
|
Record = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EventBuffer==NULL) {
|
|
|
|
restore_state();
|
|
|
|
Record = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( (ui_event_counter < ui_number_of_events) && (EventBuffer[ui_event_counter].frame <= FrameCount) )
|
|
|
|
{
|
|
|
|
switch ( EventBuffer[ui_event_counter].type )
|
|
|
|
{
|
|
|
|
case 1: // Mouse moved
|
|
|
|
Mouse.new_dx = EventBuffer[ui_event_counter].data & 0xFFFF;
|
|
|
|
Mouse.new_dy = (EventBuffer[ui_event_counter].data >> 16) & 0xFFFF;
|
|
|
|
break;
|
|
|
|
case 2: // Mouse buttons changed
|
|
|
|
Mouse.new_buttons = EventBuffer[ui_event_counter].data;
|
|
|
|
break;
|
|
|
|
case 3: // Key moved down
|
|
|
|
keyd_pressed[ EventBuffer[ui_event_counter].data ] = 1;
|
|
|
|
break;
|
|
|
|
case 4: // Key moved up
|
|
|
|
keyd_pressed[ EventBuffer[ui_event_counter].data ] = 0;
|
|
|
|
break;
|
|
|
|
case 5: // Key pressed
|
|
|
|
last_keypress = EventBuffer[ui_event_counter].data;
|
|
|
|
break;
|
|
|
|
case 6: // Initial Mouse X position
|
|
|
|
Mouse.x = EventBuffer[ui_event_counter].data & 0xFFFF;
|
|
|
|
Mouse.y = (EventBuffer[ui_event_counter].data >> 16) & 0xFFFF;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ui_event_counter++;
|
|
|
|
if (ui_event_counter >= ui_number_of_events )
|
|
|
|
{
|
|
|
|
Record = 0;
|
|
|
|
restore_state();
|
|
|
|
//( 0, "Done playing %d events.\n", ui_number_of_events );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (Record)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
int next_frame;
|
|
|
|
|
|
|
|
if ( ui_event_counter < ui_number_of_events )
|
|
|
|
{
|
|
|
|
next_frame = EventBuffer[ui_event_counter].frame;
|
|
|
|
|
|
|
|
if ( (FrameCount+PlaybackSpeed) < next_frame )
|
|
|
|
FrameCount = next_frame - PlaybackSpeed;
|
|
|
|
else
|
|
|
|
FrameCount++;
|
|
|
|
} else {
|
|
|
|
FrameCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
if ( ui_event_counter < ui_number_of_events )
|
|
|
|
FrameCount = EventBuffer[ui_event_counter].frame;
|
|
|
|
else
|
|
|
|
FrameCount++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FrameCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_mouse_process();
|
|
|
|
|
|
|
|
}
|
2011-01-14 09:51:13 +00:00
|
|
|
#endif // 0
|
|
|
|
|
2013-12-08 23:37:40 +00:00
|
|
|
void (ui_dprintf_at)( UI_DIALOG * dlg, short x, short y, const char * format, ... )
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
char buffer[1000];
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, format );
|
2012-06-30 05:05:33 +00:00
|
|
|
vsnprintf(buffer,sizeof(buffer),format,args);
|
2013-12-01 18:27:54 +00:00
|
|
|
va_end(args);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-12-08 23:37:40 +00:00
|
|
|
ui_dputs_at(dlg, x, y, buffer);
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-12-08 23:37:40 +00:00
|
|
|
void ui_dputs_at( UI_DIALOG * dlg, short x, short y, const char * buffer )
|
|
|
|
{
|
|
|
|
ui_dialog_set_current_canvas( dlg );
|
2006-03-20 17:12:09 +00:00
|
|
|
gr_string( x, y, buffer );
|
|
|
|
}
|