2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2009-06-05 13:41:20 +00:00
|
|
|
* Copyright (c) 1998-2000 Matthes Bender
|
|
|
|
* Copyright (c) 2001, 2005, 2007 Sven Eberhardt
|
2010-12-23 00:01:24 +00:00
|
|
|
* Copyright (c) 2009 Günther Brammer
|
2009-05-08 13:28:41 +00:00
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
|
|
|
*
|
|
|
|
* Portions might be copyrighted by other authors who have contributed
|
|
|
|
* to OpenClonk.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
* See isc_license.txt for full license and disclaimer.
|
|
|
|
*
|
|
|
|
* "Clonk" is a registered trademark of Matthes Bender.
|
|
|
|
* See clonk_trademark_license.txt for full license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Mouse input */
|
|
|
|
|
|
|
|
#ifndef INC_C4MouseControl
|
|
|
|
#define INC_C4MouseControl
|
|
|
|
|
2011-03-11 02:43:38 +00:00
|
|
|
#include <C4Facet.h>
|
2009-05-08 13:28:41 +00:00
|
|
|
#include "C4ObjectList.h"
|
|
|
|
#include "C4Region.h"
|
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
const int32_t C4MC_Button_None = 0,
|
2010-04-10 20:44:00 +00:00
|
|
|
C4MC_Button_LeftDown = 1,
|
|
|
|
C4MC_Button_LeftUp = 2,
|
|
|
|
C4MC_Button_RightDown = 3,
|
|
|
|
C4MC_Button_RightUp = 4,
|
|
|
|
C4MC_Button_LeftDouble = 5,
|
|
|
|
C4MC_Button_RightDouble = 6,
|
|
|
|
C4MC_Button_Wheel = 7,
|
|
|
|
C4MC_Button_MiddleDown = 8,
|
|
|
|
C4MC_Button_MiddleUp = 9;
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
const int32_t C4MC_DragSensitivity = 5;
|
|
|
|
|
2009-10-25 23:09:34 +00:00
|
|
|
class C4Viewport;
|
|
|
|
class C4Menu;
|
|
|
|
class C4Player;
|
|
|
|
|
2009-05-08 13:28:41 +00:00
|
|
|
class C4MouseControl
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
friend class C4Viewport;
|
2010-03-28 17:58:21 +00:00
|
|
|
public:
|
|
|
|
C4MouseControl();
|
|
|
|
~C4MouseControl();
|
|
|
|
protected:
|
|
|
|
bool Active;
|
|
|
|
bool fMouseOwned;
|
|
|
|
int32_t Player;
|
|
|
|
C4Player *pPlayer; // valid during Move()
|
|
|
|
C4Viewport *Viewport; // valid during Move()
|
|
|
|
StdStrBuf Caption;
|
|
|
|
bool IsHelpCaption;
|
|
|
|
int32_t Cursor;
|
|
|
|
int32_t DownCursor;
|
|
|
|
int32_t CaptionBottomY;
|
|
|
|
int32_t VpX,VpY; // Pixel coordinates of mouse pos
|
|
|
|
float ViewX,ViewY; // Game coordinate scrolling offset of viewport
|
|
|
|
float GameX,GameY; // Game coordinates of mouse pos
|
|
|
|
float GuiX,GuiY; // GUI coorindates of mouse pos
|
|
|
|
C4Facet fctViewport, fctViewportGame, fctViewportGUI;
|
|
|
|
float DownX,DownY; // Game coordinates of mouse-down-pos while dragging
|
|
|
|
float DownOffsetX,DownOffsetY; // GUI coordinate offset from target region while dragging
|
|
|
|
int32_t ShowPointX,ShowPointY; // Game coordinates of throw point
|
|
|
|
int32_t KeepCaption;
|
|
|
|
int32_t ScrollSpeed;
|
|
|
|
int32_t Drag,DragSelecting;
|
|
|
|
bool LeftButtonDown,RightButtonDown,LeftDoubleIgnoreUp;
|
|
|
|
bool ButtonDownOnSelection;
|
|
|
|
bool ControlDown;
|
|
|
|
bool ShiftDown;
|
|
|
|
bool Scrolling;
|
|
|
|
bool InitCentered;
|
|
|
|
bool Help;
|
|
|
|
bool FogOfWar;
|
|
|
|
bool Visible;
|
|
|
|
C4Object *DragObject;
|
|
|
|
C4ID DragID;
|
|
|
|
C4ObjectList Selection;
|
2011-12-25 18:16:50 +00:00
|
|
|
C4Def* DragImageDef;
|
|
|
|
C4Object* DragImageObject;
|
2010-03-28 17:58:21 +00:00
|
|
|
// Target object
|
|
|
|
C4Object *TargetObject; // valid during Move()
|
|
|
|
C4Object *DownTarget;
|
|
|
|
int32_t TimeOnTargetObject;
|
|
|
|
// Region
|
|
|
|
C4Region *TargetRegion; // valid during Move()
|
|
|
|
C4Region DownRegion;
|
|
|
|
public:
|
|
|
|
void Default();
|
|
|
|
void Clear();
|
|
|
|
bool Init(int32_t iPlayer);
|
|
|
|
void Execute();
|
|
|
|
const char *GetCaption();
|
|
|
|
void HideCursor();
|
|
|
|
void ShowCursor();
|
|
|
|
void Draw(C4TargetFacet &cgo, const ZoomData &GameZoom);
|
|
|
|
void Move(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyFlags, bool fCenter = false);
|
|
|
|
void DoMoveInput();
|
|
|
|
bool IsViewport(C4Viewport *pViewport);
|
|
|
|
void ClearPointers(C4Object *pObj);
|
|
|
|
void UpdateClip(); // update clipping region for mouse cursor
|
|
|
|
void SetOwnedMouse(bool fToVal) { fMouseOwned = fToVal; }
|
|
|
|
bool IsMouseOwned() { return fMouseOwned; }
|
|
|
|
bool IsActive() { return !!Active; }
|
2010-04-10 20:44:00 +00:00
|
|
|
bool GetLastGUIPos(int32_t *x_out, int32_t *y_out) const;
|
2010-03-28 17:58:21 +00:00
|
|
|
protected:
|
|
|
|
void SendPlayerSelectNext();
|
|
|
|
void UpdateFogOfWar();
|
|
|
|
void RightUpDragNone();
|
|
|
|
void ButtonUpDragConstruct();
|
|
|
|
void ButtonUpDragScript();
|
|
|
|
void ButtonUpDragMoving();
|
|
|
|
void ButtonUpDragSelecting();
|
|
|
|
void LeftUpDragNone();
|
|
|
|
void DragConstruct();
|
|
|
|
void DragScript();
|
|
|
|
void Wheel(DWORD dwFlags);
|
|
|
|
void RightUp();
|
|
|
|
void RightDown();
|
|
|
|
void LeftDouble();
|
|
|
|
void DragNone();
|
|
|
|
void DragMoving();
|
|
|
|
void LeftUp();
|
|
|
|
void DragSelect();
|
|
|
|
void LeftDown();
|
|
|
|
void UpdateTargetRegion();
|
|
|
|
void UpdateScrolling();
|
|
|
|
void UpdateCursorTarget();
|
|
|
|
void SendCommand(int32_t iCommand, int32_t iX=0, int32_t iY=0, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iData=0, int32_t iAddMode=C4P_Command_Set);
|
|
|
|
int32_t UpdateObjectSelection();
|
|
|
|
int32_t UpdateCrewSelection();
|
|
|
|
int32_t UpdateSingleSelection();
|
|
|
|
bool SendControl(int32_t iCom, int32_t iData=0);
|
|
|
|
bool IsValidMenu(C4Menu *pMenu);
|
|
|
|
bool UpdatePutTarget(bool fVehicle);
|
|
|
|
C4Object *GetTargetObject(); // get MouseSelection object at position
|
|
|
|
bool IsPassive(); // return whether mouse is only used to look around
|
2010-09-24 17:52:20 +00:00
|
|
|
void ScrollView(float iX, float iY, float ViewWdt, float ViewHgt); // in landscape coordinates
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
public:
|
|
|
|
bool IsHelp() { return Help; }
|
|
|
|
void SetHelp() { Help = true; }
|
|
|
|
void AbortHelp() { Help = false; }
|
|
|
|
bool IsDragging();
|
|
|
|
void StartConstructionDrag(C4ID id);
|
|
|
|
int32_t GetPlayer() { return Player; }
|
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-06-05 15:20:07 +00:00
|
|
|
extern C4MouseControl MouseControl;
|
2009-05-08 13:28:41 +00:00
|
|
|
#endif
|