Made grab mouse and leave window configurable.
This commit is contained in:
parent
682c1f14ba
commit
61ca1a679e
11 changed files with 95 additions and 21 deletions
|
@ -218,7 +218,9 @@ extern Unit* UnitUnderCursor;
|
|||
/// button number under the cursor
|
||||
extern int ButtonUnderCursor;
|
||||
/// button 0 (Game Menu) was clicked down
|
||||
extern int GameMenuButtonClicked;
|
||||
extern char GameMenuButtonClicked;
|
||||
/// Mouse leaves windows stops scroll
|
||||
extern char LeaveStops;
|
||||
/// current CursorOn field
|
||||
extern enum _cursor_on_ CursorOn;
|
||||
|
||||
|
|
|
@ -1366,7 +1366,7 @@ extern void SetVideoSync(void);
|
|||
extern void CheckVideoInterrupts(void);
|
||||
|
||||
/// Toggle mouse grab mode
|
||||
extern void ToggleGrabMouse(void);
|
||||
extern void ToggleGrabMouse(int mode);
|
||||
|
||||
/// Toggle full screen mode
|
||||
extern void ToggleFullScreen(void);
|
||||
|
|
|
@ -63,8 +63,8 @@ global char* CclStartFile; /// CCL start file
|
|||
global int CclInConfigFile; /// True while config file parsing
|
||||
|
||||
global char* Tips[MAX_TIPS+1]; /// Array of tips
|
||||
global int ShowTips=0; /// Show tips at start of level
|
||||
global int CurrentTip=0; /// Current tip to display
|
||||
global int ShowTips; /// Show tips at start of level
|
||||
global int CurrentTip; /// Current tip to display
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
@ -234,6 +234,7 @@ local SCM CclDecorationOnTop(void)
|
|||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
** Show tips at the start of a level.
|
||||
*/
|
||||
|
@ -246,10 +247,34 @@ local SCM CclShowTips(void)
|
|||
|
||||
InitTips=0;
|
||||
ShowTips=1;
|
||||
memset(Tips,0,sizeof(Tips));
|
||||
// JOHNS: Done by system: memset(Tips,0,sizeof(Tips));
|
||||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Enable/disable Showing the tips at the start of a level.
|
||||
**
|
||||
** @param flag True = turn on, false = off.
|
||||
** @return The old state of tips displayed.
|
||||
*/
|
||||
local SCM CclSetShowTips(SCM flag)
|
||||
{
|
||||
int old;
|
||||
|
||||
old=ShowTips;
|
||||
ShowTips=gh_scm2bool(flag);
|
||||
|
||||
return gh_bool2scm(old);
|
||||
}
|
||||
|
||||
/**
|
||||
** Add a new tip to the list of tips.
|
||||
**
|
||||
** @param tip A new tip to be displayed before level.
|
||||
**
|
||||
** @todo FIXME: Memory for tips is never freed.
|
||||
*/
|
||||
local SCM CclAddTip(SCM tip)
|
||||
{
|
||||
int i;
|
||||
|
@ -584,7 +609,7 @@ global void InitCcl(void)
|
|||
init_subr_0("show-no-full",CclShowNoFull);
|
||||
init_subr_0("decoration-on-top",CclDecorationOnTop);
|
||||
|
||||
init_subr_0("show-tips",CclShowTips);
|
||||
gh_new_procedure1_0("set-show-tips!",CclSetShowTips);
|
||||
gh_new_procedure1_0("add-tip",CclAddTip);
|
||||
|
||||
gh_new_procedure1_0("speed-mine",CclSpeedMine);
|
||||
|
|
|
@ -526,7 +526,7 @@ local void UiFindIdleWorker(void)
|
|||
local void UiToggleGrabMouse(void)
|
||||
{
|
||||
DebugLevel0Fn("%x\n",KeyModifiers);
|
||||
ToggleGrabMouse();
|
||||
ToggleGrabMouse(0);
|
||||
SetStatusLine("Grab mouse toggled.");
|
||||
}
|
||||
|
||||
|
|
|
@ -59,9 +59,10 @@ global enum _mouse_buttons_ MouseButtons;/// current pressed mouse buttons
|
|||
|
||||
global enum _key_modifiers_ KeyModifiers;/// current keyboard modifiers
|
||||
|
||||
global int ButtonUnderCursor=-1; /// Button under cursor
|
||||
global int GameMenuButtonClicked=0; /// Game menu button (F10) was clicked
|
||||
global Unit* UnitUnderCursor; /// Unit under cursor
|
||||
global int ButtonUnderCursor=-1; /// Button under cursor
|
||||
global char GameMenuButtonClicked; /// Game menu button (F10) was clicked
|
||||
global char LeaveStops; /// Mouse leaves windows stops scroll
|
||||
|
||||
global enum _cursor_on_ CursorOn=CursorOnUnknown; /// cursor on field
|
||||
|
||||
|
@ -563,6 +564,9 @@ local void HandleMouseOn(int x,int y)
|
|||
*/
|
||||
global void HandleMouseExit(void)
|
||||
{
|
||||
if( !LeaveStops ) { // Disabled
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Denote cursor not on anything in window (used?)
|
||||
//
|
||||
|
|
|
@ -469,7 +469,7 @@ local SCM CclDefineCursor(SCM list)
|
|||
**
|
||||
** @param ident Cursor identifier.
|
||||
*/
|
||||
local SCM CclGameCursor(SCM ident)
|
||||
local SCM CclSetGameCursor(SCM ident)
|
||||
{
|
||||
char* str;
|
||||
|
||||
|
@ -1216,6 +1216,40 @@ local SCM CclSetMouseScrollSpeed(SCM num)
|
|||
return gh_int2scm(old);
|
||||
}
|
||||
|
||||
/**
|
||||
** Enable/disable grabbing the mouse.
|
||||
**
|
||||
** @param flag True = grab on, false = grab off.
|
||||
** @return FIXME: not supported: The old state of grabbing.
|
||||
*/
|
||||
local SCM CclSetGrabMouse(SCM flag)
|
||||
{
|
||||
if( gh_scm2bool(flag) ) {
|
||||
ToggleGrabMouse(1);
|
||||
} else {
|
||||
ToggleGrabMouse(-1);
|
||||
}
|
||||
|
||||
//return gh_bool2scm(old);
|
||||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
/**
|
||||
** Enable/disable leaving the window stops scrolling.
|
||||
**
|
||||
** @param flag True = stop on, false = stop off.
|
||||
** @return The old state of stopping.
|
||||
*/
|
||||
local SCM CclSetLeaveStops(SCM flag)
|
||||
{
|
||||
int old;
|
||||
|
||||
old=LeaveStops;
|
||||
LeaveStops=gh_scm2bool(flag);
|
||||
|
||||
return gh_bool2scm(old);
|
||||
}
|
||||
|
||||
/**
|
||||
** Enable/disable scrolling with the keyboard.
|
||||
**
|
||||
|
@ -1696,9 +1730,11 @@ global void UserInterfaceCclRegister(void)
|
|||
gh_new_procedure1_0("set-original-resources!",CclSetOriginalResources);
|
||||
|
||||
gh_new_procedureN("define-cursor",CclDefineCursor);
|
||||
gh_new_procedure1_0("game-cursor",CclGameCursor);
|
||||
gh_new_procedure1_0("set-game-cursor!",CclSetGameCursor);
|
||||
gh_new_procedureN("define-ui",CclDefineUI);
|
||||
|
||||
gh_new_procedure1_0("set-grab-mouse!", CclSetGrabMouse);
|
||||
gh_new_procedure1_0("set-leave-stops!", CclSetLeaveStops);
|
||||
gh_new_procedure1_0("set-key-scroll!", CclSetKeyScroll);
|
||||
gh_new_procedure1_0("set-key-scroll-speed!", CclSetKeyScrollSpeed);
|
||||
gh_new_procedure1_0("set-mouse-scroll!", CclSetMouseScroll);
|
||||
|
|
|
@ -1359,21 +1359,22 @@ global void RealizeVideoMemory(void)
|
|||
|
||||
/**
|
||||
** Toggle grab mouse.
|
||||
**
|
||||
** @param mode Wanted mode, 1 grab, -1 not grab, 0 toggle.
|
||||
*/
|
||||
global void ToggleGrabMouse(void)
|
||||
global void ToggleGrabMouse(int mode)
|
||||
{
|
||||
static int grabbed;
|
||||
|
||||
if( grabbed ) {
|
||||
if( mode<=0 && grabbed ) {
|
||||
XUngrabPointer(TheDisplay,CurrentTime);
|
||||
grabbed=0;
|
||||
} else {
|
||||
} else if( mode>=0 && !grabbed ) {
|
||||
if( XGrabPointer(TheDisplay,TheMainWindow,True,0
|
||||
,GrabModeAsync,GrabModeAsync
|
||||
,TheMainWindow, None, CurrentTime)==GrabSuccess ) {
|
||||
grabbed=1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1062,7 +1062,7 @@ global void SaveCursors(FILE* file)
|
|||
}
|
||||
|
||||
// Not ready:
|
||||
fprintf(file,";;(game-cursor '%s)\n",GameCursor->Ident);
|
||||
fprintf(file,";;(set-game-cursor! '%s)\n",GameCursor->Ident);
|
||||
// FIXME: what about the other variables???
|
||||
switch( CursorState ) {
|
||||
case CursorStatePoint:
|
||||
|
|
|
@ -864,15 +864,17 @@ global void SdlUnlockScreen(void)
|
|||
|
||||
/**
|
||||
** Toggle grab mouse.
|
||||
**
|
||||
** @param mode Wanted mode, 1 grab, -1 not grab, 0 toggle.
|
||||
*/
|
||||
global void ToggleGrabMouse(void)
|
||||
global void ToggleGrabMouse(int mode)
|
||||
{
|
||||
static int grabbed;
|
||||
|
||||
if( grabbed ) {
|
||||
if( mode<=0 && grabbed ) {
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
grabbed=0;
|
||||
} else {
|
||||
} else if( mode>=0 && !grabbed ) {
|
||||
if( SDL_WM_GrabInput(SDL_GRAB_ON)==SDL_GRAB_ON ) {
|
||||
grabbed=1;
|
||||
}
|
||||
|
|
|
@ -1319,8 +1319,10 @@ global void RealizeVideoMemory(void)
|
|||
|
||||
/**
|
||||
** Toggle grab mouse.
|
||||
**
|
||||
** @param mode Wanted mode, 1 grab, -1 not grab, 0 toggle.
|
||||
*/
|
||||
global void ToggleGrabMouse(void)
|
||||
global void ToggleGrabMouse(int mode __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -494,8 +494,10 @@ global void RealizeVideoMemory(void)
|
|||
|
||||
/**
|
||||
** Toggle grab mouse.
|
||||
**
|
||||
** @param mode Wanted mode, 1 grab, -1 not grab, 0 toggle.
|
||||
*/
|
||||
global void ToggleGrabMouse(void)
|
||||
global void ToggleGrabMouse(int mode __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue