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] Insignia Type #1416

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ This page lists all the individual contributions to the project by their author.
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
- Use `InsigniaType` to set the properties of insignia in a batch
- **handama** - AI script action to jump back to previous script
- **TaranDahl (航味麻酱)**
- Skirmish AI "sell all buildings and set all technos to hunt" behavior dehardcode
Expand Down
2 changes: 2 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<ItemGroup>
<ClCompile Include="src\New\Entity\AttachEffectClass.cpp" />
<ClCompile Include="src\New\Type\AttachEffectTypeClass.cpp" />
<ClCompile Include="src\New\Type\InsigniaTypeClass.cpp" />
<ClCompile Include="src\Commands\Commands.cpp" />
<ClCompile Include="src\Commands\DamageDisplay.cpp" />
<ClCompile Include="src\Commands\FrameByFrame.cpp" />
Expand Down Expand Up @@ -185,6 +186,7 @@
<ItemGroup>
<ClInclude Include="src\New\Entity\AttachEffectClass.h" />
<ClInclude Include="src\New\Type\AttachEffectTypeClass.h" />
<ClInclude Include="src\New\Type\InsigniaTypeClass.h" />
<ClInclude Include="src\Commands\FrameByFrame.h" />
<ClInclude Include="src\Commands\FrameStep.h" />
<ClInclude Include="src\Commands\NextIdleHarvester.h" />
Expand Down
8 changes: 5 additions & 3 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,10 @@ Due to technical constraints, these settings do not apply to buildings teleporte
### Customizable veterancy insignias

- You can now customize veterancy insignia of TechnoTypes.
- `Insignia.(Rookie|Veteran|Elite)` can be used to set a custom insignia file, optionally for each veterancy stage. Like the original / default file, `pips.shp`, they are drawn using `palette.pal` as palette.
- `InsigniaFrame(.Rookie|Veteran|Elite)` can be used to set (zero-based) frame index of the insignia to display, optionally for each veterancy stage. Using -1 uses the default setting. Default settings are -1 (none) for rookie, 14 for veteran and 15 for elite.
- A shorthand `InsigniaFrames` can be used to list them in order from rookie, veteran and elite instead as well. `InsigniaFrame(.Rookie|Veteran|Elite)` takes priority over this.
- `Insignia.(Rookie|Veteran|Elite)` can be used to set a custom insignia file, optionally for each veterancy stage. Like the original / default file, `pips.shp`, they are drawn using `palette.pal` as palette. `InsigniaFrame(.Rookie|Veteran|Elite)` can be used to set (zero-based) frame index of the insignia to display, optionally for each veterancy stage. Using -1 uses the default setting. Default settings are -1 (none) for rookie, 14 for veteran and 15 for elite. A shorthand `InsigniaFrames` can be used to list them in order from rookie, veteran and elite instead as well. `InsigniaFrame(.Rookie|Veteran|Elite)` takes priority over this.
- These settings will be overriden by the properties set in [InsigniaType](Miscellanous.md#insignia-type), if `InsigniaType` is set.
- Normal insignia can be overridden for specific weapon modes of `Gunner=true` units by setting `Insignia(.Frame/.Frames).WeaponN` where `N` stands for 1-based weapon mode index. If not set, defaults to non-mode specific insignia settings.
- These settings will be overriden by the properties set in [InsigniaType](Miscellanous.md#insignia-type), if `InsigniaType.WeaponN` is set.
- `Insignia.ShowEnemy` controls whether or not the insignia is shown to enemy players. Defaults to `[General]` -> `EnemyInsignia`, which in turn defaults to true.
- You can make insignias appear only on selected units using `DrawInsignia.OnlyOnSelected`.
- Position for insignias can be adjusted by setting `DrawInsignia.AdjustPos.Infantry` for infantry, `DrawInsignia.AdjustPos.Buildings` for buildings, and `DrawInsignia.AdjustPos.Units` for others.
Expand Down Expand Up @@ -646,6 +646,7 @@ InsigniaFrame.Rookie=-1 ; int, frame of insignia shp (zero-base
InsigniaFrame.Veteran=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.Elite=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrames=-1,-1,-1 ; int, frames of insignia shp (zero-based) or -1 for default
InsigniaType= ; InsigniaType
Insignia.WeaponN= ; filename - excluding the .shp extension
Insignia.WeaponN.Rookie= ; filename - excluding the .shp extension
Insignia.WeaponN.Veteran= ; filename - excluding the .shp extension
Expand All @@ -655,6 +656,7 @@ InsigniaFrame.WeaponN.Rookie=-1 ; int, frame of insignia shp (zero-base
InsigniaFrame.WeaponN.Veteran=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.WeaponN.Elite=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrames.WeaponN=-1,-1,-1 ; int, frames of insignia shp (zero-based) or -1 for default
InsigniaType.WeaponN= ; InsigniaType
Insignia.ShowEnemy= ; boolean
```

Expand Down
20 changes: 20 additions & 0 deletions docs/Miscellanous.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ Teleport | `{4A582747-9839-11d1-B709-00A024DDAFD1}` |
Mech | `{55D141B8-DB94-11d1-AC98-006008055BB5}` |
Ship | `{2BEA74E1-7CCA-11d3-BE14-00104B62A16C}` |

### Insignia Type

- It is now possible to define the properties of insignia in an entity, so that all properties in it will be used once it's applied to a techno.

In `rulesmd.ini`:
```ini
[InsigniaTypes]
0=SOMEINSIGNIATYPE

[SOMEINSIGNIATYPE] ; InsigniaType
Insignia= ; filename - excluding the .shp extension
Insignia.Rookie= ; filename - excluding the .shp extension
Insignia.Veteran= ; filename - excluding the .shp extension
Insignia.Elite= ; filename - excluding the .shp extension
InsigniaFrame=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.Rookie=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.Veteran=-1 ; int, frame of insignia shp (zero-based) or -1 for default
InsigniaFrame.Elite=-1 ; int, frame of insignia shp (zero-based) or -1 for default
```

## Game Speed

### Single player game speed
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ New:
- Allow infantry to use land sequences in water (by Starkku)
- `<Player @ X>` can now be used as owner for pre-placed objects on skirmish and multiplayer maps (by Starkku)
- Allow customizing charge turret delays per burst on a weapon (by Starkku)
- Use `InsigniaType` to set the properties of insignia in a batch (by Ollerus)

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <New/Type/LaserTrailTypeClass.h>
#include <New/Type/DigitalDisplayTypeClass.h>
#include <New/Type/AttachEffectTypeClass.h>
#include <New/Type/InsigniaTypeClass.h>

std::unique_ptr<RulesExt::ExtData> RulesExt::Data = nullptr;

Expand All @@ -34,6 +35,7 @@ void RulesExt::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
ShieldTypeClass::LoadFromINIList(pINI);
LaserTrailTypeClass::LoadFromINIList(&CCINIClass::INI_Art.get());
AttachEffectTypeClass::LoadFromINIList(pINI);
InsigniaTypeClass::LoadFromINIList(pINI);

Data->LoadBeforeTypeData(pThis, pINI);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Ext/Techno/Body.Visuals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ void TechnoExt::DrawInsignia(TechnoClass* pThis, Point2D* pLocation, RectangleSt

auto& frames = pTechnoTypeExt->InsigniaFrames_Weapon[weaponIndex];

if (frames != Vector3D<int>(-1, -1, -1))
insigniaFrames = frames;
if (frames.isset() && frames.Get() != Vector3D<int>(-1, -1, -1))
insigniaFrames = frames.Get();
}

if (pVeterancy->IsVeteran())
Expand Down
71 changes: 48 additions & 23 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Ext/BuildingType/Body.h>
#include <Ext/BulletType/Body.h>
#include <Ext/Techno/Body.h>
#include <New/Type/InsigniaTypeClass.h>

#include <Utilities/GeneralUtils.h>

Expand Down Expand Up @@ -407,9 +408,23 @@
this->DeployFireWeapon.Read(exINI, pSection, "DeployFireWeapon");
this->TargetZoneScanType.Read(exINI, pSection, "TargetZoneScanType");

this->Insignia.Read(exINI, pSection, "Insignia.%s");
this->InsigniaFrames.Read(exINI, pSection, "InsigniaFrames");
this->InsigniaFrame.Read(exINI, pSection, "InsigniaFrame.%s");
// insignia type
Nullable<InsigniaTypeClass*> InsigniaType;
InsigniaType.Read(exINI, pSection, "InsigniaType");

if (InsigniaType.isset())
{
this->Insignia = InsigniaType.Get()->Insignia;
this->InsigniaFrame = InsigniaType.Get()->InsigniaFrame;
this->InsigniaFrames = Vector3D<int>(-1, -1, -1); // override it so only InsigniaFrame will be used
}
else
{
this->Insignia.Read(exINI, pSection, "Insignia.%s");
this->InsigniaFrames.Read(exINI, pSection, "InsigniaFrames");
this->InsigniaFrame.Read(exINI, pSection, "InsigniaFrame.%s");
}

this->Insignia_ShowEnemy.Read(exINI, pSection, "Insignia.ShowEnemy");

this->TiltsWhenCrushes_Vehicles.Read(exINI, pSection, "TiltsWhenCrushes.Vehicles");
Expand Down Expand Up @@ -478,30 +493,40 @@

char tempBuffer[32];

if (this->OwnerObject()->Gunner && this->Insignia_Weapon.empty())
if (this->OwnerObject()->Gunner)
{
int weaponCount = this->OwnerObject()->WeaponCount;
this->Insignia_Weapon.resize(weaponCount);
this->InsigniaFrame_Weapon.resize(weaponCount);
this->InsigniaFrames_Weapon.resize(weaponCount);
size_t weaponCount = this->OwnerObject()->WeaponCount;

if (this->Insignia_Weapon.empty() || this->Insignia_Weapon.size() != weaponCount)
{
this->Insignia_Weapon.resize(weaponCount);
this->InsigniaFrame_Weapon.resize(weaponCount);
this->InsigniaFrames_Weapon.resize(weaponCount);
}

for (int i = 0; i < weaponCount; i++)

Check warning on line 507 in src/Ext/TechnoType/Body.cpp

View workflow job for this annotation

GitHub Actions / build

'<': signed/unsigned mismatch [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 507 in src/Ext/TechnoType/Body.cpp

View workflow job for this annotation

GitHub Actions / build

for (int i = 0; i < weaponCount; i++) [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 507 in src/Ext/TechnoType/Body.cpp

View workflow job for this annotation

GitHub Actions / build

^ [D:\a\Phobos\Phobos\Phobos.vcxproj]
{
Promotable<SHPStruct*> insignia;
_snprintf_s(tempBuffer, sizeof(tempBuffer), "Insignia.Weapon%d.%s", i + 1, "%s");
insignia.Read(exINI, pSection, tempBuffer);
this->Insignia_Weapon[i] = insignia;

Promotable<int> frame = Promotable<int>(-1);
_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrame.Weapon%d.%s", i + 1, "%s");
frame.Read(exINI, pSection, tempBuffer);
this->InsigniaFrame_Weapon[i] = frame;

Valueable<Vector3D<int>> frames;
frames = Vector3D<int>(-1, -1, -1);
_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrames.Weapon%d", i + 1);
frames.Read(exINI, pSection, tempBuffer);
this->InsigniaFrames_Weapon[i] = frames;
Nullable<InsigniaTypeClass*> InsigniaType_Weapon;
_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaType.Weapon%d", i + 1);
InsigniaType_Weapon.Read(exINI, pSection, tempBuffer);

if (InsigniaType_Weapon.isset())
{
this->Insignia_Weapon[i] = InsigniaType_Weapon.Get()->Insignia;
this->InsigniaFrame_Weapon[i] = InsigniaType_Weapon.Get()->InsigniaFrame;
this->InsigniaFrames_Weapon[i] = Vector3D<int>(-1, -1, -1); // override it so only InsigniaFrame will be used
}
else
{
_snprintf_s(tempBuffer, sizeof(tempBuffer), "Insignia.Weapon%d.%s", i + 1, "%s");
this->Insignia_Weapon[i].Read(exINI, pSection, tempBuffer);

_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrame.Weapon%d.%s", i + 1, "%s");
this->InsigniaFrame_Weapon[i].Read(exINI, pSection, tempBuffer);

_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrames.Weapon%d", i + 1);
this->InsigniaFrames_Weapon[i].Read(exINI, pSection, tempBuffer);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class TechnoTypeExt
Nullable<bool> Insignia_ShowEnemy;
std::vector<Promotable<SHPStruct*>> Insignia_Weapon;
std::vector<Promotable<int>> InsigniaFrame_Weapon;
std::vector<Vector3D<int>> InsigniaFrames_Weapon;
std::vector<Nullable<Vector3D<int>>> InsigniaFrames_Weapon;

Nullable<bool> TiltsWhenCrushes_Vehicles;
Nullable<bool> TiltsWhenCrushes_Overlays;
Expand Down
17 changes: 17 additions & 0 deletions src/New/Type/InsigniaTypeClass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "InsigniaTypeClass.h"

template<>
const char* Enumerable<InsigniaTypeClass>::GetMainSection()
{
return "InsigniaTypes";
}

void InsigniaTypeClass::LoadFromINI(CCINIClass* pINI)
{
const char* section = this->Name;

INI_EX exINI(pINI);

this->Insignia.Read(exINI, section, "Insignia.%s");
this->InsigniaFrame.Read(exINI, section, "InsigniaFrame.%s");
}
19 changes: 19 additions & 0 deletions src/New/Type/InsigniaTypeClass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <Utilities/Enumerable.h>
#include <Utilities/TemplateDef.h>

class InsigniaTypeClass final : public Enumerable<InsigniaTypeClass>
{
public:
Promotable<SHPStruct*> Insignia;
Promotable<int> InsigniaFrame;
Comment on lines +9 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are other tags not suitable for definition here?

Can you check the MultitagReadable-based templates btw? In PR #1304.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was once thought about Insignia.ShowEnemy, but not really sure if it should be in this.


InsigniaTypeClass(const char* const pTitle) : Enumerable<InsigniaTypeClass>(pTitle)
, Insignia { }
, InsigniaFrame { -1 }
{ }

void LoadFromINI(CCINIClass* pINI);
// No need to save and load as it's only for parsing
};
Loading