aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/AbstractTexturePack.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-07 21:56:03 -0500
committerGitHub <noreply@github.com>2026-03-08 09:56:03 +0700
commita9be52c41a02d207233199e98898fe7483d7e817 (patch)
tree71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.Client/AbstractTexturePack.cpp
parent1be5faaea781402e7de06b263eeca4c688b7712c (diff)
Project modernization (#630)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides
Diffstat (limited to 'Minecraft.Client/AbstractTexturePack.cpp')
-rw-r--r--Minecraft.Client/AbstractTexturePack.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/Minecraft.Client/AbstractTexturePack.cpp b/Minecraft.Client/AbstractTexturePack.cpp
index 80799a4c..a3c67727 100644
--- a/Minecraft.Client/AbstractTexturePack.cpp
+++ b/Minecraft.Client/AbstractTexturePack.cpp
@@ -3,21 +3,22 @@
#include "AbstractTexturePack.h"
#include "..\Minecraft.World\InputOutputStream.h"
#include "..\Minecraft.World\StringHelpers.h"
+#include "Common/UI/UI.h"
AbstractTexturePack::AbstractTexturePack(DWORD id, File *file, const wstring &name, TexturePack *fallback) : id(id), name(name)
{
// 4J init
textureId = -1;
- m_colourTable = NULL;
+ m_colourTable = nullptr;
this->file = file;
this->fallback = fallback;
- m_iconData = NULL;
+ m_iconData = nullptr;
m_iconSize = 0;
- m_comparisonData = NULL;
+ m_comparisonData = nullptr;
m_comparisonSize = 0;
// 4J Stu - These calls need to be in the most derived version of the class
@@ -41,7 +42,7 @@ void AbstractTexturePack::loadIcon()
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[ LOCATOR_SIZE ];
- const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
+ const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr);
swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/TexturePackIcon.png");
UINT size = 0;
@@ -57,7 +58,7 @@ void AbstractTexturePack::loadComparison()
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[ LOCATOR_SIZE ];
- const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
+ const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr);
swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/DefaultPack_Comparison.png");
UINT size = 0;
@@ -70,8 +71,8 @@ void AbstractTexturePack::loadDescription()
{
// 4J Unused currently
#if 0
- InputStream *inputStream = NULL;
- BufferedReader *br = NULL;
+ InputStream *inputStream = nullptr;
+ BufferedReader *br = nullptr;
//try {
inputStream = getResourceImplementation(L"/pack.txt");
br = new BufferedReader(new InputStreamReader(inputStream));
@@ -81,12 +82,12 @@ void AbstractTexturePack::loadDescription()
//} finally {
// TODO [EB]: use IOUtils.closeSilently()
// try {
- if (br != NULL)
+ if (br != nullptr)
{
br->close();
delete br;
}
- if (inputStream != NULL)
+ if (inputStream != nullptr)
{
inputStream->close();
delete inputStream;
@@ -105,7 +106,7 @@ InputStream *AbstractTexturePack::getResource(const wstring &name, bool allowFal
{
app.DebugPrintf("texture - %ls\n",name.c_str());
InputStream *is = getResourceImplementation(name);
- if (is == NULL && fallback != NULL && allowFallback)
+ if (is == nullptr && fallback != nullptr && allowFallback)
{
is = fallback->getResource(name, true);
}
@@ -121,7 +122,7 @@ InputStream *AbstractTexturePack::getResource(const wstring &name, bool allowFal
void AbstractTexturePack::unload(Textures *textures)
{
- if (iconImage != NULL && textureId != -1)
+ if (iconImage != nullptr && textureId != -1)
{
textures->releaseTexture(textureId);
}
@@ -129,7 +130,7 @@ void AbstractTexturePack::unload(Textures *textures)
void AbstractTexturePack::load(Textures *textures)
{
- if (iconImage != NULL)
+ if (iconImage != nullptr)
{
if (textureId == -1)
{
@@ -149,7 +150,7 @@ bool AbstractTexturePack::hasFile(const wstring &name, bool allowFallback)
{
bool hasFile = this->hasFile(name);
- return !hasFile && (allowFallback && fallback != NULL) ? fallback->hasFile(name, allowFallback) : hasFile;
+ return !hasFile && (allowFallback && fallback != nullptr) ? fallback->hasFile(name, allowFallback) : hasFile;
}
DWORD AbstractTexturePack::getId()
@@ -231,7 +232,7 @@ void AbstractTexturePack::loadDefaultUI()
{
#ifdef _XBOX
// load from the .xzp file
- const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
+ const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr);
// Load new skin
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
@@ -240,7 +241,7 @@ void AbstractTexturePack::loadDefaultUI()
swprintf(szResourceLocator, LOCATOR_SIZE,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/skin_Minecraft.xur");
XuiFreeVisuals(L"");
- app.LoadSkin(szResourceLocator,NULL);//L"TexturePack");
+ app.LoadSkin(szResourceLocator,nullptr);//L"TexturePack");
//CXuiSceneBase::GetInstance()->SetVisualPrefix(L"TexturePack");
CXuiSceneBase::GetInstance()->SkinChanged(CXuiSceneBase::GetInstance()->m_hObj);
#else
@@ -259,7 +260,7 @@ void AbstractTexturePack::loadDefaultColourTable()
// Load the file
#ifdef __PS3__
// need to check if it's a BD build, so pass in the name
- File coloursFile(AbstractTexturePack::getPath(true,app.GetBootedFromDiscPatch()?"colours.col":NULL).append(L"res/colours.col"));
+ File coloursFile(AbstractTexturePack::getPath(true,app.GetBootedFromDiscPatch()?"colours.col":nullptr).append(L"res/colours.col"));
#else
File coloursFile(AbstractTexturePack::getPath(true).append(L"res/colours.col"));
@@ -269,12 +270,12 @@ void AbstractTexturePack::loadDefaultColourTable()
if(coloursFile.exists())
{
DWORD dwLength = coloursFile.length();
- byteArray data(dwLength);
+ byteArray data(static_cast<unsigned int>(dwLength));
FileInputStream fis(coloursFile);
fis.read(data,0,dwLength);
fis.close();
- if(m_colourTable != NULL) delete m_colourTable;
+ if(m_colourTable != nullptr) delete m_colourTable;
m_colourTable = new ColourTable(data.data, dwLength);
delete [] data.data;
@@ -290,7 +291,7 @@ void AbstractTexturePack::loadDefaultHTMLColourTable()
{
#ifdef _XBOX
// load from the .xzp file
- const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
+ const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr);
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
WCHAR szResourceLocator[ LOCATOR_SIZE ];
@@ -309,7 +310,7 @@ void AbstractTexturePack::loadDefaultHTMLColourTable()
{
wsprintfW(szResourceLocator,L"section://%X,%s#%s",c_ModuleHandle,L"media", L"media/");
HXUIOBJ hScene;
- HRESULT hr = XuiSceneCreate(szResourceLocator,L"xuiscene_colourtable.xur", NULL, &hScene);
+ HRESULT hr = XuiSceneCreate(szResourceLocator,L"xuiscene_colourtable.xur", nullptr, &hScene);
if(HRESULT_SUCCEEDED(hr))
{
@@ -333,7 +334,7 @@ void AbstractTexturePack::loadHTMLColourTableFromXuiScene(HXUIOBJ hObj)
HXUIOBJ child;
HRESULT hr = XuiElementGetFirstChild(hObj, &child);
- while(HRESULT_SUCCEEDED(hr) && child != NULL)
+ while(HRESULT_SUCCEEDED(hr) && child != nullptr)
{
LPCWSTR childName;
XuiElementGetId(child,&childName);
@@ -374,7 +375,7 @@ void AbstractTexturePack::unloadUI()
wstring AbstractTexturePack::getXuiRootPath()
{
- const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL);
+ const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(nullptr);
// Load new skin
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
@@ -386,14 +387,14 @@ wstring AbstractTexturePack::getXuiRootPath()
PBYTE AbstractTexturePack::getPackIcon(DWORD &dwImageBytes)
{
- if(m_iconSize == 0 || m_iconData == NULL) loadIcon();
+ if(m_iconSize == 0 || m_iconData == nullptr) loadIcon();
dwImageBytes = m_iconSize;
return m_iconData;
}
PBYTE AbstractTexturePack::getPackComparison(DWORD &dwImageBytes)
{
- if(m_comparisonSize == 0 || m_comparisonData == NULL) loadComparison();
+ if(m_comparisonSize == 0 || m_comparisonData == nullptr) loadComparison();
dwImageBytes = m_comparisonSize;
return m_comparisonData;