mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-20 06:53:30 +00:00
the whole game
This commit is contained in:
49
src/AppPlatform_android23.h
Executable file
49
src/AppPlatform_android23.h
Executable file
@@ -0,0 +1,49 @@
|
||||
#include "AppPlatform_android.h"
|
||||
#include <android/asset_manager.h>
|
||||
#include <android/native_activity.h>
|
||||
|
||||
class AppPlatform_android23 : public AppPlatform_android
|
||||
{
|
||||
typedef AppPlatform_android super;
|
||||
public:
|
||||
AppPlatform_android23()
|
||||
: _assetManager(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// If we're using Android 2.3+, try reading assets from NDK at first.
|
||||
// If that doesn't work, read through java/JNI as usual.
|
||||
BinaryBlob readAssetFile(const std::string& filename) {
|
||||
if (!_isInited)
|
||||
return BinaryBlob();
|
||||
|
||||
if (_assetManager != NULL) {
|
||||
AAsset* asset = AAssetManager_open(_assetManager, filename.c_str(), AASSET_MODE_BUFFER);
|
||||
if (asset != NULL) {
|
||||
const int len = AAsset_getLength(asset);
|
||||
const void* buf = len > 0? AAsset_getBuffer(asset) : NULL;
|
||||
|
||||
BinaryBlob blob;
|
||||
if (buf != NULL) {
|
||||
blob = BinaryBlob(new unsigned char[len], len);
|
||||
memcpy(blob.data, buf, len);
|
||||
}
|
||||
AAsset_close(asset);
|
||||
if (blob.data)
|
||||
return blob;
|
||||
}
|
||||
}
|
||||
return super::readAssetFile(filename);
|
||||
}
|
||||
|
||||
|
||||
// Another init method... added to read data from the activity, and setup constants
|
||||
// @note: This is called after instance is set from the outside, BUT this
|
||||
// will be rewritten later on anyway
|
||||
void initWithActivity(struct ANativeActivity* activity) {
|
||||
_assetManager = activity->assetManager;
|
||||
}
|
||||
|
||||
private:
|
||||
AAssetManager* _assetManager;
|
||||
};
|
||||
Reference in New Issue
Block a user