Skip to content

Commit

Permalink
Add Life icon with option
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora-yx committed Oct 25, 2022
1 parent 057193e commit e0c5abe
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Super-Tails.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Super-Tails", "Super-Tails\Super-Tails.vcxproj", "{F4D06D48-E532-44AC-9EFC-A9737E707719}"
ProjectSection(ProjectDependencies) = postProject
{90CF4AD9-6603-458F-8E3F-E99C0818E43D} = {90CF4AD9-6603-458F-8E3F-E99C0818E43D}
{EC0293F5-4BCF-46B2-8133-18CAEA141C5B} = {EC0293F5-4BCF-46B2-8133-18CAEA141C5B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModLoaderCommon", "sadx-mod-loader\mod-loader-common\ModLoaderCommon\ModLoaderCommon.vcxproj", "{EC0293F5-4BCF-46B2-8133-18CAEA141C5B}"
EndProject
Expand Down
1 change: 1 addition & 0 deletions Super-Tails/Super-Tails.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<ClCompile Include="audio.cpp" />
<ClCompile Include="config.cpp" />
<ClCompile Include="flickies.cpp" />
<ClCompile Include="hud.cpp" />
<ClCompile Include="mod.cpp" />
<ClCompile Include="physics.cpp" />
<ClCompile Include="stdafx.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions Super-Tails/Super-Tails.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<ClCompile Include="water-hack.cpp">
<Filter>Source Files\abilities</Filter>
</ClCompile>
<ClCompile Include="hud.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
Expand Down
2 changes: 2 additions & 0 deletions Super-Tails/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bool AlwaysSuperMiles = false;
bool superAura = true;
bool customPhysics = true;
int charType = Dreamcast;
bool lifeIcon = true;

Buttons TransformButton = Buttons_Y;

Expand All @@ -30,6 +31,7 @@ void initConfig(const char* path)
AlwaysSuperMiles = config->getBool("General", "AlwaysSuperMiles", false);
superAura = config->getBool("General", "superAura", true);
customPhysics = config->getBool("General", "customPhysics", true);
lifeIcon = config->getBool("General", "lifeIcon", true);

CurrentSuperMusic = config->getInt("Audio", "CurrentSuperMusic", Random);
CurrentSFX = config->getInt("Audio", "GetVoice", SADX_SFX);
Expand Down
4 changes: 4 additions & 0 deletions Super-Tails/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ extern bool customPhysics;
extern int charType;
extern Buttons TransformButton;
extern bool MultiModEnabled;
extern bool lifeIcon;

extern bool isDCConv;

extern HelperFunctions help;

Expand All @@ -38,6 +41,7 @@ void initFlicky();
void CheckSuperMusic_Restart(int playerID);
void WaterHack_Init();
void init_PhysicsHack();
void __cdecl DisplaySuperMiles_Icon();
void initConfig(const char* path);

enum SuperTailsMusic {
Expand Down
39 changes: 39 additions & 0 deletions Super-Tails/hud.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "stdafx.h"
#include "ScaleInfo.h"

extern NJS_TEXLIST SuperMilesLifeIcon_Textlist;

static NJS_TEXANIM SUPERMILES_EXTRA_TEXANIM = { 0x20, 0x20, 0, 0, 0, 0, 0x100, 0x100, 0, 0x20 };
static NJS_SPRITE SUPERMILES_EXTRA_SPRITE = { {0}, 1.0f, 1.0f, 0, &SuperMilesLifeIcon_Textlist, &SUPERMILES_EXTRA_TEXANIM };

bool isInActionStage()
{
return CurrentLevel < LevelIDs_StationSquare || CurrentLevel > LevelIDs_Past && CurrentLevel < LevelIDs_SSGarden;
}

void __cdecl DisplaySuperMiles_Icon()
{
if (!lifeIcon || !IsIngame() || !EntityData1Ptrs[0] || EntityData1Ptrs[0]->CharID != Characters_Tails || !isSuperTails || !isInActionStage())
return;

help.PushScaleUI(uiscale::Align_Automatic, false, 1.0f, 1.0f);
njColorBlendingMode(NJD_SOURCE_COLOR, NJD_COLOR_BLENDING_SRCALPHA);
njColorBlendingMode(NJD_DESTINATION_COLOR, NJD_COLOR_BLENDING_INVSRCALPHA);

njSetTexture(&SuperMilesLifeIcon_Textlist);

if (HideLives >= 0)
{
SUPERMILES_EXTRA_SPRITE.p.x = 16.0f;

if (isDCConv)
SUPERMILES_EXTRA_SPRITE.p.y = VerticalStretch * 480.0f - 80.0f;
else
SUPERMILES_EXTRA_SPRITE.p.y = VerticalStretch * 480.0f - 64.0f;

njDrawSprite2D_ForcePriority(&SUPERMILES_EXTRA_SPRITE, 0, -1.501, NJD_SPRITE_ALPHA);
ClampGlobalColorThing_Thing();
}

help.PopScaleUI();
}
5 changes: 3 additions & 2 deletions Super-Tails/mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
HelperFunctions help;

bool MultiModEnabled = false;
bool isDCConv = false;

extern "C" {

Expand All @@ -28,14 +29,14 @@ extern "C" {
init_PhysicsHack();

MultiModEnabled = GetModuleHandle(L"sadx-multiplayer") != nullptr;
isDCConv = GetModuleHandle(L"DCMods_Main") != NULL;
}


__declspec(dllexport) void __cdecl OnFrame()
{

//SetDebugFontSize(13.0f * (unsigned short)VerticalResolution / 480.0f);
//DisplayDebugStringFormatted(NJM_LOCATION(2, 1), "Current bird: %d", birdCount);
DisplaySuperMiles_Icon();
}

__declspec(dllexport) ModInfo SADXModInfo = { ModLoaderVer };
Expand Down
7 changes: 6 additions & 1 deletion Super-Tails/super-tails.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum SuperTailsM {
superTailsUntransfo,
};


NJS_TEXNAME Miles_LifeIconTex[1];
NJS_TEXNAME SUPERMILES_DC[25];
NJS_TEXNAME SUPERMILES_DX[16];

Expand All @@ -21,22 +21,27 @@ NJS_TEXNAME Flicky_Tex[7];

NJS_TEXLIST Flicky_TEXLIST = { arrayptrandlength(Flicky_Tex) };

NJS_TEXLIST SuperMilesLifeIcon_Textlist = { arrayptrandlength(Miles_LifeIconTex) };

PVMEntry superTails_DCEntry[] = {
{"SUPERMILES_DC", &SuperMilesDC_TEXLIST},
{"flickyTex", &Flicky_TEXLIST },
{"SUPERSONIC", &SUPERSONIC_TEXLIST},
{"MilesLifeIcon", &SuperMilesLifeIcon_Textlist}
};

PVMEntry superTails_DXEntry[] = {
{"SUPERMILES_DX", &SuperMilesDX_TEXLIST},
{"flickyTex", &Flicky_TEXLIST },
{"SUPERSONIC", &SUPERSONIC_TEXLIST},
{"MilesLifeIcon", &SuperMilesLifeIcon_Textlist}
};

//if player set "no textures changes"
PVMEntry superTails_Entry[] = {
{"flickyTex", &Flicky_TEXLIST },
{"SUPERSONIC", &SUPERSONIC_TEXLIST},
{"MilesLifeIcon", &SuperMilesLifeIcon_Textlist},
};

void Load_SuperPhysics(taskwk* data1);
Expand Down

0 comments on commit e0c5abe

Please # to comment.