Skip to content

Commit

Permalink
feat: Font Config
Browse files Browse the repository at this point in the history
  • Loading branch information
AthallahDzaki committed Aug 26, 2024
1 parent 6dee2fd commit bc916e9
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 10 deletions.
128 changes: 128 additions & 0 deletions src/gtasa/effects/custom/player/PlayCutsceneEffect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#include "util/EffectBase.h"
#include "util/GenericUtil.h"
#include "util/Teleportation.h"

#include <CMessages.h>
#include <CPad.h>
#include <CPlayerPed.h>
#include <extensions/ScriptCommands.h>

using namespace plugin;

char cutsceneArray[148][64]
= {"BCESA4W", "BCESA5W", "BCESAR2", "BCESAR4", "BCESAR5", "BCRAS1",
"BCRAS2", "BHILL1", "BHILL2", "BHILL3A", "BHILL3B", "BHILL3C",
"BHILL5A", "BHILL5B", "CAS6B_1", "CAS6B_2", "CAS_11A", "CAS_1A",
"CAS_2", "CAS_3", "CAS_4A", "CAS_4B", "CAS_4C", "CAS_5A",
"CAS_6A", "CAS_7B", "CAS_9A1", "CAS_9A2", "CAT_1", "CAT_2",
"CAT_3", "CAT_4", "CESAR1A", "CRASH1A", "CRASH3A", "CRASHV1",
"CRASHV2A", "CRASHV2B", "CUTTEST", "D10_ALT", "D8_ALT", "DATE1A",
"DATE1B", "DATE2A", "DATE2B", "DATE3A", "DATE3B", "DATE4A",
"DATE4B", "DATE5A", "DATE5B", "DATE6A", "DATE6B", "DESERT1",
"DESERT2", "DESERT3", "DESERT4", "DESERT6", "DESERT8", "DESERT9",
"DES_10A", "DES_10B", "DOC_2", "EPILOG", "FARL_2A", "FARL_3A",
"FARL_3B", "FARL_4A", "FARL_5A", "FINAL1A", "FINAL2A", "FINAL2B",
"GARAG1B", "GARAG1C", "GARAG3A", "GROVE1A", "GROVE1B", "GROVE1C",
"GROVE2", "HEIST1A", "HEIST2A", "HEIST4A", "HEIST5A", "HEIST6A",
"HEIST8A", "INTRO1A", "INTRO1B", "INTRO2A", "PROLOG1", "PROLOG3",
"RIOT4E1", "RIOT4E2", "RIOT_1A", "RIOT_1B", "RIOT_2", "RIOT_4A",
"RIOT_4B", "RIOT_4C", "RIOT_4D", "RYDER1A", "RYDER2A", "RYDER3A",
"SCRASH1", "SCRASH2", "SMOKE1A", "SMOKE1B", "SMOKE2A", "SMOKE2B",
"SMOKE3A", "SMOKE4A", "STEAL_1", "STEAL_2", "STEAL_4", "STEAL_5",
"STRAP1A", "STRAP2A", "STRAP3A", "STRAP4A", "STRP4B1", "STRP4B2",
"SWEET1A", "SWEET1B", "SWEET1C", "SWEET2A", "SWEET2B", "SWEET3A",
"SWEET3B", "SWEET4A", "SWEET5A", "SWEET6A", "SWEET6B", "SWEET7A",
"SYND_2A", "SYND_2B", "SYND_3A", "SYND_4A", "SYND_4B", "SYND_7",
"TRUTH_1", "TRUTH_2", "W2_ALT", "WOOZI1A", "WOOZI1B", "WOOZIE2",
"WOOZIE4", "ZERO_1", "ZERO_2", "ZERO_4"};

class PlayRandomCutscene : public EffectBase
{
CVector oldPosition;
int previousInterior = 0;
bool cutsceneLoaded = false;

public:
bool
CanActivate () override
{
return FindPlayerPed ();
}

void
OnStart (EffectInstance *inst) override
{
CPed *playerCPed;
CPlayerPed *player = FindPlayerPed ();

// Command<0x01F5>(0, &playerCPed); // GET_PLAYER_CHAR

oldPosition = player->GetPosition ();
previousInterior = player->m_nAreaCode;

// Command<eScriptCommands::COMMAND_MAKE_PLAYER_SAFE_FOR_CUTSCENE>
// (playerCPed);

CPad *pad = player->GetPadFromPlayer ();
if (!pad) return;

pad->DisablePlayerControls = true;

int index = inst->Random (0, 10000) % 148;

CMessages::AddMessageJumpQ (cutsceneArray[index], 5000, 0, 0);
Command<eScriptCommands::COMMAND_LOAD_CUTSCENE> (cutsceneArray[index]);
}

void
OnEnd (EffectInstance *inst) override
{
CPlayerPed *player = FindPlayerPed ();
if (!player) return;

CPad *pad = player->GetPadFromPlayer ();
if (!pad) return;

pad->DisablePlayerControls = false;
}

void
OnTick (EffectInstance *inst) override
{
// static char message[256];
// sprintf (message, "Cutscene Loaded: %d | Cutscene finished: %d",
// cutsceneLoaded,
// Command<eScriptCommands::COMMAND_HAS_CUTSCENE_FINISHED> ());
// CMessages::AddMessageJumpQ (message, 1000, 0, 0);

inst->ResetTimer ();

if (!Command<eScriptCommands::COMMAND_HAS_CUTSCENE_LOADED>()) {
return; // Skip this time, cutscene is not loaded
}

if (!cutsceneLoaded)
{
Command<eScriptCommands::COMMAND_START_CUTSCENE> ();
cutsceneLoaded = true;
}

if(Command<eScriptCommands::COMMAND_IS_SKIP_CUTSCENE_BUTTON_PRESSED>()) {
Command<eScriptCommands::COMMAND_CLEAR_CUTSCENE> ();
Teleportation::Teleport (oldPosition, previousInterior);
inst->Disable ();
}

if (Command<eScriptCommands::COMMAND_HAS_CUTSCENE_FINISHED> ()
&& cutsceneLoaded)
{
Command<eScriptCommands::COMMAND_CLEAR_CUTSCENE> ();

Teleportation::Teleport (oldPosition, previousInterior);

inst->Disable ();
}
}
};

// DEFINE_EFFECT (PlayRandomCutscene, "effect_random_cutscene", 0);
40 changes: 40 additions & 0 deletions src/shared/util/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,46 @@ EffectsTopToBottom = true
# Default: false
DrawVotesOnTop = true
# Will change the width of font size
# Default: 0.6
EffectFontWidth = 0.6
# Will change the height of font size
# Default: 0.8
EffectFontHeight = 0.8
# Will change the width of font size for subtext
# Default: 0.4
EffectSubTextFontWidth = 0.4
# Will change the height of font size for subtext
# Default: 0.6
EffectSubTextFontHeight = 0.6
# Will change the line spacing between effects
# Default: 45.0
EffectYSpacing = 45.0
# Will change the width of font size for voting
# Default: 0.6
VoteFontWidth = 0.6
# Will change the height of font size for voting
# Default: 0.8
VoteFontHeight = 0.8
# Will change the width of font size for subtext in voting
# Default: 0.4
VoteSubTextFontWidth = 0.4
# Will change the height of font size for subtext in voting
# Default: 0.6
VoteSubTextFontHeight = 0.6
# Will change the bar size
# Default: 200.0
BarWidth = 200.0
#######################################################
#######################################################
Expand Down
10 changes: 6 additions & 4 deletions src/shared/util/DrawVoting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#include "util/Config.h"
#include "util/Globals.h"

static const float TEXT_SCALE_X = 0.6f;
static const float TEXT_SCALE_Y = 0.8f;
static const float TEXT_SCALE_X = (float) CONFIG ("Drawing.VoteFontWidth", 0.6);
static const float TEXT_SCALE_Y = (float) CONFIG ("Drawing.VoteFontHeight", 0.8);

static const float SUBTEXT_SCALE_X = 0.4f;
static const float SUBTEXT_SCALE_Y = 0.6f;
static const float SUBTEXT_SCALE_X = (float) CONFIG ("Drawing.VoteSubTextFontWidth", 0.4);
static const float SUBTEXT_SCALE_Y = (float) CONFIG ("Drawing.VoteSubTextFontHeight", 0.6);

static const float BAR_SIZE = CONFIG ("Drawing.BarWidth", 200.0);

void
DrawVoting::DrawVotes ()
Expand Down
3 changes: 2 additions & 1 deletion src/shared/util/EffectBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "util/EffectDatabase.h"
#include "util/EffectInstance.h"
#include "util/GameUtil.h"
#include "util/Globals.h"

#include <bitset>
#include <set>
Expand Down Expand Up @@ -88,7 +89,7 @@ class EffectBase
virtual bool
CanTickDown_Internal (EffectInstance *instance)
{
if (!CONFIG ("Chaos.AlwaysCountDownEffects", false)
if (!CONFIG ("Chaos.AlwaysCountDownEffects", false) && !Globals::enabledEffects["effect_random_cutscene"]
|| CONFIG_CC_ENABLED)
{
if (GameUtil::IsCutsceneProcessing ()) return false;
Expand Down
10 changes: 5 additions & 5 deletions src/shared/util/EffectDrawHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#include <CFont.h>
#include <extensions/FontPrint.h>

static const float TEXT_SCALE_X = 0.6f;
static const float TEXT_SCALE_Y = 0.8f;
static const float TEXT_SCALE_X = (float) CONFIG ("Drawing.EffectFontWidth", 0.6);
static const float TEXT_SCALE_Y = (float) CONFIG ("Drawing.EffectFontHeight", 0.8);

static const float SUBTEXT_SCALE_X = 0.4f;
static const float SUBTEXT_SCALE_Y = 0.6f;
static const float SUBTEXT_SCALE_X = (float) CONFIG ("Drawing.EffectSubTextFontWidth", 0.6);
static const float SUBTEXT_SCALE_Y = (float) CONFIG ("Drawing.EffectSubTextFontHeight", 0.4);

static const float Y_SPACING = 45.0f;
static const float Y_SPACING = (float) CONFIG ("Drawing.EffectYSpacing", 45.0);

bool
EffectDrawHandler::AreEffectsInset (bool checkOneTimeEffects)
Expand Down

0 comments on commit bc916e9

Please sign in to comment.