Skip to content

Commit

Permalink
1.3.4:
Browse files Browse the repository at this point in the history
- compatible for Android Oreo
- fix image flip issue
- fix image affine issue
  • Loading branch information
ZeaS committed Nov 19, 2017
1 parent 9b232c6 commit 0b7e2b5
Show file tree
Hide file tree
Showing 29 changed files with 507 additions and 292 deletions.
2 changes: 1 addition & 1 deletion cocos/kr2/Resources/res/locale/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<Item id="cannot_create_preference" text="Can not create individual preference file."/>
<Item id="use_internal_path" text="Please copy your game folder into package path to avoid this warning or you may lost your savedata:&#10;%1&#10;&#10;Continue anyway?"/>
<Item id="continue_run" text="Continue"/>
<Item id="get_sdcard_permission" text="Fetch Permission"/>
<Item id="get_sdcard_permission" text="Fetch Permission(May Slow)"/>
<Item id="crash_report" text="Crash Report"/>
<Item id="crash_report_msg" text="Crash detected, send data (%d files) to help improving this app?"/>
<Item id="menu_rotate" text="Rotate Screen"/>
Expand Down
4 changes: 2 additions & 2 deletions cocos/kr2/Resources/res/locale/zh_cn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
<Item id="ensure_to_override_file" text="确认要覆盖吗:"/>
<Item id="readonly_storage" text="发现只读的外部存储器"/>
<Item id="cannot_create_preference" text="无法创建配置"/>
<Item id="use_internal_path" text="为避免弹出这个提示以及可能出现的存档丢失,请移动您的游戏路径到这里&#10;%1&#10;&#10;仍然使用当前路径运行?"/>
<Item id="use_internal_path" text="为避免弹出这个提示以及可能出现的存档丢失,建议移动您的游戏路径到这里&#10;%1&#10;&#10;仍然使用当前路径运行?"/>
<Item id="continue_run" text="仍然继续"/>
<Item id="get_sdcard_permission" text="获取写入权限"/>
<Item id="get_sdcard_permission" text="获取写入权限(可能很慢)"/>
<Item id="crash_report" text="崩溃报告"/>
<Item id="crash_report_msg" text="发现崩溃数据,发送数据(%d个文件)到服务器以助我们改进这个应用?"/>
<Item id="menu_rotate" text="旋转屏幕"/>
Expand Down
4 changes: 2 additions & 2 deletions cocos/kr2/Resources/res/locale/zh_tw.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
<Item id="ensure_to_override_file" text="确认要覆盖吗:"/>
<Item id="readonly_storage" text="发现只读的外部存储器"/>
<Item id="cannot_create_preference" text="无法创建配置"/>
<Item id="use_internal_path" text="为避免弹出这个提示以及可能出现的存档丢失,请移动您的游戏路径到这里&#10;%1&#10;&#10;仍然使用当前路径运行?"/>
<Item id="use_internal_path" text="为避免弹出这个提示以及可能出现的存档丢失,建议移动您的游戏路径到这里&#10;%1&#10;&#10;仍然使用当前路径运行?"/>
<Item id="continue_run" text="仍然继续"/>
<Item id="get_sdcard_permission" text="获取写入权限"/>
<Item id="get_sdcard_permission" text="获取写入权限(可能很慢)"/>
<Item id="crash_report" text="崩溃报告"/>
<Item id="crash_report_msg" text="发现崩溃数据,发送数据(%d个文件)到服务器以助我们改进这个应用?"/>
<Item id="menu_rotate" text="旋转屏幕"/>
Expand Down
6 changes: 3 additions & 3 deletions project/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.tvp.kirikiri2"
android:versionCode="63"
android:versionName="1.3.3"
android:versionCode="64"
android:versionName="1.3.4"
android:installLocation="auto">

<!-- Android 2.3.3 -->
Expand All @@ -21,7 +21,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:allowBackup="true">
android:allowBackup="true" android:resizeableActivity="true">
<meta-data android:name="android.app.lib_name"
android:value="game" />
<activity android:name="Kirikiroid2"
Expand Down
9 changes: 7 additions & 2 deletions project/android/jni/src/SDL_android_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "cocos2d/AppDelegate.h"
#include "cocos2d/MainScene.h"
#include "ConfigManager/GlobalConfigManager.h"
#include "Application.h"

/*******************************************************************************
Functions called by JNI
Expand All @@ -16,8 +17,6 @@
#include "client/linux/handler/minidump_descriptor.h"

//std::string Android_GetDumpStoragePath();
void start_profile() {}
void stop_profile() {}

static bool __DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
void* context, bool succeeded)
Expand Down Expand Up @@ -274,4 +273,10 @@ extern "C" {
return true;
}

JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeOnLowMemory(JNIEnv* env, jclass cls)
{
Android_PushEvents([]() {
::Application->OnLowMemory();
});
}
}
4 changes: 2 additions & 2 deletions src/core/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/base \
$(LOCAL_PATH)/../../vendor/opus/opusfile/include \
$(LOCAL_PATH)/../../vendor/opencv/current/build/include \
$(LOCAL_PATH)/../../vendor/openal/current/include \
$(LOCAL_PATH)/../../vendor/threadpool11/ext/include \
$(LOCAL_PATH)/../../vendor/lz4 \
$(LOCAL_PATH)/../../libs/android/bpg/include \
$(LOCAL_PATH)/../../libs/android/ffmpeg/include \
$(LOCAL_PATH)/../../libs/android/libarchive/include \
Expand All @@ -86,7 +86,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/base \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/external/png/include/android \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/external \

LOCAL_CPPFLAGS += -DTJS_TEXT_OUT_CRLF -D__STDC_CONSTANT_MACROS
LOCAL_CPPFLAGS += -DTJS_TEXT_OUT_CRLF -D__STDC_CONSTANT_MACROS -DUSE_UNICODE_FSTRING
LOCAL_CFLAGS += -DTJS_TEXT_OUT_CRLF -D_7ZIP_ST
LOCAL_STATIC_LIBRARIES := ffmpeg libopencv_imgproc libopencv_core libopencv_hal libtbb gdiplus_static cpufeatures \
opusfile_static opus_static onig_static libbpg_static vorbis_static cairo_static pixman_static expat_static \
Expand Down
2 changes: 1 addition & 1 deletion src/core/base/ScriptMgnIntf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ void TVPExecuteStartupScript()
std::vector<ttstr> btns;
btns.emplace_back(LocaleConfigManager::GetInstance()->GetText("msgbox_ok"));
btns.emplace_back(LocaleConfigManager::GetInstance()->GetText("browse_patch_lib"));
if (TVPShowSimpleMessageBox(msg, TVPGetPackageVersionString()) == 1) {
if (TVPShowSimpleMessageBox(msg, TVPGetPackageVersionString(), btns) == 1) {
TVPOpenPatchLibUrl();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/base/win32/SysInitImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ void TVPAfterSystemInit()
}

// draw thread num
tjs_int drawThreadNum = 1;
tjs_int drawThreadNum = 0;
if (TVPGetCommandLine(TJS_W("-drawthread"), &opt)) {
ttstr str(opt);
if (str == TJS_W("auto"))
Expand Down
38 changes: 21 additions & 17 deletions src/core/environ/android/AndroidUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,23 @@ void TVPForceSwapBuffer() {
eglSwapBuffers(eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW));
}

static bool _IsLollipop() {
static int _GetAndroidSDKVersion() {
JNIEnv *pEnv = JniHelper::getEnv();
jclass classID = pEnv->FindClass("android/os/Build$VERSION");
jfieldID idSDK_INT = pEnv->GetStaticFieldID(classID, "SDK_INT", "I");
jint sdkid = pEnv->GetStaticIntField(classID, idSDK_INT);
return sdkid >= 21;
return pEnv->GetStaticIntField(classID, idSDK_INT);
}
static int GetAndroidSDKVersion() {
static int result = _GetAndroidSDKVersion();
return result;
}

static bool IsLollipop() {
static bool result = _IsLollipop();
return result;
return GetAndroidSDKVersion() >= 21;
}

static bool IsOreo() {
return GetAndroidSDKVersion() >= 26;
}

void TVPFetchSDCardPermission() {
Expand Down Expand Up @@ -701,24 +707,25 @@ static bool TVPWriteDataToFileJava(const std::string &filename, const void* data
if (JniHelper::getStaticMethodInfo(methodInfo, "org/tvp/kirikiri2/KR2Activity", "WriteFile", "(Ljava/lang/String;[B)Z")) {
cocos2d::FileUtils *fileutil = cocos2d::FileUtils::getInstance();
bool ret = false;
do { // write files until file not exist
int retry = 3;
do {
jstring jstr = methodInfo.env->NewStringUTF(filename.c_str());
jbyteArray arr = methodInfo.env->NewByteArray(size);
methodInfo.env->SetByteArrayRegion(arr, 0, size, (jbyte*)data);
bool ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID, jstr, arr);
ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID, jstr, arr);
methodInfo.env->DeleteLocalRef(arr);
methodInfo.env->DeleteLocalRef(jstr);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
} while (!fileutil->isFileExist(filename));
} while (!fileutil->isFileExist(filename) && --retry);
return ret;
}
return false;
}

bool TVPWriteDataToFile(const ttstr &filepath, const void *data, unsigned int size) {
cocos2d::FileUtils *fileutil = cocos2d::FileUtils::getInstance();
std::string filename = filepath.AsStdString();
if (fileutil->isFileExist(filename)) {
cocos2d::FileUtils *fileutil = cocos2d::FileUtils::getInstance();
while (fileutil->isFileExist(filename)) {
// for number filename suffix issue
time_t t = time(nullptr);
std::vector<char> buffer;
Expand All @@ -731,17 +738,14 @@ bool TVPWriteDataToFile(const ttstr &filepath, const void *data, unsigned int si
if (fp) {
bool ret = fwrite(data, 1, size, fp) == size;
fclose(fp);
ret = (remove(tempname.c_str()) == 0) && ret;
remove(tempname.c_str());
return ret;
}
}
while (fileutil->isFileExist(filename)) {
if (!TVPRenameFile(filename, tempname)) {
return false;
}
}
bool ret = TVPWriteDataToFileJava(filename, data, size);
ret = TVPDeleteFile(tempname) && ret;
if (fileutil->isFileExist(tempname.c_str())) {
TVPDeleteFile(tempname);
}
return ret;
}
FILE *fp = fopen(filename.c_str(), "wb");
Expand Down
8 changes: 3 additions & 5 deletions src/core/environ/cocos2d/AppDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ USING_NS_CC;
static Size designResolutionSize(960, 640);
bool TVPCheckStartupArg();
std::string TVPGetCurrentLanguage();
cocos2d::CustomFileUtils *TVPCreateCustomFileUtils();

void TVPAppDelegate::applicationWillEnterForeground() {
::Application->OnActivate();
Expand All @@ -31,8 +30,7 @@ void TVPAppDelegate::applicationDidEnterBackground() {
bool TVPAppDelegate::applicationDidFinishLaunching() {
cocos2d::log("applicationDidFinishLaunching");
// initialize director
cocos2d::CustomFileUtils *fileutil = TVPCreateCustomFileUtils();
FileUtils::setDelegate(fileutil);
FileUtils::setDelegate(TVPCreateCustomFileUtils());
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if (!glview) {
Expand Down Expand Up @@ -60,10 +58,10 @@ bool TVPAppDelegate::applicationDidFinishLaunching() {

std::string skinpath = GlobalConfigManager::GetInstance()->GetValue<std::string>("skin_path", "");
if (!skinpath.empty()) {
if (!fileutil->isFileExist(skinpath)) {
if (!FileUtils::getInstance()->isFileExist(skinpath)) {
GlobalConfigManager::GetInstance()->SetValue("skin_path", "");
} else {
fileutil->addAutoSearchArchive(skinpath);
TVPAddAutoSearchArchive(skinpath);
}
}

Expand Down
27 changes: 24 additions & 3 deletions src/core/environ/cocos2d/MainScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,35 @@ class TVPWindowLayer : public cocos2d::extension::ScrollView, public iWindowLaye

void onMouseDownEvent(Event *_e) {
EventMouse *e = static_cast<EventMouse*>(_e);
if (e->getMouseButton() == 1) {
int btn = e->getMouseButton();
switch (btn) {
case 1:
_mouseBtn = mbRight;
onMouseDown(e->getLocation());
break;
case 2:
_mouseBtn = mbMiddle;
onMouseDown(e->getLocation());
break;
default:
break;
}
}

void onMouseUpEvent(Event *_e) {
EventMouse *e = static_cast<EventMouse*>(_e);
if (e->getMouseButton() == 1) {
int btn = e->getMouseButton();
switch (btn) {
case 1:
_mouseBtn = mbRight;
onMouseUp(e->getLocation());
break;
case 2:
_mouseBtn = mbMiddle;
onMouseUp(e->getLocation());
break;
default:
break;
}
}

Expand Down Expand Up @@ -531,6 +549,9 @@ class TVPWindowLayer : public cocos2d::extension::ScrollView, public iWindowLaye
_mouseBtn = ::mbRight;
_touchPoint = (_touchPoint + touch->getLocation()) / 2;
break;
case 3:
_mouseBtn = ::mbMiddle;
//_touchPoint = (_touchPoint + touch->getLocation()) / 2;
default:
break;
}
Expand Down Expand Up @@ -897,7 +918,7 @@ class TVPWindowLayer : public cocos2d::extension::ScrollView, public iWindowLaye
sh = tex->GetInternalHeight()* ((float)LayerHeight / tex->GetHeight());
_drawTextureScaleY = 1 / _drawTextureScaleY;
}
DrawSprite->setTextureRect(Rect(0, 0, sw, sh)/*, false, Size(tex->GetWidth(), tex->GetHeight())*/);
DrawSprite->setTextureRect(Rect(0, 0, sw, sh));
DrawSprite->setBlendFunc(BlendFunc::DISABLE);
ResetDrawSprite();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/environ/ui/XP3RepackForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void TVPProcessXP3Repack(const std::string &dir)
delete st;
});
if (filelist.empty()) {
TVPShowSimpleMessageBox(locmgr->GetText("archive_repack_no_xp3").c_str(), "XP3Repack", 0, nullptr);
TVPShowSimpleMessageBox(locmgr->GetText("archive_repack_no_xp3").c_str(), "XP3Repack");
} else {
TVPXP3RepackFileListForm::show(filelist, dir);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/environ/ui/extension/UIExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ void XKPageView::adjust(float offset)
xOrY = pageSize.height;
}

if (abs(offset) < xOrY / 2){
if (std::abs(offset) < xOrY / 2){
this->setContentOffsetInDuration(vec, 0.1f);
return;
}

int i = abs(offset / xOrY) + 1;
int i = std::abs(offset / xOrY) + 1;
if (offset < 0) {
current_index += i;
if (current_index >= pageCount){
Expand Down
2 changes: 1 addition & 1 deletion src/core/environ/ui/extension/UIExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class XKPageView : public cocos2d::extension::ScrollView
private:
virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unusedEvent) override;
virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *unusedEvent) override;
virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unusedEvent) override;;
virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unusedEvent) override;

void performedAnimatedScroll(float dt);
int current_index;
Expand Down
2 changes: 1 addition & 1 deletion src/core/tjs2/tjsDisassemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ void tTJSInterCodeContext::Disassemble(tjs_int start, tjs_int end)
Disassemble(tTJSScriptBlock::GetConsoleOutput(), Block, start, end);
}
//---------------------------------------------------------------------------
void tTJSInterCodeContext::DisassenbleSrcLine(tjs_int codepos)
void tTJSInterCodeContext::DisassembleSrcLine(tjs_int codepos)
{
tjs_int start = FindSrcLineStartCodePos(codepos);
Disassemble(start, codepos + 1);
Expand Down
18 changes: 10 additions & 8 deletions src/core/tjs2/tjsInterCodeExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "tjsArray.h"
#include "tjsDebug.h"
#include "tjsOctPack.h"
#include "tjsGlobalStringMap.h"
#include <set>
#include <mutex>

Expand Down Expand Up @@ -916,7 +917,7 @@ void tTJSInterCodeContext::DisplayExceptionGeneratedCode(tjs_int codepos,

tjs->OutputToConsole(info.c_str());
tjs->OutputToConsole(TJS_W("-- Disassembled VM code --"));
DisassenbleSrcLine(codepos);
DisassembleSrcLine(codepos);

tjs->OutputToConsole(TJS_W("-- Register dump --"));

Expand Down Expand Up @@ -2100,7 +2101,8 @@ void tTJSInterCodeContext::TypeOfMemberDirect(tTJSVariant *ra,
}
else if(hr == TJS_E_MEMBERNOTFOUND)
{
TJS_GET_VM_REG(ra, code[1]) = TJS_W("undefined");
static tTJSString undefined_name(TJSMapGlobalStringMap(TJS_W("undefined")));
TJS_GET_VM_REG(ra, code[1]) = undefined_name;
}
else if(TJS_FAILED(hr))
TJSThrowFrom_tjs_error(hr, TJS_GET_VM_REG(DataArea, code[3]).GetString());
Expand Down Expand Up @@ -2866,12 +2868,12 @@ void tTJSInterCodeContext::ProcessOctetFunction(const tjs_char *member, const tT
void tTJSInterCodeContext::TypeOf(tTJSVariant &val)
{
// processes TJS2's typeof operator.
static tTJSString void_name(TJS_W("void"));
static tTJSString Object_name(TJS_W("Object"));
static tTJSString String_name(TJS_W("String"));
static tTJSString Integer_name(TJS_W("Integer"));
static tTJSString Real_name(TJS_W("Real"));
static tTJSString Octet_name(TJS_W("Octet"));
static tTJSString void_name(TJSMapGlobalStringMap(TJS_W("void")));
static tTJSString Object_name(TJSMapGlobalStringMap(TJS_W("Object")));
static tTJSString String_name(TJSMapGlobalStringMap(TJS_W("String")));
static tTJSString Integer_name(TJSMapGlobalStringMap(TJS_W("Integer")));
static tTJSString Real_name(TJSMapGlobalStringMap(TJS_W("Real")));
static tTJSString Octet_name(TJSMapGlobalStringMap(TJS_W("Octet")));

switch(val.Type())
{
Expand Down
Loading

0 comments on commit 0b7e2b5

Please sign in to comment.