* Add PatchManager - Allows you to patch terrain.png and items.png on the fly.

This can be used for modding, since you don't need to share copyrighted Mojang assets alongside your texture patches.
This commit is contained in:
iProgramInCpp
2023-08-09 22:13:04 +03:00
parent a7f56c5581
commit df47842c5e
14 changed files with 311 additions and 8 deletions

View File

@@ -183,8 +183,13 @@ Texture AppPlatform_windows::loadTexture(const std::string& str, bool b)
goto _error;
}
uint32_t* img2 = new uint32_t[width * height];
memcpy(img2, img, width * height * sizeof(uint32_t));
stbi_image_free(img);
img = nullptr;
fclose(f);
return Texture(width, height, (uint32_t*)img, 1, 0);
return Texture(width, height, img2, 1, 0);
}
std::vector<std::string> AppPlatform_windows::getOptionStrings()
@@ -233,6 +238,18 @@ void AppPlatform_windows::setOptionStrings(const std::vector<std::string>& str)
os << str[i] << ':' << str[i + 1] << '\n';
}
std::string AppPlatform_windows::getPatchData()
{
std::ifstream ifs("assets/patches/patch_data.txt");
if (!ifs.is_open())
return "";
std::stringstream ss;
ss << ifs.rdbuf();
return ss.str();
}
void AppPlatform_windows::setScreenSize(int width, int height)
{
m_ScreenWidth = width;