Skip to content

Commit 25ae7b2

Browse files
Merge branch 'main' into main
2 parents c455548 + cf7a8ad commit 25ae7b2

23 files changed

Lines changed: 269 additions & 158 deletions

include/RE/B/BSResourceNiBinaryStream.h

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,31 @@ namespace RE
1616
public NiBinaryStream
1717
{
1818
public:
19-
inline static constexpr auto RTTI = { RTTI::BSResourceNiBinaryStream };
20-
inline static constexpr auto VTABLE = { VTABLE::BSResourceNiBinaryStream };
19+
inline static constexpr auto RTTI{ RTTI::BSResourceNiBinaryStream };
20+
inline static constexpr auto VTABLE{ VTABLE::BSResourceNiBinaryStream };
2121

2222
class BufferType;
2323

2424
BSResourceNiBinaryStream();
25-
BSResourceNiBinaryStream(const char* a_fileName);
26-
BSResourceNiBinaryStream(const std::string& a_fileName);
27-
~BSResourceNiBinaryStream() override; // 00
25+
BSResourceNiBinaryStream(const char* a_file, bool a_writeable = false, BSResource::Location* a_optionalStart = nullptr, bool a_fullReadHint = false);
26+
27+
virtual ~BSResourceNiBinaryStream() override; // 00
2828

2929
// override (NiBinaryStream)
3030
explicit operator bool() const noexcept override { return static_cast<bool>(stream); }; // 01 - { return static_cast<bool>(stream); }
3131
void Seek(std::ptrdiff_t a_numBytes) override; // 02
32-
std::size_t GetPosition() const noexcept override { return pos; }; // 03 - { return streamPos; }
32+
std::size_t GetPosition() const noexcept override { return streamPos; }; // 03 - { return streamPos; }
3333
void GetBufferInfo(BufferInfo& a_buf) override; // 04
34-
std::size_t DoRead(void* a_buf, std::size_t a_toRead) override; // 05
35-
std::size_t DoWrite(const void* a_buf, std::size_t a_toWrite) override; // 05
36-
37-
bool good() { return static_cast<bool>(stream); };
34+
std::size_t DoRead(void* a_buf, std::size_t a_bytes) override; // 05
35+
std::size_t DoWrite(const void* a_buf, std::size_t a_bytes) override; // 05
3836

3937
[[nodiscard]] static BSResourceNiBinaryStream* BinaryStreamWithRescan(const char* a_fileName);
4038

4139
// members
42-
BSTSmartPointer<BSResource::Stream> stream; // 10
43-
BufferType* buffer; // 18
44-
std::size_t pos; // 20
45-
BSResource::ErrorCode lastError; // 28
46-
47-
private:
48-
BSResourceNiBinaryStream* ctor(const char* a_name, bool a_writeable = false, BSResource::Location* a_optionalStart = 0, bool a_fullReadHint = false);
49-
void dtor();
40+
BSTSmartPointer<BSResource::Stream> stream{ nullptr }; // 10
41+
BufferType* buffer{ nullptr }; // 18
42+
std::size_t streamPos{ 0 }; // 20
43+
BSResource::ErrorCode lastError{ BSResource::ErrorCode::kNone }; // 28
5044
};
51-
5245
static_assert(sizeof(BSResourceNiBinaryStream) == 0x30);
5346
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include "RE/B/BSResourceNiBinaryStream.h"
4+
#include "RE/B/BSStreamParserData.h"
5+
6+
namespace RE
7+
{
8+
class BSResourceStreamParser :
9+
public BSResourceNiBinaryStream,
10+
public BSStreamParserData
11+
{
12+
public:
13+
inline static constexpr auto RTTI{ RTTI::BSResourceStreamParser };
14+
inline static constexpr auto VTABLE{ VTABLE::BSResourceStreamParser };
15+
16+
BSResourceStreamParser(const char* a_file) :
17+
BSResourceNiBinaryStream(a_file, false, nullptr, false)
18+
{}
19+
20+
virtual ~BSResourceStreamParser() = default; // 00
21+
22+
// override (BSStreamParserData)
23+
virtual bool Begin() override { return BSResourceNiBinaryStream::operator bool(); } // 1:01
24+
virtual void End() override {} // 1:02
25+
virtual NiBinaryStream* GetStream() override { return this; } // 1:03
26+
};
27+
}

include/RE/B/BSScaleformManager.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#pragma once
22

3+
#include "RE/B/BSScaleformTranslator.h"
34
#include "RE/B/BSStringT.h"
45
#include "RE/B/BSTEvent.h"
56
#include "RE/B/BSTSingleton.h"
7+
#include "Scaleform/G/GFx_Loader.h"
68
#include "Scaleform/G/GFx_Movie.h"
79
#include "Scaleform/P/Ptr.h"
810

911
namespace Scaleform::GFx
1012
{
1113
class DrawTextManager;
12-
class Loader;
1314
}
1415

1516
namespace RE
@@ -35,6 +36,11 @@ namespace RE
3536
return *singleton;
3637
}
3738

39+
BSScaleformTranslator* GetTranslator() const
40+
{
41+
return loader->GetStateAddRef<BSScaleformTranslator>();
42+
}
43+
3844
bool LoadMovie(
3945
IMenu& a_menu,
4046
Scaleform::Ptr<Scaleform::GFx::Movie>& a_movie,

include/RE/B/BSScaleformTranslator.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#pragma once
22

3+
#include "RE/B/BSResourceStreamParser.h"
4+
#include "RE/B/BSStreamParser.h"
35
#include "RE/B/BSTranslator.h"
6+
#include "RE/S/Setting.h"
47
#include "Scaleform/G/GFX_Translator.h"
58

69
namespace RE
@@ -9,6 +12,28 @@ namespace RE
912
public Scaleform::GFx::Translator
1013
{
1114
public:
15+
void AddTranslations(BSStreamParser<wchar_t>* a_parser)
16+
{
17+
using func_t = void (*)(BSScaleformTranslator*, BSStreamParser<wchar_t>*);
18+
static REL::Relocation<func_t> func{ ID::BSScaleformTranslator::AddTranslations };
19+
func(this, a_parser);
20+
}
21+
22+
void AddTranslationsFile(const char* a_file)
23+
{
24+
BSResourceStreamParser parserResource(a_file);
25+
BSStreamParser<wchar_t> parser(&parserResource);
26+
AddTranslations(&parser);
27+
}
28+
29+
void AddTranslationsMod(const char* a_name)
30+
{
31+
const auto setting = GetINISetting("sLanguage:General");
32+
const auto language = setting ? setting->GetString() : "EN";
33+
const auto path = std::format("Interface\\Translations\\{}_{}.txt", a_name, language);
34+
AddTranslationsFile(path.c_str());
35+
}
36+
1237
// members
1338
BSTranslator translator; //20
1439
};

include/RE/B/BSStreamParser.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
namespace RE
4+
{
5+
class BSStreamParserData;
6+
7+
template <class T>
8+
class BSStreamParser
9+
{
10+
public:
11+
BSStreamParser(BSStreamParserData* a_data) :
12+
data(a_data)
13+
{
14+
if (const auto stream = a_data->GetStream()) {
15+
NiBinaryStream::BufferInfo info;
16+
stream->GetBufferInfo(info);
17+
streamSizeInBytes = info.fileSize;
18+
}
19+
}
20+
21+
// members
22+
T readBuffer[256]{};
23+
T* readPosition{ 0 };
24+
BSStreamParserData* data;
25+
std::uint64_t streamSizeInBytes{ 0 };
26+
};
27+
static_assert(sizeof(BSStreamParser<char>) == 0x118);
28+
static_assert(sizeof(BSStreamParser<wchar_t>) == 0x218);
29+
}

include/RE/B/BSStreamParserData.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
namespace RE
4+
{
5+
class NiBinaryStream;
6+
7+
class BSStreamParserData
8+
{
9+
public:
10+
inline static constexpr auto RTTI{ RTTI::BSStreamParserData };
11+
inline static constexpr auto VTABLE{ VTABLE::BSStreamParserData };
12+
13+
virtual ~BSStreamParserData() = default; // 00
14+
15+
virtual bool Begin() = 0; // 01
16+
virtual void End() = 0; // 02
17+
virtual NiBinaryStream* GetStream() = 0; // 03
18+
};
19+
}

include/RE/Fallout.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
#include "RE/B/BSReloadShaderI.h"
286286
#include "RE/B/BSResource.h"
287287
#include "RE/B/BSResourceNiBinaryStream.h"
288+
#include "RE/B/BSResourceStreamParser.h"
288289
#include "RE/B/BSResource_Archive2_AsyncReaderStream.h"
289290
#include "RE/B/BSResource_Archive2_ClearRegistryEvent.h"
290291
#include "RE/B/BSResource_Archive2_DataReader.h"
@@ -387,6 +388,8 @@
387388
#include "RE/B/BSStorage.h"
388389
#include "RE/B/BSStorageDefs.h"
389390
#include "RE/B/BSStreamHeader.h"
391+
#include "RE/B/BSStreamParser.h"
392+
#include "RE/B/BSStreamParserData.h"
390393
#include "RE/B/BSStringPool.h"
391394
#include "RE/B/BSStringT.h"
392395
#include "RE/B/BSSystemFile.h"

include/RE/I/Interface3D.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace RE
144144
{
145145
using func_t = decltype(&Renderer::MainScreen_AddPointLight);
146146
static REL::Relocation<func_t> func{ ID::Interface3D::MainScreen_AddPointLight };
147-
return func(this, a_translation, a_diffuse, a_radius, a_dimmerVal);
147+
func(this, a_translation, a_diffuse, a_radius, a_dimmerVal);
148148
}
149149

150150
void MainScreen_AddSpotLight(
@@ -159,14 +159,14 @@ namespace RE
159159
{
160160
using func_t = decltype(&Renderer::MainScreen_AddSpotLight);
161161
static REL::Relocation<func_t> func{ ID::Interface3D::MainScreen_AddSpotLight };
162-
return func(this, a_translation, a_lookAtPosition, a_lookAtObject, a_fov, a_diffuse, a_radius, a_dimmerVal, a_castShadows);
162+
func(this, a_translation, a_lookAtPosition, a_lookAtObject, a_fov, a_diffuse, a_radius, a_dimmerVal, a_castShadows);
163163
}
164164

165165
void MainScreen_ClearLights()
166166
{
167167
using func_t = decltype(&Renderer::MainScreen_ClearLights);
168168
static REL::Relocation<func_t> func{ ID::Interface3D::MainScreen_ClearLights };
169-
return func(this);
169+
func(this);
170170
}
171171

172172
void MainScreen_EnableAO(bool a_value)
@@ -222,7 +222,7 @@ namespace RE
222222
{
223223
using func_t = decltype(&Renderer::MainScreen_SetScreenAttached3D);
224224
static REL::Relocation<func_t> func{ ID::Interface3D::MainScreen_SetScreenAttached3D };
225-
return func(this, a_root3D);
225+
func(this, a_root3D);
226226
}
227227

228228
void MainScreen_SetUseDeferredRenderer(bool a_value)
@@ -234,7 +234,7 @@ namespace RE
234234
{
235235
using func_t = decltype(&Renderer::MainScreen_SetWorldAttached3D);
236236
static REL::Relocation<func_t> func{ ID::Interface3D::MainScreen_SetWorldAttached3D };
237-
return func(this, a_root3D);
237+
func(this, a_root3D);
238238
}
239239

240240
void MainScreen_SetWorldAttachedMenuIntensity(float a_diffuse, float a_emit)
@@ -256,21 +256,21 @@ namespace RE
256256
{
257257
using func_t = decltype(&Renderer::Offscreen_AddLight);
258258
static REL::Relocation<func_t> func{ ID::Interface3D::Offscreen_AddLight };
259-
return func(this, a_translation, a_diffuse, a_specular, a_dimmerVal);
259+
func(this, a_translation, a_diffuse, a_specular, a_dimmerVal);
260260
}
261261

262262
void Offscreen_Clear3D()
263263
{
264264
using func_t = decltype(&Renderer::Offscreen_Clear3D);
265265
static REL::Relocation<func_t> func{ ID::Interface3D::Offscreen_Clear3D };
266-
return func(this);
266+
func(this);
267267
}
268268

269269
void Offscreen_ClearLights()
270270
{
271271
using func_t = decltype(&Renderer::Offscreen_ClearLights);
272272
static REL::Relocation<func_t> func{ ID::Interface3D::Offscreen_ClearLights };
273-
return func(this);
273+
func(this);
274274
}
275275

276276
void Offscreen_Enable3D(bool a_value)
@@ -296,7 +296,7 @@ namespace RE
296296
{
297297
using func_t = decltype(&Renderer::Offscreen_Set3D);
298298
static REL::Relocation<func_t> func{ ID::Interface3D::Offscreen_Set3D };
299-
return func(this, a_3D);
299+
func(this, a_3D);
300300
}
301301

302302
void Offscreen_SetBackgroundColor(const NiColorA& a_color)
@@ -318,7 +318,7 @@ namespace RE
318318
{
319319
using func_t = decltype(&Renderer::Offscreen_SetDebugMode);
320320
static REL::Relocation<func_t> func{ ID::Interface3D::Offscreen_SetDebugMode };
321-
return func(this, a_on, a_small, a_target);
321+
func(this, a_on, a_small, a_target);
322322
}
323323

324324
void Offscreen_SetDirectionalLight(
@@ -329,7 +329,7 @@ namespace RE
329329
{
330330
using func_t = decltype(&Renderer::Offscreen_SetDirectionalLight);
331331
static REL::Relocation<func_t> func{ ID::Interface3D::Offscreen_SetDirectionalLight };
332-
return func(this, a_xyPlaneAngle, a_zAngle, a_diffuse, a_dimmerVal);
332+
func(this, a_xyPlaneAngle, a_zAngle, a_diffuse, a_dimmerVal);
333333
}
334334

335335
void Offscreen_SetDisplayMode(
@@ -361,35 +361,35 @@ namespace RE
361361
{
362362
using func_t = decltype(&Renderer::Enable);
363363
static REL::Relocation<func_t> func{ ID::Interface3D::Enable };
364-
return func(this, a_unhideGeometries);
364+
func(this, a_unhideGeometries);
365365
}
366366

367367
void Disable()
368368
{
369369
using func_t = decltype(&Renderer::Disable);
370370
static REL::Relocation<func_t> func{ ID::Interface3D::Disable };
371-
return func(this);
371+
func(this);
372372
}
373373

374374
static void DisableAll(bool a_disableAll)
375375
{
376376
using func_t = decltype(&Renderer::DisableAll);
377377
static REL::Relocation<func_t> func{ ID::Interface3D::DisableAll };
378-
return func(a_disableAll);
378+
func(a_disableAll);
379379
}
380380

381381
void Release()
382382
{
383383
using func_t = decltype(&Renderer::Release);
384384
static REL::Relocation<func_t> func{ ID::Interface3D::Release };
385-
return func(this);
385+
func(this);
386386
}
387387

388388
void SetViewport(Scaleform::GFx::Movie& a_ui, const NiRect<float>& a_renderArea)
389389
{
390390
using func_t = decltype(&Renderer::SetViewport);
391391
static REL::Relocation<func_t> func{ ID::Interface3D::SetViewport };
392-
return func(this, a_ui, a_renderArea);
392+
func(this, a_ui, a_renderArea);
393393
}
394394

395395
// members

0 commit comments

Comments
 (0)