1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

Deprecate artifact-related building types

This commit is contained in:
Ivan Savenko
2024-08-26 21:25:39 +00:00
parent 55fd7bd7aa
commit 408a632002
19 changed files with 141 additions and 118 deletions

View File

@@ -145,7 +145,7 @@ void CBuildingRect::clickPressed(const Point & cursorPosition)
if(getBuilding() && area && (parent->selectedBuilding==this))
{
auto building = getBuilding();
parent->buildingClicked(building->bid, building->subId, building->upgrade);
parent->buildingClicked(building->bid);
}
}
@@ -681,24 +681,78 @@ const CGHeroInstance * CCastleBuildings::getHero()
return town->garrisonHero;
}
void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuildingSubID subID, BuildingID upgrades)
void CCastleBuildings::buildingClicked(BuildingID building)
{
logGlobal->trace("You've clicked on %d", (int)building.toEnum());
const CBuilding *b = town->town->buildings.find(building)->second;
if (town->getWarMachineInBuilding(building).hasValue())
BuildingID buildingToEnter = building;
for(;;)
{
enterBlacksmith(building, town->getWarMachineInBuilding(building));
return;
const CBuilding *b = town->town->buildings.find(buildingToEnter)->second;
if (buildingTryActivateCustomUI(buildingToEnter, building))
return;
if (!b->upgrade.hasValue())
{
enterBuilding(building);
return;
}
buildingToEnter = b->upgrade;
}
}
bool CCastleBuildings::buildingTryActivateCustomUI(BuildingID buildingToTest, BuildingID buildingTarget)
{
logGlobal->trace("You've clicked on %d", (int)buildingToTest.toEnum());
const CBuilding *b = town->town->buildings.at(buildingToTest);
if (town->getWarMachineInBuilding(buildingToTest).hasValue())
{
enterBlacksmith(buildingTarget, town->getWarMachineInBuilding(buildingToTest));
return true;
}
if (building >= BuildingID::DWELL_FIRST)
// FIXME: implement correct visiting of thieves guild
if (!b->marketModes.empty())
{
enterDwelling((BuildingID::getLevelFromDwelling(building)));
switch (*b->marketModes.begin())
{
case EMarketMode::CREATURE_UNDEAD:
GH.windows().createAndPushWindow<CTransformerWindow>(town, getHero(), nullptr);
return true;
case EMarketMode::RESOURCE_SKILL:
if (getHero())
GH.windows().createAndPushWindow<CUniversityWindow>(getHero(), buildingTarget, town, nullptr);
return true;
case EMarketMode::RESOURCE_RESOURCE:
// can't use allied marketplace
if (town->getOwner() == LOCPLINT->playerID)
{
GH.windows().createAndPushWindow<CMarketWindow>(town, getHero(), nullptr, *b->marketModes.begin());
return true;
}
else
return false;
default:
if(getHero())
GH.windows().createAndPushWindow<CMarketWindow>(town, getHero(), nullptr, *b->marketModes.begin());
else
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
return true;
}
}
if (buildingToTest >= BuildingID::DWELL_FIRST)
{
enterDwelling((BuildingID::getLevelFromDwelling(buildingToTest)));
return true;
}
else
{
switch(building)
switch(buildingToTest)
{
case BuildingID::MAGES_GUILD_1:
case BuildingID::MAGES_GUILD_2:
@@ -706,117 +760,74 @@ void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuil
case BuildingID::MAGES_GUILD_4:
case BuildingID::MAGES_GUILD_5:
enterMagesGuild();
break;
return true;
case BuildingID::TAVERN:
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
break;
return true;
case BuildingID::SHIPYARD:
if(town->shipyardStatus() == IBoatGenerator::GOOD)
{
LOCPLINT->showShipyardDialog(town);
return true;
}
else if(town->shipyardStatus() == IBoatGenerator::BOAT_ALREADY_BUILT)
{
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]);
break;
return true;
}
return false;
case BuildingID::FORT:
case BuildingID::CITADEL:
case BuildingID::CASTLE:
GH.windows().createAndPushWindow<CFortScreen>(town);
break;
return true;
case BuildingID::VILLAGE_HALL:
case BuildingID::CITY_HALL:
case BuildingID::TOWN_HALL:
case BuildingID::CAPITOL:
enterTownHall();
break;
case BuildingID::MARKETPLACE:
// can't use allied marketplace
if (town->getOwner() == LOCPLINT->playerID)
GH.windows().createAndPushWindow<CMarketWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_RESOURCE);
else
enterBuilding(building);
break;
return true;
case BuildingID::SHIP:
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]); //Cannot build another boat
break;
return true;
case BuildingID::SPECIAL_1:
case BuildingID::SPECIAL_2:
case BuildingID::SPECIAL_3:
case BuildingID::SPECIAL_4:
switch (subID)
switch (b->subId)
{
case BuildingSubID::NONE:
enterBuilding(building);
break;
case BuildingSubID::MYSTIC_POND:
enterFountain(building, subID, upgrades);
break;
case BuildingSubID::ARTIFACT_MERCHANT:
if(town->visitingHero)
GH.windows().createAndPushWindow<CMarketWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_ARTIFACT);
else
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
break;
case BuildingSubID::FOUNTAIN_OF_FORTUNE:
enterFountain(building, subID, upgrades);
break;
case BuildingSubID::FREELANCERS_GUILD:
if(getHero())
GH.windows().createAndPushWindow<CMarketWindow>(town, getHero(), nullptr, EMarketMode::CREATURE_RESOURCE);
else
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
break;
case BuildingSubID::MAGIC_UNIVERSITY:
if (getHero())
GH.windows().createAndPushWindow<CUniversityWindow>(getHero(), town, nullptr);
else
enterBuilding(building);
break;
enterFountain(buildingToTest, b->subId, buildingTarget);
return true;
case BuildingSubID::CASTLE_GATE:
if (LOCPLINT->makingTurn)
{
enterCastleGate();
else
enterBuilding(building);
break;
case BuildingSubID::CREATURE_TRANSFORMER: //Skeleton Transformer
GH.windows().createAndPushWindow<CTransformerWindow>(town, getHero(), nullptr);
break;
return true;
}
return false;
case BuildingSubID::PORTAL_OF_SUMMONING:
if (town->creatures[town->town->creatures.size()].second.empty())//No creatures
LOCPLINT->showInfoDialog(CGI->generaltexth->tcommands[30]);
else
enterDwelling(town->town->creatures.size());
break;
return true;
case BuildingSubID::BANK:
enterBank();
break;
default:
if(upgrades == BuildingID::TAVERN)
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
else
enterBuilding(building);
break;
return true;
}
break;
return false;
default:
enterBuilding(building);
break;
return false;
}
}
}