mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-08-14 02:08:20 -04:00
revision of events
This commit is contained in:
parent
858c4384e8
commit
669f72908e
33 changed files with 661 additions and 382 deletions
|
@ -4,6 +4,9 @@
|
|||
#include "event.h"
|
||||
#include "devices.h"
|
||||
#include "bmouse.h"
|
||||
|
||||
#include "memman.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
char visible=0;
|
||||
|
@ -74,6 +77,7 @@ void update_mysky(void)
|
|||
if (x.event)
|
||||
{
|
||||
ms_last_event=x;
|
||||
x.event = 0;
|
||||
}
|
||||
if(!visible) move_ms_cursor(x.x-h_x,x.y-h_y,0);
|
||||
}
|
||||
|
|
|
@ -232,15 +232,16 @@ void enter_event(T_EVENT_ROOT **tree,EVENT_MSG *msg)
|
|||
va_end(cpy.data);
|
||||
p->calls--;
|
||||
p->nezavora=1;
|
||||
if (msg->msg==-2)
|
||||
if (cpy.msg==-2)
|
||||
{
|
||||
p->proc=NULL;
|
||||
msg->msg=ev;
|
||||
cpy.msg=ev;
|
||||
}
|
||||
s=p->next;
|
||||
if (!p->calls && p->proc==NULL)
|
||||
force_delete_curr(tree,r,p);
|
||||
if (msg->msg==-1) break;
|
||||
if (cpy.msg==-1)
|
||||
break;
|
||||
}
|
||||
/* if (p->next!=s)
|
||||
if (r->list!=p)
|
||||
|
|
12
libs/event.h
12
libs/event.h
|
@ -99,6 +99,18 @@ extern char *otevri_zavoru;
|
|||
//extern int curtask;
|
||||
//extern char *task_info;
|
||||
|
||||
///copies message
|
||||
static inline EVENT_MSG clone_message(EVENT_MSG *msg) {
|
||||
EVENT_MSG out;
|
||||
out.msg = msg->msg;
|
||||
va_copy(out.data, msg->data);
|
||||
return out;
|
||||
}
|
||||
///destroys copied message
|
||||
static inline void destroy_message(EVENT_MSG *msg) {
|
||||
va_end(msg->data);
|
||||
}
|
||||
|
||||
void init_events(void);
|
||||
// inicalizuje zakladni strom udalosto
|
||||
void send_message(int message,...);
|
||||
|
|
99
libs/gui.c
99
libs/gui.c
|
@ -610,42 +610,58 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
|||
if (msg->msg==E_MOUSE)
|
||||
{
|
||||
*oz=1;
|
||||
EVENT_MSG fwmsg = clone_message(msg);
|
||||
fwmsg.msg = msg->msg;
|
||||
va_copy(fwmsg.data, msg->data);
|
||||
msev=get_mouse(msg);
|
||||
aktivate_window(msev);
|
||||
if (o_aktual==NULL)
|
||||
if (o_start!=NULL && (msev->tl1 || msev->tl2 || msev->tl3))
|
||||
{
|
||||
o_aktual=o_start;
|
||||
while (o_aktual!=NULL && (!o_aktual->enabled || !mouse_in_object(msev,o_aktual,waktual) || o_aktual->call_event==empty3)) o_aktual=o_aktual->next;
|
||||
if (o_aktual==NULL) return;
|
||||
msg2.msg=E_GET_FOCUS;
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
o_aktual->on_enter();
|
||||
o_aktual->call_event(msg,o_aktual);
|
||||
}
|
||||
else return;
|
||||
else
|
||||
{
|
||||
if (o_aktual->enabled) b=mouse_in_object(msev,o_aktual,waktual);else b=0;
|
||||
if (b)
|
||||
o_aktual->call_event(msg,o_aktual);
|
||||
if ((msev->tl1 || msev->tl2 || msev->tl3)&& !b)
|
||||
{
|
||||
o_aktual->on_exit();
|
||||
if (f_cancel_event) return;
|
||||
msg2.msg=E_LOST_FOCUS;
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
p=o_start;
|
||||
while (p!=NULL && (!p->enabled || !mouse_in_object(msev,p,waktual) || p->call_event==empty3))
|
||||
p=p->next;
|
||||
if (p!=NULL) o_aktual=p;
|
||||
msg2.msg=E_GET_FOCUS;
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
o_aktual->on_enter();
|
||||
if (p!=NULL) o_aktual->call_event(msg,o_aktual);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (o_aktual == NULL) {
|
||||
if (o_start != NULL && (msev->tl1 || msev->tl2 || msev->tl3)) {
|
||||
o_aktual = o_start;
|
||||
while (o_aktual != NULL
|
||||
&& (!o_aktual->enabled
|
||||
|| !mouse_in_object(msev, o_aktual, waktual)
|
||||
|| o_aktual->call_event == empty3))
|
||||
o_aktual = o_aktual->next;
|
||||
if (o_aktual != NULL) {
|
||||
msg2.msg = E_GET_FOCUS;
|
||||
o_aktual->call_event(&msg2, o_aktual);
|
||||
o_aktual->on_enter();
|
||||
o_aktual->call_event(&fwmsg, o_aktual);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (o_aktual->enabled) {
|
||||
b = mouse_in_object(msev, o_aktual, waktual);
|
||||
} else {
|
||||
b = 0;
|
||||
}
|
||||
if (b) {
|
||||
o_aktual->call_event(&fwmsg, o_aktual);
|
||||
}
|
||||
if ((msev->tl1 || msev->tl2 || msev->tl3) && !b) {
|
||||
o_aktual->on_exit();
|
||||
if (f_cancel_event)
|
||||
return;
|
||||
msg2.msg = E_LOST_FOCUS;
|
||||
o_aktual->call_event(&msg2, o_aktual);
|
||||
p = o_start;
|
||||
while (p != NULL
|
||||
&& (!p->enabled || !mouse_in_object(msev, p, waktual)
|
||||
|| p->call_event == empty3))
|
||||
p = p->next;
|
||||
if (p != NULL) {
|
||||
o_aktual = p;
|
||||
}
|
||||
msg2.msg = E_GET_FOCUS;
|
||||
o_aktual->call_event(&msg2, o_aktual);
|
||||
o_aktual->on_enter();
|
||||
if (p != NULL)
|
||||
o_aktual->call_event(msg, o_aktual);
|
||||
}
|
||||
}
|
||||
destroy_message(&fwmsg);
|
||||
}
|
||||
if (msg->msg==E_KEYBOARD)
|
||||
{
|
||||
*oz=1;
|
||||
|
@ -689,20 +705,23 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
|||
if (msg->msg==E_GUI)
|
||||
{
|
||||
OBJREC *o;
|
||||
|
||||
EVENT_MSG msg2 = clone_message(msg);
|
||||
|
||||
int control = va_arg(msg->data, int);
|
||||
msg->msg = va_arg(msg->data, int);
|
||||
o=find_object(waktual,control);
|
||||
|
||||
EVENT_MSG msg2;
|
||||
|
||||
|
||||
if (o!=NULL)
|
||||
{
|
||||
msg2.msg=msg->msg;
|
||||
va_copy(msg2.data,msg->data);
|
||||
o->call_event(&msg2,o);
|
||||
o->on_event(msg,o_aktual);
|
||||
va_end(msg2.data);
|
||||
EVENT_MSG msg3 = clone_message(msg);
|
||||
o->call_event(&msg2,o);
|
||||
o->on_event(&msg3,o_aktual);
|
||||
destroy_message(&msg3);
|
||||
}
|
||||
destroy_message(&msg2);
|
||||
|
||||
}
|
||||
if (msg->msg==E_CHANGE)
|
||||
|
|
|
@ -38,7 +38,7 @@ int32_t last_load_size;
|
|||
void standard_mem_error(size_t size)
|
||||
{
|
||||
char buff[256];
|
||||
SEND_LOG("(ERROR) Memory allocation error detected, %u bytes missing",size,0);
|
||||
SEND_LOG("(ERROR) Memory allocation error detected, %lu bytes missing",size);
|
||||
DXCloseMode();
|
||||
sprintf(buff,"Memory allocation error\n Application can't allocate %lu bytes of memory (%xh)\n",size,memman_handle);
|
||||
display_error(buff);
|
||||
|
@ -48,7 +48,7 @@ void standard_mem_error(size_t size)
|
|||
void load_error(char *filename)
|
||||
{
|
||||
char buff[256];
|
||||
SEND_LOG("(ERROR) Load error detected, system can't load file: %s",filename,0);
|
||||
SEND_LOG("(ERROR) Load error detected, system can't load file: %s",filename);
|
||||
#ifdef LOGFILE
|
||||
// bonz_table();
|
||||
#endif
|
||||
|
@ -100,7 +100,7 @@ void *load_file(char *filename)
|
|||
size_t size;
|
||||
|
||||
if (mman_action!=NULL) mman_action(MMA_READ);
|
||||
SEND_LOG("(LOAD) Loading file '%s'",filename,0);
|
||||
SEND_LOG("(LOAD) Loading file '%s'",filename);
|
||||
f=fopen(filename, "rb");
|
||||
if (f==NULL) {
|
||||
load_error(filename);
|
||||
|
@ -139,10 +139,10 @@ uint32_t bk_global_counter=0;
|
|||
char *swap_path;
|
||||
|
||||
#ifdef LOGFILE
|
||||
static void bonz_table()
|
||||
void bonz_table()
|
||||
{
|
||||
int i;
|
||||
if (bmf==-1) return;
|
||||
if (bmf==NULL) return;
|
||||
for(i=0;i<nmtab_size;i++)
|
||||
{
|
||||
fprintf(stderr,"%-12.12s %12d\n",nametable[i].name,nametable[i].seek);
|
||||
|
@ -164,9 +164,9 @@ static int test_file_exist_DOS(int group,char *filename)
|
|||
|
||||
void load_grp_table()
|
||||
{
|
||||
int32_t i;
|
||||
int32_t i = 0;;
|
||||
|
||||
SEND_LOG("(LOAD) Loading Group Table",0,0);
|
||||
SEND_LOG("(LOAD) Loading Group Table");
|
||||
fseek(bmf,4,SEEK_SET);
|
||||
fread(&i,4,1,bmf);
|
||||
grptable=(int32_t *)getmem(i+4);
|
||||
|
@ -174,7 +174,7 @@ void load_grp_table()
|
|||
fread(grptable,i,1,bmf);
|
||||
grptabsiz=i;
|
||||
for(i=0;i<(grptabsiz>>3);i++) grptable[i*2+1]=(grptable[i*2+1]-grptabsiz)>>4;
|
||||
SEND_LOG("(LOAD) Group Table Loaded",0,0);
|
||||
SEND_LOG("(LOAD) Group Table Loaded");
|
||||
}
|
||||
|
||||
void load_file_table()
|
||||
|
@ -182,16 +182,17 @@ void load_file_table()
|
|||
int strsize;
|
||||
void *p;
|
||||
|
||||
SEND_LOG("(LOAD) Loading File Table",0,0);
|
||||
SEND_LOG("(LOAD) Loading File Table");
|
||||
fseek(bmf,grptabsiz,SEEK_SET);
|
||||
fseek(bmf,12,SEEK_CUR);
|
||||
fread(&strsize,4,1,bmf);
|
||||
strsize-=grptabsiz;
|
||||
fseek(bmf,grptabsiz,SEEK_SET);
|
||||
p=getmem(strsize);memcpy(&nametable,&p,4);
|
||||
p=getmem(strsize);
|
||||
nametable = p;
|
||||
fread(nametable,1,strsize,bmf);
|
||||
nmtab_size=strsize/sizeof(*nametable);
|
||||
SEND_LOG("(LOAD) File Table Loaded",0,0);
|
||||
SEND_LOG("(LOAD) File Table Loaded");
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,7 +233,7 @@ int swap_block(THANDLE_DATA *h)
|
|||
fseek(swap,0,SEEK_END);
|
||||
wsize=ftell(swap);
|
||||
fseek(swap,pos,SEEK_SET);
|
||||
SEND_LOG("(SWAP) Swaping block '%-.12hs'",h->src_file,0);
|
||||
SEND_LOG("(SWAP) Swaping block '%-.12s'",h->src_file);
|
||||
wsize=fwrite(h->blockdata,1,h->size,swap);
|
||||
swap_status=1;
|
||||
if ((unsigned)wsize==h->size)
|
||||
|
@ -244,7 +245,7 @@ int swap_block(THANDLE_DATA *h)
|
|||
}
|
||||
else
|
||||
{
|
||||
SEND_LOG("(SWAP) Swap failed!",0,0);
|
||||
SEND_LOG("(SWAP) Swap failed!");
|
||||
swap_error();
|
||||
}
|
||||
swap_free_block(pos,h->size);
|
||||
|
@ -350,10 +351,10 @@ THANDLE_DATA *kill_block(int handle)
|
|||
h=get_handle(handle);if (h->status==BK_NOT_USED) return h;
|
||||
if (h->flags & BK_LOCKED)
|
||||
{
|
||||
SEND_LOG("(ERROR) Unable to kill block! It is LOCKED! '%-.12hs' (%04X)",h->src_file,handle);
|
||||
SEND_LOG("(ERROR) Unable to kill block! It is LOCKED! '%-.12s' (%04X)",h->src_file,handle);
|
||||
return NULL;
|
||||
}
|
||||
SEND_LOG("(KILL) Killing block '%-.12hs' (%04X)",h->src_file,handle);
|
||||
SEND_LOG("(KILL) Killing block '%-.12s' (%04X)",h->src_file,handle);
|
||||
if (h->status==BK_SAME_AS) return h;
|
||||
if (h->status==BK_PRESENT) free(h->blockdata);
|
||||
if (h->flags & BK_HSWAP) swap_free_block(h->seekpos,h->size);
|
||||
|
@ -405,7 +406,7 @@ void *load_swaped_block(THANDLE_DATA *h)
|
|||
|
||||
if (mman_action!=NULL) mman_action(MMA_SWAP_READ);
|
||||
i=getmem(h->size);
|
||||
SEND_LOG("(LOAD)(SWAP) Loading block from swap named '%-.12hs'",h->src_file,0);
|
||||
SEND_LOG("(LOAD)(SWAP) Loading block from swap named '%-.12s'",h->src_file);
|
||||
fseek(swap,h->seekpos,SEEK_SET);
|
||||
fread(i,1,h->size,swap);
|
||||
h->status=BK_PRESENT;
|
||||
|
@ -451,7 +452,7 @@ THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path)
|
|||
if (i==handle) return h;
|
||||
if (kill_block(handle)==NULL)
|
||||
{
|
||||
SEND_LOG("(ERROR) File/Block can't be registred, handle is already in use '%-.12hs' handle %04X",filename,handle);
|
||||
SEND_LOG("(ERROR) File/Block can't be registred, handle is already in use '%-.12s' handle %04X",filename,handle);
|
||||
return NULL;
|
||||
}
|
||||
if (i!=-1 && i!=handle)
|
||||
|
@ -466,8 +467,8 @@ THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path)
|
|||
h->loadproc=decompress;
|
||||
if (filename[0])
|
||||
h->seekpos=get_file_entry(path,h->src_file);
|
||||
SEND_LOG("(REGISTER) File/Block registred '%-.12hs' handle %04X",h->src_file,handle);
|
||||
SEND_LOG("(REGISTER) Seekpos=%d",h->seekpos,0);
|
||||
SEND_LOG("(REGISTER) File/Block registred '%-.12s' handle %04X",h->src_file,handle);
|
||||
SEND_LOG("(REGISTER) Seekpos=%d",h->seekpos);
|
||||
h->flags=0;
|
||||
h->path=path;
|
||||
if (h->status!=BK_DIRLIST) h->status=BK_NOT_LOADED;
|
||||
|
@ -498,7 +499,7 @@ void *afile(char *filename,int group,int32_t *blocksize)
|
|||
}
|
||||
else if (mman_pathlist!=NULL)
|
||||
{
|
||||
SEND_LOG("(LOAD) Afile is loading file '%s' from disk",d,group);
|
||||
SEND_LOG("(LOAD) Afile is loading file '%s' from disk (group %d)",d,group);
|
||||
c=alloca(strlen(filename)+strlen(mman_pathlist[group])+2);
|
||||
c=strcat(strcpy(c,mman_pathlist[group]),filename);
|
||||
p=load_file(c);
|
||||
|
@ -531,7 +532,7 @@ void *ablock(int handle)
|
|||
void *p;int32_t s;
|
||||
char c[200];
|
||||
|
||||
SEND_LOG("(LOAD) Loading file as block '%-.12hs' %04X",h->src_file,handle);
|
||||
SEND_LOG("(LOAD) Loading file as block '%-.12s' %04X",h->src_file,handle);
|
||||
if (h->seekpos==0)
|
||||
{
|
||||
if (h->src_file[0]!=0)
|
||||
|
@ -704,7 +705,7 @@ void undef_handle(int handle)
|
|||
if (h->status!=BK_NOT_USED)
|
||||
{
|
||||
if (kill_block(handle)==NULL) return;
|
||||
SEND_LOG("(REGISTER) File/Block unregistred %04X (%-.12hs)",handle,h->src_file);
|
||||
SEND_LOG("(REGISTER) File/Block unregistred %04X (%-.12s)",handle,h->src_file);
|
||||
}
|
||||
h->src_file[0]=0;
|
||||
h->seekpos=0;
|
||||
|
@ -840,7 +841,7 @@ char add_patch_file(char *filename)
|
|||
int32_t poc;
|
||||
int i,cc=0;
|
||||
TNAMETABLE p;
|
||||
SEND_LOG("Adding patch: %s",filename,0);
|
||||
SEND_LOG("Adding patch: %s",filename);
|
||||
if (!patch) return 2;
|
||||
if (!bmf) return 3;
|
||||
patch=fopen(filename,"rb");
|
||||
|
|
|
@ -3,8 +3,15 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifndef _MEMMAN_H_
|
||||
#define _MEMMAN_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define freemem(size) free(size);
|
||||
//#define malloc(size) getmem(size)
|
||||
#define New(typ) (typ *)getmem(sizeof(typ))
|
||||
|
@ -110,12 +117,19 @@ void display_status(void); //zobrazi na display status memmanageru
|
|||
#ifdef LOGFILE
|
||||
char *get_time_str(void);
|
||||
int q_current_task(void);
|
||||
void send_log_impl(int task, const char *format, ...) __attribute__((format(printf, 2, 3)));
|
||||
#define OPEN_LOG(log) memcpy(stderr,fopen(log,"w"),sizeof(FILE));
|
||||
#define SEND_LOG(format,parm1,parm2) fprintf(stderr,"%-2d %s "format"\n",q_current_task(void),get_time_str(void),parm1,parm2),fflush(stderr)
|
||||
#define SEND_LOG(...) send_log_impl(q_current_task(), __VA_ARGS__)
|
||||
#define CLOSE_LOG(void) fclose(logfile);
|
||||
#else
|
||||
#define OPEN_LOG(log)
|
||||
#define SEND_LOG(format,parm1,parm2)
|
||||
#define SEND_LOG(...)
|
||||
#define CLOSE_LOG(void)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@ int mix_back_sound(int synchro);
|
|||
int open_backsound(char *filename);
|
||||
void change_music(const char *filename);
|
||||
int get_timer_value(void);
|
||||
char *device_name(int device);
|
||||
const char *device_name(int device);
|
||||
void force_music_volume(int volume);
|
||||
|
||||
void set_backsnd_freq(int freq);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue