浏览代码

Hex Edge Highlight Images moved to VCMI mod

krs 2 年之前
父节点
当前提交
4a3426bb70
共有 23 个文件被更改,包括 123 次插入28 次删除
  1. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/bottom.png
  2. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomLeft.png
  3. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomLeftCorner.png
  4. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomLeftHalfCorner.png
  5. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomRight.png
  6. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomRightCorner.png
  7. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomRightHalfCorner.png
  8. 二进制
      Mods/vcmi/Sprites/battle/rangeHighlights/green/empty.png
  9. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/fullHex.png
  10. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/left.png
  11. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/leftHalf.png
  12. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/right.png
  13. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/rightHalf.png
  14. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/top.png
  15. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/topLeft.png
  16. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/topLeftCorner.png
  17. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/topLeftHalfCorner.png
  18. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/topRight.png
  19. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/topRightCorner.png
  20. 0 0
      Mods/vcmi/Sprites/battle/rangeHighlights/green/topRightHalfCorner.png
  21. 46 0
      Mods/vcmi/Sprites/battle/rangeHighlights/rangeHighlightsGreen.json
  22. 76 27
      client/battle/BattleFieldController.cpp
  23. 1 1
      client/battle/BattleFieldController.h

+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/bottom.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/bottom.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/bottomLeft.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomLeft.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/bottomLeftCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomLeftCorner.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/bottomLeftHalfCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomLeftHalfCorner.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/bottomRight.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomRight.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/bottomRightCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomRightCorner.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/bottomRightHalfCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/bottomRightHalfCorner.png


二进制
Mods/vcmi/Sprites/battle/rangeHighlights/green/empty.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/fullHex.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/fullHex.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/left.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/left.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/leftHalf.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/leftHalf.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/right.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/right.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/rightHalf.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/rightHalf.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/top.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/top.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/topLeft.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/topLeft.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/topLeftCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/topLeftCorner.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/topLeftHalfCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/topLeftHalfCorner.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/topRight.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/topRight.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/topRightCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/topRightCorner.png


+ 0 - 0
Mods/vcmi/Data/rangeHighlights/green/topRightHalfCorner.png → Mods/vcmi/Sprites/battle/rangeHighlights/green/topRightHalfCorner.png


+ 46 - 0
Mods/vcmi/Sprites/battle/rangeHighlights/rangeHighlightsGreen.json

@@ -0,0 +1,46 @@
+{
+	"basepath" : "battle/rangeHighlights/green/",
+	"images" :
+	[
+		{ "frame" : 00, "file" : "empty.png"},						// 000001 -> 00 empty frame
+			
+		// load single edges
+		{ "frame" : 01, "file" : "topLeft.png"},                    //000001 -> 01
+		{ "frame" : 02, "file" : "topRight.png"},                   //000010 -> 02
+		{ "frame" : 03, "file" : "right.png"},                      //000100 -> 04
+		{ "frame" : 04, "file" : "bottomRight.png"},                //001000 -> 08
+		{ "frame" : 05, "file" : "bottomLeft.png"},                 //010000 -> 16
+		{ "frame" : 06, "file" : "left.png"},                       //100000 -> 32
+		
+		// load double edges
+		{ "frame" : 07, "file" : "top.png"},                        //000011 -> 03
+		{ "frame" : 08, "file" : "bottom.png"},                     //011000 -> 24
+		{ "frame" : 09, "file" : "topRightHalfCorner.png"},         //000110 -> 06
+		{ "frame" : 10, "file" : "bottomRightHalfCorner.png"},      //001100 -> 12
+		{ "frame" : 11, "file" : "bottomLeftHalfCorner.png"},       //110000 -> 48
+		{ "frame" : 12, "file" : "topLeftHalfCorner.png"},          //100001 -> 33
+		
+		// load halves
+		{ "frame" : 13, "file" : "rightHalf.png"},                  //001110 -> 14
+		{ "frame" : 14, "file" : "leftHalf.png"},                   //110001 -> 49
+		
+		// load corners
+		{ "frame" : 15, "file" : "topRightCorner.png"},             //000111 -> 07
+		{ "frame" : 16, "file" : "bottomRightCorner.png"},          //011100 -> 28
+		{ "frame" : 17, "file" : "bottomLeftCorner.png"},           //111000 -> 56
+		{ "frame" : 18, "file" : "topLeftCorner.png"}               //100011 -> 35
+	]
+}
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 76 - 27
client/battle/BattleFieldController.cpp

@@ -29,6 +29,7 @@
 #include "../gui/CGuiHandler.h"
 #include "../gui/CursorHandler.h"
 #include "../adventureMap/CInGameConsole.h"
+#include "../client/render/CAnimation.h"
 
 #include "../../CCallback.h"
 #include "../../lib/BattleFieldHandler.h"
@@ -36,6 +37,76 @@
 #include "../../lib/CStack.h"
 #include "../../lib/spells/ISpellMechanics.h"
 
+namespace HexMasks
+{
+	// mask definitions that has set to 1 the edges present in the hex edges highlight image
+	/*
+	    /\
+	   0  1
+	  /    \
+	 |      |
+	 5      2
+	 |      |
+	  \    /
+	   4  3
+	    \/
+	*/
+	enum HexEdgeMasks {
+		empty                 = 0b000000, // empty used when wanting to keep indexes the same but no highlight should be displayed
+		topLeft               = 0b000001,
+		topRight              = 0b000010,
+		right                 = 0b000100,
+		bottomRight           = 0b001000,
+		bottomLeft            = 0b010000,
+		left                  = 0b100000,
+						  
+		top                   = 0b000011,
+		bottom                = 0b011000,
+		topRightHalfCorner    = 0b000110,
+		bottomRightHalfCorner = 0b001100,
+		bottomLeftHalfCorner  = 0b110000,
+		topLeftHalfCorner     = 0b100001,
+						  
+		rightHalf             = 0b001110,
+		leftHalf              = 0b110001,
+						  
+		topRightCorner        = 0b000111,
+		bottomRightCorner     = 0b011100,
+		bottomLeftCorner      = 0b111000,
+		topLeftCorner         = 0b100011
+	};
+}
+
+std::map<int, int> hexEdgeMaskToFrameIndex;
+
+void initializeHexEdgeMaskToFrameIndex()
+{
+	hexEdgeMaskToFrameIndex[HexMasks::empty] = 0;
+
+    hexEdgeMaskToFrameIndex[HexMasks::topLeft] = 1;
+    hexEdgeMaskToFrameIndex[HexMasks::topRight] = 2;
+    hexEdgeMaskToFrameIndex[HexMasks::right] = 3;
+    hexEdgeMaskToFrameIndex[HexMasks::bottomRight] = 4;
+    hexEdgeMaskToFrameIndex[HexMasks::bottomLeft] = 5;
+    hexEdgeMaskToFrameIndex[HexMasks::left] = 6;
+
+    hexEdgeMaskToFrameIndex[HexMasks::top] = 7;
+    hexEdgeMaskToFrameIndex[HexMasks::bottom] = 8;
+
+    hexEdgeMaskToFrameIndex[HexMasks::topRightHalfCorner] = 9;
+    hexEdgeMaskToFrameIndex[HexMasks::bottomRightHalfCorner] = 10;
+    hexEdgeMaskToFrameIndex[HexMasks::bottomLeftHalfCorner] = 11;
+    hexEdgeMaskToFrameIndex[HexMasks::topLeftHalfCorner] = 12;
+
+    hexEdgeMaskToFrameIndex[HexMasks::rightHalf] = 13;
+    hexEdgeMaskToFrameIndex[HexMasks::leftHalf] = 14;
+
+    hexEdgeMaskToFrameIndex[HexMasks::topRightCorner] = 15;
+    hexEdgeMaskToFrameIndex[HexMasks::bottomRightCorner] = 16;
+    hexEdgeMaskToFrameIndex[HexMasks::bottomLeftCorner] = 17;
+    hexEdgeMaskToFrameIndex[HexMasks::topLeftCorner] = 18;
+}
+
 BattleFieldController::BattleFieldController(BattleInterface & owner):
 	owner(owner)
 {
@@ -50,32 +121,10 @@ BattleFieldController::BattleFieldController(BattleInterface & owner):
 	attackCursors = std::make_shared<CAnimation>("CRCOMBAT");
 	attackCursors->preload();
 
-	// load single edges
-	fullDamageRangeLimitImages[0b000001] = IImage::createFromFile("rangeHighlights/green/topLeft.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b000010] = IImage::createFromFile("rangeHighlights/green/topRight.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b000100] = IImage::createFromFile("rangeHighlights/green/right.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b001000] = IImage::createFromFile("rangeHighlights/green/bottomRight.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b010000] = IImage::createFromFile("rangeHighlights/green/bottomLeft.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b100000] = IImage::createFromFile("rangeHighlights/green/left.PNG", EImageBlitMode::COLORKEY);
-
-	// load double edges
-	fullDamageRangeLimitImages[0b000011] = IImage::createFromFile("rangeHighlights/green/top.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b011000] = IImage::createFromFile("rangeHighlights/green/bottom.PNG", EImageBlitMode::COLORKEY);
-
-	fullDamageRangeLimitImages[0b000110] = IImage::createFromFile("rangeHighlights/green/topRightHalfCorner.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b001100] = IImage::createFromFile("rangeHighlights/green/bottomRightHalfCorner.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b110000] = IImage::createFromFile("rangeHighlights/green/bottomLeftHalfCorner.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b100001] = IImage::createFromFile("rangeHighlights/green/topLeftHalfCorner.PNG", EImageBlitMode::COLORKEY);
-
-	// load halves
-	fullDamageRangeLimitImages[0b001110] = IImage::createFromFile("rangeHighlights/green/rightHalf.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b110001] = IImage::createFromFile("rangeHighlights/green/leftHalf.PNG", EImageBlitMode::COLORKEY);
-
-	// load corners
-	fullDamageRangeLimitImages[0b000111] = IImage::createFromFile("rangeHighlights/green/topRightCorner.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b011100] = IImage::createFromFile("rangeHighlights/green/bottomRightCorner.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b111000] = IImage::createFromFile("rangeHighlights/green/bottomLeftCorner.PNG", EImageBlitMode::COLORKEY);
-	fullDamageRangeLimitImages[0b100011] = IImage::createFromFile("rangeHighlights/green/topLeftCorner.PNG", EImageBlitMode::COLORKEY);
+	fullDamageRangeLimitImages = std::make_unique<CAnimation>("battle/rangeHighlights/rangeHighlightsGreen.json");
+	fullDamageRangeLimitImages->preload();
+
+	initializeHexEdgeMaskToFrameIndex();
 
 	if(!owner.siegeController)
 	{
@@ -488,7 +537,7 @@ std::vector<std::shared_ptr<IImage>> BattleFieldController::calculateFullRangedD
 			mask.set(direction);
 
 		uint8_t imageKey = static_cast<uint8_t>(mask.to_ulong());
-		output.push_back(fullDamageRangeLimitImages[imageKey]);
+		output.push_back(fullDamageRangeLimitImages->getImage(hexEdgeMaskToFrameIndex[imageKey]));
 	}
 
 	return output;

+ 1 - 1
client/battle/BattleFieldController.h

@@ -32,8 +32,8 @@ class BattleFieldController : public CIntObject
 	std::shared_ptr<IImage> cellBorder;
 	std::shared_ptr<IImage> cellUnitMovementHighlight;
 	std::shared_ptr<IImage> cellUnitMaxMovementHighlight;
-
 	std::shared_ptr<IImage> cellShade;
+	std::unique_ptr<CAnimation> fullDamageRangeLimitImages;
 
 	std::shared_ptr<CAnimation> attackCursors;