Restrict mouse to viewport added.

This commit is contained in:
johns 2002-06-17 19:58:53 +00:00
parent 99eae21af0
commit 9755182577
5 changed files with 57 additions and 21 deletions

View file

@ -73,6 +73,7 @@ global void CleanModules(void)
CleanIcons();
CleanCursors();
// CleanMenus();
CleanUserInterface();
CleanCampaign();
CleanTriggers();
@ -116,6 +117,7 @@ global void InitModules(void)
InitIcons();
InitVideoCursors();
InitUserInterface(RaceWcNames ? RaceWcNames[1] : "oops");
// InitMenus();
InitPlayers();
InitMissileTypes();
InitMissiles();

View file

@ -259,6 +259,11 @@ extern char **KeyStrokeHelps; /// Keystroke help pairs
#define MENUS_MAXMENU 128 /// FIXME: wrong place, docu
#define MENUS_MAXFUNC 128 /// FIXME: wrong place, docu
#ifdef DOXYGEN // no real code, only for document
#else
/// FIXME: docu
typedef hashtable(Menu*,MENUS_MAXMENU) _MenuHash;
extern _MenuHash MenuHash;
@ -266,6 +271,8 @@ extern _MenuHash MenuHash;
typedef hashtable(void*,MENUS_MAXFUNC) _MenuFuncHash;
extern _MenuFuncHash MenuFuncHash;
#endif
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/

View file

@ -320,6 +320,8 @@ extern void UIHandleButtonDown(unsigned button);
/// Called if any mouse button is released up
extern void UIHandleButtonUp(unsigned button);
/// Restrict mouse cursor to viewport
extern void RestrictCursorToViewport(void);
/// Restrict mouse cursor to minimap
extern void RestrictCursorToMinimap(void);

View file

@ -4302,7 +4302,6 @@ local void StartEditor(void)
GetInfoFromSelectPath();
ProcessMenu("menu-editor-select", 1);
}
local void EditorNewMap(void)
@ -4314,6 +4313,7 @@ local void EditorNewMap(void)
// FIXME: currently just loads default.pud
strcpy(CurrentMapPath, "default.pud");
// FIXME: Use EditorRunning and main-loop.
EditorMainLoop();
EndMenu();
}
@ -4347,6 +4347,7 @@ local void EditorLoadMap(void)
strcat(ScenSelectPath, ScenSelectFileName); // Final map name with path
}
// FIXME: Use EditorRunning and main-loop.
EditorMainLoop();
EndMenu();
}

View file

@ -568,37 +568,61 @@ global void HandleMouseExit(void)
GameCursor = TheUI.Point.Cursor;
}
/**
** Restrict mouse cursor to viewport.
*/
global void RestrictCursorToViewport(void)
{
const Viewport *vp;
vp = &TheUI.VP[TheUI.LastClickedVP];
if (CursorX < vp->X) {
CursorStartX = vp->X;
} else if (CursorX >= vp->EndX) {
CursorStartX = vp->EndX - 1;
} else {
CursorStartX = CursorX;
}
if (CursorY < vp->Y) {
CursorStartY = vp->Y;
} else if (CursorY >= vp->EndY) {
CursorStartY = vp->EndY - 1;
} else {
CursorStartY = CursorY;
}
TheUI.WarpX = CursorX = CursorStartX;
TheUI.WarpY = CursorY = CursorStartY;
CursorOn = CursorOnMap;
}
/**
** Restrict mouse cursor to minimap
*/
global void RestrictCursorToMinimap(void)
{
if( CursorX<TheUI.MinimapX+24 ) {
CursorStartX=TheUI.MinimapX+24;
}
else if( CursorX>=TheUI.MinimapX+24+MINIMAP_W ) {
CursorStartX=TheUI.MinimapX+24+MINIMAP_W-1;
}
else {
CursorStartX=CursorX;
if (CursorX < TheUI.MinimapX + 24) {
CursorStartX = TheUI.MinimapX + 24;
} else if (CursorX >= TheUI.MinimapX + 24 + MINIMAP_W) {
CursorStartX = TheUI.MinimapX + 24 + MINIMAP_W - 1;
} else {
CursorStartX = CursorX;
}
if( CursorY<TheUI.MinimapY+2 ) {
CursorStartY=TheUI.MinimapY+2;
}
else if( CursorY>=TheUI.MinimapY+2+MINIMAP_H ) {
CursorStartY=TheUI.MinimapY+2+MINIMAP_H-1;
}
else {
CursorStartY=CursorY;
if (CursorY < TheUI.MinimapY + 2) {
CursorStartY = TheUI.MinimapY + 2;
} else if (CursorY >= TheUI.MinimapY + 2 + MINIMAP_H) {
CursorStartY = TheUI.MinimapY + 2 + MINIMAP_H - 1;
} else {
CursorStartY = CursorY;
}
CursorX=TheUI.WarpX=CursorStartX;
CursorY=TheUI.WarpY=CursorStartY;
CursorOn=CursorOnMinimap;
CursorX = TheUI.WarpX = CursorStartX;
CursorY = TheUI.WarpY = CursorStartY;
CursorOn = CursorOnMinimap;
}
/**
** Handle movement of the cursor.
**