Commit f33d84c9 authored by fallenstardust's avatar fallenstardust

启动参数

parent bf9c83e7
......@@ -77,7 +77,7 @@ int main(int argc, char* argv[]) {
wchar_t fname[1024];
char* tmp = sub_string(arg, 2);
BufferIO::DecodeUTF8(tmp, fname);
__android_log_print(ANDROID_LOG_INFO, "ygo", "load cdb=%s", tmp);
__android_log_print(ANDROID_LOG_DEBUG, "ygo", "load cdb=%s", tmp);
ygo::dataManager.LoadDB(fname);
delete tmp;
} else if(!strcmp(arg, "-k")) { // Keep on return
......
......@@ -28,6 +28,7 @@ import android.widget.TextView;
import android.widget.Toast;
import java.nio.ByteBuffer;
import java.util.Arrays;
import cn.garymb.ygodata.YGOGameOptions;
import cn.garymb.ygomobile.controller.NetworkController;
......@@ -411,6 +412,10 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public ByteBuffer getNativeInitOptions() {
NativeInitOptions options = app().getNativeInitOptions();
options.mArgvList.clear();
if (mArgV != null) {
options.mArgvList.addAll(Arrays.asList(mArgV));
}
return options.toNativeBuffer();
}
......@@ -517,17 +522,4 @@ public class YGOMobileActivity extends NativeActivity implements
}
super.surfaceRedrawNeeded(holder);
}
@Override
public int getArgc(){
return mArgV == null ? 0 : mArgV.length;
}
@Override
public String getArgv(int index){
if(index >= 0 && mArgV != null && index < mArgV.length){
return mArgV[index];
}
return null;
}
}
......@@ -211,9 +211,5 @@ public final class IrrlichtBridge {
int getPositionX();
int getPositionY();
int getArgc();
String getArgv(int index);
}
}
......@@ -24,6 +24,7 @@ import java.io.File;
import java.util.HashMap;
import cn.garymb.ygodata.YGOGameOptions;
import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.plus.ViewTargetPlus;
......@@ -150,7 +151,14 @@ public class YGOStarter {
private static long lasttime = 0;
public static void startGame(Activity activity, YGOGameOptions options) {
/**
*
* @param activity
* @param options
* @param args 例如(播放完退出游戏):-r 1111.yrp
* 或者(播放完不退出游戏):-k -r 1111.yrp
*/
public static void startGame(Activity activity, YGOGameOptions options, String args) {
//如果距离上次加入游戏的时间大于1秒才处理
if (System.currentTimeMillis() - lasttime >= 1000) {
lasttime = System.currentTimeMillis();
......@@ -164,6 +172,9 @@ public class YGOStarter {
intent.putExtra(YGOGameOptions.YGO_GAME_OPTIONS_BUNDLE_KEY, options);
intent.putExtra(YGOGameOptions.YGO_GAME_OPTIONS_BUNDLE_TIME, System.currentTimeMillis());
}
if(args != null) {
intent.putExtra(IrrlichtBridge.EXTRA_ARGV, args.split(" "));
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.e("YGOStarter", "跳转前" + System.currentTimeMillis());
activity.startActivity(intent);
......
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