Jelajahi Sumber

Expanded cursors enum to include all possible values

Ivan Savenko 2 tahun lalu
induk
melakukan
291bb9b204
3 mengubah file dengan 47 tambahan dan 7 penghapusan
  1. 29 7
      client/gui/CCursorHandler.h
  2. 11 0
      lib/battle/BattleHex.cpp
  3. 7 0
      lib/battle/BattleHex.h

+ 29 - 7
client/gui/CCursorHandler.h

@@ -15,13 +15,35 @@ struct SDL_Texture;
 
 namespace ECursor
 {
-	enum ECursorTypes { ADVENTURE, COMBAT, DEFAULT, SPELLBOOK };
-
-	enum EBattleCursors { COMBAT_BLOCKED, COMBAT_MOVE, COMBAT_FLY, COMBAT_SHOOT,
-						COMBAT_HERO, COMBAT_QUERY, COMBAT_POINTER,
-						//various attack frames
-						COMBAT_SHOOT_PENALTY = 15, COMBAT_SHOOT_CATAPULT, COMBAT_HEAL,
-						COMBAT_SACRIFICE, COMBAT_TELEPORT};
+	enum ECursorTypes {
+		ADVENTURE, // set of various cursors for adventure map
+		COMBAT,    // set of various cursors for combat
+		DEFAULT,   // default arror and hourglass cursors
+		SPELLBOOK  // animated cursor for spellcasting
+	};
+
+	enum EBattleCursors {
+		COMBAT_BLOCKED        = 0,
+		COMBAT_MOVE           = 1,
+		COMBAT_FLY            = 2,
+		COMBAT_SHOOT          = 3,
+		COMBAT_HERO           = 4,
+		COMBAT_QUERY          = 5,
+		COMBAT_POINTER        = 6,
+		COMBAT_HIT_NORTHEAST  = 7,
+		COMBAT_HIT_EAST       = 8,
+		COMBAT_HIT_SOUTHEAST  = 9,
+		COMBAT_HIT_SOUTHWEST  = 10,
+		COMBAT_HIT_WEST       = 11,
+		COMBAT_HIT_NORTHWEST  = 12,
+		COMBAT_HIT_NORTH      = 13,
+		COMBAT_HIT_SOUTH      = 14,
+		COMBAT_SHOOT_PENALTY  = 15,
+		COMBAT_SHOOT_CATAPULT = 16,
+		COMBAT_HEAL           = 17,
+		COMBAT_SACRIFICE      = 18,
+		COMBAT_TELEPORT       = 19
+	};
 }
 
 /// handles mouse cursor

+ 11 - 0
lib/battle/BattleHex.cpp

@@ -140,6 +140,17 @@ std::vector<BattleHex> BattleHex::neighbouringTiles() const
 	return ret;
 }
 
+std::vector<BattleHex> BattleHex::allNeighbouringTiles() const
+{
+	std::vector<BattleHex> ret;
+	ret.resize(6);
+
+	for(EDir dir = EDir(0); dir <= EDir(5); dir = EDir(dir+1))
+		ret[dir] = cloneInDirection(dir, false);
+
+	return ret;
+}
+
 signed char BattleHex::mutualPosition(BattleHex hex1, BattleHex hex2)
 {
 	for(EDir dir = EDir(0); dir <= EDir(5); dir = EDir(dir+1))

+ 7 - 0
lib/battle/BattleHex.h

@@ -74,7 +74,14 @@ struct DLL_LINKAGE BattleHex //TODO: decide if this should be changed to class f
 	BattleHex& operator+=(EDir dir);
 	BattleHex cloneInDirection(EDir dir, bool hasToBeValid = true) const;
 	BattleHex operator+(EDir dir) const;
+
+	/// returns all valid neighbouring tiles
 	std::vector<BattleHex> neighbouringTiles() const;
+
+	/// returns all tiles, unavailable tiles will be set as invalid
+	/// order of returned tiles matches EDir enim
+	std::vector<BattleHex> allNeighbouringTiles() const;
+
 	static signed char mutualPosition(BattleHex hex1, BattleHex hex2);
 	static char getDistance(BattleHex hex1, BattleHex hex2);
 	static void checkAndPush(BattleHex tile, std::vector<BattleHex> & ret);