Add basic tooltip
This commit is contained in:
@@ -152,7 +152,14 @@ void drawGameUI(Game *game, f32 dt) {
|
||||
bool selected = input->building == buildingOrder[i];
|
||||
PlayerResources *res = &game->playerResources[game->player];
|
||||
bool canAfford = canAffordBuilding(buildingType, *res);
|
||||
uiGameBuild(buildingNames[i], rec, tex, canAfford, &selected);
|
||||
bool hovered = false;
|
||||
uiGameBuild(buildingNames[i], rec, tex, canAfford, &selected, &hovered);
|
||||
if (hovered) {
|
||||
input->toolTipCost.active = true;
|
||||
i32 costs[RES_COUNT] = {0};
|
||||
getBuildingCost(buildingType, costs);
|
||||
bzMemCpy(input->toolTipCost.costs, costs, sizeof(costs));
|
||||
}
|
||||
if (!canAfford)
|
||||
selected = false;
|
||||
if (selected) {
|
||||
@@ -243,11 +250,16 @@ void drawGameUI(Game *game, f32 dt) {
|
||||
canAfford &= playerRes->pop < playerRes->popCapacity;
|
||||
f32 progress = slot->elapsed / slot->recruitTime;
|
||||
if (slot->numRecruiting <= 0) progress = -1.0f;
|
||||
bool hovered = false;
|
||||
uiGameRecruit(label, rec, tex, slot->numRecruiting, progress,
|
||||
canAfford, &selected);
|
||||
canAfford, &selected, &hovered);
|
||||
i32 res[RES_COUNT] = {0,};
|
||||
getEntityCost(slot->entityType, res);
|
||||
if (hovered) {
|
||||
input->toolTipCost.active = true;
|
||||
bzMemCpy(input->toolTipCost.costs, res, sizeof(res));
|
||||
}
|
||||
if (selected) {
|
||||
i32 res[RES_COUNT] = {0,};
|
||||
getEntityCost(slot->entityType, res);
|
||||
playerRes->pop++;
|
||||
playerRes->food -= res[RES_FOOD];
|
||||
playerRes->wood -= res[RES_WOOD];
|
||||
@@ -287,6 +299,12 @@ void drawGameUI(Game *game, f32 dt) {
|
||||
}
|
||||
|
||||
bzUIEnd(UI);
|
||||
|
||||
if (input->toolTipCost.active) {
|
||||
uiGameTooltipCost(input->mouse, input->toolTipCost.costs, tex);
|
||||
input->toolTipCost.active = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void drawGameOverUI(Game *game, f32 dt) {
|
||||
|
||||
Reference in New Issue
Block a user