Browse Source

small change

meemknight 1 year ago
parent
commit
06290de0e9

+ 70 - 59
Pika/gameplay/containers/isometricGame/isometricGame.cpp

@@ -71,6 +71,7 @@ static bool canPlayerStay(int type, int redstone)
 {
 {
 	return type == 0 || type == IsometricGameEditor::Blocks::redstone ||
 	return type == 0 || type == IsometricGameEditor::Blocks::redstone ||
 		type == IsometricGameEditor::Blocks::redstoneTorch ||
 		type == IsometricGameEditor::Blocks::redstoneTorch ||
+		type == IsometricGameEditor::Blocks::chest ||
 		type == IsometricGameEditor::Blocks::lever ||
 		type == IsometricGameEditor::Blocks::lever ||
 	 	(type == IsometricGameEditor::Blocks::trapdor && redstone == 1);
 	 	(type == IsometricGameEditor::Blocks::trapdor && redstone == 1);
 }
 }
@@ -658,7 +659,7 @@ bool IsometricGame::update(pika::Input input, pika::WindowState windowState, Req
 					auto b = map.getSafe({currentBlock.x + x, 1, currentBlock.y + z});
 					auto b = map.getSafe({currentBlock.x + x, 1, currentBlock.y + z});
 					if (b && canPlayerStay(b->get().x, 
 					if (b && canPlayerStay(b->get().x, 
 						getRedstoneStatusUnsafe({currentBlock.x + x, 1, currentBlock.y + z}).status)
 						getRedstoneStatusUnsafe({currentBlock.x + x, 1, currentBlock.y + z}).status)
-						&& map.getSafe({currentBlock.x + x, 0, currentBlock.y + z})->get().x != 0 //not walking on air
+						//&& map.getSafe({currentBlock.x + x, 0, currentBlock.y + z})->get().x != 0 //not walking on air
 						)
 						)
 					{
 					{
 						if (searcehedPositions.find({currentBlock.x + x, currentBlock.y + z})
 						if (searcehedPositions.find({currentBlock.x + x, currentBlock.y + z})
@@ -721,6 +722,11 @@ bool IsometricGame::update(pika::Input input, pika::WindowState windowState, Req
 				b->set(0, 0);
 				b->set(0, 0);
 				redstoneTorchesCount++;
 				redstoneTorchesCount++;
 			}
 			}
+			else if (b->get().x == IsometricGameEditor::Blocks::chest)
+			{
+				b->set(0, 0);
+				foodCount++;
+			}
 			else if (b->get().x == 0)
 			else if (b->get().x == 0)
 			{
 			{
 				if (itemSelected == 0 && redstoneCount)
 				if (itemSelected == 0 && redstoneCount)
@@ -745,87 +751,92 @@ bool IsometricGame::update(pika::Input input, pika::WindowState windowState, Req
 
 
 #pragma region UI2
 #pragma region UI2
 
 
-	if (itemSelected == 0 && !redstoneCount)
+	if (1)
 	{
 	{
-		itemSelected = -1;
-	}
 
 
-	if (itemSelected == 1 && !redstoneTorchesCount)
-	{
-		itemSelected = -1;
-	}
+		if (itemSelected == 0 && !redstoneCount)
+		{
+			itemSelected = -1;
+		}
 
 
-	renderer.pushCamera();
-	{
-		glui::Frame f(uiBox);
-		renderer.renderRectangle(uiBox, {0.1,0.1,0.1,0.5});
-		
-		float boxSize = uiBox.z/3.f;
+		if (itemSelected == 1 && !redstoneTorchesCount)
+		{
+			itemSelected = -1;
+		}
 
 
-		if (redstoneCount)
-		renderer.renderRectangle({uiBox.x, uiBox.y, boxSize, boxSize}, itemsSprite, {1,1,1,0.9},
-			{}, 0.f, itemsAtlas.get(0,0));
+		renderer.pushCamera();
+		{
+			glui::Frame f(uiBox);
+			renderer.renderRectangle(uiBox, {0.1,0.1,0.1,0.5});
 
 
-		if (redstoneTorchesCount)
-		renderer.renderRectangle({uiBox.x + boxSize, uiBox.y, boxSize, boxSize}, itemsSprite, {1,1,1,0.9},
-			{}, 0.f, itemsAtlas.get(1, 0));
+			float boxSize = uiBox.z / 3.f;
 
 
-		if (foodCount)
-		renderer.renderRectangle({uiBox.x + boxSize * 2, uiBox.y, boxSize, boxSize}, itemsSprite, {1,1,1,0.9},
-			{}, 0.f, itemsAtlas.get(2, 0));
+			if (redstoneCount)
+				renderer.renderRectangle({uiBox.x, uiBox.y, boxSize, boxSize}, itemsSprite, {1,1,1,0.9},
+				{}, 0.f, itemsAtlas.get(0, 0));
 
 
-		if (itemSelected != -1)
-		{
-			renderer.renderRectangle({uiBox.x + boxSize * itemSelected, uiBox.y, boxSize, boxSize}, itemFrameSprite);
-		}
+			if (redstoneTorchesCount)
+				renderer.renderRectangle({uiBox.x + boxSize, uiBox.y, boxSize, boxSize}, itemsSprite, {1,1,1,0.9},
+				{}, 0.f, itemsAtlas.get(1, 0));
+
+			if (foodCount)
+				renderer.renderRectangle({uiBox.x + boxSize * 2, uiBox.y, boxSize, boxSize}, itemsSprite, {1,1,1,0.9},
+				{}, 0.f, itemsAtlas.get(2, 0));
 
 
-		if (redstoneCount)
-		renderer.renderText({uiBox.x + boxSize*0.75, uiBox.y + boxSize * 0.75},
-			std::to_string(redstoneCount).c_str(), font, Colors_White);
+			if (itemSelected != -1)
+			{
+				renderer.renderRectangle({uiBox.x + boxSize * itemSelected, uiBox.y, boxSize, boxSize}, itemFrameSprite);
+			}
 
 
-		if (redstoneTorchesCount)
-		renderer.renderText({uiBox.x + boxSize * 1.75, uiBox.y + boxSize * 0.75},
-			std::to_string(redstoneTorchesCount).c_str(), font, Colors_White);
+			if (redstoneCount)
+				renderer.renderText({uiBox.x + boxSize * 0.75, uiBox.y + boxSize * 0.75},
+				std::to_string(redstoneCount).c_str(), font, Colors_White);
 
 
-		if (foodCount)
-		renderer.renderText({uiBox.x + boxSize * 2.75, uiBox.y + boxSize * 0.75},
-			std::to_string(foodCount).c_str(), font, Colors_White);
+			if (redstoneTorchesCount)
+				renderer.renderText({uiBox.x + boxSize * 1.75, uiBox.y + boxSize * 0.75},
+				std::to_string(redstoneTorchesCount).c_str(), font, Colors_White);
 
 
-		if (input.lMouse.pressed())
-		{
-			if (IsometricGameEditor::pointInBox(glm::vec2(input.mouseX, input.mouseY), {uiBox.x, uiBox.y, boxSize, boxSize}))
+			if (foodCount)
+				renderer.renderText({uiBox.x + boxSize * 2.75, uiBox.y + boxSize * 0.75},
+				std::to_string(foodCount).c_str(), font, Colors_White);
+
+			if (input.lMouse.pressed())
 			{
 			{
-				if (itemSelected == 0) 
+				if (IsometricGameEditor::pointInBox(glm::vec2(input.mouseX, input.mouseY), {uiBox.x, uiBox.y, boxSize, boxSize}))
 				{
 				{
-					itemSelected = -1;
-				}
-				else
-				{
-					itemSelected = 0;
+					if (itemSelected == 0)
+					{
+						itemSelected = -1;
+					}
+					else
+					{
+						itemSelected = 0;
+					}
 				}
 				}
-			}
 
 
-			if (IsometricGameEditor::pointInBox(glm::vec2(input.mouseX, input.mouseY), {uiBox.x + boxSize, uiBox.y, boxSize, boxSize}))
-			{
-				if (itemSelected == 1)
+				if (IsometricGameEditor::pointInBox(glm::vec2(input.mouseX, input.mouseY), {uiBox.x + boxSize, uiBox.y, boxSize, boxSize}))
 				{
 				{
-					itemSelected = -1;
+					if (itemSelected == 1)
+					{
+						itemSelected = -1;
+					}
+					else
+					{
+						itemSelected = 1;
+					}
 				}
 				}
-				else
+
+				if (IsometricGameEditor::pointInBox(glm::vec2(input.mouseX, input.mouseY), {uiBox.x + boxSize * 2, uiBox.y, boxSize, boxSize}))
 				{
 				{
-					itemSelected = 1;
+					itemSelected = 2; //toto eat
 				}
 				}
 			}
 			}
 
 
-			if (IsometricGameEditor::pointInBox(glm::vec2(input.mouseX, input.mouseY), {uiBox.x + boxSize * 2, uiBox.y, boxSize, boxSize}))
-			{
-				itemSelected = 2; //toto eat
-			}
+
 		}
 		}
+		renderer.popCamera();
 
 
-		
-	}
-	renderer.popCamera();
+	};
 
 
 #pragma endregion
 #pragma endregion
 
 

+ 2 - 0
Pika/gameplay/containers/isometricGame/isometricGame.h

@@ -67,6 +67,8 @@ struct IsometricGame: public Container
 	}
 	}
 
 
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument);
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument);
+
+
 	int currentBlock = 0;
 	int currentBlock = 0;
 
 
 	struct Block
 	struct Block

+ 6 - 1
Pika/gameplay/containers/minecraftDungeons/mcDungeonsgameplay.h

@@ -124,6 +124,8 @@ struct McDungeonsGameplay: public Container
 		return worldData[x][y][z];
 		return worldData[x][y][z];
 	}
 	}
 
 
+	//todo input inspector in container manager (make it both as a function and as a widget)
+
 	bool isInRange(int x, int y, int z)
 	bool isInRange(int x, int y, int z)
 	{
 	{
 		if (x < 0 || y < 0 || z < 0 || x >= worldSize.x || y >= worldSize.y || z >= worldSize.z)
 		if (x < 0 || y < 0 || z < 0 || x >= worldSize.x || y >= worldSize.y || z >= worldSize.z)
@@ -962,7 +964,10 @@ struct McDungeonsGameplay: public Container
 			}
 			}
 			else
 			else
 			{
 			{
-				editor.update(requestedInfo.requestedImguiIds, renderer, input, 4, requestedInfo, {windowState.windowW,windowState.windowH});
+
+				editor.update(requestedInfo.requestedImguiIds, 
+					renderer, input, 4, requestedInfo, {windowState.windowW,windowState.windowH});
+
 			}
 			}
 			
 			
 
 

BIN
Pika/resources/iso/maps/optical.isomap


+ 2 - 2
Pika/resources/logs.txt

@@ -1,2 +1,2 @@
-#2024-01-08 22:07:28: Created container: IsometricGame
-#2024-01-08 22:07:43: Destroyed continer: IsometricGame #1
+#2024-01-10 18:35:02: Created container: PikaTextEditor
+#2024-01-10 18:35:04: Destroyed continer: PikaTextEditor #1