Commit 0e8d39b0 authored by fallenstardust's avatar fallenstardust

增加本地人机

parent 8134065f
...@@ -328,6 +328,24 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -328,6 +328,24 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
NetServer::StopServer(); NetServer::StopServer();
break; break;
} }
#elif defined(_IRR_ANDROID_PLATFORM_)
char args[512];
char arg1[512];
BufferIO::EncodeUTF8(mainGame->botInfo[sel].command, arg1);
char arg2[32];
arg2[0]=0;
if(mainGame->chkBotHand->isChecked())
sprintf(arg2, " Hand=1");
char arg3[32];
sprintf(arg3, " Port=%d", mainGame->gameConf.serverport);
sprintf(args, "%s%s%s", arg1, arg2, arg3);
android::runWindbot(mainGame->appMain, args);
if(!NetServer::StartServer(mainGame->gameConf.serverport))
break;
if(!DuelClient::StartClient(0x7f000001, mainGame->gameConf.serverport)) {
NetServer::StopServer();
break;
}
#else #else
if(fork() == 0) { if(fork() == 0) {
usleep(100000); usleep(100000);
......
...@@ -981,5 +981,31 @@ bool android_deck_delete(const char* deck_name) { ...@@ -981,5 +981,31 @@ bool android_deck_delete(const char* deck_name) {
return status == 0; return status == 0;
} }
void runWindbot(ANDROID_APP app, const char* args) {
if (!app || !app->activity || !app->activity->vm)
return;
JNIEnv* jni = 0;
app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni)
return;
// Retrieves NativeActivity.
jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
jmethodID MethodGetApp = jni->GetMethodID(ClassNativeActivity,
"getApplication", "()Landroid/app/Application;");
jobject application = jni->CallObjectMethod(lNativeActivity, MethodGetApp);
jclass classApp = jni->GetObjectClass(application);
jmethodID runWindbotMethod = jni->GetMethodID(classApp, "runWindbot",
"(Ljava/lang/String;)V");
jstring argsstring = jni->NewStringUTF(args);
jni->CallVoidMethod(application, runWindbotMethod, argsstring);
if (argsstring) {
jni->DeleteLocalRef(argsstring);
}
jni->DeleteLocalRef(classApp);
jni->DeleteLocalRef(ClassNativeActivity);
app->activity->vm->DetachCurrentThread();
}
} // namespace android } // namespace android
} // namespace irr } // namespace irr
...@@ -177,6 +177,8 @@ extern unsigned char* android_script_reader(const char* script_name, int* slen); ...@@ -177,6 +177,8 @@ extern unsigned char* android_script_reader(const char* script_name, int* slen);
extern bool android_deck_delete(const char* deck_name); extern bool android_deck_delete(const char* deck_name);
extern void runWindbot(ANDROID_APP app, const char* args);
} }
} }
......
...@@ -169,6 +169,9 @@ public final class IrrlichtBridge { ...@@ -169,6 +169,9 @@ public final class IrrlichtBridge {
float getScreenHeight(); float getScreenHeight();
void playSoundEffect(String path); void playSoundEffect(String path);
void runWindbot(String args);
// float getSmallerSize(); // float getSmallerSize();
// float getXScale(); // float getXScale();
// float getYScale(); // float getYScale();
......
...@@ -53,6 +53,9 @@ android { ...@@ -53,6 +53,9 @@ android {
exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE'
} }
aaptOptions {
noCompress 'dll'
}
buildToolsVersion '27.0.3' buildToolsVersion '27.0.3'
} }
...@@ -77,6 +80,8 @@ dependencies { ...@@ -77,6 +80,8 @@ dependencies {
implementation 'org.greenrobot:eventbus:3.0.0' implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'com.tubb.smrv:swipemenu-recyclerview:5.4.0' implementation 'com.tubb.smrv:swipemenu-recyclerview:5.4.0'
// //
implementation(name: 'libWindbot', ext: 'aar')
//
mycardImplementation(name: 'xwalk_core_library-22.52.561.4', ext: 'aar') mycardImplementation(name: 'xwalk_core_library-22.52.561.4', ext: 'aar')
implementation 'com.nightonke:boommenu:2.1.0' implementation 'com.nightonke:boommenu:2.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
......
...@@ -2,6 +2,7 @@ package cn.garymb.ygomobile; ...@@ -2,6 +2,7 @@ package cn.garymb.ygomobile;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatDelegate; import android.support.v7.app.AppCompatDelegate;
public class App extends GameApplication { public class App extends GameApplication {
...@@ -98,4 +99,12 @@ public class App extends GameApplication { ...@@ -98,4 +99,12 @@ public class App extends GameApplication {
public float getScreenHeight() { public float getScreenHeight() {
return AppsSettings.get().getScreenHeight(); return AppsSettings.get().getScreenHeight();
} }
@Override
public void runWindbot(String args) {
Intent intent = new Intent();
intent.putExtra("args", args);
intent.setAction("RUN_WINDBOT");
getBaseContext().sendBroadcast(intent);
}
} }
package cn.garymb.ygomobile.ui.home; package cn.garymb.ygomobile.ui.home;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
...@@ -27,6 +30,7 @@ import com.nightonke.boommenu.BoomMenuButton; ...@@ -27,6 +30,7 @@ import com.nightonke.boommenu.BoomMenuButton;
import com.qihoo.appstore.common.updatesdk.lib.UpdateHelper; import com.qihoo.appstore.common.updatesdk.lib.UpdateHelper;
import com.tubb.smrv.SwipeMenuRecyclerView; import com.tubb.smrv.SwipeMenuRecyclerView;
import org.chromium.mojo.bindings.MessageReceiver;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
...@@ -52,6 +56,7 @@ import cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener; ...@@ -52,6 +56,7 @@ import cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener;
import cn.garymb.ygomobile.ui.plus.DialogPlus; import cn.garymb.ygomobile.ui.plus.DialogPlus;
import cn.garymb.ygomobile.ui.preference.SettingsActivity; import cn.garymb.ygomobile.ui.preference.SettingsActivity;
import cn.garymb.ygomobile.utils.AlipayPayUtils; import cn.garymb.ygomobile.utils.AlipayPayUtils;
import libwindbot.windbot.WindBot;
abstract class HomeActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener{ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener{
protected SwipeMenuRecyclerView mServerList; protected SwipeMenuRecyclerView mServerList;
...@@ -77,11 +82,17 @@ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNav ...@@ -77,11 +82,17 @@ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNav
mServerListManager = new ServerListManager(this, mServerListAdapter); mServerListManager = new ServerListManager(this, mServerListAdapter);
mServerListManager.bind(mServerList); mServerListManager.bind(mServerList);
mServerListManager.syncLoadData(); mServerListManager.syncLoadData();
//windbot
WindBot.initAndroid("/storage/emulated/0/ygocore", "/storage/emulated/0/ygocore/cards.cdb");
MessageReceiver mReceiver = new MessageReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("RUN_WINDBOT");
getContext().registerReceiver(mReceiver, filter);
//event //event
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
initBoomMenuButton($(R.id.bmb)); initBoomMenuButton($(R.id.bmb));
//trpay //trpay
TrPay.getInstance(HomeActivity.this).initPaySdk("e1014da420ea4405898c01273d6731b6","baidu"); TrPay.getInstance(HomeActivity.this).initPaySdk("e1014da420ea4405898c01273d6731b6","YGOMobile");
//autoupadte checking //autoupadte checking
checkForceUpdateSilent(); checkForceUpdateSilent();
} }
...@@ -92,6 +103,17 @@ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNav ...@@ -92,6 +103,17 @@ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNav
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
} }
public class MessageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("RUN_WINDBOT")) {
String args=intent.getStringExtra("args");
WindBot.runAndroid(args);
}
}
};
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onServerInfoEvent(ServerInfoEvent event) { public void onServerInfoEvent(ServerInfoEvent event) {
if (event.delete) { if (event.delete) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment