Browse Source

Merge pull request #242 from dydzio0614/MapScrollCursor

Implement adventure map scroll cursor change
ArseniyShestakov 9 years ago
parent
commit
eec14028fe
2 changed files with 33 additions and 0 deletions
  1. 32 0
      client/windows/CAdvmapInterface.cpp
  2. 1 0
      client/windows/CAdvmapInterface.h

+ 32 - 0
client/windows/CAdvmapInterface.cpp

@@ -59,6 +59,31 @@ using namespace CSDL_Ext;
 
 CAdvMapInt *adventureInt;
 
+static void setScrollingCursor(ui8 direction)
+{
+	if(direction & CAdvMapInt::RIGHT)
+	{
+		if(direction & CAdvMapInt::UP)
+			CCS->curh->changeGraphic(ECursor::ADVENTURE, 33);
+		else if(direction & CAdvMapInt::DOWN)
+			CCS->curh->changeGraphic(ECursor::ADVENTURE, 35);
+		else
+			CCS->curh->changeGraphic(ECursor::ADVENTURE, 34);
+	}
+	else if(direction & CAdvMapInt::LEFT)
+	{
+		if(direction & CAdvMapInt::UP)
+			CCS->curh->changeGraphic(ECursor::ADVENTURE, 39);
+		else if(direction & CAdvMapInt::DOWN)
+			CCS->curh->changeGraphic(ECursor::ADVENTURE, 37);
+		else
+			CCS->curh->changeGraphic(ECursor::ADVENTURE, 38);
+	}
+	else if(direction & CAdvMapInt::UP)
+		CCS->curh->changeGraphic(ECursor::ADVENTURE, 32);
+	else if(direction & CAdvMapInt::DOWN)
+		CCS->curh->changeGraphic(ECursor::ADVENTURE, 36);
+}
 
 CTerrainRect::CTerrainRect()
 	: fadeSurface(nullptr),
@@ -955,11 +980,18 @@ void CAdvMapInt::show(SDL_Surface * to)
 
 		if(scrollingDir)
 		{
+			setScrollingCursor(scrollingDir);
+			scrollingState = true;
 			updateScreen = true;
 			minimap.redraw();
 			if (mode == EAdvMapMode::WORLD_VIEW)
 				terrain.redraw();
 		}
+		else if(scrollingState)
+		{
+			CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
+			scrollingState = false;
+		}
 	}
 	if(updateScreen)
 	{

+ 1 - 0
client/windows/CAdvmapInterface.h

@@ -121,6 +121,7 @@ public:
 
 	enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
 	ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
+	bool scrollingState;
 
 	enum{NA, INGAME, WAITING} state;