Skip to content
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
2 changes: 1 addition & 1 deletion Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,4 @@
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Credits
- **thomassneddon** - general assistance
- **Starkku** - Warhead shield penetration & breaking, strafing aircraft weapon customization, vehicle DeployFire fixes/improvements, stationary VehicleTypes, Burst logic improvements, TechnoType auto-firing weapons, Secondary weapon fallback customization, weapon target type filtering, AreaFire targeting customization, CreateUnit improvements, Attached animation & jumpjet unit layer customization, IsSimpleDeployer improvements, Shield modification warheads, Warhead decloaking toggle
- **SukaHati (Erzoid)** - Minimum interceptor guard range
- **Morton (MortonPL)** - XDrawOffset, Shield passthrough & absorption, building LimboDelivery, fix for Image in art rules
- **Morton (MortonPL)** - XDrawOffset, Shield passthrough & absorption, building LimboDelivery, fix for Image in art rules, power delta counter
- **mevitar** - honorary shield tester *triple* award
- **Damfoos** - extensive and thorough testing
- **Rise of the East community** - extensive playtesting of in-dev features
Expand Down
38 changes: 19 additions & 19 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,25 @@ In `rulesmd.ini`:
Powered.KillSpawns=no ; boolean
```

### Customizable unit image in art

- `Image` tag in art INI is no longer limited to AnimationTypes and BuildingTypes, and can be applied to all TechnoTypes (InfantryTypes, VehicleTypes, AircraftTypes, BuildingTypes).
- The tag specifies **only** the file name (without extension) of the asset that replaces TechnoType's graphics. If the name in `Image` is also an entry in the art INI, **no tags will be read from it**.
- **By default this feature is disabled** to remain compatible with YR. To use this feature, enable it in rules with `ArtImageSwap=true`.
- This feature supports SHP images for InfantryTypes, SHP and VXL images for VehicleTypes and VXL images for AircraftTypes.

In `rulesmd.ini`:
```ini
[General]
ArtImageSwap=false ; disabled by default
```

In `artmd.ini`:
```ini
[SOMETECHNO]
Image= ; name of the file that will be used as image, without extension
```

## Terrains

### Customizable ore spawners
Expand All @@ -188,25 +207,6 @@ SpawnsTiberium.GrowthStage=3 ; single int / comma-sep. range
SpawnsTiberium.CellsPerAnim=1 ; single int / comma-sep. range
```

### Customizable unit image in art

- `Image` tag in art INI is no longer limited to AnimationTypes and BuildingTypes, and can be applied to all TechnoTypes (InfantryTypes, VehicleTypes, AircraftTypes, BuildingTypes).
- The tag specifies **only** the file name (without extension) of the asset that replaces TechnoType's graphics. If the name in `Image` is also an entry in the art INI, **no tags will be read from it**.
- **By default this feature is disabled** to remain compatible with YR. To use this feature, enable it in rules with `ArtImageSwap=true`.
- This feature supports SHP images for InfantryTypes, SHP and VXL images for VehicleTypes and VXL images for AircraftTypes.

In `rulesmd.ini`:
```ini
[General]
ArtImageSwap=false ; disabled by default
```

In `artmd.ini`:
```ini
[SOMETECHNO]
Image= ; name of the file that will be used as image, without extension
```

## Weapons

### Customizable disk laser radius
Expand Down
34 changes: 34 additions & 0 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,40 @@ In `rulesmd.ini`:
Sidebar.ProducingProgress.Offset=0,0 ; X,Y, pixels relative to default
```

### Power delta counter

![image](_static/images/powerdelta-01.gif)
*Power delta Counter in [Assault Amerika](https://www.moddb.com/mods/assault-amerika)*

- An additional counter for your power delta (surplus) can be added near the credits indicator.
- The counter is displayed with the format of `Label(sign)(Power Delta)`. The label is PowerLabel used in tooltips (by default `⚡ U+26A1`).
- You can adjust counter position by `Sidebar.PowerDelta.Offset`, negative means left/up, positive means right/down.
- You can adjust counter text alignment by `Sidebar.PowerDelta.Align`, acceptable values are left, right, center/centre.
- By setting `PowerDelta.ConditionYellow` and `PowerDelta.ConditionRed`, the game will warn player by changing the color of counter whenever the percentage of used power exceeds the value (i.e. when drain to output ratio is above 100%, the counter will turn red).
- The exception for this rule is when both power output and drain are 0 - in this case the counter will default to yellow.

In `uimd.ini`:
```ini
[Sidebar]
PowerDelta.Show=no ; boolean
PowerDelta.ConditionYellow=75% ; double, percentage
PowerDelta.ConditionRed=100% ; double, percentage
```

In `rulesmd.ini`:
```ini
[SOMESIDE] ; Side
Sidebar.PowerDelta.Offset=0,0 ; X,Y, pixels relative to default
Sidebar.PowerDelta.ColorGreen=255,255,0 ; R,G,B
Sidebar.PowerDelta.ColorYellow=255,255,0 ; R,G,B
Sidebar.PowerDelta.ColorRed=255,0,0 ; R,G,B
Sidebar.PowerDelta.Align=left ; left|center|centre|right
```

```{note}
If you use the vanilla font in your mod, you can use {download}`the improved font <_static/files/ImprovedFont-v4.zip>` (v4 and higher) which among everything already includes the mentioned icons. Otherwise you'd need to draw them yourself using [WWFontEditor](http://nyerguds.arsaneus-design.com/project_stuff/2016/WWFontEditor/release/?C=M;O=D), for example.
```

## Tooltips

![image](_static/images/tooltips-01.png)
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ New:
- Gates can now link with walls correctly via `NSGates` or `EWGates` (by Uranusian)
- Per-warhead toggle for decloak of damaged targets (by Starkku)
- `DeployFireWeapon=-1` now allows the deployed infantries using both weapons as undeployed (by Uranusian)
- Power delta (surplus) counter for sidebar (by Morton)

Vanilla fixes:
- Fixed laser drawing code to allow for thicker lasers in house color draw mode (by Kerbiter, ChrisLv_CN)
Expand Down
Binary file added docs/_static/images/powerdelta-01.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/Ext/Side/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ void SideExt::ExtData::LoadFromINIFile(CCINIClass* pINI)
this->Sidebar_HarvesterCounter_Yellow.Read(exINI, pSection, "Sidebar.HarvesterCounter.ColorYellow");
this->Sidebar_HarvesterCounter_Red.Read(exINI, pSection, "Sidebar.HarvesterCounter.ColorRed");
this->Sidebar_ProducingProgress_Offset.Read(exINI, pSection, "Sidebar.ProducingProgress.Offset");
this->Sidebar_PowerDelta_Offset.Read(exINI, pSection, "Sidebar.PowerDelta.Offset");
this->Sidebar_PowerDelta_Green.Read(exINI, pSection, "Sidebar.PowerDelta.ColorGreen");
this->Sidebar_PowerDelta_Yellow.Read(exINI, pSection, "Sidebar.PowerDelta.ColorYellow");
this->Sidebar_PowerDelta_Red.Read(exINI, pSection, "Sidebar.PowerDelta.ColorRed");
this->Sidebar_PowerDelta_Align.Read(exINI, pSection, "Sidebar.PowerDelta.Align");
}

// =============================
Expand All @@ -45,6 +50,11 @@ void SideExt::ExtData::Serialize(T& Stm)
.Process(this->Sidebar_HarvesterCounter_Yellow)
.Process(this->Sidebar_HarvesterCounter_Red)
.Process(this->Sidebar_ProducingProgress_Offset)
.Process(this->Sidebar_PowerDelta_Offset)
.Process(this->Sidebar_PowerDelta_Green)
.Process(this->Sidebar_PowerDelta_Yellow)
.Process(this->Sidebar_PowerDelta_Red)
.Process(this->Sidebar_PowerDelta_Align)

.Process(this->IngameScore_WinTheme)
.Process(this->IngameScore_LoseTheme)
Expand Down
10 changes: 10 additions & 0 deletions src/Ext/Side/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class SideExt
Valueable<ColorStruct> Sidebar_HarvesterCounter_Yellow;
Valueable<ColorStruct> Sidebar_HarvesterCounter_Red;
Valueable<Point2D> Sidebar_ProducingProgress_Offset;
Valueable<Point2D> Sidebar_PowerDelta_Offset;
Valueable<ColorStruct> Sidebar_PowerDelta_Green;
Valueable<ColorStruct> Sidebar_PowerDelta_Yellow;
Valueable<ColorStruct> Sidebar_PowerDelta_Red;
Valueable<TextAlign> Sidebar_PowerDelta_Align;

ExtData(SideClass* OwnerObject) : Extension<SideClass>(OwnerObject)
, ArrayIndex { -1 }
Expand All @@ -31,6 +36,11 @@ class SideExt
, Sidebar_HarvesterCounter_Yellow { { 255,255,0 } }
, Sidebar_HarvesterCounter_Red { { 255,0,0 } }
, Sidebar_ProducingProgress_Offset { { 0,0 } }
, Sidebar_PowerDelta_Offset { { 0,0 } }
, Sidebar_PowerDelta_Green { { 0,255,0 } }
, Sidebar_PowerDelta_Yellow { { 255,255,0 } }
, Sidebar_PowerDelta_Red { { 255,0,0 } }
, Sidebar_PowerDelta_Align { TextAlign::Left }
{ }

virtual ~ExtData() = default;
Expand Down
30 changes: 30 additions & 0 deletions src/Misc/Hooks.UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,36 @@ DEFINE_HOOK(0x4A25E0, CreditsClass_GraphicLogic_HarvesterCounter, 0x7)
TextPrintType::UseGradPal | TextPrintType::Center | TextPrintType::Metal12);
}

if (Phobos::UI::ShowPowerDelta)
{
auto pSideExt = SideExt::ExtMap.Find(SideClass::Array->GetItem(HouseClass::Player->SideIndex));
wchar_t counter[0x20];
auto delta = HouseClass::Player->PowerOutput - HouseClass::Player->PowerDrain;

double percent = HouseClass::Player->PowerOutput != 0
? (double)HouseClass::Player->PowerDrain / (double)HouseClass::Player->PowerOutput : HouseClass::Player->PowerDrain != 0
? Phobos::UI::PowerDelta_ConditionRed : Phobos::UI::PowerDelta_ConditionYellow;

ColorStruct clrToolTip = percent < Phobos::UI::PowerDelta_ConditionYellow
? pSideExt->Sidebar_PowerDelta_Green : LESS_EQUAL(percent, Phobos::UI::PowerDelta_ConditionRed)
? pSideExt->Sidebar_PowerDelta_Yellow : pSideExt->Sidebar_PowerDelta_Red;

auto TextFlags = static_cast<TextPrintType>(static_cast<int>(TextPrintType::UseGradPal | TextPrintType::Metal12)
| static_cast<int>(pSideExt->Sidebar_PowerDelta_Align.Get()));

swprintf_s(counter, L"%ls%+d", Phobos::UI::PowerLabel, delta);

Point2D vPos = {
DSurface::Sidebar->GetWidth() / 2 - 70 + pSideExt->Sidebar_PowerDelta_Offset.Get().X,
2 + pSideExt->Sidebar_PowerDelta_Offset.Get().Y
};

RectangleStruct vRect = { 0, 0, 0, 0 };
DSurface::Sidebar->GetRect(&vRect);

DSurface::Sidebar->DrawText(counter, &vRect, &vPos, Drawing::RGB2DWORD(clrToolTip), 0, TextFlags);
}

return 0;
}

Expand Down
12 changes: 12 additions & 0 deletions src/Phobos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const wchar_t* Phobos::UI::CostLabel = L"";
const wchar_t* Phobos::UI::PowerLabel = L"";
const wchar_t* Phobos::UI::TimeLabel = L"";
const wchar_t* Phobos::UI::HarvesterLabel = L"";
bool Phobos::UI::ShowPowerDelta = false;
double Phobos::UI::PowerDelta_ConditionYellow = 0.75;
double Phobos::UI::PowerDelta_ConditionRed = 1.0;

bool Phobos::Config::ToolTipDescriptions = true;
bool Phobos::Config::PrioritySelectionFiltering = true;
Expand Down Expand Up @@ -201,6 +204,15 @@ DEFINE_HOOK(0x5FACDF, OptionsClass_LoadSettings_LoadPhobosSettings, 0x5)

Phobos::UI::ShowProducingProgress =
pINI_UIMD->ReadBool(SIDEBAR_SECTION, "ProducingProgress.Show", false);

Phobos::UI::ShowPowerDelta =
pINI_UIMD->ReadBool(SIDEBAR_SECTION, "PowerDelta.Show", false);

Phobos::UI::PowerDelta_ConditionYellow =
pINI_UIMD->ReadDouble(SIDEBAR_SECTION, "PowerDelta.ConditionYellow", Phobos::UI::PowerDelta_ConditionYellow);

Phobos::UI::PowerDelta_ConditionRed =
pINI_UIMD->ReadDouble(SIDEBAR_SECTION, "PowerDelta.ConditionRed", Phobos::UI::PowerDelta_ConditionRed);
}

Phobos::CloseConfig(pINI_UIMD);
Expand Down
3 changes: 3 additions & 0 deletions src/Phobos.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Phobos
static double HarvesterCounter_ConditionYellow;
static double HarvesterCounter_ConditionRed;
static bool ShowProducingProgress;
static bool ShowPowerDelta;
static double PowerDelta_ConditionYellow;
static double PowerDelta_ConditionRed;

static const wchar_t* CostLabel;
static const wchar_t* PowerLabel;
Expand Down
10 changes: 10 additions & 0 deletions src/Utilities/Enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ enum class PhobosAction {
Drive = 2
};

enum class TextAlign : int
{
None = 0xFFF,
Left = 0x000,
Center = 0x100,
Right = 0x200,
};

MAKE_ENUM_FLAGS(TextAlign);

class MouseCursorHotSpotX {
public:
typedef MouseHotSpotX Value;
Expand Down
35 changes: 35 additions & 0 deletions src/Utilities/TemplateDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,41 @@ namespace detail {
return false;
}

template <>
inline bool read<TextAlign>(TextAlign& value, INI_EX& parser, const char* pSection, const char* pKey, bool allocate)
{
if (parser.ReadString(pSection, pKey))
{
auto parsed = TextAlign::None;
auto str = parser.value();
if (_strcmpi(str, "left") == 0)
{
parsed = TextAlign::Left;
}
else if (_strcmpi(str, "center") == 0)
{
parsed = TextAlign::Center;
}
else if (_strcmpi(str, "centre") == 0)
{
parsed = TextAlign::Center;
}
else if (_strcmpi(str, "right") == 0)
{
parsed = TextAlign::Right;
}
else if (_strcmpi(str, "none") == 0)
{
Debug::INIParseFailed(pSection, pKey, parser.value(), "Text Alignment can be either Left, Center/Centre or Right");
return false;
}
if (parsed != TextAlign::None)
value = parsed;
return true;
}
return false;
}

template <typename T>
void parse_values(std::vector<T>& vector, INI_EX& parser, const char* pSection, const char* pKey) {
char* context = nullptr;
Expand Down