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

Can edit the SuperWeapon Icon display status text #1147

Open
wants to merge 3 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
3 changes: 2 additions & 1 deletion src/extensions/sidebar/sidebarext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "sidebarext.h"
#include "spritecollection.h"
#include "super.h"
#include "superext.h"
#include "supertype.h"
#include "supertypeext.h"
#include "techno.h"
Expand Down Expand Up @@ -1666,7 +1667,7 @@ void StripClassExt::_Draw_It(bool complete)
production = true;
completed = !PlayerPtr->SuperWeapon[spc]->Needs_Redraw();
isready = PlayerPtr->SuperWeapon[spc]->Is_Ready();
state = PlayerPtr->SuperWeapon[spc]->Ready_String();
state = Extension::Fetch<SuperClassExtension>(PlayerPtr->SuperWeapon[spc])->Ready_String();
stage = PlayerPtr->SuperWeapon[spc]->Anim_Stage();
darken = false;

Expand Down
50 changes: 49 additions & 1 deletion src/extensions/super/superext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
*
******************************************************************************/
#include "superext.h"
#include "supertypeext.h"
#include "super.h"
#include "wwcrc.h"
#include "extension.h"
#include "asserthandler.h"
#include "debughandler.h"

#include "wstring.h"
#include "language.h"
#include "fetchres.h"

/**
* Class constructor.
Expand Down Expand Up @@ -164,3 +167,48 @@ void SuperClassExtension::Compute_CRC(WWCRCEngine &crc) const
{
//EXT_DEBUG_TRACE("SuperClassExtension::Compute_CRC - Name: %s (0x%08X)\n", Name(), (uintptr_t)(This()));
}

/**
* Added Ready_String of custom string function.
*
* @author: GenKyoko
*/
const char* SuperClassExtension::Ready_String() const
{
SuperClass* pThis = This();
SuperWeaponTypeClassExtension* pTypeExt = Extension::Fetch<SuperWeaponTypeClassExtension>(pThis->Class);

if (pThis->IsSuspended)
{
return pTypeExt->Misc_SuspendString;
}

if (!pThis->Class->IsUseChargeDrain)
{
SpecialWeaponType type = pThis->Class->ActsLike;
bool IsReady = pThis->IsReady;

if (type == SPECIAL_HUNTER_SEEKER) {
if (!IsReady)
return nullptr;
return pTypeExt->Misc_ReadyString;
}
if (!IsReady)
return nullptr;
return pTypeExt->Misc_ReadyString;
}

if (!pThis->field_34) {
return pTypeExt->Misc_ChargingString;
}

if (!(pThis->field_34 - 1)) {
return pTypeExt->Misc_ReadyString;
}

if ((pThis->field_34 - 1) != 1) {
return nullptr;
}

return pTypeExt->Misc_ActiveString;
}
2 changes: 2 additions & 0 deletions src/extensions/super/superext.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ SuperClassExtension final : public AbstractClassExtension
virtual const SuperClass *This_Const() const override { return reinterpret_cast<const SuperClass *>(AbstractClassExtension::This_Const()); }
virtual RTTIType What_Am_I() const override { return RTTI_SUPERWEAPON; }

const char* Ready_String() const;

public:
/**
* The time at which the flash mode should return to normal.
Expand Down
22 changes: 22 additions & 0 deletions src/extensions/super/superext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ DECLARE_PATCH(_SuperClass_Place_HunterSeeker_Type_Patch)
}
}

DECLARE_PATCH(_SuperClass_Ready_String_Patch)
{
GET_REGISTER_STATIC(SuperClass*, this_ptr, ecx);

static const char* ready_str;
static SuperClassExtension* extension;
extension = Extension::Fetch<SuperClassExtension>(this_ptr);

ready_str = extension->Ready_String();

/**
* A new string obtained using a function.
*/
_asm {
mov eax, ready_str
mov [esp+40], eax
}

JMP(0x005F526F)
}

/**
* Main function for patching the hooks.
Expand All @@ -100,4 +120,6 @@ void SuperClassExtension_Hooks()
SuperClassExtension_Init();

Patch_Jump(0x0060C5DE, &_SuperClass_Place_HunterSeeker_Type_Patch);
Patch_Jump(0x005F5266, &_SuperClass_Ready_String_Patch);

}
16 changes: 14 additions & 2 deletions src/extensions/supertype/supertypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#include "extension.h"
#include "asserthandler.h"
#include "debughandler.h"

#include "fetchres.h"
#include "language.h"

/**
* Class constructor.
Expand All @@ -45,7 +46,11 @@ SuperWeaponTypeClassExtension::SuperWeaponTypeClassExtension(const SuperWeaponTy
SidebarImage(),
IsShowTimer(false),
CameoImageSurface(nullptr),
ActionOutOfRange(ACTION_EMPULSE_RANGE)
ActionOutOfRange(ACTION_EMPULSE_RANGE),
Misc_ReadyString(),
Misc_SuspendString(),
Misc_ActiveString(),
Misc_ChargingString()
{
//if (this_ptr) EXT_DEBUG_TRACE("SuperWeaponTypeClassExtension::SuperWeaponTypeClassExtension - Name: %s (0x%08X)\n", Name(), (uintptr_t)(This()));

Expand Down Expand Up @@ -213,6 +218,13 @@ bool SuperWeaponTypeClassExtension::Read_INI(CCINIClass &ini)

ActionOutOfRange = ini.Get_ActionType(ini_name, "ActionOutOfRange", ActionOutOfRange);

// String
bool IsHS = This()->Type == SPECIAL_HUNTER_SEEKER;
ini.Get_String(ini_name, "ReadyString", Fetch_String(IsHS?TXT_RELEASE_THE_HOUNDS:TXT_READY), Misc_ReadyString, 0x10);
ini.Get_String(ini_name, "ActivedString", Fetch_String(TXT_FIRESTORM_ON), Misc_ActiveString, 0x10);
ini.Get_String(ini_name, "ChargingString", Fetch_String(TXT_CHARGING), Misc_ChargingString, 0x10);
ini.Get_String(ini_name, "SuspendString", Fetch_String(TXT_HOLD), Misc_SuspendString, 0x10);

IsInitialized = true;

return true;
Expand Down
22 changes: 20 additions & 2 deletions src/extensions/supertype/supertypeext.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
#include "abstracttypeext.h"
#include "supertype.h"


class BSurface;


class DECLSPEC_UUID(UUID_SUPERWEAPONTYPE_EXTENSION)
SuperWeaponTypeClassExtension final : public AbstractTypeClassExtension
{
Expand Down Expand Up @@ -86,4 +84,24 @@ SuperWeaponTypeClassExtension final : public AbstractTypeClassExtension
* Action type used for the cursor when the SW is out of range to fire.
*/
ActionType ActionOutOfRange;

/**
* The string that appears when it's ready.
*/
char Misc_ReadyString[0x11];

/**
* A string that is displayed when preparing a special weapon with a charge function.
*/
char Misc_ChargingString[0x11];

/**
* A string when activating a special weapon using IsUseChargeDrain.
*/
char Misc_ActiveString[0x11];

/**
* The string that appears when a special weapon is ready to be interrupted.
*/
char Misc_SuspendString[0x11];
};