Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Highly Customized] Grey cameo preview and cameo overlays #1477

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ This page lists all the individual contributions to the project by their author.
- `TurretOffset` support for SHP vehicles
- Customizable rocker amplitude
- Customizable wake anim
- Initial effort on optimization for crates' random distribution
- Initial effort on optimization for crates' random distribution
- **Fryone**
- Customizable ElectricBolt Arcs
- Sound entry on unit's creation
Expand All @@ -384,6 +384,7 @@ This page lists all the individual contributions to the project by their author.
- Enhanced Straight trajectory
- Enable Building Production Queue
- Fix for sidebar not updating queued unit numbers when on hold
- Grey cameo preview and cameo overlays
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
43 changes: 43 additions & 0 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,49 @@ In `rulesmd.ini`:
MissingCameo=XXICON.SHP ; filename - including the .shp/.pcx extension
```

### Show cameo when unbuildable

- A setting that allows you to preview information. This feature can be used as before, playing "new construction options" and clearing the specific production queue when prerequisites loss.
- `Cameo.AlwaysExist` controls whether you can see the cameo when the prerequisite have not satisfied (`TechnoLevel`, `Owner` & `Cameo.RequiredHouses`, `RequiredHouses`, `ForbiddenHouses`, `FactoryOwners`, `StolenTech`, `SecretLab` and `RequiredTheaters`, etc should be satisfied, if the `Cameo.OverrideTechnos` is met, it will override the `Owner` & `Cameo.RequiredHouses` conditions). Defaults to `[AudioVisual]` -> `Cameo.AlwaysExist`.
- `Cameo.RequiredHouses` determines whether to add a condition together with `Owner` for `Cameo.AlwaysExist` check when the value is not empty. Suitable for situations where cameo is no need to be modified in games.
- `Cameo.OverrideTechnos` determines whether the cameo can also be displayed when you own one of these technos when the value is not empty. Suitable for situations where cameo need to be dynamically modified in games.
- `ShowBuildingStatistics` controls whether the number of buildings of this type that you currently own needs to be displayed in the upper left corner of the building cameo (requires the cameo exist).
- `Cameo.ShouldCount` controls whether this type of building need to count if `ShowBuildingStatistics=true`. Default to check if building's own `BuildCat` is not `Combat` or `BuildLimit` is set.
- `Cameo.OverlayShapes` controls the drawn image file.
- `Cameo.OverlayFrames` controls which frame in `Cameo.OverlayShapes` to draw in four different situations: currently owned this building type, can automatically build this building, grey cameo and have its prerequisite, grey cameo but have no prerequisite (The second situation requires `AutoBuilding` to be true, the last situation requires `Cameo.AlwaysExist` to be true). When set to a negative number, it means that there is no need to draw under the corresponding conditions.
- `Cameo.OverlayPalette` the color palette used when drawing `Cameo.OverlayShapes`.
- The `UIDescription.Unbuildable` is like `UIDescription`, but this only appearing when the techno is truly unbuildable.

In `ra2md.ini`:
```ini
[Phobos]
ShowBuildingStatistics=false ; boolean
```

In `rulesmd.ini`:
```ini
[AudioVisual]
Cameo.AlwaysExist=false ; boolean
Cameo.OverlayShapes=pips.shp ; filename - including the .shp extension
Cameo.OverlayFrames= ; integer - owned this building, can automatically build, grey and have its prerequisite, grey but have no prerequisite
Cameo.OverlayPalette=palette.pal ; filename - including the .pal extension

[SOMETECHNO] ; TechnoType
Cameo.AlwaysExist= ; boolean
Cameo.RequiredHouses= ; list of house types
Cameo.OverrideTechnos= ; List of TechnoTypes
UIDescription.Unbuildable= ; CSF entry key

[SOMEBUILDING] ; BuildingType
Cameo.ShouldCount= ; boolean
```

In `artmd.ini`:
```ini
[SOMETECHNO] ; TechnoType
GreyCameoPCX= ; PCX filename - including the .pcx extension
```

### Harvester counter

![image](_static/images/harvestercounter-01.gif)
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ New:
- Custom exit cell for infantry factory (by Starkku)
- Option for vehicles to keep target when issued move command (by Starkku)
- Skip anim delay for burst fire (by TaranDahl)
- Grey cameo preview and cameo overlays (by CrimRecya)

Vanilla fixes:
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby (by CrimRecya)
Expand Down
23 changes: 9 additions & 14 deletions src/Ext/BuildingType/Body.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "Body.h"

#include <Ext/House/Body.h>
#include <EventClass.h>
#include <TacticalClass.h>

#include <Utilities/GeneralUtils.h>
#include <Ext/TechnoType/Body.h>
#include <Ext/House/Body.h>
#include <Ext/SWType/Body.h>
#include <Ext/Scenario/Body.h>

BuildingTypeExt::ExtContainer BuildingTypeExt::ExtMap;

Expand Down Expand Up @@ -61,19 +66,6 @@ int BuildingTypeExt::GetEnhancedPower(BuildingClass* pBuilding, HouseClass* pHou
return static_cast<int>(std::round(pBuilding->GetPowerOutput() * fFactor)) + nAmount;
}

int BuildingTypeExt::CountOwnedNowWithDeployOrUpgrade(BuildingTypeClass* pType, HouseClass* pHouse)
{
const auto upgrades = BuildingTypeExt::GetUpgradesAmount(pType, pHouse);

if (upgrades != -1)
return upgrades;

if (const auto pUndeploy = pType->UndeploysInto)
return pHouse->CountOwnedNow(pType) + pHouse->CountOwnedNow(pUndeploy);

return pHouse->CountOwnedNow(pType);
}

int BuildingTypeExt::GetUpgradesAmount(BuildingTypeClass* pBuilding, HouseClass* pHouse) // not including producing upgrades
{
int result = 0;
Expand Down Expand Up @@ -163,6 +155,8 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->SellBuildupLength.Read(exINI, pSection, "SellBuildupLength");
this->IsDestroyableObstacle.Read(exINI, pSection, "IsDestroyableObstacle");

this->Cameo_ShouldCount.Read(exINI, pSection, "Cameo.ShouldCount");

this->FactoryPlant_AllowTypes.Read(exINI, pSection, "FactoryPlant.AllowTypes");
this->FactoryPlant_DisallowTypes.Read(exINI, pSection, "FactoryPlant.DisallowTypes");

Expand Down Expand Up @@ -289,6 +283,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
.Process(this->ConsideredVehicle)
.Process(this->ZShapePointMove_OnBuildup)
.Process(this->SellBuildupLength)
.Process(this->Cameo_ShouldCount)
.Process(this->AircraftDockingDirs)
.Process(this->FactoryPlant_AllowTypes)
.Process(this->FactoryPlant_DisallowTypes)
Expand Down
5 changes: 4 additions & 1 deletion src/Ext/BuildingType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <SuperClass.h>
#include <SuperWeaponTypeClass.h>

#include <Ext/TechnoType/Body.h>
#include <Helpers/Macro.h>
#include <Utilities/Container.h>
#include <Utilities/TemplateDef.h>
Expand Down Expand Up @@ -64,6 +65,8 @@ class BuildingTypeExt
Valueable<int> SellBuildupLength;
Valueable<bool> IsDestroyableObstacle;

Nullable<bool> Cameo_ShouldCount;

Valueable<bool> IsAnimDelayedBurst;

std::vector<std::optional<DirType>> AircraftDockingDirs;
Expand Down Expand Up @@ -119,6 +122,7 @@ class BuildingTypeExt
, ConsideredVehicle {}
, ZShapePointMove_OnBuildup { false }
, SellBuildupLength { 23 }
, Cameo_ShouldCount {}
, AircraftDockingDirs {}
, FactoryPlant_AllowTypes {}
, FactoryPlant_DisallowTypes {}
Expand Down Expand Up @@ -170,6 +174,5 @@ class BuildingTypeExt

static int GetEnhancedPower(BuildingClass* pBuilding, HouseClass* pHouse);
static bool CanUpgrade(BuildingClass* pBuilding, BuildingTypeClass* pUpgradeType, HouseClass* pUpgradeOwner);
static int CountOwnedNowWithDeployOrUpgrade(BuildingTypeClass* pBuilding, HouseClass* pHouse);
static int GetUpgradesAmount(BuildingTypeClass* pBuilding, HouseClass* pHouse);
};
37 changes: 19 additions & 18 deletions src/Ext/BuildingType/Hooks.Upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,45 +74,46 @@ int BuildLimitRemaining(HouseClass const* const pHouse, BuildingTypeClass const*
return -BuildLimit - pHouse->CountOwnedEver(pItem);
}

int CheckBuildLimit(HouseClass const* const pHouse, BuildingTypeClass const* const pItem, bool const includeQueued)
CanBuildResult CheckBuildLimit(HouseClass const* const pHouse, BuildingTypeClass const* const pItem, bool const includeQueued)
{
enum { NotReached = 1, ReachedPermanently = -1, ReachedTemporarily = 0 };

int BuildLimit = pItem->BuildLimit;
int Remaining = BuildLimitRemaining(pHouse, pItem);

if (BuildLimit >= 0 && Remaining <= 0)
return (includeQueued && FactoryClass::FindByOwnerAndProduct(pHouse, pItem)) ? NotReached : ReachedPermanently;

return Remaining > 0 ? NotReached : ReachedTemporarily;
return (includeQueued && FactoryClass::FindByOwnerAndProduct(pHouse, pItem)) ? CanBuildResult::Buildable : CanBuildResult::Unbuildable;

return Remaining > 0 ? CanBuildResult::Buildable : CanBuildResult::TemporarilyUnbuildable;
}

DEFINE_HOOK(0x4F8361, HouseClass_CanBuild_UpgradesInteraction, 0x5)
{
GET(HouseClass const* const, pThis, ECX);
GET_STACK(TechnoTypeClass const* const, pItem, 0x4);
GET_STACK(bool, buildLimitOnly, 0x8);
GET_STACK(bool const, includeInProduction, 0xC);
GET(CanBuildResult const, resultOfAres, EAX);
GET(HouseClass* const, pThis, ECX);
GET_STACK(TechnoTypeClass* const, pItem, 0x4);
GET_STACK(const bool, buildLimitOnly, 0x8);
GET_STACK(const bool, includeInProduction, 0xC);
GET(CanBuildResult, canBuild, EAX); // resultOfAres

if (auto const pBuilding = abstract_cast<BuildingTypeClass const* const>(pItem))
if (canBuild == CanBuildResult::Buildable)
{
if (auto pBuildingExt = BuildingTypeExt::ExtMap.Find(pBuilding))
if (auto const pBuilding = abstract_cast<BuildingTypeClass* const>(pItem))
{
if (pBuildingExt->PowersUp_Buildings.size() > 0 && resultOfAres == CanBuildResult::Buildable)
R->EAX(CheckBuildLimit(pThis, pBuilding, includeInProduction));
if (BuildingTypeExt::ExtMap.Find(pBuilding)->PowersUp_Buildings.size() > 0)
canBuild = CheckBuildLimit(pThis, pBuilding, includeInProduction);
}
}

if (resultOfAres == CanBuildResult::Buildable)
if (canBuild == CanBuildResult::Buildable)
{
R->EAX(HouseExt::BuildLimitGroupCheck(pThis, pItem, buildLimitOnly, includeInProduction));
canBuild = HouseExt::BuildLimitGroupCheck(pThis, pItem, buildLimitOnly, includeInProduction);

if (HouseExt::ReachedBuildLimit(pThis, pItem, true))
R->EAX(CanBuildResult::TemporarilyUnbuildable);
canBuild = CanBuildResult::TemporarilyUnbuildable;
}

if (!buildLimitOnly && includeInProduction && pThis == HouseClass::CurrentPlayer()) // Eliminate any non-producible calls
canBuild = TechnoTypeExt::CheckAlwaysExistCameo(pItem, canBuild);

R->EAX(canBuild);
return 0;
}

Expand Down
Loading