📄 controltab.cpp
字号:
}
//flags = flags + (KeyVar.CommandsKeyCombo << SECOND_KEY_SHIFT) + (KeyVar.CommandsKeyComboMod << SECOND_KEY_MOD_SHIFT);
function = UserFunctionTable.GetFunction(DKScanCode,flags,&pmouse,&pbutton);
text = (C_Text *)win->FindControl(FUNCTION_LIST);
if(text)
{
text->Refresh();
if(function)
{
C_Text *temp;
C_Button *btn;
long ID;
ID = UserFunctionTable.GetControl(DKScanCode,flags) ;
CommandCombo = 0;
btn = (C_Button *)win->FindControl(ID);
if(btn)
CommandCombo = btn->GetUserNumber(EDITABLE);
if(CommandCombo == -1)
{
KeyVar.CommandsKeyCombo = DKScanCode;
KeyVar.CommandsKeyComboMod = ShiftStates;
}
else
{
KeyVar.CommandsKeyCombo = 0;
KeyVar.CommandsKeyComboMod = 0;
}
ID = ID - KEYCODES + MAPPING;
temp = (C_Text *)win->FindControl(ID);
if(temp)
descrip = temp->GetText();
if(descrip)
text->SetText(descrip);
else
text->SetText(TXT_NO_FUNCTION);
if(!KeyVar.EditKey && temp)
{
UI95_RECT Client;
Client = win->GetClientArea(temp->GetClient());
win->SetVirtualY(temp->GetY() - Client.top,temp->GetClient());
win->AdjustScrollbar(temp->GetClient());
win->RefreshClient(temp->GetClient());
}
}
else
{
text->SetText(TXT_NO_FUNCTION);
KeyVar.CommandsKeyCombo = 0;
KeyVar.CommandsKeyComboMod = 0;
}
text->Refresh();
}
}
return TRUE;
}
return FALSE;
}
void KeycodeCB(long ID,short hittype,C_Base *control)
{
if(hittype != C_TYPE_LMOUSEUP)
return;
if(KeyVar.EditKey)
{
C_Button *button;
button = (C_Button *)control->Parent_->FindControl(KeyVar.CurrControl);
SetButtonColor(button);
}
if(KeyVar.CurrControl == ID && KeyVar.EditKey)
{
KeyVar.EditKey = FALSE;
return;
}
if( control->GetUserNumber(EDITABLE) < 1 )
{
KeyVar.CurrControl = ID;
KeyVar.EditKey = FALSE;
}
else
{
KeyVar.CurrControl = ID;
((C_Button *)control)->SetFgColor(0,RGB(0,255,255));
((C_Button *)control)->Refresh();
KeyVar.EditKey = TRUE;
}
return;
}
int AddUndisplayedKey(KeyMap &Map)
{
if(NumUndispKeys < 300)
{
UndisplayedKeys[NumUndispKeys].func = Map.func;
UndisplayedKeys[NumUndispKeys].buttonId = Map.buttonId;
UndisplayedKeys[NumUndispKeys].mouseSide = Map.mouseSide;
UndisplayedKeys[NumUndispKeys].key2 = Map.key2;
UndisplayedKeys[NumUndispKeys].mod2 = Map.mod2;
UndisplayedKeys[NumUndispKeys].key1= Map.key1;
UndisplayedKeys[NumUndispKeys].mod1= Map.mod1;
UndisplayedKeys[NumUndispKeys].editable = Map.editable;
strcpy(UndisplayedKeys[NumUndispKeys].descrip, Map.descrip);
NumUndispKeys++;
return TRUE;
}
return FALSE;
}
int AddKeyMapLines(C_Window *win, C_Line *Hline, C_Line *Vline, int count)
{
int retval = TRUE;
if(!win)
return FALSE;
C_Line *line;
line = (C_Line *)win->FindControl(HLINE + count);
if(!line)
{
line = new C_Line;
if(line)
{
line->Setup(HLINE + count,Hline->GetType());
line->SetColor(RGB(191,191,191));
line->SetXYWH(Hline->GetX(),Hline->GetY() + Vline->GetH()*count,Hline->GetW(),Hline->GetH());
line->SetFlags(Hline->GetFlags());
line->SetClient(Hline->GetClient());
line->SetGroup(Hline->GetGroup());
line->SetCluster(Hline->GetCluster());
win->AddControl(line);
line->Refresh();
}
else
retval = FALSE;
}
line = (C_Line *)win->FindControl(VLINE + count);
if(!line)
{
line = new C_Line;
if(line)
{
line->Setup(VLINE + count,Vline->GetType());
line->SetColor(RGB(191,191,191));
line->SetXYWH(Vline->GetX(),Vline->GetY() + Vline->GetH()*count,Vline->GetW(),Vline->GetH());
line->SetFlags(Vline->GetFlags());
line->SetClient(Vline->GetClient());
line->SetGroup(Vline->GetGroup());
line->SetCluster(Vline->GetCluster());
win->AddControl(line);
line->Refresh();
}
else
retval = FALSE;
}
return retval;
}
void UpdateKeyMapButton(C_Button *button, KeyMap &Map, int count)
{
int flags = Map.mod2 + (Map.key1 << SECOND_KEY_SHIFT) + (Map.mod1 << SECOND_KEY_MOD_SHIFT);
button->SetUserNumber(KEY2,Map.key2);
button->SetUserNumber(FLAGS,flags);
button->SetUserNumber(BUTTON_ID,Map.buttonId);
button->SetUserNumber(MOUSE_SIDE,Map.mouseSide);
button->SetUserNumber(EDITABLE,Map.editable);
button->SetUserPtr(FUNCTION_PTR,(void*)Map.func);
if(Map.key2 == -1)
{
button->SetText(0,TXT_NO_KEY);
}
else
{
_TCHAR totalDescrip[MAX_PATH] = {0};
if(Map.key1 > 0)
{
_TCHAR firstMod[MAX_PATH] = {0};
_TCHAR secondMod[MAX_PATH] = {0};
DoShiftStates(firstMod,Map.mod1);
DoShiftStates(secondMod,Map.mod2);
_stprintf(totalDescrip,"%s%s : %s%s",firstMod,KeyDescrips[Map.key1],secondMod,KeyDescrips[Map.key2]);
}
else
{
DoShiftStates(totalDescrip,Map.mod2);
strcat(totalDescrip,KeyDescrips[Map.key2]);
}
UserFunctionTable.SetControl(Map.key2,flags,KEYCODES + count); //define this as KEYCODES
button->SetText(0,totalDescrip);
}
SetButtonColor(button);
}
int UpdateKeyMap(C_Window *win, C_Button *Keycodes, int height, KeyMap &Map, HotSpotStruct HotSpot, int count )
{
C_Button *button;
long flags;
flags = Map.mod2 + (Map.key1 << SECOND_KEY_SHIFT) + (Map.mod1 << SECOND_KEY_MOD_SHIFT);
button = (C_Button *)win->FindControl(KEYCODES + count);
if(button)
{
button->Refresh();
UpdateKeyMapButton(button, Map, count);
button->Refresh();
return TRUE;
}
else
{
button = new C_Button;
if(button)
{
button->Setup(KEYCODES + count, Keycodes->GetType(), Keycodes->GetX(),
Keycodes->GetY() + height*count);
button->SetClient(Keycodes->GetClient());
button->SetGroup(Keycodes->GetGroup());
button->SetCluster(Keycodes->GetCluster());
button->SetFont(Keycodes->GetFont());
button->SetFlags(Keycodes->GetFlags());
button->SetCallback(KeycodeCB);
button->SetHotSpot(HotSpot.X, HotSpot.Y, HotSpot.W, HotSpot.H);
if(Keycodes->GetSound(1))
button->SetSound((Keycodes->GetSound(1))->ID, 1);
UpdateKeyMapButton(button, Map, count);
win->AddControl(button);
button->Refresh();
return TRUE;
}
}
return FALSE;
}
int UpdateMappingDescrip(C_Window *win, C_Text *Mapping, int height, _TCHAR *descrip, int count)
{
C_Text *text;
text = (C_Text *)win->FindControl(MAPPING+count);
if(text)
{
text->Refresh();
text->SetText(descrip);
text->Refresh();
return TRUE;
}
else
{
text = new C_Text;
if(text)
{
text->Setup(MAPPING+count, Mapping->GetType());
text->SetFGColor(Mapping->GetFGColor());
text->SetBGColor(Mapping->GetBGColor());
text->SetClient(Mapping->GetClient());
text->SetGroup(Mapping->GetGroup());
text->SetCluster(Mapping->GetCluster());
text->SetFont(Mapping->GetFont());
text->SetFlags(Mapping->GetFlags());
text->SetXY(Mapping->GetX(),Mapping->GetY() + height*count);
text->SetText(descrip);
win->AddControl(text);
text->Refresh();
return TRUE;
}
}
return FALSE;
}
int SetHdrStatusLine(C_Window *win, C_Button *Keycodes, C_Line *Vline, KeyMap &Map, HotSpotStruct HotSpot, int count)
{
C_Line *line;
line = (C_Line *)win->FindControl(KEYCODES - count);
if(line)
{
if(Map.editable != -1)
{
line->SetFlagBitOn(C_BIT_INVISIBLE);
}
else
{
line->SetFlagBitOff(C_BIT_INVISIBLE);
}
line->Refresh();
return TRUE;
}
else
{
line = new C_Line;
if(line)
{
UI95_RECT client;
client = win->GetClientArea(3);
line->Setup(KEYCODES - count,0);
//line->SetXYWH( Keycodes->GetX() + HotX,
// Keycodes->GetY() + Vline->GetH()*count + HotY,
// HotW,HotH);
line->SetXYWH( Keycodes->GetX() + HotSpot.X,
Keycodes->GetY() + Vline->GetH()*count + HotSpot.Y,
client.right - client.left,HotSpot.H);
line->SetColor(RGB(65,128,173));//lt blue
line->SetFlags(Vline->GetFlags());
line->SetClient(Vline->GetClient());
line->SetGroup(Vline->GetGroup());
line->SetCluster(Vline->GetCluster());
win->AddControl(line);
line->Refresh();
//this is a header, so we put a lt blue line behind it
if(Map.editable != -1)
{
line->SetFlagBitOn(C_BIT_INVISIBLE);
}
line->Refresh();
return TRUE;
}
}
return FALSE;
}
BOOL SaveKeyMapList( char *filename )
{
if(!KeyVar.Modified)
return TRUE;
KeyVar.Modified = FALSE;
FILE *fp;
C_Window *win;
C_Button *button;
InputFunctionType theFunc;
char *funcDescrip;
int i,key1,mod1,mod2,flags, count = 0;
C_Text *text;
char descrip[_MAX_PATH];
win = gMainHandler->FindWindow(SETUP_WIN);
if(!win)
return FALSE;
char path[_MAX_PATH];
sprintf(path,"%s\\config\\%s.key",FalconDataDirectory,filename);
fp = fopen(path,"wt");
if(!fp)
return FALSE;
button = (C_Button *)win->FindControl(KEYCODES);
while(button)
{
//int pmouse,pbutton;
flags = button->GetUserNumber(FLAGS);
mod2 = flags & MOD2_MASK;
key1 = (flags & KEY1_MASK) >> SECOND_KEY_SHIFT;
mod1 = (flags & MOD1_MASK) >> SECOND_KEY_MOD_SHIFT;
theFunc = (InputFunctionType)button->GetUserPtr(FUNCTION_PTR);
funcDescrip = FindStringFromFunction(theFunc);
text = (C_Text *)win->FindControl(MAPPING + count);
if(text)
sprintf(descrip, "%c%s%c", '"', text->GetText(), '"');
else
strcpy(descrip,"");
if(key1 == 0xff)
{
key1 = -1;
mod1 = 0;
}
fprintf(fp,"%s %d %d %#X %X %#X %X %d %s\n",funcDescrip,button->GetUserNumber(BUTTON_ID),button->GetUserNumber(MOUSE_SIDE),button->GetUserNumber(KEY2),mod2,key1,mod1,button->GetUserNumber(EDITABLE),descrip);
count++;
button = (C_Button *)win->FindControl(KEYCODES + count);
}
for(i = 0; i < NumUndispKeys;i++)
{
funcDescrip = FindStringFromFunction(UndisplayedKeys[i].func);
fprintf(fp,"%s %d %d %#X %d %#X %d %d %s\n",
funcDescrip,
UndisplayedKeys[i].buttonId ,
UndisplayedKeys[i].mouseSide,
UndisplayedKeys[i].key2,
UndisplayedKeys[i].mod2,
UndisplayedKeys[i].key1,
UndisplayedKeys[i].mod1,
UndisplayedKeys[i].editable,
UndisplayedKeys[i].descrip
);
}
for(i =0;i<UserFunctionTable.NumButtons;i++)
{
int cpButtonID;
theFunc = UserFunctionTable.GetButtonFunction(i, &cpButtonID);
if(theFunc)
{
funcDescrip = FindStringFromFunction(theFunc);
fprintf(fp,"%s %d %d -2 0 0x0 0\n",funcDescrip,i,cpButtonID);
}
}
for(i =0;i<UserFunctionTable.NumPOVs;i++)
{
int cpButtonID;
for(int j=0; j < 8; j++)
{
theFunc = UserFunctionTable.GetPOVFunction(i,j, &cpButtonID);
if(theFunc)
{
funcDescrip = FindStringFromFunction(theFunc);
fprintf(fp,"%s %d %d -3 %d 0x0 0\n",funcDescrip,i,cpButtonID,j);
}
}
}
fclose(fp);
return TRUE;
}
void SaveKeyCB(long,short hittype,C_Base *control)
{
C_Window *win;
C_EditBox * ebox;
_TCHAR fname[MAX_PATH];
if(hittype != C_TYPE_LMOUSEUP)
return;
win=gMainHandler->FindWindow(SAVE_WIN);
if(!win)
return;
gMainHandler->HideWindow(win);
gMainHandler->HideWindow(control->Parent_);
ebox=(C_EditBox*)win->FindControl(FILE_NAME);
if(ebox)
{
_tcscpy(fname,ebox->GetText());
if(fname[0] == 0)
return;
KeyVar.Modified = TRUE;
if(SaveKeyMapList(fname))
_tcscpy(PlayerOptions.keyfile,ebox->GetText());
}
}
void VerifySaveKeyCB(long ID,short hittype,C_Base *control)
{
C_EditBox * ebox;
_TCHAR fname[MAX_PATH];
FILE *fp;
if(hittype != C_TYPE_LMOUSEUP)
return;
ebox=(C_EditBox*)control->Parent_->FindControl(FILE_NAME);
if(ebox)
{
_stprintf(fname,"config\\%s.key",ebox->GetText ());
fp=fopen(fname,"r");
if(fp)
{
fclose(fp);
AreYouSure(TXT_WARNING,TXT_FILE_EXISTS,SaveKeyCB,CloseWindowCB);
}
else
SaveKeyCB(ID,hittype,control);
}
}
void SaveKeyButtonCB(long,short hittype,C_Base *)
{
if(hittype != C_TYPE_LMOUSEUP)
return;
SetDeleteCallback(DelKeyFileCB);
SaveAFile(TXT_SAVE_KEYBOARD,"config\\*.KEY",NULL,VerifySaveKeyCB,CloseWindowCB);
}
int RemoveExcessControls(C_Window *win, int count)
{
C_Button *button;
C_Text *text;
C_Line *line;
int retval = FALSE;
button = (C_Button *)win->FindControl(KEYCODES + count);
if(button)
{
win->RemoveControl(KEYCODES + count);
retval = TRUE;
}
text = (C_Text *)win->FindControl(MAPPING + count);
if(text)
{
win->RemoveControl(MAPPING + count);
retval = TRUE;
}
line = (C_Line *)win->FindControl(KEYCODES - count);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -