diff --git a/README.md b/README.md index 93e7273..c368704 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ MorriCraft is a high-performance voxel engine built with C++ and Raylib. It feat ## Version History -### v2.1.5 - Windows Portability (Latest) -* **Static Linking**: Added `-static-libgcc` and `-static-libstdc++` to the Windows build to eliminate DLL dependency errors. -* **Stand-alone Binary**: The Windows executable is now fully portable. +### v2.1.6 - Inventory Insight (Latest) +* **Item Tooltips**: Added mouse-over names for all inventory and hotbar items. +* **UI Polish**: Dynamic tooltip positioning to ensure labels stay on-screen. -### v2.1.4 - Menu Responsiveness +### v2.1.5 - Windows Portability ### v2.1.0 - Personalization & Stability * **Integrated Skin Editor**: Personalize your shirt and pants colors directly from the Options menu. diff --git a/build-linux/MorriCraft b/build-linux/MorriCraft index c060bc2..7cf0b5f 100755 Binary files a/build-linux/MorriCraft and b/build-linux/MorriCraft differ diff --git a/build-linux/assets/version.txt b/build-linux/assets/version.txt index ef4b6a2..018da23 100644 --- a/build-linux/assets/version.txt +++ b/build-linux/assets/version.txt @@ -1 +1 @@ -v2.1.5 +v2.1.6 diff --git a/build-windows/MorriCraft.exe b/build-windows/MorriCraft.exe index 9011f41..88dcd06 100755 Binary files a/build-windows/MorriCraft.exe and b/build-windows/MorriCraft.exe differ diff --git a/build-windows/assets/version.txt b/build-windows/assets/version.txt index ef4b6a2..018da23 100644 --- a/build-windows/assets/version.txt +++ b/build-windows/assets/version.txt @@ -1 +1 @@ -v2.1.5 +v2.1.6 diff --git a/src/main.cpp b/src/main.cpp index d808d2b..063bf4d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,28 @@ enum BlockType { STICK = 14, WOOD_AXE = 15 }; +std::string GetBlockName(int type) { + switch (type) { + case AIR: return ""; + case GRASS: return "Grass Block"; + case DIRT: return "Dirt"; + case COBBLESTONE: return "Cobblestone"; + case LOG: return "Oak Log"; + case LEAVES: return "Leaves"; + case PLANK: return "Oak Planks"; + case STONE: return "Stone"; + case BEDROCK: return "Bedrock"; + case DIAMOND_ORE: return "Diamond Ore"; + case IRON_ORE: return "Iron Ore"; + case GRAVEL: return "Gravel"; + case CRAFTING_TABLE: return "Crafting Table"; + case SAND: return "Sand"; + case STICK: return "Stick"; + case WOOD_AXE: return "Wooden Axe"; + default: return "Unknown Item"; + } +} + // Simple 2D Perlin Noise implementation float dotGridGradient(int ix, int iy, float x, float y, unsigned int seed) { unsigned int hash = ix * 3284157443 ^ iy * 1911520717; @@ -86,6 +108,7 @@ std::unordered_map worldChunks; static unsigned int globalSeedHash = 0; static std::string currentWorldName = ""; static std::string playerName = "Player"; +static std::string hoveredItemName = ""; static bool serverMode = false; static float masterMusicVolume = 1.0f; static float masterSoundVolume = 1.0f; @@ -2479,6 +2502,7 @@ int main(void) // Draw Gameplay overlay if we entered gameplay if (currentState == GAMEPLAY || currentState == PAUSE_MENU || currentState == CRAFTING_GUI) { + hoveredItemName = ""; // ---- Atmospheric Calculations (Previously global) ---- // lightLevel and blockTint are derived from the global dayFactor @@ -2789,6 +2813,10 @@ int main(void) DrawRectangleRec(slotRect, hov ? (Color){90,90,90,255} : (Color){60,60,60,255}); DrawRectangleLinesEx(slotRect, 2.0f, hov ? WHITE : (Color){100,100,100,200}); + if (hov && slot.blockType != AIR) { + hoveredItemName = GetBlockName(slot.blockType); + } + if (slot.count > 0 && slot.blockType != AIR) { int bt = slot.blockType; Texture2D tex = (bt == GRASS) ? grassTopTexture : (bt == CRAFTING_TABLE ? craftingSideTexture : blockTextures[bt]); @@ -2968,6 +2996,20 @@ int main(void) } } + // --- Draw Hover Tooltip --- + if (hoveredItemName != "" && mouseHeldItem.blockType == AIR) { + Vector2 tSize = MeasureTextEx(customFont, hoveredItemName.c_str(), 18, 1.0f); + int tx = mousePos.x + 15; + int ty = mousePos.y - 25; + // Keep tooltip on screen + if (tx + tSize.x + 10 > currentWidth) tx = mousePos.x - tSize.x - 15; + if (ty < 0) ty = mousePos.y + 15; + + DrawRectangle(tx - 5, ty - 5, tSize.x + 10, tSize.y + 10, (Color){20, 20, 20, 240}); + DrawRectangleLines(tx - 5, ty - 5, tSize.x + 10, tSize.y + 10, (Color){100, 100, 100, 255}); + DrawTextEx(customFont, hoveredItemName.c_str(), (Vector2){(float)tx, (float)ty}, 18, 1.0f, WHITE); + } + if (currentState == PAUSE_MENU) { // Draw dark overlay DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 0, 0, 0, 150 }); diff --git a/version.txt b/version.txt index ef4b6a2..018da23 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v2.1.5 +v2.1.6