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

[Minor] Add separate tag for grid transparency when PlacementPreview is enabled #1194

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,19 @@ DisplayIncome.Offset=0,0 ; X,Y, pixels relative to default
*Building placement preview using 50% translucency in [Rise of the East](https://www.moddb.com/mods/riseoftheeast)*

- Building previews can now be enabled when placing a building for construction. This can be enabled on a global basis with `[AudioVisual]->PlacementPreview` and then further customized for each building with `[SOMEBUILDING]->PlacementPreview`.
- The building placement grid (`place.shp`) translucency setting can be adjusted via `PlacementGrid.Translucency`.
- The building placement grid (`place.shp`) translucency setting can be adjusted via `PlacementGrid.Translucency` if `PlacementPreview` is disabled and `PlacementGrid.TranslucencyWithPreview` if enabled.
- If using the building's appropriate `Buildup` is not desired, customizations allow for you to choose the exact SHP and frame you'd prefer to show as preview through `PlacementPreview.Shape`, `PlacementPreview.ShapeFrame` and `PlacementPreview.Palette`.
- You can specify theater-specific palettes and shapes by putting three `~` marks to the theater specific part of the filename. `~~~` is replaced with the theater’s three-letter extension.
- `PlacementPreview.ShapeFrame=` tag defaults to building's artmd.ini `Buildup` entry's last non-shadow frame. If there is no 'Buildup' specified it will instead attempt to default to the building's normal first frame (animation frames and bibs are not included in this preview).

In `rulesmd.ini`:
```ini
[AudioVisual]
PlacementGrid.Translucency=0 ; translucency level (0/25/50/75)
PlacementGrid.TranslucencyWithPreview= ; translucency level (0/25/50/75), defaults to [AudioVisual]->PlacementGrid.Translucency

PlacementPreview=no ; boolean
PlacementPreview.Translucency=75 ; translucency level (0/25/50/75)
PlacementGrid.Translucency=0 ; translucency level (0/25/50/75)

[SOMEBUILDING]
PlacementPreview=yes ; boolean
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ New:
- Customizable straight trajectory detonation & snap distance and pass-through option (by Starkku)
- Airstrike & spy plane fixed spawn distance & height (by Starkku)
- Allow enabling application of `Verses` and `PercentAtMax` for negative damage (by Starkku)
- In addition to `PlacementGrid.Translucency`, allow to set the transparency of the grid when PlacementPreview is enabled, using the `PlacementGrid.TranslucencyWithPreview` tag (by Belonit).

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
12 changes: 10 additions & 2 deletions src/Ext/BuildingType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,17 @@ DEFINE_HOOK(0x6D528A, TacticalClass_DrawPlacement_PlacementPreview, 0x6)

DEFINE_HOOK(0x47EFAE, CellClass_Draw_It_SetPlacementGridTranslucency, 0x6)
{
LEA_STACK(BlitterFlags*, blitFlags, STACK_OFFSET(0x68, -0x58));
auto pRules = RulesExt::Global();
BlitterFlags translucency = (pRules->PlacementPreview && Phobos::Config::ShowPlacementPreview)
? pRules->PlacementGrid_TranslucencyWithPreview.Get(pRules->PlacementGrid_Translucency)
: pRules->PlacementGrid_Translucency;

if (translucency != BlitterFlags::None)
{
LEA_STACK(BlitterFlags*, blitFlags, STACK_OFFSET(0x68, -0x58));
*blitFlags |= translucency;
}

*blitFlags |= RulesExt::Global()->PlacementGrid_Translucency;
return 0;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->RadHasInvoker.Read(exINI, GameStrings::Radiation, "RadHasInvoker");
this->MissingCameo.Read(pINI, GameStrings::AudioVisual, "MissingCameo");

this->PlacementGrid_Translucency.Read(exINI, GameStrings::AudioVisual, "PlacementGrid.Translucency");
this->PlacementGrid_TranslucencyWithPreview.Read(exINI, GameStrings::AudioVisual, "PlacementGrid.TranslucencyWithPreview");
this->PlacementPreview.Read(exINI, GameStrings::AudioVisual, "PlacementPreview");
this->PlacementPreview_Translucency.Read(exINI, GameStrings::AudioVisual, "PlacementPreview.Translucency");
this->PlacementGrid_Translucency.Read(exINI, GameStrings::AudioVisual, "PlacementGrid.Translucency");

this->Pips_Shield.Read(exINI, GameStrings::AudioVisual, "Pips.Shield");
this->Pips_Shield_Background.Read(exINI, GameStrings::AudioVisual, "Pips.Shield.Background");
this->Pips_Shield_Building.Read(exINI, GameStrings::AudioVisual, "Pips.Shield.Building");
Expand Down Expand Up @@ -221,6 +223,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->JumpjetNoWobbles)
.Process(this->MissingCameo)
.Process(this->PlacementGrid_Translucency)
.Process(this->PlacementGrid_TranslucencyWithPreview)
.Process(this->PlacementPreview)
.Process(this->PlacementPreview_Translucency)
.Process(this->Pips_Shield)
Expand Down
6 changes: 6 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ class RulesExt
Valueable<bool> JumpjetNoWobbles;

PhobosFixedString<32u> MissingCameo;

TranslucencyLevel PlacementGrid_Translucency;
Nullable<TranslucencyLevel> PlacementGrid_TranslucencyWithPreview;
Valueable<bool> PlacementPreview;
TranslucencyLevel PlacementPreview_Translucency;

Valueable<Vector3D<int>> Pips_Shield;
Nullable<SHPStruct*> Pips_Shield_Background;
Valueable<Vector3D<int>> Pips_Shield_Building;
Expand Down Expand Up @@ -119,9 +122,12 @@ class RulesExt
, JumpjetCrash { 5.0 }
, JumpjetNoWobbles { false }
, MissingCameo { GameStrings::XXICON_SHP() }

, PlacementGrid_Translucency { 0 }
, PlacementGrid_TranslucencyWithPreview { }
, PlacementPreview { false }
, PlacementPreview_Translucency { 75 }

, Pips_Shield_Background { }
, Pips_Shield_Building { { -1,-1,-1 } }
, Pips_Shield_Building_Empty { }
Expand Down
Loading