Merge pull request #20 from cxong/develop

Show dragging cursor in galaxy map
This commit is contained in:
Stephen J Sweeney 2017-05-10 08:22:40 +01:00 committed by GitHub
commit 4feb2dfa8a
4 changed files with 21 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

View File

@ -762,6 +762,7 @@ static void handleMouse(void)
{
scrollingMap = 0;
}
setMouseCursor(app.mouse.button[SDL_BUTTON_LEFT] && show == SHOW_GALAXY);
}
static void startMission(void)

View File

@ -61,6 +61,7 @@ extern void updateAllMissions(void);
extern StarSystem *getStarSystem(char *name);
extern void showOKDialog(void (*callback)(void), const char *format, ...);
extern char *getTranslatedString(char *string);
extern void setMouseCursor(int isDrag);
extern void clearInput(void);
extern void awardCampaignTrophies(void);
extern void awardStatsTrophies(void);

View File

@ -21,13 +21,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "input.h"
static SDL_Texture *mousePointer;
static SDL_Texture *mousePointerNormal;
static SDL_Texture *mousePointerMove;
void initInput(void)
{
memset(&app.mouse, 0, sizeof(Mouse));
mousePointer = getTexture("gfx/input/mousePointer.png");
mousePointerNormal = getTexture("gfx/input/mousePointer.png");
mousePointerMove = getTexture("gfx/input/mousePointerMove.png");
mousePointer = mousePointerNormal;
SDL_QueryTexture(mousePointer, NULL, NULL, &app.mouse.w, &app.mouse.h);
}
@ -89,6 +93,18 @@ void doMouseMotion(SDL_MouseMotionEvent *event)
app.mouse.dy = event->yrel;
}
void setMouseCursor(int isDrag)
{
if (isDrag)
{
mousePointer = mousePointerMove;
}
else
{
mousePointer = mousePointerNormal;
}
}
void drawMouse(void)
{
int x, y;
@ -111,4 +127,6 @@ void clearInput(void)
while (SDL_PollEvent(&event))
{
}
setMouseCursor(0);
}