home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ Games Programming
/
CPPGAMES.ISO
/
thx
/
source
/
theatrix
/
kdfold.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-25
|
1KB
|
69 lines
#include "kdfold.h"
void HotkeyFolder::thxregister_key(Hand* hand,int code,callback cb)
{
// first, check if the code is already in the list
for (int i=0;i<numentries;i++)
{
if (entry[i].code==code)
{
entry[i].list.add(hand,cb);
return;
}
}
// if it wasn't check for an empty spot to put it in
for (i=0;i<numentries;i++)
{
if (entry[i].code==0)
{
entry[i].list.add(hand,cb);
return;
}
}
// if the code is not in the list and there are no empty slots, add
// the code at the end of the list
entry[numentries].code=code;
entry[numentries].list.add(hand,cb);
numentries++;
}
void HotkeyFolder::unregister_key(Hand* hand,int code,callback cb)
{
for (int i=0;i<numentries;i++)
{
if (entry[i].code==code)
{
entry[i].list.del(hand,cb);
if (entry[i].list.getnum()==0) entry[i].code=0;
return;
}
}
}
void HotkeyFolder::delHand(Hand* h)
{
for (int i = 0; i < numentries; i++)
entry[i].list.delHand(h);
}
void HotkeyFolder::reset()
{
for (int i=0;i<MAXDOWNENTRY;i++)
{
entry[i].list.reset();
entry[i].code=0;
}
}
void HotkeyFolder::dispatch(int, int, int)
{
for (int i=0;i<numentries;i++)
{
int code=entry[i].code;
if (code!=0 && fg_kbtest(code))
entry[i].list.execute_callbacks(code);
}
}