result = alipay.payV2(orderInfo, true);
+ Log.i("msp", result.toString());
+
+ Message msg = new Message();
+ msg.what = SDK_PAY_FLAG;
+ msg.obj = result;
+ mHandler.sendMessage(msg);
+ };
+
+ // 必须异步调用
+ Thread payThread = new Thread(payRunnable);
+ payThread.start();
+ }
+
+
+}
diff --git a/android/app/src/main/java/co/steamcloud/cargame/MoveButton.java b/android/app/src/main/java/co/steamcloud/cargame/MoveButton.java
new file mode 100644
index 0000000..1ba3826
--- /dev/null
+++ b/android/app/src/main/java/co/steamcloud/cargame/MoveButton.java
@@ -0,0 +1,97 @@
+package co.steamcloud.cargame;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.RelativeLayout;
+
+public class MoveButton extends RelativeLayout {
+
+
+ private OnClickCallBackListener mListener;
+ private float mOriginalX;
+ private float mOriginalY;
+ private float mOriginalRawX;
+ private float mOriginalRawY;
+ public float touchInitX;
+ public float touchInitY;
+ boolean isMove = false;
+ public float moveX;
+ public float moveY;
+
+ public MoveButton(Context context) {
+ super(context);
+ }
+
+ public MoveButton(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public MoveButton(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (Config.s_keyboard) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ moveX = 0;
+ moveY = 0;
+ mOriginalX = getX();
+ mOriginalY = getY();
+ mOriginalRawX = event.getRawX();
+ mOriginalRawY = event.getRawY();
+
+ touchInitX = event.getX();
+ touchInitY = event.getY();
+ isMove = false;
+
+ if (mListener != null) {
+ mListener.onActionDown(event);
+ }
+ break;
+ case MotionEvent.ACTION_MOVE:
+ if (Math.abs(event.getX() - touchInitX) > 10 || Math.abs(event.getY() - touchInitY) > 10) {
+ isMove = true;
+ moveX = mOriginalX + event.getRawX() - mOriginalRawX;
+ setX(moveX);
+ moveY = mOriginalY + event.getRawY() - mOriginalRawY;
+ setY(mOriginalY + event.getRawY() - mOriginalRawY);
+ if (mListener != null){
+ mListener.onActionMove(moveX, moveY);
+ }
+ }
+
+ break;
+ case MotionEvent.ACTION_UP:
+ if (!isMove) {
+
+ }
+ break;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public void setOnClickCallBackListener(OnClickCallBackListener listener) {
+ this.mListener = listener;
+ }
+
+
+ public interface OnClickCallBackListener {
+ void onActionDown(MotionEvent event);
+
+ //void onActionUp();
+
+ void onActionMove(float moveX, float moveY);
+ }
+
+ public void setPosition(float x, float y) {
+ this.setX(x);
+ this.setY(y);
+ }
+
+
+}
diff --git a/android/app/src/main/java/co/steamcloud/cargame/MyButton.java b/android/app/src/main/java/co/steamcloud/cargame/MyButton.java
new file mode 100644
index 0000000..d13fbb9
--- /dev/null
+++ b/android/app/src/main/java/co/steamcloud/cargame/MyButton.java
@@ -0,0 +1,115 @@
+package co.steamcloud.cargame;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+public class MyButton extends androidx.appcompat.widget.AppCompatTextView {
+
+
+ public MyButton(@NonNull Context context) {
+ super(context);
+
+ }
+
+ public MyButton(@NonNull Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public MyButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+ private OnClickCallBackListener mListener;
+ private ViewChangMsgListener viewChangMsgListener;
+
+ private String KeyIndex;
+ private String KeyName;
+ private String X;
+ private String Y;
+ private int W;
+ private int H;
+ private String SelectedImage;
+ private String KeyImage;
+ private float Scale;
+
+ private float mOriginalX;
+ private float mOriginalY;
+ private float mOriginalRawX;
+ private float mOriginalRawY;
+ public float touchInitX;
+ public float touchInitY;
+ boolean isMove = false;
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mOriginalX = getX();
+ mOriginalY = getY();
+ mOriginalRawX = event.getRawX();
+ mOriginalRawY = event.getRawY();
+
+ touchInitX = event.getX();
+ touchInitY = event.getY();
+ isMove = false;
+
+ break;
+ case MotionEvent.ACTION_MOVE:
+ if (Math.abs(event.getX() - touchInitX) > 10 || Math.abs(event.getY() - touchInitY) > 10) {
+ isMove = true;
+ setX(mOriginalX + event.getRawX() - mOriginalRawX);
+ setY(mOriginalY + event.getRawY() - mOriginalRawY);
+ }
+
+ break;
+ case MotionEvent.ACTION_UP:
+ if (!isMove) {
+ if (mListener!=null){
+ mListener.onActionDown();
+ }
+ }
+
+ break;
+ }
+
+
+ return true;
+ }
+ public void setOnClickCallBackListener(OnClickCallBackListener listener){
+ this.mListener=listener;
+ }
+
+ public void keyBoardDelectListener(ViewChangMsgListener viewChangMsgListener){
+ this.viewChangMsgListener =viewChangMsgListener;
+ }
+
+
+ public interface OnClickCallBackListener{
+ void onActionDown();
+ void onActionMove(float x,float y);
+ }
+
+ public void setPosition(float x,float y) {
+ this.setX(x);
+ this.setY(y);
+ }
+
+ public interface ViewChangMsgListener{
+ void changTexture(String path);
+ void showDeletPopup(MyButton view);
+ void showDeletPopup(String index);
+ void showFloatPopup();
+ }
+ public interface virtualHandleChangeListener{
+ void layerBtnSetVisible(int tag);
+ }
+ public interface virtualKeyboardChangeListener
+ {
+ void removeChild(View child);
+ void hideDirection();
+ }
+}
diff --git a/android/app/src/main/java/co/steamcloud/cargame/PeterTimeCountRefresh.java b/android/app/src/main/java/co/steamcloud/cargame/PeterTimeCountRefresh.java
new file mode 100644
index 0000000..045ff3f
--- /dev/null
+++ b/android/app/src/main/java/co/steamcloud/cargame/PeterTimeCountRefresh.java
@@ -0,0 +1,62 @@
+package co.steamcloud.cargame;
+
+import android.os.CountDownTimer;
+
+public class PeterTimeCountRefresh extends CountDownTimer {
+ private OnTimerFinishListener finishListener;
+ private OnTimerProgressListener progressListener;
+
+ /**
+ * @param millisInFuture 分钟转换成 毫秒
+ * @param countDownInterval 计时的时间间隔
+ */
+ public PeterTimeCountRefresh(long millisInFuture, long countDownInterval) {
+ super(millisInFuture, countDownInterval);//参数依次为总时长,和计时的时间间隔,要显示的按钮
+ }
+
+
+ @Override
+ public void onTick(long millisUntilFinished) {//计时过程显示
+ if (progressListener != null) {
+ progressListener.onTimerProgress(millisUntilFinished);
+ }
+ }
+
+ @Override
+ public void onFinish() {//计时完毕时触发
+ if (finishListener != null) {
+ finishListener.onTimerFinish();
+ }
+ }
+
+ /**
+ * 设置timer走完的回调
+ */
+ public void setOnTimerFinishListener(OnTimerFinishListener finishListener) {
+ this.finishListener = finishListener;
+ }
+
+ /**
+ * 设置监听进度的
+ */
+ public void setOnTimerProgressListener(OnTimerProgressListener progressListener) {
+ this.progressListener = progressListener;
+ }
+
+ /**
+ * Timer 执行完成的回调
+ */
+ public interface OnTimerFinishListener {
+
+ void onTimerFinish();
+ }
+
+ /**
+ * Timer 进度的监听
+ */
+ public interface OnTimerProgressListener {
+
+ void onTimerProgress(long timeLong);
+ }
+
+}
diff --git a/android/app/src/main/java/co/steamcloud/cargame/PlayGameActivity.java b/android/app/src/main/java/co/steamcloud/cargame/PlayGameActivity.java
new file mode 100644
index 0000000..cdfda5f
--- /dev/null
+++ b/android/app/src/main/java/co/steamcloud/cargame/PlayGameActivity.java
@@ -0,0 +1,3935 @@
+package co.steamcloud.cargame;
+
+
+import static co.steamcloud.cargame.Config.s_keyboard;
+
+import android.animation.ValueAnimator;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.SystemClock;
+import android.text.TextUtils;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.HapticFeedbackConstants;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.constraintlayout.widget.Group;
+
+import com.airbnb.lottie.LottieAnimationView;
+import com.bumptech.glide.load.resource.drawable.GlideDrawable;
+import com.bumptech.glide.request.animation.GlideAnimation;
+import com.bumptech.glide.request.target.SimpleTarget;
+import com.zjrx.common.util.LogUtil;
+import com.zjrx.jyengine.JyCode;
+import com.zjrx.jyengine.JyFeedBackEvent;
+import com.zjrx.jyengine.JyGameStatusListener;
+import com.zjrx.jyengine.JySurfaceView;
+import com.zjrx.jyengine.WhaleCloud;
+import com.zjrx.jyengine.bs.OnApiRequestListener;
+import com.zjrx.jyengine.eventbus.MouseEvent;
+import com.zjrx.jyengine.input.handle.GameHandle;
+import com.zjrx.jyengine.input.tController;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.simple.eventbus.EventBus;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import co.steamcloud.cargame.HttpUtils.OpenApiRequest;
+import co.steamcloud.cargame.entity.VirtualKeyListBean;
+import co.steamcloud.cargame.glide.GlideImageLoader;
+import co.steamcloud.cargame.time.SubscribeTimeManage;
+import co.steamcloud.cargame.utils.AppConfigFileImpl;
+import co.steamcloud.cargame.utils.AppUtil;
+
+public class PlayGameActivity extends Activity {
+ public static final String TAG = "PlayGameActivity";
+ private ConstraintLayout content;
+ private JySurfaceView mVideoView;
+ private SurfaceView mVideoViewLegacy;
+ private GameFrameLayOut gameLayout;
+ private FrameLayout NetworkKeyboard, NetworkCursor, MNKeyboard;
+ private ImageView close_set, img_qr;
+ private MyButton menu_set, Move_show_hide;
+ private ConstraintLayout menu, seting, custom_button;
+ private Group seting_g1, seting_g2, seting_g3;
+ private TextView set_control, set_frame, set_GamePad, wifi, custom_button_default, custom_button_yg, custom_button_close;
+ private MyButton mImageCursor;
+ /*进度条*/
+ private ConstraintLayout loadingCL;
+ private ImageView loading;
+ private LottieAnimationView animationView;
+ private ProgressBar progressbar1;
+ private TextView fadenum;
+ private TextView qosTextView;
+ private RelativeLayout qosLayout;
+ private CountDownTimerUtil countDownTimerUtil;
+ private ValueAnimator valueAnimator;
+ /*进度条*/
+ private TextView speed1, speed2, speed3, speed4, speed5, handle1, handle2, handle3, handle4, proportion1, proportion2, tvDpi, tvDpi2;
+ private SeekBar skDpi, skDpi2;
+ private double multiple = 1.0;
+ private double multiple2 = 0.8f;
+
+ public boolean bGameStart = false;
+ //接收视频流宽和高
+ int mFrameWidth = 1920;
+ int mFrameHeight = 1080;
+ //手机屏幕宽和高
+ private int SCREEN_WIDTH = 1920;
+ private int SCREEN_HEIGHT = 1080;
+ private int ZOOM_WIDTH = 1920;//等比缩放
+ private int ZOOM_HEIGHT = 1080;//等比缩放
+ private int ZOOM_W = 1920;//缩放
+ private int ZOOM_H = 1080;//缩放
+
+ int orientation_now = Configuration.ORIENTATION_LANDSCAPE;
+ int orientation_last = Configuration.ORIENTATION_PORTRAIT;
+ JySurfaceView.ScaleType mScalingType = JySurfaceView.ScaleType.ASPECT_FULL_SCREEN;//ASPECT_FIT, ASPECT_FILL, ASPECT_BALANCED,ASPECT_FULL_SCREEN
+ private View handleView;
+ private ConstraintLayout HandleCL;
+ private FrameLayout VisualAngle;
+ private Button select;
+ private String gameData = "";//启动游戏数据
+ private String isReconPlay = "false";//是否是重连游戏
+ public boolean btn_right_close = false;//右边摇杆是否关闭
+ public int virtual_mode = 1;//1表示虚拟手柄,2表示自定义虚拟手柄,3表示虚拟键盘,4表示自定义虚拟键盘
+ public int shubiao_mode = 1;//鼠标模式 1=点击模式 2=滑屏点击
+ //操控输入
+ tController player1 = new tController((byte) 0); //手柄
+ MouseEvent mouseEvent = new MouseEvent(); //鼠标
+ Timer keyEventTimer = null;
+ TimerTask keyEventTimerTask = null;
+ private boolean IsGameInput = true;//虚拟手柄
+ private boolean IsKeyBoard = true;//虚拟键盘
+ private boolean IsGameMouse;
+ public int Ismode = 1;//1手柄 2键盘
+ private boolean showKeyboard = false;
+
+ private boolean textInput = false;
+
+ int mDstx = 0;
+ int mDsty = 0;
+
+ private float mouseEventX, mouseEventY, moveX, moveY;
+ private float lastMouseX, lastMouseY;
+ private float downX = 0, downY = 0, downX2 = 0, downY2 = 0;
+ private float lastMoveX = 0, lastMoveY = 0;
+ private float lastMoveX2 = 0, lastMoveY2 = 0;
+
+
+ private float downJoystickX = 0, downJoystickY = 0, moveJoystickX, moveJoystickY;
+
+
+ // NetHander netHander = new NetHander();
+ int popupPraise;
+
+ private int nounTime = 0;
+
+ private int sY, sX;
+ private ConstraintLayout conDiamond;
+ private TextView tvCountDown;
+ private Button btRecharge;
+ // private ImageView imgShowHide;
+ private PeterTimeCountRefresh refresh;
+
+ private Boolean isShow = false;
+ private String orderId;
+ private String QuickPaymentId;
+ private String payMoney;
+ private String payChannel;
+ private String rechargeId;
+ private String ProductId;
+ // private GameBuyDialog dialog;
+ private boolean isShock = false;//震动
+ private boolean isInsufficientDialog = false;
+
+ TextView button_a, button_b, button_x, button_y, lt, lb, rt, rb, ls, rs, start, back;
+ ImageView dpad_up, dpad_down, dpad_left, dpad_right, dpad_up_left, dpad_up_right, dpad_down_left,
+ dpad_down_right;
+ private boolean consumed;
+ private ImageView imgKeySet, imgSwitchKey, imgSwitchRightRocker, imgSwitchKeyboard, imgSwitchShock;
+ private KeyboardUtil keyboardUtil;
+ private TextView tvVipType, tvDiamanteNum, tvExitGame, tvReturnApp;
+ private ConstraintLayout conBuy;
+ private ImageView imgVipType;
+ private OpenApiRequest openApiRequest;
+ private Bitmap qrCodeBitmap;
+ // private JoinMembershipDialog joinMembershipDialog;
+
+ /**
+ * 启动计时
+ */
+ private void startTime() {
+ SubscribeTimeManage.getInstance().register(onTimeListener);
+ }
+
+ /**
+ * 取消计时
+ */
+ private void stopTime() {
+ SubscribeTimeManage.getInstance().unregister(onTimeListener);
+ }
+
+ /**
+ * 一秒走一次
+ */
+ SubscribeTimeManage.OnTimeListener onTimeListener = new SubscribeTimeManage.OnTimeListener() {
+ @Override
+ public void oneSecond() {
+ nounTime++;
+ }
+ };
+ private String pingNum = "";
+ private String ipString = "";
+ private boolean m_isPing = false;
+
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
+ Window w = getWindow();
+ if (w != null) {
+ w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);//保持常亮
+ w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//全屏:隐藏状态栏
+ w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//将window扩展至全屏,并且不会覆盖状态栏。
+ w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);//避免在状态栏的显示状态发生变化时重新布局,从而避免界面卡顿。
+ }
+
+ openApiRequest = new OpenApiRequest();
+ //获取游戏设置
+ openApiRequest.gameSetting(new OnApiRequestListener() {
+ @Override
+ public void onResponse(String data, int code, String msg) {
+ Log.d(TAG, "onResponse: data==" + data);
+ Log.d(TAG, "onResponse: code==" + code);
+ Log.d(TAG, "onResponse: msg==" + msg);
+
+
+ try {
+ JSONObject jsonObject = new JSONObject(data);
+ String jsonData = jsonObject.getString("data");
+ if (jsonData.equals("null")) {
+ Log.d(TAG, "onResponse: 游戏设置数据异常");
+ return;
+ }
+ Log.d(TAG, "onResponse: jsonData==" + jsonData);
+ JSONObject heartData = new JSONObject(jsonData);
+
+ String handleQrCode = heartData.getString("handleQrCode");//H5手柄扫码二维码
+
+ Resources res = getResources();
+ Bitmap logoBitmap = BitmapFactory.decodeResource(res, R.mipmap.ic_launcher);
+
+ qrCodeBitmap = AppUtil.createQRCodeBitmap(handleQrCode, 200, 200, "UTF-8", "H", "1", R.color.black, Color.WHITE, logoBitmap, 0.2f);
+
+ Log.d(TAG, "onResponse: data=" + jsonObject);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void onFailure(Exception e) {
+ Log.d(TAG, "onResponse: e==" + e);
+ }
+ });
+
+ //隐藏系统按钮
+ hideBottomUIMenu();
+ setContentView(R.layout.activity_game);
+// EventBus.getDefault().register(this);
+
+ //游戏数据
+ gameData = getIntent().getStringExtra("GameData");
+ //是否重连游戏
+ isReconPlay = getIntent().getStringExtra("isReconPlay");
+ Log.i(TAG, "onCreate: gameData==" + gameData);
+ if (gameData == null || gameData.isEmpty()) {
+ finish();
+ return;
+ }
+ ActivityCollector.addActivity(PlayGameActivity.this);
+
+ //初始化view
+ initUI();
+
+ bGameStart = true;
+
+ //按键震动
+ isShock = AppConfigFileImpl.getBooleanParams(getApplicationContext(), "isShock");
+ if (imgSwitchShock != null) {
+ if (isShock) {
+ imgSwitchShock.setImageResource(R.mipmap.switch_open);
+ } else {
+ imgSwitchShock.setImageResource(R.mipmap.switch_close);
+ }
+ }
+
+ startGame(); //启动游戏
+ updateLayoutSize();
+ startTime();//启动记时
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (keyEventTimerTask != null && keyEventTimer != null) {
+ startKeyEventSchedule();
+ }
+ }
+
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if (keyEventTimer != null) {
+ keyEventTimer.cancel();
+ }
+ if (keyEventTimerTask != null) {
+ keyEventTimerTask.cancel();
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (keyEventTimer != null) {
+ keyEventTimer.cancel();
+ keyEventTimer = null;
+ }
+ if (keyEventTimerTask != null) {
+ keyEventTimerTask.cancel();
+ keyEventTimerTask = null;
+ }
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ if (valueAnimator != null) {
+ valueAnimator.cancel();
+ }
+ if (mVideoView != null) {
+ mVideoView.release();
+ mVideoView = null;
+ }
+ if (refresh != null) {
+ refresh.cancel();
+ }
+ stopTime();
+ super.onDestroy();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ LogUtil.i("onLayoutChange SCREEN_WIDTH: " + SCREEN_WIDTH + " SCREEN_HEIGHT:" + SCREEN_HEIGHT);
+ if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
+ orientation_now = Configuration.ORIENTATION_PORTRAIT;
+ } else {
+ orientation_now = Configuration.ORIENTATION_LANDSCAPE;
+ }
+ updateLayoutSize();
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ onKeyEvent(keyCode, true);
+ LogUtil.d("key quit");
+
+ if (bGameStart) {
+ //键盘ESC 会发送ESC键值和back键值。该判断确保BACK(esc)能发送到游戏服务器
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ //WhaleCloud.getInstance().stopGame("返回键退出");
+ showDialog("退出游戏", "确定退出游戏吗?", "退出游戏", "取消", new IDialogTwoView() {
+ @Override
+ public void cancel() {
+ hideBottomUIMenu();
+ }
+
+ @Override
+ public void onSure() {
+ closeGame();
+ }
+
+ @Override
+ public void returnApp() {
+// returnAppMain();
+ }
+ });
+ return true;
+ } else {
+ consumed = WhaleCloud.getInstance().handleKeyEvent(keyCode, event, true);
+ Log.d(TAG, "onKeyDown: keyCode==" + keyCode);
+ }
+ } else {
+ finish();
+ }
+ return consumed;
+ }
+
+ //返回app
+ private void returnAppMain() {
+ Intent intent1 = new Intent(PlayGameActivity.this, MainActivity.class);
+ intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ PlayGameActivity.this.startActivity(intent1);
+// EventBus.getDefault().post("returnApp", EventBusParams.GAME);
+ }
+
+ private void showUItoast(final String toastMsg) {
+ try {
+ runOnUiThread(() -> Toast.makeText(App.getInstance(), toastMsg, Toast.LENGTH_SHORT).show());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ boolean consumed = WhaleCloud.getInstance().handleKeyEvent(keyCode, event, false);
+ if (consumed) {
+ return true;
+ }
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean dispatchGenericMotionEvent(MotionEvent event) {
+ boolean consumed;
+ Log.d(TAG, "dispatchGenericMotionEvent: event==" + event);
+ LogUtil.d("...dispatchGenericMotionEvent:" + event);
+ consumed = WhaleCloud.getInstance().dispatchGenericMotionEvent(event);
+ return consumed;
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent event) {
+ boolean consumed;
+ if (event.getToolType(0) != MotionEvent.TOOL_TYPE_FINGER) {
+ consumed = WhaleCloud.getInstance().dispatchGenericMotionEvent(event);
+ if (consumed) {
+ return true;
+ }
+ }
+
+ return super.dispatchTouchEvent(event);
+ }
+
+
+ public void startKeyEventSchedule() {
+ if (keyEventTimer != null) {
+ keyEventTimer.cancel();
+ keyEventTimer = null;
+ }
+ if (keyEventTimerTask != null) {
+ keyEventTimerTask.cancel();
+ keyEventTimerTask = null;
+ }
+ keyEventTimer = new Timer();
+ keyEventTimerTask = new TimerTask() {
+ @Override
+ public void run() {
+ Config.keyEvent_time++;
+ if (Config.is_Playing == false) {
+ if (keyEventTimer != null) {
+ keyEventTimer.cancel();
+ keyEventTimer = null;
+ }
+ if (keyEventTimerTask != null) {
+ keyEventTimerTask.cancel();
+ keyEventTimerTask = null;
+ }
+ }
+ if (Config.keyEvent_time == Config.time_out_prealarm) {
+ Log.d(TAG, "run: 由于您长时间无操作,将60秒后退出游戏。");
+ showUItoast("由于您长时间无操作,将60秒后退出游戏。");
+ } else if (Config.keyEvent_time >= Config.time_out_max_second) {
+ if (keyEventTimer != null) {
+ keyEventTimer.cancel();
+ keyEventTimer = null;
+ }
+ if (keyEventTimerTask != null) {
+ keyEventTimerTask.cancel();
+ keyEventTimerTask = null;
+ }
+ closeGame();
+ }
+ }
+ };
+ keyEventTimer.schedule(keyEventTimerTask, 0, 1000);
+ }
+
+ public void onKeyEvent(int keyCode, boolean isKeyDown) {
+ if (isKeyDown) {
+ Config.keyEvent_time = 0;
+
+ } else {
+ //Config.myMultKeyTrigger.removeKey(keyCode, System.currentTimeMillis());
+ }
+ }
+
+ private void initUI() {
+// dialog = new GameBuyDialog(PlayGameActivity.this, Config.gamePara.my_GameId);
+// joinMembershipDialog = new JoinMembershipDialog(PlayGameActivity.this);
+ qosLayout = findViewById(R.id.qosLayout);
+// if (NetHander.isDebug) {
+// qosLayout.setVisibility(View.VISIBLE);
+// }
+ qosTextView = findViewById(R.id.qosTextView);
+ content = findViewById(R.id.content);
+ gameLayout = findViewById(R.id.video_renderer_layout);
+ NetworkKeyboard = findViewById(R.id.NetworkKeyboard);
+ MNKeyboard = findViewById(R.id.MNKeyboard);
+ NetworkCursor = findViewById(R.id.NetworkCursor);
+ menu_set = findViewById(R.id.menu_set);
+ Move_show_hide = findViewById(R.id.Move_show_hide);
+ wifi = findViewById(R.id.wifi);
+ seting = findViewById(R.id.seting);
+ close_set = findViewById(R.id.close_set);
+ custom_button_close = findViewById(R.id.custom_button_close);
+ custom_button_yg = findViewById(R.id.custom_button_yg);
+ custom_button_default = findViewById(R.id.custom_button_default);
+ custom_button = findViewById(R.id.custom_button);
+ menu = findViewById(R.id.menu);
+
+ loadingCL = findViewById(R.id.loadingCL);
+ loading = findViewById(R.id.loading);
+ animationView = findViewById(R.id.animation_view);
+ progressbar1 = findViewById(R.id.progressbar1);
+ fadenum = findViewById(R.id.fadenum);
+
+ speed1 = findViewById(R.id.speed1);
+ speed2 = findViewById(R.id.speed2);
+ speed3 = findViewById(R.id.speed3);
+ speed4 = findViewById(R.id.speed4);
+ speed5 = findViewById(R.id.speed5);
+ handle1 = findViewById(R.id.handle1);
+ handle2 = findViewById(R.id.handle2);
+ proportion1 = findViewById(R.id.proportion1);
+ proportion2 = findViewById(R.id.proportion2);
+ handle3 = findViewById(R.id.handle3);
+ handle4 = findViewById(R.id.handle4);
+ skDpi = findViewById(R.id.sk_dpi);
+ tvDpi = findViewById(R.id.tv_dpi);
+ skDpi2 = findViewById(R.id.sk_dpi2);
+ tvDpi2 = findViewById(R.id.tv_dpi2);
+
+ conDiamond = findViewById(R.id.con_diamonds);
+ tvCountDown = findViewById(R.id.tv_count_down);
+ btRecharge = findViewById(R.id.bt_recharge);
+
+ imgKeySet = findViewById(R.id.img_key_set);
+ imgSwitchKey = findViewById(R.id.img_switch_key);
+ imgSwitchRightRocker = findViewById(R.id.img_switch_right_rocker);
+ imgSwitchKeyboard = findViewById(R.id.img_switch_keyboard);
+ imgSwitchShock = findViewById(R.id.img_switch_shock);
+ tvExitGame = findViewById(R.id.tv_exit_game);
+ tvReturnApp = findViewById(R.id.tv_return_app);
+ tvReturnApp.setOnClickListener(view -> {
+ if (menu != null) {
+ menu.setVisibility(View.GONE);
+ }
+ returnAppMain();
+ });
+
+ //退出游戏按钮
+ tvExitGame.setOnClickListener(view -> {
+ if (menu != null) {
+ menu.setVisibility(View.GONE);
+ }
+ showDialog("退出游戏", "确定退出游戏吗?", "退出游戏", "取消", new IDialogTwoView() {
+ @Override
+ public void cancel() {
+ hideBottomUIMenu();
+ }
+
+ @Override
+ public void onSure() {
+ closeGame();
+ }
+
+ @Override
+ public void returnApp() {
+// returnAppMain();
+ }
+ });
+ });
+
+ imgSwitchShock.setOnClickListener(view -> {
+ isShock = !isShock;
+ if (isShock) {
+ imgSwitchShock.setImageResource(R.mipmap.switch_open);
+ AppConfigFileImpl.saveParams(getApplicationContext(), "isShock", true);
+ } else {
+ imgSwitchShock.setImageResource(R.mipmap.switch_close);
+ AppConfigFileImpl.saveParams(getApplicationContext(), "isShock", false);
+ }
+ });
+
+ imgSwitchKeyboard.setOnClickListener(view -> {
+ if (menu != null) {
+ menu.setVisibility(View.GONE);
+ }
+ textInput = !textInput;
+ showKeyboard = true;
+ keyboardUtil = new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this);
+ if (textInput) {
+ imgSwitchKeyboard.setImageResource(R.mipmap.switch_open);
+ keyboardUtil.showKeyboard();
+ } else {
+ imgSwitchKeyboard.setImageResource(R.mipmap.switch_close);
+ keyboardUtil.hideKeyboard();
+ }
+ });
+
+ imgSwitchRightRocker.setOnClickListener(view -> {
+ if (btn_right_close) {
+ btn_right_close = false;
+ custom_button_yg.setText("右摇杆:开");
+ imgSwitchRightRocker.setImageResource(R.mipmap.switch_close);
+ yaogan_right.setVisibility(View.VISIBLE);
+ } else {
+ btn_right_close = true;
+ custom_button_yg.setText("右摇杆:关");
+ imgSwitchRightRocker.setImageResource(R.mipmap.switch_open);
+ yaogan_right.setVisibility(View.GONE);
+ }
+ });
+
+ imgSwitchKey.setOnClickListener(view -> {
+ if (menu != null) {
+ menu.setVisibility(View.GONE);
+ }
+ //显示隐藏键盘
+ if (Config.is_immersion) {
+ if (Move_show_hide != null) {
+ Move_show_hide.setBackgroundResource(R.mipmap.ic_key_hide);
+ }
+ imgSwitchKey.setImageResource(R.mipmap.switch_open);
+ if (Ismode == 1) {
+ if (HandleCL != null) {
+ HandleCL.setVisibility(View.VISIBLE);
+ }
+ } else if (Ismode == 2) {
+ NetworkKeyboard.setVisibility(View.VISIBLE);
+ }
+ } else {
+ if (Ismode == 1) {
+ if (HandleCL != null && select != null) {
+ HandleCL.setVisibility(View.GONE);
+ }
+ } else if (Ismode == 2) {
+ NetworkKeyboard.setVisibility(View.GONE);
+ }
+ if (Move_show_hide != null) {
+ Move_show_hide.setBackgroundResource(R.mipmap.ic_key_show);
+ }
+ imgSwitchKey.setImageResource(R.mipmap.switch_close);
+ }
+ Config.is_immersion = !Config.is_immersion;
+ });
+
+ imgKeySet.setOnClickListener(view -> {
+ seting.setVisibility(View.GONE);
+ wifi.setVisibility(View.GONE);
+ menu_set.setVisibility(View.GONE);
+ custom_button.setVisibility(View.VISIBLE);
+ s_keyboard = true;
+ CustomButton(s_keyboard);
+ });
+
+ //判断屏幕大小
+ DisplayMetrics dm = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(dm);//display = getWindowManager().getDefaultDisplay();display.getMetrics(dm)(把屏幕尺寸信息赋值给DisplayMetrics dm);
+ if (dm.widthPixels > dm.heightPixels) {
+ SCREEN_WIDTH = dm.widthPixels/*- getNavigationHeight(PlayGameActivity.this)*/;
+ SCREEN_HEIGHT = dm.heightPixels;
+ } else {
+ SCREEN_WIDTH = dm.heightPixels/*- getNavigationHeight(PlayGameActivity.this)*/;
+ SCREEN_HEIGHT = dm.widthPixels;
+ }
+ Globe.landscapeScaleWidht = ((float) SCREEN_WIDTH / Globe.landscapeSW);
+ Globe.landscapeScaleHeight = ((float) SCREEN_HEIGHT / Globe.landscapeSH);
+
+ /*content.post(new Runnable() {
+ @Override
+ public void run() {
+
+ ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) gameLayout.getLayoutParams();
+ lp.width = SCREEN_WIDTH;
+ lp.height = SCREEN_HEIGHT;
+ gameLayout.setLayoutParams(lp);
+ }
+ });*/
+
+ //鼠标灵敏度
+ skDpi.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ tvDpi.setText(progress + "");
+ multiple = progress * 0.1 + 0.7;
+ Log.d(TAG, "onProgressChanged: multiple==" + multiple);
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+
+ }
+ });
+
+ //滑屏灵敏度
+ skDpi2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ tvDpi2.setText(progress + "");
+ switch (progress) {
+ case 1:
+ multiple2 = 0.55f;
+ break;
+ case 2:
+ multiple2 = 0.6f;
+ break;
+ case 3:
+ multiple2 = 0.65f;
+ break;
+ case 4:
+ multiple2 = 0.7f;
+ break;
+ case 5:
+ multiple2 = 0.75f;
+ break;
+ case 6:
+ multiple2 = 0.8f;
+ break;
+ case 7:
+ multiple2 = 0.85f;
+ break;
+ case 8:
+ multiple2 = 0.9f;
+ break;
+ case 9:
+ multiple2 = 0.95f;
+ break;
+ case 10:
+ multiple2 = 1;
+ break;
+ }
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+
+ }
+ });
+
+
+ proportion1.setOnClickListener(v -> {
+ proportion1.setBackgroundResource(R.drawable.shape_blue_bg);
+ proportion2.setBackgroundResource(R.drawable.bg_border_performance);
+
+ gameLayout.post(new Runnable() {
+ @Override
+ public void run() {
+ //0.5625 1080/1920
+ //横屏导致
+ if (WhaleCloud.getInstance().isLegcyView()) {
+ //乐谱图片控件调整大小
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoViewLegacy.getLayoutParams();
+ lp.width = ZOOM_WIDTH;
+ lp.height = ZOOM_HEIGHT;
+ mVideoViewLegacy.setLayoutParams(lp);
+ } else {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
+ lp.width = ZOOM_WIDTH;
+ lp.height = ZOOM_HEIGHT;
+ mVideoView.setLayoutParams(lp);
+ }
+ FrameLayout.LayoutParams clp = (FrameLayout.LayoutParams) NetworkCursor.getLayoutParams();
+ clp.width = ZOOM_WIDTH;
+ clp.height = ZOOM_HEIGHT;
+ NetworkCursor.setLayoutParams(clp);
+ ZOOM_W = ZOOM_WIDTH;
+ ZOOM_H = ZOOM_HEIGHT;
+ }
+ });
+ });
+ proportion2.setOnClickListener(v -> {
+ proportion2.setBackgroundResource(R.drawable.shape_blue_bg);
+ proportion1.setBackgroundResource(R.drawable.bg_border_performance);
+ gameLayout.post(() -> {
+ ZOOM_W = 0;
+ //0.5625 1080/1920
+ //横屏导致
+ if (WhaleCloud.getInstance().isLegcyView()) {
+ //乐谱图片控件调整大小
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoViewLegacy.getLayoutParams();
+ lp.width = SCREEN_WIDTH;
+ lp.height = SCREEN_HEIGHT;
+ mVideoViewLegacy.setLayoutParams(lp);
+ } else {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
+ lp.width = SCREEN_WIDTH;
+ lp.height = SCREEN_HEIGHT;
+ mVideoView.setLayoutParams(lp);
+ }
+
+ FrameLayout.LayoutParams clp = (FrameLayout.LayoutParams) NetworkCursor.getLayoutParams();
+ clp.width = SCREEN_WIDTH;
+ clp.height = SCREEN_HEIGHT;
+ NetworkCursor.setLayoutParams(clp);
+ ZOOM_W = SCREEN_WIDTH;
+ ZOOM_H = SCREEN_HEIGHT;
+
+ });
+ });
+
+// speed1.setOnClickListener(v -> {
+// setPictureQuality(6, speed1);
+// });
+// speed2.setOnClickListener(v -> {
+// setPictureQuality(7, speed2);
+// });
+// speed3.setOnClickListener(v -> {
+// setPictureQuality(8, speed3);
+// });
+// speed4.setOnClickListener(v -> {
+// setPictureQuality(9, speed4);
+// });
+// speed5.setOnClickListener(v -> {
+// setPictureQuality(10, speed5);
+// });
+ handle1.setOnClickListener(v -> {
+// if (IsGameInput) {
+ handle1.setEnabled(false);
+ handle1.setBackgroundResource(R.drawable.shape_blue_bg1);
+ imgKeySet.setBackgroundResource(R.drawable.shape_blue_bg2);
+ imgKeySet.setEnabled(true);
+ if (MNKeyboard != null) {
+ MNKeyboard.setVisibility(View.VISIBLE);
+ }
+ if (IsKeyBoard) {
+ NetworkKeyboard.setVisibility(View.GONE);
+ Ismode = 1;
+ handle2.setEnabled(true);
+ handle2.setBackgroundResource(R.drawable.bg_border_performance);
+ custom_button_yg.setVisibility(View.VISIBLE);
+ }
+
+// }
+ });
+ handle2.setOnClickListener(v -> {
+// if (IsKeyBoard) {
+ handle2.setEnabled(false);
+ handle2.setBackgroundResource(R.drawable.shape_blue_bg);
+ NetworkKeyboard.setVisibility(View.VISIBLE);
+ if (IsGameInput) {
+ handle1.setBackgroundResource(R.drawable.bg_border_performance3);
+ imgKeySet.setBackgroundResource(R.drawable.bg_border_performance4);
+ handle1.setEnabled(true);
+ imgKeySet.setEnabled(false);
+ Ismode = 2;
+ if (MNKeyboard != null) {
+ MNKeyboard.setVisibility(View.GONE);
+ }
+ custom_button_yg.setVisibility(View.GONE);
+ }
+
+// }
+ });
+ handle3.setOnClickListener(v -> {
+ if (shubiao_mode == 2) {
+ shubiao_mode = 1;
+ handle3.setEnabled(false);
+ handle3.setBackgroundResource(R.drawable.shape_blue_bg);
+ handle4.setEnabled(true);
+ handle4.setBackgroundResource(R.drawable.bg_border_performance);
+ }
+ });
+ handle4.setOnClickListener(v -> {
+ if (shubiao_mode == 1) {
+ shubiao_mode = 2;
+ handle4.setEnabled(false);
+ handle4.setBackgroundResource(R.drawable.shape_blue_bg);
+ handle3.setEnabled(true);
+ handle3.setBackgroundResource(R.drawable.bg_border_performance);
+ }
+ });
+
+ menu_set.setOnClickCallBackListener(new MyButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown() {
+ seting.setVisibility(View.VISIBLE);
+ if (keyboardUtil != null) {
+ textInput = keyboardUtil.isShow;
+ if (textInput) {
+ imgSwitchKeyboard.setImageResource(R.mipmap.switch_open);
+ } else {
+ imgSwitchKeyboard.setImageResource(R.mipmap.switch_close);
+ }
+ }
+ selectSet(0);
+
+ }
+
+ @Override
+ public void onActionMove(float x, float y) {
+
+ }
+ });
+
+ Move_show_hide.setOnClickCallBackListener(new MyButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown() {
+ Config.keyEvent_time = 0;
+ //显示隐藏键盘
+ if (Config.is_immersion) {
+ if (HandleCL != null) {
+ HandleCL.setVisibility(View.VISIBLE);
+ }
+ Move_show_hide.setBackgroundResource(R.mipmap.ic_key_hide);
+ imgSwitchKey.setImageResource(R.mipmap.switch_open);
+ } else {
+ if (HandleCL != null) {
+ HandleCL.setVisibility(View.GONE);
+ }
+ Move_show_hide.setBackgroundResource(R.mipmap.ic_key_show);
+ imgSwitchKey.setImageResource(R.mipmap.switch_close);
+ }
+ Config.is_immersion = !Config.is_immersion;
+ }
+
+ @Override
+ public void onActionMove(float x, float y) {
+
+ }
+ });
+
+ seting.setOnClickListener(v -> {
+ });
+ close_set.setOnClickListener(v -> {
+ hideBottomUIMenu();
+ seting.setVisibility(View.GONE);
+ });
+ menu.setOnClickListener(v -> {
+ });
+
+ if (WhaleCloud.getInstance().isLegcyView()) {
+ mVideoViewLegacy = findViewById(R.id.video_render_legacy);
+ mVideoViewLegacy.bringToFront();
+ } else {
+ mVideoView = findViewById(R.id.video_render);
+ mVideoView.jySetScaleType(JySurfaceView.ScaleType.ASPECT_FULL_SCREEN);
+ }
+ gameLayout.post(new Runnable() {
+ @Override
+ public void run() {
+ //0.5625 1080/1920
+ //横屏导致
+ ZOOM_WIDTH = SCREEN_WIDTH;//1440
+ ZOOM_HEIGHT = SCREEN_HEIGHT;
+ int ww = (int) (ZOOM_HEIGHT * 1.0 / 0.5625);
+ if (ZOOM_WIDTH > ww) {
+ ZOOM_WIDTH = ww;
+ } else {
+ proportion1.setEnabled(false);
+ proportion2.setEnabled(false);
+ proportion2.setBackgroundResource(R.drawable.bg_border_performance2);
+ }
+
+ if (WhaleCloud.getInstance().isLegcyView()) {
+ if (mVideoViewLegacy == null) {
+ mVideoViewLegacy = findViewById(R.id.video_render_legacy);
+ mVideoViewLegacy.bringToFront();
+ if (mVideoView != null) {
+ mVideoView.setVisibility(View.GONE);
+ }
+ }
+ //乐谱图片控件调整大小
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoViewLegacy.getLayoutParams();
+ lp.width = ZOOM_WIDTH;
+ lp.height = ZOOM_HEIGHT;
+ mVideoViewLegacy.bringToFront();
+ mVideoViewLegacy.setLayoutParams(lp);
+ mVideoViewLegacy.addOnLayoutChangeListener(OnVideoViewLayoutChange);
+ WhaleCloud.getInstance().initVideoViewLegacy(mVideoViewLegacy);
+ } else {
+ if (mVideoView == null) {
+ mVideoView = findViewById(R.id.video_render);
+ mVideoView.jySetScaleType(JySurfaceView.ScaleType.ASPECT_FULL_SCREEN);
+ if (mVideoViewLegacy != null) {
+ mVideoViewLegacy.setVisibility(View.GONE);
+ }
+ }
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
+ lp.width = ZOOM_WIDTH;
+ lp.height = ZOOM_HEIGHT;
+ mVideoView.jySetScaleType(mScalingType);
+ mVideoView.setLayoutParams(lp);
+ mVideoView.addOnLayoutChangeListener(OnVideoViewLayoutChange);
+ WhaleCloud.getInstance().initVideoView(mVideoView);
+
+ }
+ }
+ });
+ NetworkKeyboard.post(() -> {
+ FrameLayout.LayoutParams clp = (FrameLayout.LayoutParams) NetworkCursor.getLayoutParams();
+ clp.width = ZOOM_WIDTH;
+ clp.height = ZOOM_HEIGHT;
+ NetworkCursor.setLayoutParams(clp);
+ NetworkCursor.setOnTouchListener(touchListener);//按钮按中时滑屏
+ //NetworkKeyboard.setOnTouchListener(touchListener);//非按钮按中时滑屏
+ });
+
+ mImageCursor = findViewById(R.id.imageCursor);
+ initHandle();
+ initSetView();
+
+ }
+
+
+ //设置画质
+// private void setPictureQuality(int type, TextView textView) {
+// if (setCodeRate(type)) {
+// speed1.setBackgroundResource(R.drawable.bg_border_performance);
+// speed2.setBackgroundResource(R.drawable.bg_border_performance);
+// speed3.setBackgroundResource(R.drawable.bg_border_performance);
+// speed4.setBackgroundResource(R.drawable.bg_border_performance);
+// speed5.setBackgroundResource(R.drawable.bg_border_performance);
+//
+// textView.setBackgroundResource(R.drawable.shape_blue_bg);
+// }
+//
+// }
+
+ private void initSetView() {
+ seting_g1 = findViewById(R.id.seting_g1);
+ seting_g2 = findViewById(R.id.seting_g2);
+ seting_g3 = findViewById(R.id.seting_g3);
+ set_control = findViewById(R.id.set_control);
+ set_frame = findViewById(R.id.set_frame);
+ set_GamePad = findViewById(R.id.set_GamePad);
+ custom_button = findViewById(R.id.custom_button);
+ img_qr = findViewById(R.id.img_qr);
+
+ img_qr.setImageBitmap(qrCodeBitmap);
+
+ set_control.setOnClickListener(v -> {
+ selectSet(0);
+ });
+ set_frame.setOnClickListener(v -> {
+ selectSet(1);
+ });
+ set_GamePad.setOnClickListener(v -> {
+ selectSet(2);
+ });
+ custom_button_close.setOnClickListener(v -> {
+ custom_button.setVisibility(View.GONE);
+ menu_set.setVisibility(View.VISIBLE);
+ seting.setVisibility(View.VISIBLE);
+ s_keyboard = false;
+ CustomButton(s_keyboard);
+ });
+ custom_button_default.setOnClickListener(v -> {
+ initDefault();
+ initButtonPosition();
+ });
+
+ custom_button_yg.setOnClickListener(v -> {
+ if (custom_button_yg.getText().equals("右摇杆:开")) {
+ custom_button_yg.setText("右摇杆:关");
+ imgSwitchRightRocker.setImageResource(R.mipmap.switch_open);
+ yaogan_right.setVisibility(View.GONE);
+ btn_right_close = true;
+ } else {
+ custom_button_yg.setText("右摇杆:开");
+ imgSwitchRightRocker.setImageResource(R.mipmap.switch_close);
+ yaogan_right.setVisibility(View.VISIBLE);
+ btn_right_close = false;
+ }
+ });
+
+ }
+
+ //0控制 1画面
+ private void selectSet(int type) {
+
+ switch (type) {
+ case 0:
+ if (seting_g1 != null) {
+ seting_g1.setVisibility(View.GONE);
+ }
+ if (seting_g2 != null) {
+ seting_g2.setVisibility(View.VISIBLE);
+ }
+ if (seting_g3 != null) {
+ seting_g3.setVisibility(View.GONE);
+ }
+ if (set_control != null) {
+ set_control.setBackgroundResource(R.drawable.shape_set_item_bg);
+ }
+ if (set_frame != null) {
+ set_frame.setBackgroundResource(0);
+ }
+ if (set_GamePad != null) {
+ set_GamePad.setBackgroundResource(0);
+ }
+ break;
+
+ case 1:
+ if (seting_g1 != null) {
+ seting_g1.setVisibility(View.VISIBLE);
+ }
+ if (seting_g2 != null) {
+ seting_g2.setVisibility(View.GONE);
+ }
+ if (seting_g3 != null) {
+ seting_g3.setVisibility(View.GONE);
+ }
+ if (set_control != null) {
+ set_control.setBackgroundResource(0);
+ }
+ if (set_frame != null) {
+ set_frame.setBackgroundResource(R.drawable.shape_set_item_bg);
+ }
+ if (set_GamePad != null) {
+ set_GamePad.setBackgroundResource(0);
+ }
+ break;
+
+ case 2:
+ if (seting_g1 != null) {
+ seting_g1.setVisibility(View.GONE);
+ }
+ if (seting_g2 != null) {
+ seting_g2.setVisibility(View.GONE);
+ }
+ if (seting_g3 != null) {
+ seting_g3.setVisibility(View.VISIBLE);
+ }
+ if (set_control != null) {
+ set_control.setBackgroundResource(0);
+ }
+ if (set_frame != null) {
+ set_frame.setBackgroundResource(0);
+ }
+ if (set_GamePad != null) {
+ set_GamePad.setBackgroundResource(R.drawable.shape_set_item_bg);
+ }
+ break;
+ }
+ }
+
+
+ private View.OnLayoutChangeListener OnVideoViewLayoutChange = new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
+ LogUtil.i("onLayoutChange 游戏区域 videoView " + i + "," + i1 + "," + i2 + "," + i3);
+ setGameRect();
+ //WhaleCloud.getInstance().setGameRect(i, i1, i2, i3);
+ //setGameRect(i, i1, i2, i3);
+ }
+ };
+
+ private void setGameRect() {
+ int[] outLocation = {0, 0};
+ //gameLayout.getLocationInWindow(outLocation);
+ //LogUtil.i("onLayoutChange gameLayout 游戏区域 " + outLocation[0] + "," + outLocation[1] + "," + mVideoView.getLayoutParams().width + "," + mVideoView.getLayoutParams().height);
+ //LogUtil.i("onLayoutChange gameLayout 游戏区域: " + SCREEN_WIDTH + "," + SCREEN_HEIGHT);
+ if (WhaleCloud.getInstance().isLegcyView()) {
+ if (mVideoViewLegacy.getLayoutParams().width > 0 && mVideoViewLegacy.getLayoutParams().height > 0) {
+ WhaleCloud.getInstance().setGameRect(0, 0, mVideoViewLegacy.getLayoutParams().width, mVideoViewLegacy.getLayoutParams().height);
+ } else {// -1 = match_parent ,需要设置游戏区域
+ WhaleCloud.getInstance().setGameRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ }
+ } else {
+ if (mVideoView.getLayoutParams().width > 0 && mVideoView.getLayoutParams().height > 0) {
+ WhaleCloud.getInstance().setGameRect(0, 0, mVideoView.getLayoutParams().width, mVideoView.getLayoutParams().height);
+ } else {// -1 = match_parent ,需要设置游戏区域
+ WhaleCloud.getInstance().setGameRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ }
+ }
+ }
+
+ Map CustomButtonMap = new HashMap<>();
+ MoveButton yaogan_left, yaogan_right, direction_key, Move_a, Move_b, Move_x, Move_y, Move_rs, Move_rt, Move_rb,
+ Move_lt, Move_lb, Move_ls, Move_start, Move_back;
+
+ public void initDefault() {
+ try {
+ CustomButtonMap.put("yaogan_left", 106 * Globe.landscapeScaleWidht + "@" + 653.5 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("direction_key", 565 * Globe.landscapeScaleWidht + "@" + 730.0 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("yaogan_right", 1248 * Globe.landscapeScaleWidht + "@" + 770 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_a", 1645 * Globe.landscapeScaleWidht + "@" + 799 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_b", 1774 * Globe.landscapeScaleWidht + "@" + 680 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_x", 1521 * Globe.landscapeScaleWidht + "@" + 680 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_y", 1645 * Globe.landscapeScaleWidht + "@" + 562 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_rs", 1547 * Globe.landscapeScaleWidht + "@" + 300 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_rt", 1698 * Globe.landscapeScaleWidht + "@" + 343 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_rb", 1452 * Globe.landscapeScaleWidht + "@" + 453 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_ls", 134 * Globe.landscapeScaleWidht + "@" + 303 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_lt", 44 * Globe.landscapeScaleWidht + "@" + 480 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_lb", 261 * Globe.landscapeScaleWidht + "@" + 404 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_back", 1774 * Globe.landscapeScaleWidht + "@" + 30 * Globe.landscapeScaleHeight);
+ CustomButtonMap.put("Move_start", 1774 * Globe.landscapeScaleWidht + "@" + 149 * Globe.landscapeScaleHeight);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ //调用前必须先初始化按钮
+ public void initButtonPosition() {
+ try {
+ if (CustomButtonMap.get("yaogan_left") != null && !TextUtils.isEmpty(CustomButtonMap.get("yaogan_left").toString())) {
+ String[] split = CustomButtonMap.get("yaogan_left").toString().split("@");
+ yaogan_left.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("direction_key") != null && !TextUtils.isEmpty(CustomButtonMap.get("direction_key").toString())) {
+ String[] split = CustomButtonMap.get("direction_key").toString().split("@");
+ direction_key.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("yaogan_right") != null && !TextUtils.isEmpty(CustomButtonMap.get("yaogan_right").toString())) {
+ String[] split = CustomButtonMap.get("yaogan_right").toString().split("@");
+ yaogan_right.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_a") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_a").toString())) {
+ String[] split = CustomButtonMap.get("Move_a").toString().split("@");
+ Move_a.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_b") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_b").toString())) {
+ String[] split = CustomButtonMap.get("Move_b").toString().split("@");
+ Move_b.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_x") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_x").toString())) {
+ String[] split = CustomButtonMap.get("Move_x").toString().split("@");
+ Move_x.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_y") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_y").toString())) {
+ String[] split = CustomButtonMap.get("Move_y").toString().split("@");
+ Move_y.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_rs") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_rs").toString())) {
+ String[] split = CustomButtonMap.get("Move_rs").toString().split("@");
+ Move_rs.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_rt") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_rt").toString())) {
+ String[] split = CustomButtonMap.get("Move_rt").toString().split("@");
+ Move_rt.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_rb") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_rb").toString())) {
+ String[] split = CustomButtonMap.get("Move_rb").toString().split("@");
+ Move_rb.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_lt") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_lt").toString())) {
+ String[] split = CustomButtonMap.get("Move_lt").toString().split("@");
+ Move_lt.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_lb") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_lb").toString())) {
+ String[] split = CustomButtonMap.get("Move_lb").toString().split("@");
+ Move_lb.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_ls") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_ls").toString())) {
+ String[] split = CustomButtonMap.get("Move_ls").toString().split("@");
+ Move_ls.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_back") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_back").toString())) {
+ String[] split = CustomButtonMap.get("Move_back").toString().split("@");
+ Move_back.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ if (CustomButtonMap.get("Move_start") != null && !TextUtils.isEmpty(CustomButtonMap.get("Move_start").toString())) {
+ String[] split = CustomButtonMap.get("Move_start").toString().split("@");
+ Move_start.setPosition(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
+ }
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void initHandle() {
+
+ handleView = LayoutInflater.from(this).inflate(R.layout.layout_handle, null);
+ HandleCL = handleView.findViewById(R.id.HandleCL);
+
+ VisualAngle = handleView.findViewById(R.id.visual_angle);
+ VisualAngle.setOnTouchListener(new joystickTouchListener());//按钮按中时滑屏
+
+
+ String CustomButton = AppConfigFileImpl.getStringParams(getApplicationContext(), "CustomButton");
+ if (!TextUtils.isEmpty(CustomButton)) {
+ Log.d(TAG, "CustomButton " + CustomButton);
+ CustomButtonMap = GsonJsonUtil.stringToMap(CustomButton);
+ } else {
+ initDefault();//默认配置
+ }
+ yaogan_left = handleView.findViewById(R.id.yaogan_left);
+ yaogan_left.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "yaogan_left " + moveX + "@" + moveY);
+ CustomButtonMap.put("yaogan_left", moveX + "@" + moveY);
+ }
+
+ });
+ yaogan_right = handleView.findViewById(R.id.yaogan_right);
+ yaogan_right.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "yaogan_right " + moveX + "@" + moveY);
+ CustomButtonMap.put("yaogan_right", moveX + "@" + moveY);
+ }
+
+ });
+
+ direction_key = handleView.findViewById(R.id.direction_key);
+ direction_key.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "direction_key " + moveX + "@" + moveY);
+ CustomButtonMap.put("direction_key", moveX + "@" + moveY);
+ }
+
+ });
+
+ Move_a = handleView.findViewById(R.id.Move_a);
+ Move_a.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_a " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_a", moveX + "@" + moveY);
+ }
+
+
+ });
+ Move_b = handleView.findViewById(R.id.Move_b);
+ Move_b.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_b " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_b", moveX + "@" + moveY);
+ }
+
+
+ });
+ Move_x = handleView.findViewById(R.id.Move_x);
+ Move_x.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_x " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_x", moveX + "@" + moveY);
+ }
+
+
+ });
+ Move_y = handleView.findViewById(R.id.Move_y);
+ Move_y.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_y " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_y", moveX + "@" + moveY);
+ }
+
+
+ });
+ Move_rs = handleView.findViewById(R.id.Move_rs);
+ Move_rs.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_rs " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_rs", moveX + "@" + moveY);
+ }
+
+
+ });
+ Move_rt = handleView.findViewById(R.id.Move_rt);
+ Move_rt.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_rt " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_rt", moveX + "@" + moveY);
+ }
+ });
+ Move_rb = handleView.findViewById(R.id.Move_rb);
+ Move_rb.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_rb " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_rb", moveX + "@" + moveY);
+ }
+ });
+ Move_lt = handleView.findViewById(R.id.Move_lt);
+ Move_lt.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_lt " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_lt", moveX + "@" + moveY);
+ }
+ });
+ Move_lb = handleView.findViewById(R.id.Move_lb);
+ Move_lb.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_lb " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_lb", moveX + "@" + moveY);
+ }
+ });
+
+ Move_ls = handleView.findViewById(R.id.Move_ls);
+ Move_ls.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_ls " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_ls", moveX + "@" + moveY);
+ }
+ });
+
+ Move_start = handleView.findViewById(R.id.Move_start);
+ Move_start.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_start " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_start", moveX + "@" + moveY);
+ }
+ });
+ Move_back = handleView.findViewById(R.id.Move_back);
+ Move_back.setOnClickCallBackListener(new MoveButton.OnClickCallBackListener() {
+ @Override
+ public void onActionDown(MotionEvent event) {
+ }
+
+ @Override
+ public void onActionMove(float moveX, float moveY) {
+ Log.d(TAG, "Move_back " + moveX + "@" + moveY);
+ CustomButtonMap.put("Move_back", moveX + "@" + moveY);
+ }
+ });
+
+ initButtonPosition();
+
+ button_a = handleView.findViewById(R.id.button_a);
+ button_a.setOnTouchListener(new CustomOnTouchListener(tController.BTN_A, false));
+ button_b = handleView.findViewById(R.id.button_b);
+ button_b.setOnTouchListener(new CustomOnTouchListener(tController.BTN_B, false));
+ button_x = handleView.findViewById(R.id.button_x);
+ button_x.setOnTouchListener(new CustomOnTouchListener(tController.BTN_X, false));
+ button_y = handleView.findViewById(R.id.button_y);
+ button_y.setOnTouchListener(new CustomOnTouchListener(tController.BTN_Y, false));
+ dpad_up = handleView.findViewById(R.id.dpad_up);
+ dpad_up.setOnTouchListener(new CustomOnTouchListener(tController.BTN_UP, false));
+ dpad_down = handleView.findViewById(R.id.dpad_down);
+ dpad_down.setOnTouchListener(new CustomOnTouchListener(tController.BTN_DOWN, false));
+ dpad_left = handleView.findViewById(R.id.dpad_left);
+ dpad_left.setOnTouchListener(new CustomOnTouchListener(tController.BTN_LEFT, false));
+ dpad_right = handleView.findViewById(R.id.dpad_right);
+ dpad_right.setOnTouchListener(new CustomOnTouchListener(tController.BTN_RIGHT, false));
+ dpad_up_left = handleView.findViewById(R.id.dpad_up_left);
+ dpad_up_left.setOnTouchListener(new CustomOnTouchListener(tController.BTN_UP_LEFT, true) {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ dpad_up.onTouchEvent(event);
+ dpad_left.onTouchEvent(event);
+ return super.onTouch(v, event);
+ }
+ });
+ dpad_up_right = handleView.findViewById(R.id.dpad_up_right);
+ dpad_up_right.setOnTouchListener(new CustomOnTouchListener(tController.BTN_UP_RIGHT, true) {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ dpad_up.onTouchEvent(event);
+ dpad_right.onTouchEvent(event);
+ return super.onTouch(v, event);
+ }
+ });
+ dpad_down_left = handleView.findViewById(R.id.dpad_down_left);
+ dpad_down_left.setOnTouchListener(new CustomOnTouchListener(tController.BTN_DOWN_LEFT, true) {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ dpad_down.onTouchEvent(event);
+ dpad_left.onTouchEvent(event);
+ return super.onTouch(v, event);
+ }
+ });
+ dpad_down_right = handleView.findViewById(R.id.dpad_down_right);
+ dpad_down_right.setOnTouchListener(new CustomOnTouchListener(tController.BTN_DOWN_RIGHT, true) {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ dpad_down.onTouchEvent(event);
+ dpad_right.onTouchEvent(event);
+ return super.onTouch(v, event);
+ }
+ });
+ JoystickView2 joystickLeft = (JoystickView2) handleView.findViewById(R.id.joystick_left);
+ joystickLeft.setOnJoystickListener(new JoystickView2.OnJoystickListener() {
+ @Override
+ public void onPosition(float x, float y) {
+ Config.keyEvent_time = 0;
+ Log.w(TAG, "stick x=" + x + " y=" + y);
+ player1.setXY(x, y, true);
+ WhaleCloud.getInstance().sendGamepadStatus(player1);
+ //System.out.println("player1 setXY x="+x+"y="+y);
+ }
+
+ @Override
+ public void onVibrator() {
+ //joystickLeft.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ if (isShock) {
+ joystickLeft.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ }
+ }
+ });
+ JoystickView2 joystickRight = (JoystickView2) handleView.findViewById(R.id.joystick_right);
+ joystickRight.setOnJoystickListener(new JoystickView2.OnJoystickListener() {
+ @Override
+ public void onPosition(float x, float y) {
+ Config.keyEvent_time = 0;
+ //Log.d(TAG, "onPosition: ");
+// WhaleCloud.getInstance().virHandleJoystickRight(2000,x,y,false);
+ //Log.w(TAG,"stick " + x + "=" + y);
+ player1.setXY(x, y, false);
+ WhaleCloud.getInstance().sendGamepadStatus(player1);
+ }
+
+ @Override
+ public void onVibrator() {
+ if (isShock) {
+ joystickRight.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ }
+ }
+ });
+
+ start = handleView.findViewById(R.id.start);
+ start.setOnTouchListener(new CustomOnTouchListener(tController.BTN_START, false));
+ select = handleView.findViewById(R.id.select);
+ select.setOnClickListener(v -> {
+ Config.keyEvent_time = 0;
+ //显示隐藏键盘
+ if (Config.is_immersion) {
+ if (HandleCL != null) {
+ HandleCL.setVisibility(View.VISIBLE);
+ }
+ if (select != null) {
+ select.setBackgroundResource(R.mipmap.conceal);
+ }
+// if (menu_yincanganjian != null) {
+// menu_yincanganjian.setImageResource(R.mipmap.btn_yincanganjian);
+// }
+
+ } else {
+ if (HandleCL != null) {
+ HandleCL.setVisibility(View.GONE);
+ }
+ if (select != null) {
+ select.setBackgroundResource(R.mipmap.display);
+ }
+// if (menu_yincanganjian != null) {
+// menu_yincanganjian.setImageResource(R.mipmap.btn_anjianxinashi);
+// }
+ }
+ Config.is_immersion = !Config.is_immersion;
+ });
+ back = handleView.findViewById(R.id.back);
+ back.setOnTouchListener(new CustomOnTouchListener(tController.BTN_BACK, false));
+ lt = handleView.findViewById(R.id.lt);
+ lt.setOnTouchListener(new CustomOnTouchListener(tController.BTN_LT, false));
+ lb = handleView.findViewById(R.id.lb);
+ lb.setOnTouchListener(new CustomOnTouchListener(tController.BTN_LB, false));
+ rt = handleView.findViewById(R.id.rt);
+ rt.setOnTouchListener(new CustomOnTouchListener(tController.BTN_RT, false));
+ rb = handleView.findViewById(R.id.rb);
+ rb.setOnTouchListener(new CustomOnTouchListener(tController.BTN_RB, false));
+ ls = handleView.findViewById(R.id.ls);
+ ls.setOnTouchListener(new CustomOnTouchListener(tController.BTN_L3, false));
+ rs = handleView.findViewById(R.id.rs);
+ rs.setOnTouchListener(new CustomOnTouchListener(tController.BTN_R3, false));
+
+
+ button_a.setClickable(true);
+ button_b.setClickable(true);
+ button_x.setClickable(true);
+ button_y.setClickable(true);
+ start.setClickable(true);
+ back.setClickable(true);
+ dpad_up.setClickable(true);
+ dpad_left.setClickable(true);
+ dpad_right.setClickable(true);
+ dpad_down.setClickable(true);
+ rs.setClickable(true);
+ rt.setClickable(true);
+ rb.setClickable(true);
+ lt.setClickable(true);
+ lb.setClickable(true);
+ ls.setClickable(true);
+
+ }
+
+
+ //编辑按钮
+ public void CustomButton(boolean isCustom) {
+ if (isCustom) {
+ /*String CustomButton = AppConfigFileImpl.getStringParams(getApplicationContext(), "CustomButton");
+ if(!TextUtils.isEmpty(CustomButton)){
+ CustomButtonMap = GsonJsonUtil.stringToMap(CustomButton);
+ }*/
+ button_a.setClickable(false);
+ button_b.setClickable(false);
+ button_x.setClickable(false);
+ button_y.setClickable(false);
+ start.setClickable(false);
+ back.setClickable(false);
+ dpad_up.setClickable(false);
+ dpad_left.setClickable(false);
+ dpad_right.setClickable(false);
+ dpad_down.setClickable(false);
+ rs.setClickable(false);
+ rt.setClickable(false);
+ rb.setClickable(false);
+ lt.setClickable(false);
+ lb.setClickable(false);
+ ls.setClickable(false);
+ button_a.setBackgroundResource(R.mipmap.play_ls);
+ button_b.setBackgroundResource(R.mipmap.play_ls);
+ button_x.setBackgroundResource(R.mipmap.play_ls);
+ button_y.setBackgroundResource(R.mipmap.play_ls);
+ start.setBackgroundResource(R.mipmap.start);
+ back.setBackgroundResource(R.mipmap.back);
+ dpad_up.setBackgroundResource(0);
+ dpad_left.setBackgroundResource(0);
+ dpad_right.setBackgroundResource(0);
+ dpad_down.setBackgroundResource(0);
+ rs.setBackgroundResource(R.mipmap.play_ls);
+ rt.setBackgroundResource(R.mipmap.play_ls);
+ rb.setBackgroundResource(R.mipmap.play_ls);
+ lt.setBackgroundResource(R.mipmap.play_ls);
+ lb.setBackgroundResource(R.mipmap.play_ls);
+ ls.setBackgroundResource(R.mipmap.play_ls);
+ } else {
+ String json = GsonJsonUtil.stringToJsonString(CustomButtonMap);
+ Log.d(TAG, "yaogan_left " + json);
+ AppConfigFileImpl.saveParams(getApplicationContext(), "CustomButton", json);
+ button_a.setBackgroundResource(R.drawable.handle_button_ls);
+ button_b.setBackgroundResource(R.drawable.handle_button_ls);
+ button_x.setBackgroundResource(R.drawable.handle_button_ls);
+ button_y.setBackgroundResource(R.drawable.handle_button_ls);
+ start.setBackgroundResource(R.drawable.button_play_start);
+ back.setBackgroundResource(R.drawable.button_back);
+ dpad_up.setBackgroundResource(R.drawable.button_up);
+ dpad_left.setBackgroundResource(R.drawable.button_left);
+ dpad_right.setBackgroundResource(R.drawable.button_right);
+ dpad_down.setBackgroundResource(R.drawable.button_down);
+
+ rs.setBackgroundResource(R.drawable.handle_button_ls);
+ rt.setBackgroundResource(R.drawable.handle_button_ls);
+ rb.setBackgroundResource(R.drawable.handle_button_ls);
+ lt.setBackgroundResource(R.drawable.handle_button_ls);
+ lb.setBackgroundResource(R.drawable.handle_button_ls);
+ ls.setBackgroundResource(R.drawable.handle_button_ls);
+
+ button_a.setClickable(true);
+ button_b.setClickable(true);
+ button_x.setClickable(true);
+ button_y.setClickable(true);
+ start.setClickable(true);
+ back.setClickable(true);
+ dpad_up.setClickable(true);
+ dpad_left.setClickable(true);
+ dpad_right.setClickable(true);
+ dpad_down.setClickable(true);
+ rs.setClickable(true);
+ rt.setClickable(true);
+ rb.setClickable(true);
+ lt.setClickable(true);
+ lb.setClickable(true);
+ ls.setClickable(true);
+ }
+
+ }
+
+
+ private class CustomOnTouchListener implements View.OnTouchListener {
+ private boolean isConsume;
+ private short code;
+
+ public CustomOnTouchListener(short keyCode, boolean isConsume) {
+ this.code = keyCode;
+ this.isConsume = isConsume;
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (s_keyboard) {
+ return false;
+ }
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ if (code == tController.BTN_LT) {
+ player1.bLeftTrigger = (byte) 0xff;
+ } else if (code == tController.BTN_RT) {
+ player1.bRightTrigger = (byte) 0xff;
+ } else {
+ Log.w(TAG, "key down" + code);
+ player1.setButton(code, true);
+ }
+ WhaleCloud.getInstance().sendGamepadStatus(player1);
+
+ if (isShock) {
+ v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ }
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ if (code == tController.BTN_LT) {
+ player1.bLeftTrigger = (byte) 0x0;
+ } else if (code == tController.BTN_RT) {
+ player1.bRightTrigger = (byte) 0x0;
+ } else {
+ player1.setButton(code, false);
+ }
+ WhaleCloud.getInstance().sendGamepadStatus(player1);
+ }
+ return isConsume;
+ }
+ }
+
+ float moveJoystickX1, moveJoystickY1;
+
+ /**
+ * 视角滑动
+ * 鲸云摇杆接口测得:
+ * 1摇杆是以自设圆心的x,y为1到-1的坐标轴圆
+ * 2用x,y的坐标来描述视角移动的方向和速度
+ * (0,-1)为速度最快的正上 (0,-0,5)为速度中等的正上
+ * (0,1)为速度最快的正下 (0,0,5)为速度中等的正下
+ * (-1,0)为速度最快的正左 (-0.5,0)为速度中等的正左
+ * (1,0)为速度最快的正左 (0,5,0)为速度中等的正左
+ *
+ * x <= -0.5 && x < 0 a y <= -0.5 && y < 0 w (左上)
+ * x >= 0.5 && x > 0 d y <= -0.5 && y < 0 w (右上)
+ * x <= -0.5 && x < 0 a y >= 0.5 && y > 0 s (左下)
+ * x >= 0.5 && x > 0 d y >= 0.5 && y > 0 s (右下)
+ *
+ * 算法1
+ * 以0为圆点1为半径画圆,同时建立坐标系,
+ * 用圆点外的两个点连线,算出以圆点为起点的平行线,平行线与圆的交点为终点,圆点到终点的线为该方向上的所有点
+ * 通过圆点到终点的线上的点来确定方向
+ * 通过调整平行上的点来实现速度变换
+ *
+ * 由两点得出直线,当直线不与x轴和y轴垂直时,套用用直线公式,如果垂直,那就是固定方向上的移动
+ * a = y2-y1 b = x1-x2 c = x2*y1 - x1*y2
+ * ax + by + c = 0
+ *
+ * 由圆点(0,0)可以得出 c = 0
+ *
+ * 圆的标准方程为(x-a)的平方+(y-b)的平方=r的平方 (a,b)为圆心,r为半径
+ *
+ * 求圆上点的坐标需要已知的条件:圆心、半径、角度
+ * 已知a(x1,y1) b(x2,y2),则k=(y1-y2)/(x1-x2)
+ *
+ * 算法2
+ * 使用函数:1计算两个点的距离,2判断如果两个点的距离大于1的属于挪动视角,3对速度进行降频
+ */
+
+ //视角滑动
+ private class joystickTouchListener implements View.OnTouchListener {
+
+ public joystickTouchListener() {
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ Config.keyEvent_time = 0;
+ try {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+
+ downJoystickX = event.getX(0);
+ downJoystickY = event.getY(0);
+
+ //player1.setXY(x, y, false);
+ //WhaleCloud.getInstance().sendGamepadStatus(player1);
+ break;
+ case MotionEvent.ACTION_UP:
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ player1.setXY(0, 0, false);
+ WhaleCloud.getInstance().sendGamepadStatus(player1);
+ break;
+ case MotionEvent.ACTION_MOVE:
+
+ //计算两个点的距离
+ float tr = (float) RoundCalculator.calTwoPointDistant(downJoystickX, downJoystickY, event.getX(0), event.getY(0));
+
+ Log.d(TAG, "downJoystick " + tr);
+
+ //如果两个点的距离大于3
+ if (tr > 1) {
+ float dotCenterOnShow[] = RoundCalculator.calPointLocationByAngle(
+ downJoystickX, downJoystickY, event.getX(0), event.getY(0), 1);
+ moveJoystickX = dotCenterOnShow[0];
+ moveJoystickY = dotCenterOnShow[1];
+
+ float offsetX = moveJoystickX - downJoystickX;
+ float offsetY = moveJoystickY - downJoystickY;
+
+ float x = offsetX / 1;
+ float y = offsetY / 1;
+
+ if (x > 1.0F) {
+ x = 1.0F;
+ }
+
+ if (x < -1.0F) {
+ x = -1.0F;
+ }
+
+ if (y > 1.0F) {
+ y = 1.0F;
+ }
+
+ if (y < -1.0F) {
+ y = -1.0F;
+ }
+ if ((x == 0 && y == -1) || (x == 0 && y == 1) || (x == 1 && y == 0) || (x == -1 && y == 0)) {
+ //操过正常值过滤处理
+ } else {
+ Log.d(TAG, "downJoystick1 " + x + "=" + y);
+ player1.setXY((float) (x * multiple2), (float) (y * multiple2), false);
+ WhaleCloud.getInstance().sendGamepadStatus(player1);
+ }
+
+ downJoystickX = event.getX(0);
+ downJoystickY = event.getY(0);
+ } else {
+ player1.setXY(0, 0, false);
+ WhaleCloud.getInstance().sendGamepadStatus(player1);
+ }
+
+
+ break;
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+ }
+
+
+ public static int longPress = 0;//长按状态 0初始状态 1正常移动 2长按移动
+ Timer sameTimer = null;
+ TimerTask sameTimerTask = null;
+ public boolean doubleSameTime = true;
+ private long lastClickTime = 0;
+ private int point_num = 0;//当前触摸的点数
+
+
+ //鼠标滑动
+ View.OnTouchListener touchListener = new View.OnTouchListener() {
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ try {
+
+ Log.w("onTouch", "2" + v);
+
+ Config.keyEvent_time = 0;
+
+ if (event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER) {
+ float x = 0;
+ float y = 0;
+
+ if (shubiao_mode == 2) {
+ switch (event.getActionMasked()) {
+ case MotionEvent.ACTION_POINTER_DOWN:
+ point_num += 1;
+
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ if (doubleSameTime) {
+
+ if (sameTimer == null) {
+ sameTimer = new Timer();
+ sameTimerTask = new TimerTask() {
+ @Override
+ public void run() {
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ doubleSameTime = false;
+ if (point_num == 2) {
+ mouseEvent.set_leftButton(false);
+ mouseEvent.set_RightButton(true);
+ mouseEvent.set_ScrollButton(false);
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ System.out.println("LQQQQQ event.getAction() = 2同时按下");
+ } else if (point_num == 3) {
+ if (showKeyboard) {
+ showKeyboard = false;
+ runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard());
+ } else {
+ showKeyboard = true;
+ runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).showKeyboard());
+ }
+ System.out.println("LQQQQQ event.getAction() = 3同时按下");
+ }
+
+ }
+ };
+ sameTimer.schedule(sameTimerTask, 20, 100);
+ }
+
+ }
+
+ break;
+ case MotionEvent.ACTION_POINTER_UP:
+ point_num -= 1;
+ break;
+
+ case MotionEvent.ACTION_DOWN:
+ point_num = 1;
+ if (!showKeyboard) {
+ downX = event.getX(0) * (float) multiple;
+ downY = event.getY(0) * (float) multiple;
+ moveX = 0;
+ moveY = 0;
+ longPress = 0;
+ lastClickTime = System.currentTimeMillis();
+ doubleSameTime = true;
+ if (sameTimer == null) {
+ sameTimer = new Timer();
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ sameTimerTask = new TimerTask() {
+ @Override
+ public void run() {
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ doubleSameTime = false;
+ System.out.println("LQQQQQ event.getAction() = mouseEvent");
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }
+ };
+ sameTimer.schedule(sameTimerTask, 20, 100);
+ }
+ }
+
+
+ break;
+ case MotionEvent.ACTION_UP:
+ point_num = 0;
+ if (showKeyboard) {
+ showKeyboard = false;
+ runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard());
+ } else {
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+
+ float UPX = event.getX(0);
+ float UPY = event.getY(0);
+ if ((moveX == 0 && moveY == 0) || Math.abs(UPX - downX) < 10 && Math.abs(UPY - downY) < 10) {
+ if (longPress == 0) {
+ mouseEvent.set_leftButton(true);
+ mouseEvent.set_RightButton(false);
+ mouseEvent.set_ScrollButton(false);
+ System.out.println("LQQQQQ event.getAction() = 手指移动位置按下鼠标左键");
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }
+ }
+ new Handler().postDelayed(() -> {
+ //鼠标抬起
+ if (longPress != 1) {
+ mouseEvent.set_leftButton(false);
+ mouseEvent.set_RightButton(false);
+ mouseEvent.set_ScrollButton(false);
+ System.out.println("LQQQQQ event.getAction() = 手指移动位置离开鼠标左键");
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }
+ longPress = 0;
+ }, 10);
+
+ lastMouseX = mouseEventX;
+ lastMouseY = mouseEventY;
+
+ lastMoveX = 0;
+ lastMoveY = 0;
+
+ mouseEvent.x_rel = 0;
+ mouseEvent.y_rel = 0;
+ }
+
+
+ break;
+ case MotionEvent.ACTION_MOVE:
+ // DisplayMetrics dm = getResources().getDisplayMetrics();
+
+ if (!showKeyboard) {
+ moveX = event.getX(0) * (float) multiple;
+ moveY = event.getY(0) * (float) multiple;
+ float offsetX = moveX - downX;
+ float offsetY = moveY - downY;
+
+ if ((Math.abs(offsetX) > 10 || Math.abs(offsetY) > 10)) {
+ long time = System.currentTimeMillis();
+ long timeD = time - lastClickTime;
+ if (longPress == 0 && timeD < 500) {
+ longPress = 1;
+ } else if (longPress == 0 && timeD >= 500) {
+ longPress = 2;
+ //鼠标轻点发送鼠标左键
+ mouseEvent.set_leftButton(true);
+ mouseEvent.set_RightButton(false);
+ mouseEvent.set_ScrollButton(false);
+ System.out.println("LQQQQQ event.getAction() = 手指移动位置按下鼠标左键");
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }
+ }
+
+ float mouseX = offsetX + lastMouseX;
+ float mouseY = offsetY + lastMouseY;
+ mouseEventX = mouseX <= 0 ? 0 : mouseX >= SCREEN_WIDTH ? SCREEN_WIDTH : mouseX;
+ mouseEventY = mouseY <= 0 ? 0 : mouseY >= SCREEN_HEIGHT ? SCREEN_HEIGHT : mouseY;
+ if (lastMoveX != 0) {
+ mouseEvent.x_rel = moveX - lastMoveX;
+ mouseEvent.y_rel = moveY - lastMoveY;
+ } else {
+ mouseEvent.x_rel = 0;
+ mouseEvent.y_rel = 0;
+ }
+ mouseEvent.x = mouseEventX;
+ mouseEvent.y = mouseEventY;
+
+ lastMoveX = moveX;
+ lastMoveY = moveY;
+ updateCursorPosition(mouseEventX, mouseEventY);
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }
+ break;
+ }
+ } else {
+ if (event.getActionMasked() == MotionEvent.ACTION_UP) {
+ point_num = 0;
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ float UPX = event.getX(0);
+ float UPY = event.getY(0);
+ if (Math.abs(UPX - downX2) < 10 && Math.abs(UPY - downY2) < 10) {
+ if (longPress == 0) {
+ mouseEvent.set_leftButton(true);
+ mouseEvent.set_RightButton(false);
+ mouseEvent.set_ScrollButton(false);
+ System.out.println("LQQQQQ event.getAction() = 手指移动位置按下鼠标左键");
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }
+ }
+ new Handler().postDelayed(() -> {
+ //鼠标抬起
+ mouseEvent.set_leftButton(false);
+ mouseEvent.set_RightButton(false);
+ mouseEvent.set_ScrollButton(false);
+ System.out.println("LQQQQQ event.getAction() = 手指移动位置离开鼠标左键");
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }, 10);
+
+ lastMouseX = mouseEventX;
+ lastMouseY = mouseEventY;
+
+ lastMoveX = 0;
+ lastMoveY = 0;
+
+ mouseEvent.x_rel = 0;
+ mouseEvent.y_rel = 0;
+ } else if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ if (showKeyboard) {
+ showKeyboard = false;
+ runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard());
+ }
+
+ point_num = 1;
+
+ //Log.w(TAG,"onTouch: "+"mouse left key down");
+ float x1 = event.getX(0);// / Math.max(screen_width, 1);
+ float y1 = event.getY(0);//
+
+ //虚拟鼠标测试坐标偏移
+ if ((x1 - 0) < 0) {
+ x1 = 0;
+ } else {
+ x1 = x1 - 0;
+ }
+ if ((y1 - 0) < 0) {
+ y1 = 0;
+ } else {
+ y1 = y1 - 0;
+ }
+ mouseEvent.x = x1;
+ mouseEvent.y = y1;
+
+ lastMoveX2 = x1 - downX2;
+ lastMoveY2 = y1 - downY2;
+
+ if (lastMoveX2 != 0 || lastMoveY2 != 0) {
+ mouseEvent.x_rel = lastMoveX2;
+ mouseEvent.y_rel = lastMoveY2;
+ } else {
+ mouseEvent.x_rel = 0;
+ mouseEvent.y_rel = 0;
+ }
+ downX2 = x1;
+ downY2 = y1;
+ updateCursorPosition(downX2, downY2);
+ doubleSameTime = true;
+ if (sameTimer == null) {
+ sameTimer = new Timer();
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ sameTimerTask = new TimerTask() {
+ @Override
+ public void run() {
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ doubleSameTime = false;
+ System.out.println("LQQQQQ event.getAction() = sameTimer");
+ /* mouseEvent.set_leftButton(true);
+ mouseEvent.set_RightButton(false);
+ mouseEvent.set_ScrollButton(false);*/
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ }
+ };
+ sameTimer.schedule(sameTimerTask, 20, 100);
+ }
+ //WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ //System.out.println("LQQQQQ event.getAction() = 手指点击位置按下鼠标左键");
+ } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ float x1 = event.getX(0);// / Math.max(screen_width, 1);
+ float y1 = event.getY(0);// / Math.max(screen_height, 1);
+ //虚拟鼠标测试坐标偏移
+ if ((x1 - 0) < 0) {
+ x1 = 0;
+ } else {
+ x1 = x1 - 0;
+ }
+ if ((y1 - 0) < 0) {
+ y1 = 0;
+ } else {
+ y1 = y1 - 0;
+ }
+ // 虚拟鼠标测试坐标偏移 end
+ mouseEvent.x = x1;
+ mouseEvent.y = y1;
+ lastMoveX2 = x1 - downX2;
+ lastMoveY2 = y1 - downY2;
+
+ if (lastMoveX2 != 0 || lastMoveY2 != 0) {
+ mouseEvent.x_rel = lastMoveX2;
+ mouseEvent.y_rel = lastMoveY2;
+ } else {
+ mouseEvent.x_rel = 0;
+ mouseEvent.y_rel = 0;
+ }
+ downX2 = x1;
+ downY2 = y1;
+ updateCursorPosition(downX2, downY2);
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ //System.out.println("LQQQQQ event.getAction() = 手指移动位置");
+ } else if (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
+ point_num += 1;
+
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ if (doubleSameTime) {
+
+ if (sameTimer == null) {
+ sameTimer = new Timer();
+ sameTimerTask = new TimerTask() {
+ @Override
+ public void run() {
+ if (sameTimer != null) {
+ sameTimer.cancel();
+ sameTimer = null;
+ }
+ if (sameTimerTask != null) {
+ sameTimerTask.cancel();
+ sameTimerTask = null;
+ }
+ doubleSameTime = false;
+ if (point_num == 2) {
+ mouseEvent.set_leftButton(false);
+ mouseEvent.set_RightButton(true);
+ mouseEvent.set_ScrollButton(false);
+ WhaleCloud.getInstance().sendMouseStatus(mouseEvent);
+ System.out.println("LQQQQQ event.getAction() = 2同时按下");
+ } else if (point_num == 3) {
+ if (showKeyboard) {
+ showKeyboard = false;
+ runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).hideKeyboard());
+ } else {
+ showKeyboard = true;
+ runOnUiThread(() -> new KeyboardUtil(PlayGameActivity.this, PlayGameActivity.this).showKeyboard());
+ }
+ System.out.println("LQQQQQ event.getAction() = 3同时按下");
+ }
+
+ }
+ };
+ sameTimer.schedule(sameTimerTask, 20, 100);
+ }
+
+ }
+ } else if (event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) {
+ point_num -= 1;
+ }
+
+ }
+ }
+
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+ };
+
+
+ public void updateCursorPosition(float x, float y) {
+ final int dstx = mDstx = (int) x;
+ final int dsty = mDsty = (int) y;
+ if (NetworkKeyboard != null) {
+ runOnUiThread(() -> {
+ mImageCursor.setTranslationX(dstx);
+ mImageCursor.setTranslationY(dsty);
+ }
+ );
+ }
+ }
+
+ //鼠标
+ public void updateCursorIcon(byte[] iconData, byte x_offset, byte y_offset) {
+ try {
+ final Bitmap bmp = BitmapFactory.decodeByteArray(iconData, 0, iconData.length);
+ /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//安卓7 以上支持物理鼠标图标修改
+ runOnUiThread(() -> {
+ if (bmp != null) {
+ PointerIcon mNewPI = PointerIcon.create(bmp, (float) x_offset, (float) y_offset);
+ getWindow().getDecorView().setPointerIcon(mNewPI);
+ } else {
+ //没有接口可以隐藏鼠标,画个空图标
+ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.cursor_null, null);
+ PointerIcon mNewPI = PointerIcon.create(bitmap, (float) x_offset, (float) y_offset);
+ getWindow().getDecorView().setPointerIcon(mNewPI);
+ }
+ });
+ }else {*/
+ final int dstx = mDstx - x_offset;
+ final int dsty = mDsty - y_offset;
+
+ /*if (NetworkKeyboard != null) {
+ runOnUiThread(() -> {
+ mImageCursor.setTranslationX(dstx);
+ mImageCursor.setTranslationY(dsty);
+ }
+ );
+ }*/
+ /* }*/
+ runOnUiThread(() -> {
+ if (NetworkKeyboard != null) {
+ if (bmp != null) {
+ mImageCursor.setBackground(new BitmapDrawable(getResources(), bmp));
+ /* mImageCursor.setHeight(50);
+ mImageCursor.setWidth(50);*/
+ } else {
+ if (!IsGameMouse) {
+ mImageCursor.setBackgroundResource(R.drawable.cursor);
+ } else {
+ mImageCursor.setBackground(null);
+ }
+ }
+ //mImageCursor.setBackground(new BitmapDrawable(getResources(), bmp));
+ }
+ });
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ //run on UI thread
+ private void updateLayoutSize() {
+ if (WhaleCloud.getInstance().isLegcyView()) {
+ if (orientation_now != orientation_last) {
+ LogUtil.i("updateLayoutSize SCREEN_WIDTH: " + orientation_last + "-->" + orientation_now);
+ orientation_last = orientation_now;
+ if (orientation_now == Configuration.ORIENTATION_PORTRAIT) {
+ /* gameLayout.getLayoutParams().height = SCREEN_WIDTH / 3;
+ gameLayout.getLayoutParams().width = gameLayout.getLayoutParams().height * mFrameWidth / mFrameHeight;*/
+ LogUtil.i("updateLayoutSize gameLayout : " + mVideoViewLegacy.getLayoutParams().width + " x " + mVideoViewLegacy.getLayoutParams().height);
+
+ } else {
+ /*gameLayout.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
+ gameLayout.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;*/
+ LogUtil.i("updateLayoutSize gameLayout : " + mVideoViewLegacy.getLayoutParams().width + " x " + mVideoViewLegacy.getLayoutParams().height);
+
+ }
+ }
+ } else {
+ if (orientation_now != orientation_last) {
+ LogUtil.i("updateLayoutSize orientation: " + orientation_last + "-->" + orientation_now);
+ orientation_last = orientation_now;
+ if (orientation_now == Configuration.ORIENTATION_PORTRAIT) {
+
+ LogUtil.i("ORIENTATION_PORTRAIT updateLayoutSize gameLayout: " + gameLayout.getLayoutParams().width + " x " + gameLayout.getLayoutParams().height);
+ } else {
+
+ LogUtil.i("ORIENTATION_LAND updateLayoutSize gameLayout: " + gameLayout.getLayoutParams().width + " x " + gameLayout.getLayoutParams().height);
+
+ }
+ }
+ }
+ // 横屏添加手柄或鼠标
+ try {
+ if (Config.controllMode.equals("0")) {
+ //gameLayout.addView(handleView);
+ } else if (Config.controllMode.equals("1")) {
+ //gameLayout.addView(cursorLayout);
+ } else {
+ //gameLayout.addView(touchLayout);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ //更新游戏区域坐标
+ }
+
+ private String gameConfig = "";
+
+// private void startGame(JyConfig.START_GAME_MODE startGameMode) {
+//// GameLoading();
+// getGameSetting();
+//
+// try {
+// switch (startGameMode) {
+// case GAME_MODE_NORMAL:
+// WhaleCloud.getInstance().start(gameData, mListener);
+// //setGameRect();
+// break;
+// case GAME_MODE_RECONNECT:
+// WhaleCloud.getInstance().reconPlayGame(gameData, mListener);
+// //setGameRect();
+// break;
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// finish();
+// }
+// }
+
+ private void startGame() {
+ getGameSetting();//获取游戏设置
+ if (isReconPlay.equals("false")) {
+ //正常启动
+ WhaleCloud.getInstance().start(gameData, mListener);
+ } else {
+ //断线重连
+ WhaleCloud.getInstance().reconPlayGame(gameData, mListener);
+ }
+
+
+// OpenApiRequest.playGame(this, Config.gamePara, new OnApiRequestListener() {
+// @Override
+// public void onResponse(String body, int code, String httpmsg) {
+// Log.w(TAG, "playGame body: " + body);
+// Log.w(TAG, "playGame code: " + code);
+// Log.w(TAG, "playGame msg: " + httpmsg);
+// if (code == 200) {
+// Gson gs = new Gson();
+// playGameEntityResp result;
+//
+// try {
+// result = gs.fromJson(body, playGameEntityResp.class);
+// int status = result.status;
+// Log.w(TAG, "result.data.getAsString()" + result.data.toString());
+// if (status == 200) {
+// Config.sc_id = result.getSc_id();
+// Config.gamePara.sc_id = String.valueOf(Config.sc_id);
+// bGameStart = true;
+// if (queTimerTask != null) {
+// queTimerTask.cancel();
+// }
+//
+//// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(CustomGameActivity.this);
+//// int tmpInt = sp.getInt(SP_DECODE_TYPE, -1);
+//// int mouseModel = sp.getInt(SP_MOUSE_MODULE, MOUSE_MODEL_ABSOLUTE);
+//// WhaleCloud.getInstance().setDecodeType(2);
+//// WhaleCloud.getInstance().setMouseModel(mImageCursor, mouseModel);
+//// WhaleCloud.getInstance().setMouseModel(mouseModel);
+// WhaleCloud.getInstance().start(result.data.toString(), mListener);
+//
+//// if (WhaleCloud.getInstance().isLegcyView()) {
+//// setGameRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+//// }
+// } else if (status == 201) {
+//
+//// if (queTimer != null) {
+//// queTimer.cancel();
+//// }
+//// queTimer = new Timer();
+//// queTimer.schedule(queTimerTask, 10 * 1000, 10 * 1000);
+//
+// try {
+// JSONObject jsonObject = new JSONObject(body);
+// status = jsonObject.getInt("status");
+// String msg = jsonObject.getString("msg");
+// JSONObject data = jsonObject.getJSONObject("data");
+// Config.play_queue_id = data.getInt("play_queue_id");
+// Config.queue_pos = data.getInt("queue_pos");
+// } catch (JSONException e) {
+// showUItoast("开始游戏接口解析出错: " + body);
+// LogUtil.e("开始游戏接口解析出错: " + body);
+// }
+// final String toastMsg = "排队中,排队ID:" + Config.play_queue_id + " 排队位置:" + Config.queue_pos;
+// showUItoast(toastMsg);
+//
+// } else {
+// final String toastMsg = "游戏申请失败:" + status + "|" + result.msg;
+// Log.w(TAG, toastMsg);
+// runOnUiThread(new Runnable() {
+// @Override
+// public void run() {
+// showToast(toastMsg);
+// finish();
+//// createDialog(DIALOG_QUIT_OK, toastMsg);
+// }
+// });
+// }
+// } catch (JsonSyntaxException e) {
+// Log.w(TAG, "OpenApiRequest.playGame json 解析错误");
+// return;
+// }
+// } else {
+// final String toastMsg = "启动游戏失败!|" + code + "|" + httpmsg;
+// runOnUiThread(new Runnable() {
+// @Override
+// public void run() {
+// showToast(toastMsg);
+// }
+// });
+// }
+// }
+//
+// @Override
+// public void onFailure(Exception err) {
+// showUItoast(err.getMessage());
+// finish();
+// }
+// });
+
+ }
+
+ String s_FloatingIcon = "";
+ int loadingTime = 0;
+
+ private void GameLoading() {
+ //String dataInfo = new NetHander().getGameLoadingImage(Config.gamePara.my_GameId);
+// netHander.getGameLoadingImage(Config.gamePara.my_GameId, new DataResponseCallback() {
+// @Override
+// public void onResponseSuccess(ResponseDao response) {
+// try {
+// if (!PlayGameActivity.this.isFinishing()) {
+// JSONObject jo1 = new JSONObject(response.getData().toString());
+// JSONObject jo2 = new JSONObject(jo1.getString("LoadBgImage"));
+// JSONObject jo3 = new JSONObject(jo1.getString("IconImage"));
+// s_FloatingIcon = jo2.getString("Url");
+// GlideImageLoader.display(PlayGameActivity.this, loading, s_FloatingIcon);
+// loadingTime = jo1.getInt("GameLoadTime") + 2;
+//
+// valueAnimator = ValueAnimator.ofInt(0, 100).setDuration(loadingTime * 1000);
+// valueAnimator.addUpdateListener(animator -> {
+// final int value = (int) animator.getAnimatedValue();
+//
+// fadenum.setText(value + "");
+// progressbar1.setProgress(value);
+// if (value == 100) {
+// showUItoast("提示:长时间无操作,将会退出游戏。");
+// loadingCL.setVisibility(View.GONE);
+// }
+// });
+// valueAnimator.start();
+// }
+// } catch (JSONException e) {
+// e.printStackTrace();
+// }
+//
+// }
+//
+// @Override
+// public void onResponseFail(String errorString) {
+//
+// }
+// });
+
+
+ //gameConfig = new NetHander().getGameConfig();
+ }
+
+ public void getGameSetting() {
+ //有虚拟键盘
+ if (IsKeyBoard) {
+ //请求虚拟键盘
+ //JSONArray keyboardList = new JSONArray(netHander.getGameVirKeyboard(PlayGameActivity.this));
+// netHander.getGameVirKeyboard(new DataResponseCallback() {
+// @Override
+// public void onResponseSuccess(ResponseDao response) {
+// if (response.getCode() == 0 && response.getResult() == 0) {
+// //JSONObject jo1 = null;
+// VirtualKey(response.getData().toString());
+// }
+// }
+//
+// @Override
+// public void onResponseFail(String errorString) {
+//
+// }
+// });
+ mImageCursor.setVisibility(View.VISIBLE);
+ mImageCursor.setFocusableInTouchMode(false);
+
+ handle3.setTextColor(getResources().getColor(R.color.white));
+// handle3.setBackgroundColor(getResources().getColor(R.color.handle2_gb));
+// handle4.setTextColor(getResources().getColor(R.color.colorAccent1));
+// handle4.setBackgroundColor(getResources().getColor(R.color.handle1_gb));
+
+ if (IsGameInput) {
+ MNKeyboard.addView(handleView);
+ NetworkKeyboard.setVisibility(View.GONE);
+ Ismode = 1;
+// handle1.setBackgroundColor(getResources().getColor(R.color.handle1_gb));
+// handle2.setBackgroundColor(getResources().getColor(R.color.handle2_gb));
+ handle2.setTextColor(Color.parseColor("#FFFFFF"));
+ custom_button_yg.setVisibility(View.VISIBLE);
+ } else {
+ handle1.setEnabled(false);
+// handle1.setBackgroundColor(getResources().getColor(R.color.handle2_gb));
+ handle1.setTextColor(Color.parseColor("#33FFFFFF"));
+
+ MNKeyboard.setVisibility(View.GONE);
+ NetworkKeyboard.setVisibility(View.VISIBLE);
+ Ismode = 2;
+// handle2.setBackgroundColor(getResources().getColor(R.color.handle1_gb));
+ handle2.setTextColor(Color.parseColor("#FFFFFF"));
+ custom_button_yg.setVisibility(View.GONE);
+ }
+
+ }
+
+// netHander.getGameSetting(new DataResponseCallback() {
+// @Override
+// public void onResponseSuccess(ResponseDao response) {
+// Log.i(TAG, "onResponseSuccess: getGameSetting" + response.getData().toString());
+// try {
+// if (response.getCode() == 0 && response.getResult() == 0) {
+//
+// JSONObject totalJo = new JSONObject(response.getData().toString());
+// IsGameMouse = totalJo.getBoolean("IsGameMouse");
+// IsGameInput = totalJo.getBoolean("IsGameInput");
+// IsKeyBoard = totalJo.getBoolean("IsKeyBoard");
+// //IsKeyBoard = IsGameInput = true;
+// if (IsGameInput == true && IsKeyBoard == false) {
+// virtual_mode = 1;
+// } else if (IsGameInput == false && IsKeyBoard == true) {
+// virtual_mode = 3;
+// }
+// JSONObject keyBtnConfigJo = new JSONObject();//默认虚拟手柄按键配置
+// keyBtnConfigJo.put("btn_right_close", btn_right_close);
+// keyBtnConfigJo.put("virtual_mode", virtual_mode);
+// //writeKeyBtnConfig(keyBtnConfigJo.toString());
+//
+// boolean IsGuideShow = totalJo.getBoolean("IsGuideShow");
+// if (IsGuideShow) {
+// String IsGuide = AppConfigFileImpl.getStringParams(getApplicationContext(), "IsGuide");
+// if (IsGuide.isEmpty()) {
+// runOnUiThread(() -> TipsDialog(new IDialogTwoView() {
+// @Override
+// public void cancel() {
+// hideBottomUIMenu();
+// }
+//
+// @Override
+// public void onSure() {
+// AppConfigFileImpl.saveParams(getApplicationContext(), "IsGuide", "1");
+// }
+//
+// @Override
+// public void returnApp() {
+// returnAppMain();
+// }
+// }));
+// }
+// }
+//
+// //有虚拟键盘
+// if (IsKeyBoard) {
+// //请求虚拟键盘
+// //JSONArray keyboardList = new JSONArray(netHander.getGameVirKeyboard(PlayGameActivity.this));
+// netHander.getGameVirKeyboard(new DataResponseCallback() {
+// @Override
+// public void onResponseSuccess(ResponseDao response) {
+// if (response.getCode() == 0 && response.getResult() == 0) {
+// //JSONObject jo1 = null;
+// VirtualKey(response.getData().toString());
+// }
+// }
+//
+// @Override
+// public void onResponseFail(String errorString) {
+//
+// }
+// });
+// mImageCursor.setVisibility(View.VISIBLE);
+// mImageCursor.setFocusableInTouchMode(false);
+//
+// handle3.setTextColor(Color.parseColor("#FFFFFF"));
+// handle4.setTextColor(Color.parseColor("#FFFFFF"));
+// handle3.setBackgroundResource(R.drawable.bg_border_performance);
+// handle4.setBackgroundResource(R.drawable.shape_blue_bg);
+//
+// if (IsGameInput) {
+// MNKeyboard.addView(handleView);
+// NetworkKeyboard.setVisibility(View.GONE);
+// Ismode = 1;
+// handle1.setBackgroundResource(R.drawable.shape_blue_bg1);
+// imgKeySet.setBackgroundResource(R.drawable.shape_blue_bg2);
+// handle2.setBackgroundResource(R.drawable.bg_border_performance);
+// handle2.setTextColor(Color.parseColor("#FFFFFF"));
+// custom_button_yg.setVisibility(View.VISIBLE);
+// } else {
+// handle1.setEnabled(false);
+// handle1.setBackgroundResource(R.drawable.bg_border_performance2);
+// handle1.setTextColor(Color.parseColor("#33FFFFFF"));
+//
+// MNKeyboard.setVisibility(View.GONE);
+// NetworkKeyboard.setVisibility(View.VISIBLE);
+// Ismode = 2;
+// handle2.setBackgroundResource(R.drawable.shape_blue_bg);
+// handle2.setTextColor(Color.parseColor("#FFFFFF"));
+// custom_button_yg.setVisibility(View.GONE);
+// }
+//
+// } else {
+// //没有虚拟键盘,直接加载默认手柄
+// MNKeyboard.addView(handleView);
+// NetworkKeyboard.setVisibility(View.GONE);
+//
+// Ismode = 1;
+// handle1.setBackgroundResource(R.drawable.shape_blue_bg1);
+// imgKeySet.setBackgroundResource(R.drawable.shape_blue_bg2);
+//// handle2.setBackgroundResource(R.drawable.bg_border_performance2);
+//// handle2.setTextColor(Color.parseColor("#33FFFFFF"));
+// handle3.setEnabled(false);
+// handle4.setEnabled(false);
+// }
+//
+// } else {
+// showUItoast(response.getDescription().toString());
+// }
+// } catch (JSONException e) {
+// e.printStackTrace();
+// }
+// }
+//
+// @Override
+// public void onResponseFail(String errorString) {
+// Log.i(TAG, "onResponseFail: getGameSetting" + errorString);
+// }
+// });
+
+ }
+
+
+ /**
+ * 游戏监听
+ */
+ JyGameStatusListener mListener = new JyGameStatusListener() {
+ @Override
+ public void onGameFeedBack(@NonNull JyFeedBackEvent event) {
+ if (event.eventID == JyFeedBackEvent.EVENT_CURSOR_UPDATE) {
+ updateCursorIcon(event.cursorIcon, event.x_offset, event.y_offset);
+ } else if (event.eventID == JyFeedBackEvent.EVENT_POSITION_UPDATE) {
+ //updateCursorPosition(event.position_x, event.position_y);
+ } else if (event.eventID == JyFeedBackEvent.EVENT_INPUT) {//输入提示
+ //LogUtil.d("EVENT_INPUT:");
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ showKeyboard = true;
+ new KeyboardUtil(PlayGameActivity.this, App.getInstance().getApplicationContext()).showKeyboard();
+ }
+ });
+
+ }
+ }
+
+ @Override
+ public void onForwardMsgFromGs(String s) {
+
+ }
+
+
+ @Override
+ public void onGameStarting() {
+ Log.i(TAG, "onGameStarting: ");
+ }
+
+ @Override
+ public void onGameBegin() {
+ Log.i(TAG, "onGameBegin: ");
+ }
+
+
+ @Override
+ public void onGameStop() {
+ //游戏结束
+ Log.i(TAG, "onGameStop: 游戏结束");
+ if (ActivityCollector.activities != null && ActivityCollector.activities.size() > 0) {
+ ActivityCollector.removeActivity(PlayGameActivity.this);
+ }
+
+ HashMap