mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-23 20:09:46 +03:00
* 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:
@@ -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;
|
||||
|
||||
@@ -52,6 +52,9 @@ public:
|
||||
// Also add these to allow saving options.
|
||||
void setOptionStrings(const std::vector <std::string>& str) override;
|
||||
|
||||
// Also add this to allow dynamic texture patching.
|
||||
std::string getPatchData() override;
|
||||
|
||||
void setScreenSize(int width, int height);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user