Skip to content

Commit 0c098da

Browse files
author
Manzarek
committed
feat(gta-streaming-five): Background minimap overlays
1 parent dd6a1a9 commit 0c098da

File tree

5 files changed

+45
-16
lines changed

5 files changed

+45
-16
lines changed

code/components/citizen-resources-gta/src/TextChangingFunctions.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ static InitFunction initFunction([] ()
140140
if (FX_SUCCEEDED(fx::GetCurrentScriptRuntime(&runtime)))
141141
{
142142
fx::Resource* resource = reinterpret_cast<fx::Resource*>(runtime->GetParentObject());
143-
int overlayIdx = sf::AddMinimapOverlay(resource->GetPath() + "/" + context.CheckArgument<const char*>(0), -1);
143+
144+
auto gfxFileName = context.CheckArgument<const char*>(0);
145+
auto background = context.GetArgument<bool>(1);
146+
147+
int overlayIdx = sf::AddMinimapOverlay(resource->GetPath() + "/" + gfxFileName, -1, background);
144148

145149
resource->OnStop.Connect([=]()
146150
{
@@ -168,8 +172,9 @@ static InitFunction initFunction([] ()
168172

169173
auto gfxFileName = context.CheckArgument<const char*>(0);
170174
auto depth = context.GetArgument<int>(1);
175+
auto background = context.GetArgument<bool>(2);
171176

172-
int overlayIdx = sf::AddMinimapOverlay(resource->GetPath() + "/" + gfxFileName, depth);
177+
int overlayIdx = sf::AddMinimapOverlay(resource->GetPath() + "/" + gfxFileName, depth, background);
173178

174179
resource->OnStop.Connect([=]()
175180
{

code/components/gta-streaming-five/include/sfFontStuff.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace sf
1414

1515
void GTA_STREAMING_EXPORT RegisterFontLib(const std::string& swfName);
1616

17-
int GTA_STREAMING_EXPORT AddMinimapOverlay(const std::string& swfName, int depth);
17+
int GTA_STREAMING_EXPORT AddMinimapOverlay(const std::string& swfName, int depth, bool background);
1818

1919
void GTA_STREAMING_EXPORT RemoveMinimapOverlay(int swfId);
2020

code/components/gta-streaming-five/src/ScaleformHacks.cpp

+33-11
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ class OverlayMethodFunctionHandler : public GFxFunctionHandler
134134
}
135135
};
136136

137-
static GFxValue overlayRootClip;
137+
static GFxValue overlayRootClip;
138+
static GFxValue overlayBackgroundRootClip;
139+
140+
static GFxValue* g_foregroundOverlay3D;
141+
static GFxValue* g_backgroundOverlay3D;
142+
138143
static void(*g_origSetupTerritories)();
139144

140-
static GFxValue* g_foregroundOverlay3D;
141145
static uint32_t* g_gfxId;
142146

143147
static void SetupTerritories()
@@ -147,6 +151,10 @@ static void SetupTerritories()
147151
overlayRootClip = {};
148152

149153
g_foregroundOverlay3D->CreateEmptyMovieClip(&overlayRootClip, "asTestClip3D", -1);
154+
155+
overlayBackgroundRootClip = {};
156+
157+
g_backgroundOverlay3D->CreateEmptyMovieClip(&overlayBackgroundRootClip, "asTestBgClip3D", 0);
150158

151159
auto movie = _getScaleformMovie(*g_gfxId);
152160

@@ -160,8 +168,9 @@ static void SetupTerritories()
160168

161169
struct MinimapOverlayLoadRequest
162170
{
163-
int sfwId;
164-
int depth;
171+
int swfId;
172+
int depth;
173+
bool background;
165174
};
166175

167176
static std::map<std::string, MinimapOverlayLoadRequest> g_minimapOverlayLoadQueue;
@@ -185,11 +194,11 @@ static hook::cdecl_stub<bool(uint32_t, int, const char*, int, int)> _setupGfxCal
185194

186195
namespace sf
187196
{
188-
int AddMinimapOverlay(const std::string& swfName, int depth)
197+
int AddMinimapOverlay(const std::string& swfName, int depth, bool background)
189198
{
190199
auto id = ++g_minimapOverlaySwfId;
191200

192-
g_minimapOverlayLoadQueue.insert({ swfName, { id, depth } });
201+
g_minimapOverlayLoadQueue.insert({ swfName, { id, depth, background } });
193202

194203
return id;
195204
}
@@ -287,16 +296,23 @@ static HookFunction hookFunction([]()
287296
{
288297
auto swf = std::make_shared<GFxValue>();
289298

290-
auto instanceName = va("id%d", request.sfwId);
299+
auto instanceName = va("id%d", request.swfId);
291300

292-
overlayRootClip.CreateEmptyMovieClip(swf.get(), instanceName, request.depth);
301+
if (request.background)
302+
{
303+
overlayBackgroundRootClip.CreateEmptyMovieClip(swf.get(), instanceName, request.depth);
304+
}
305+
else
306+
{
307+
overlayRootClip.CreateEmptyMovieClip(swf.get(), instanceName, request.depth);
308+
}
293309

294310
GFxValue result;
295311
GFxValue args(gfxFileName.c_str());
296312

297313
swf->Invoke("loadMovie", &result, &args, 1);
298314

299-
g_overlayClips[request.sfwId] = swf;
315+
g_overlayClips[request.swfId] = swf;
300316

301317
toRemoveFromMinimapOverlayLoadQueue.insert(gfxFileName);
302318
}
@@ -317,8 +333,14 @@ static HookFunction hookFunction([]()
317333
g_minimapOverlayRemoveQueue.clear();
318334
});
319335

320-
{
321-
auto location = hook::get_pattern<char>("74 3B E8 ? ? ? ? 33 C9 E8", 0x31);
336+
{
337+
// SetupFreeways
338+
auto location = hook::get_pattern<char>("74 3B E8 ? ? ? ? 33 C9 E8", 0x2C);
339+
340+
g_backgroundOverlay3D = hook::get_address<decltype(g_backgroundOverlay3D)>(hook::get_call(location) + (xbr::IsGameBuildOrGreater<2372>() ? 0x18 : 0x1C));
341+
342+
// SetupTerritories
343+
location = hook::get_pattern<char>("74 3B E8 ? ? ? ? 33 C9 E8", 0x31);
322344

323345
g_foregroundOverlay3D = hook::get_address<decltype(g_foregroundOverlay3D)>(hook::get_call(location) + (xbr::IsGameBuildOrGreater<2372>() ? 0x18 : 0x1C));
324346

ext/native-decls/AddMinimapOverlay.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ game: gta5
66
## ADD_MINIMAP_OVERLAY
77

88
```c
9-
int ADD_MINIMAP_OVERLAY(char* name);
9+
int ADD_MINIMAP_OVERLAY(char* name, cs_split BOOL background);
1010
```
1111
1212
Loads a minimap overlay from a GFx file in the current resource.
@@ -15,6 +15,7 @@ If you need to control the depth of overlay use [`ADD_MINIMAP_OVERLAY_WITH_DEPTH
1515
1616
## Parameters
1717
* **name**: The path to a `.gfx` file in the current resource. It has to be specified as a `file`.
18+
* **background**: Overlay is a background overlay.
1819
1920
## Return value
2021
A minimap overlay ID.

ext/native-decls/AddMinimapOverlayWithDepth.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ game: gta5
66
## ADD_MINIMAP_OVERLAY_WITH_DEPTH
77

88
```c
9-
int ADD_MINIMAP_OVERLAY_WITH_DEPTH(char* name, int depth);
9+
int ADD_MINIMAP_OVERLAY_WITH_DEPTH(char* name, int depth, cs_split BOOL background);
1010
```
1111
1212
Loads a minimap overlay from a GFx file in the current resource.
1313
1414
## Parameters
1515
* **name**: The path to a `.gfx` file in the current resource. It has to be specified as a `file`.
1616
* **depth**: The depth of new overlay on the minimap. Pass `-1` for game to figure out the highest depth itself. Should not be greater than `0x7EFFFFFD`.
17+
* **background**: Overlay is a background overlay.
1718
1819
## Return value
1920
A minimap overlay ID.

0 commit comments

Comments
 (0)