Skip to content

Commit

Permalink
3.6.32
Browse files Browse the repository at this point in the history
  • Loading branch information
cainhuang committed Apr 28, 2017
1 parent cd5b599 commit 1f8184a
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--EXPORTED BY TOOL, DON'T MODIFY IT!-->
<!--Source File: FirstBT.xml-->
<behavior name="FirstBT" agenttype="FirstAgent" version="5">
<node class="Action" id="0">
<property Method="Self.FirstAgent::SayHello()" />
<property ResultOption="BT_SUCCESS" />
</node>
</behavior>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!--EXPORTED BY TOOL, DON'T MODIFY IT!-->
<agents version="1" signature="107115361" />
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class MainActivity extends AppCompatActivity {

// Used to load the 'native-lib' library on application startup.
// Used to load the libraries on application startup.
static {
System.loadLibrary("behaviac_gcc_debug");
System.loadLibrary("tutorial_11_gcc_debug");
Expand All @@ -19,12 +19,12 @@ protected void onCreate(Bundle savedInstanceState) {

// Example of a call to a native method
TextView tv = (TextView) findViewById(R.id.sample_text);
tv.setText(stringFromJNI());
tv.setText(TestMain(getApplication().getAssets()));
}

/**
* A native method that is implemented by the 'native-lib' native library,
* A native method that is implemented by the native library,
* which is packaged with this application.
*/
public native String stringFromJNI();
public native String TestMain(android.content.res.AssetManager assetManager);
}
Binary file modified docs/behaviac.chm
Binary file not shown.
50 changes: 50 additions & 0 deletions src/common/file/filesystem_gcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,58 @@ namespace behaviac {
umask(old);
}

void ListFiles_android(behaviac::vector<behaviac::string>& files, const char* szDirName, bool bRecurrsive)
{
AAssetManager* mgr = behaviac::CFileManager::GetInstance()->GetAssetManager();
if (mgr != NULL)
{
const char* validDir = szDirName;
//skip "assets:/"
if (behaviac::StringUtils::StartsWith(validDir, "assets:/"))
{
validDir = validDir + 8;
}

AAssetDir* dir = AAssetManager_openDir(mgr, validDir);
if (dir != NULL)
{
bool bEndsWithSlash = behaviac::StringUtils::EndsWith(szDirName, "/");
if (!bEndsWithSlash)
{
bEndsWithSlash = behaviac::StringUtils::EndsWith(szDirName, "\\");
}

while (true)
{
const char* fileName = AAssetDir_getNextFileName(dir);
if (fileName == NULL)
{
break;
}

if (bEndsWithSlash)
{
fileName = behaviac::FormatString("%s%s", szDirName, fileName);
}
else
{
fileName = behaviac::FormatString("%s/%s", szDirName, fileName);
}

files.push_back(fileName);
}

AAssetDir_close(dir);
}
}
}

void CFileSystem::ListFiles(behaviac::vector<behaviac::string>& files, const char* szDirName, bool bRecurrsive) {
#if BEHAVIAC_CCDEFINE_ANDROID && (BEHAVIAC_CCDEFINE_ANDROID_VER > 8)
ListFiles_android(files, szDirName, bRecurrsive);
#else
ListFiles_internal(files, szDirName, bRecurrsive);
#endif
}

void CFileSystem::HandleSeekError(const char* szFilename) {
Expand Down
17 changes: 12 additions & 5 deletions tutorials/tutorial_11/cpp/tutorial_11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "behaviac_generated/types/behaviac_types.h"
#include "behaviac_generated/behaviors/behaviac_generated_behaviors.h"

#if BEHAVIAC_CCDEFINE_ANDROID
#include <android/log.h>
#include <jni.h>

#if (BEHAVIAC_CCDEFINE_ANDROID_VER > 8)
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#endif

//#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "tutorial_11", __VA_ARGS__))
#define LOGI(...)
#else
Expand Down Expand Up @@ -59,15 +63,13 @@ const char* InitBehavic()
{
LOGI("InitBehavic\n");

behaviac::Workspace::GetInstance()->RegisterBehaviorTreeCreator("FirstBT", behaviac::bt_FirstBT::Create);

#if !BEHAVIAC_CCDEFINE_ANDROID
behaviac::Workspace::GetInstance()->SetFilePath("../tutorials/tutorial_11/cpp/exported");
#else
behaviac::Workspace::GetInstance()->SetFilePath("assets:/behaviac/exported");
#endif

behaviac::Workspace::GetInstance()->SetFileFormat(behaviac::Workspace::EFF_cpp);
behaviac::Workspace::GetInstance()->SetFileFormat(behaviac::Workspace::EFF_xml);

return "InitBehavic\n";
}
Expand Down Expand Up @@ -169,8 +171,13 @@ std::string TestBehaviac()

extern "C"
JNIEXPORT jstring JNICALL
Java_com_tencent_behaviac_behaviac_1android_MainActivity_stringFromJNI( JNIEnv *env, jobject /* this */)
Java_com_tencent_behaviac_behaviac_1android_MainActivity_TestMain(JNIEnv* env, jclass cls, jobject assetManager)
{
AAssetManager* mgr = AAssetManager_fromJava(env, assetManager);
BEHAVIAC_ASSERT(mgr);

behaviac::CFileManager::GetInstance()->SetAssetManager(mgr);

std::string str = TestBehaviac();

return env->NewStringUTF(str.c_str());
Expand Down

0 comments on commit 1f8184a

Please sign in to comment.