mirror of
https://github.com/celisej567/mcpe.git
synced 2025-12-31 17:49:17 +03:00
* Fix options and screenshot saving.
This commit is contained in:
@@ -55,8 +55,31 @@ void AppPlatform_android::buyGame()
|
||||
{
|
||||
}
|
||||
|
||||
bool AppPlatform_android::hasFileSystemAccess()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AppPlatform_android::setExternalStoragePath(const std::string& path)
|
||||
{
|
||||
m_storageDir = path;
|
||||
}
|
||||
|
||||
void AppPlatform_android::saveScreenshot(const std::string& fileName, int width, int height)
|
||||
{
|
||||
std::string saveName = m_storageDir + "/" + fileName;
|
||||
|
||||
LOG_I("Saving in %s", saveName.c_str());
|
||||
|
||||
int npixels = width * height;
|
||||
uint32_t* pixels = new uint32_t[npixels];
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
stbi_flip_vertically_on_write(true);
|
||||
|
||||
stbi_write_png(saveName.c_str(), width, height, 4, pixels, width * 4);
|
||||
|
||||
delete[] pixels;
|
||||
}
|
||||
|
||||
int AppPlatform_android::getScreenWidth() const
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
// Also add these to allow saving options.
|
||||
//void setOptionStrings(const std::vector <std::string>& str) override;
|
||||
bool hasFileSystemAccess() override;
|
||||
|
||||
SoundSystem* const getSoundSystem() const override;
|
||||
void initSoundSystem() override;
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
|
||||
void setScreenSize(int width, int height);
|
||||
void initAndroidApp(android_app* ptr);
|
||||
void setExternalStoragePath(const std::string& path);
|
||||
|
||||
private:
|
||||
int m_ScreenWidth;
|
||||
@@ -81,5 +83,7 @@ private:
|
||||
android_app* m_app;
|
||||
|
||||
SoundSystem* m_pSoundSystem;
|
||||
|
||||
std::string m_storageDir;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include <jni.h>
|
||||
#include <errno.h>
|
||||
#include "android_native_app_glue.h"
|
||||
@@ -334,6 +342,7 @@ static void initWindow(struct engine* engine, struct android_app* app)
|
||||
if (!engine->initted)
|
||||
{
|
||||
engine->ninecraftApp->m_externalStorageDir = getExternalStorageDir(engine);
|
||||
g_AppPlatform.setExternalStoragePath(engine->ninecraftApp->m_externalStorageDir);
|
||||
engine->ninecraftApp->init();
|
||||
}
|
||||
else
|
||||
@@ -366,6 +375,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
||||
|
||||
case APP_CMD_TERM_WINDOW:
|
||||
LOG_I("APP_CMD_TERM_WINDOW");
|
||||
engine->ninecraftApp->saveOptions();
|
||||
if (engine->display)
|
||||
{
|
||||
eglMakeCurrent(engine->display, 0, 0, 0);
|
||||
@@ -382,6 +392,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
||||
break;
|
||||
case APP_CMD_LOST_FOCUS:
|
||||
engine->animating = 0;
|
||||
engine->ninecraftApp->saveOptions();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user