Inventory Insight: Added mouse-over item tooltips - v2.1.6
This commit is contained in:
parent
00cbe915d2
commit
2114e50a9f
|
|
@ -13,11 +13,11 @@ MorriCraft is a high-performance voxel engine built with C++ and Raylib. It feat
|
||||||
|
|
||||||
## Version History
|
## Version History
|
||||||
|
|
||||||
### v2.1.5 - Windows Portability (Latest)
|
### v2.1.6 - Inventory Insight (Latest)
|
||||||
* **Static Linking**: Added `-static-libgcc` and `-static-libstdc++` to the Windows build to eliminate DLL dependency errors.
|
* **Item Tooltips**: Added mouse-over names for all inventory and hotbar items.
|
||||||
* **Stand-alone Binary**: The Windows executable is now fully portable.
|
* **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
|
### v2.1.0 - Personalization & Stability
|
||||||
* **Integrated Skin Editor**: Personalize your shirt and pants colors directly from the Options menu.
|
* **Integrated Skin Editor**: Personalize your shirt and pants colors directly from the Options menu.
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
v2.1.5
|
v2.1.6
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
v2.1.5
|
v2.1.6
|
||||||
|
|
|
||||||
42
src/main.cpp
42
src/main.cpp
|
|
@ -28,6 +28,28 @@ enum BlockType {
|
||||||
STICK = 14, WOOD_AXE = 15
|
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
|
// Simple 2D Perlin Noise implementation
|
||||||
float dotGridGradient(int ix, int iy, float x, float y, unsigned int seed) {
|
float dotGridGradient(int ix, int iy, float x, float y, unsigned int seed) {
|
||||||
unsigned int hash = ix * 3284157443 ^ iy * 1911520717;
|
unsigned int hash = ix * 3284157443 ^ iy * 1911520717;
|
||||||
|
|
@ -86,6 +108,7 @@ std::unordered_map<ChunkPos, Chunk*, ChunkPosHash> worldChunks;
|
||||||
static unsigned int globalSeedHash = 0;
|
static unsigned int globalSeedHash = 0;
|
||||||
static std::string currentWorldName = "";
|
static std::string currentWorldName = "";
|
||||||
static std::string playerName = "Player";
|
static std::string playerName = "Player";
|
||||||
|
static std::string hoveredItemName = "";
|
||||||
static bool serverMode = false;
|
static bool serverMode = false;
|
||||||
static float masterMusicVolume = 1.0f;
|
static float masterMusicVolume = 1.0f;
|
||||||
static float masterSoundVolume = 1.0f;
|
static float masterSoundVolume = 1.0f;
|
||||||
|
|
@ -2479,6 +2502,7 @@ int main(void)
|
||||||
|
|
||||||
// Draw Gameplay overlay if we entered gameplay
|
// Draw Gameplay overlay if we entered gameplay
|
||||||
if (currentState == GAMEPLAY || currentState == PAUSE_MENU || currentState == CRAFTING_GUI) {
|
if (currentState == GAMEPLAY || currentState == PAUSE_MENU || currentState == CRAFTING_GUI) {
|
||||||
|
hoveredItemName = "";
|
||||||
// ---- Atmospheric Calculations (Previously global) ----
|
// ---- Atmospheric Calculations (Previously global) ----
|
||||||
// lightLevel and blockTint are derived from the global dayFactor
|
// 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});
|
DrawRectangleRec(slotRect, hov ? (Color){90,90,90,255} : (Color){60,60,60,255});
|
||||||
DrawRectangleLinesEx(slotRect, 2.0f, hov ? WHITE : (Color){100,100,100,200});
|
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) {
|
if (slot.count > 0 && slot.blockType != AIR) {
|
||||||
int bt = slot.blockType;
|
int bt = slot.blockType;
|
||||||
Texture2D tex = (bt == GRASS) ? grassTopTexture : (bt == CRAFTING_TABLE ? craftingSideTexture : blockTextures[bt]);
|
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) {
|
if (currentState == PAUSE_MENU) {
|
||||||
// Draw dark overlay
|
// Draw dark overlay
|
||||||
DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 0, 0, 0, 150 });
|
DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 0, 0, 0, 150 });
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
v2.1.5
|
v2.1.6
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue