Skip to content

Commit

Permalink
Move check to see if metal should be shown inside SetShowingMetal.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurtron committed Dec 24, 2024
1 parent 2c60e7e commit 5f2e70a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
42 changes: 22 additions & 20 deletions rts/Game/UI/GuiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,21 +1010,27 @@ void CGuiHandler::ConvertCommands(std::vector<SCommandDescription>& cmds)
}


void CGuiHandler::SetShowingMetal(bool show)
void CGuiHandler::SetShowingMetal(const SCommandDescription* cmdDesc)
{
RECOIL_DETAILED_TRACY_ZONE;
if (!show) {
if (showingMetal) {
infoTextureHandler->DisableCurrentMode();
showingMetal = false;
}
} else {
if (autoShowMetal) {
if (infoTextureHandler->GetMode() != "metal") {
infoTextureHandler->SetMode("metal");
showingMetal = true;
}
}
if (!autoShowMetal || cmdDesc == nullptr) {
return;
}
bool show = false;
if (cmdDesc->type == CMDTYPE_ICON_BUILDING) {
const UnitDef* ud = unitDefHandler->GetUnitDefByID(-cmdDesc->id);
show = ud->extractsMetal > 0;
}

if (showingMetal && !show)
{
infoTextureHandler->DisableCurrentMode();
showingMetal = false;
}
else if (!showingMetal && infoTextureHandler->GetMode() != "metal")
{
infoTextureHandler->SetMode("metal");
showingMetal = true;
}
}

Expand Down Expand Up @@ -1441,14 +1447,10 @@ void CGuiHandler::SetActiveCommandIndex(int newIndex)
if (inCommand != newIndex) {
inCommand = newIndex;
if (inCommand < commands.size()) {
const auto& cmd = commands[inCommand];
if (cmd.type == CMDTYPE_ICON_BUILDING) {
const UnitDef* ud = unitDefHandler->GetUnitDefByID(-cmd.id);
SetShowingMetal(ud->extractsMetal > 0);
}
eventHandler.ActiveCommandChanged(&cmd);
SetShowingMetal(&commands[inCommand]);
eventHandler.ActiveCommandChanged(&commands[inCommand]);
} else {
SetShowingMetal(false);
SetShowingMetal(nullptr);
eventHandler.ActiveCommandChanged(nullptr);
}

Expand Down
2 changes: 1 addition & 1 deletion rts/Game/UI/GuiHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class CGuiHandler : public CInputReceiver {
unsigned char CreateOptions(bool rightMouseButton);
unsigned char CreateOptions(int button);
void FinishCommand(int button);
void SetShowingMetal(bool show);
void SetShowingMetal(const SCommandDescription *cmdDesc);
float GetNumberInput(const SCommandDescription& cmdDesc) const;

void ProcessFrontPositions(float3& pos0, const float3& pos1);
Expand Down

0 comments on commit 5f2e70a

Please sign in to comment.