Skip to content

Commit

Permalink
添加imgui菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
StArrayJaN committed Oct 16, 2023
1 parent 8451264 commit 230d4f5
Show file tree
Hide file tree
Showing 59 changed files with 105,645 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.gradle
/local.properties
/push.sh
/app/src/main/obj
4 changes: 4 additions & 0 deletions .gitignore.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/app/build
/.gradle
/local.properties
/push.sh
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ repositories {
}
}
dependencies {
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'

implementation fileTree(dir: "libs", include: ["1.18.8.jar"])
implementation fileTree(dir: "libs", include: ["内购.jar"])
Expand Down
Binary file added app/libs/arm64-v8a/libmui.so
Binary file not shown.
50 changes: 5 additions & 45 deletions app/src/main/java/com/disney/WMW/WMWActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.disney.common.Constants.shareTarget;
import com.disney.common.WMWView;
import com.disney.config.GlobalPurchaseHandler;
import com.game.ui.Launcher;
import java.io.File;
import java.util.Locale;
import java.util.UUID;
Expand Down Expand Up @@ -59,10 +60,6 @@ public class WMWActivity extends BaseActivity {
public boolean resumeOnFocus;
private Runnable runInitIap;

static {
System.loadLibrary("fmodex");
}

public WMWActivity() {
this.isRunning = false;
this.hasFocus = false;
Expand Down Expand Up @@ -90,28 +87,6 @@ public void handleMessage(Message paramMessage) {
}

class FinishActivityArgs {}

@Override
public void onBackPressed() {
Log.e("WMW","返回被按下");
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("")
.setMessage(getString(R.string.exit_str))
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dia, int which) {
System.exit(0);
}
})
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.show();
super.onBackPressed();
}




static /* synthetic */ void access$100(WMWActivity wMWActivity) {
wMWActivity.initIap();
Expand Down Expand Up @@ -341,18 +316,10 @@ public void onCreate(Bundle var1) {
editor.putString("installationId", this.installationId);
editor.commit();
}

this.requestWindowFeature(1);
this.getWindow().setFlags(1024, 1024);
this.setDataFromManifest();
if (SAMSUNG_DRM_ENABLED) {
Log.d("WMWActivity", "Samsung DRM build. Checking license");
this.getGlobalIapHandler().requestIAPAvailability();
} else {
Log.d("WMWActivity", "Not a Samsung DRM build. Calling switchToGameView()");
this.switchToGameView();
}

this.switchToGameView();
this.getGlobalIapHandler();
}

Expand Down Expand Up @@ -616,15 +583,8 @@ public void switchToGameView() {
RelativeLayout relativelayout = new RelativeLayout(this);
relativelayout.addView(this._view);
this.setContentView(relativelayout, new LayoutParams(-1, -1));
byte b0;
if (APP_INFO.toLowerCase().contains("google")) {
b0 = 1;
} else if (APP_INFO.toLowerCase().contains("amazon")) {
b0 = 2;
} else {
b0 = 0;
}

this.mSKU = b0;

Launcher.Init(this);
this.mSKU = 1;
}
}
131 changes: 131 additions & 0 deletions app/src/main/java/com/game/ui/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package com.game.ui;

import android.app.Activity;
import android.app.Application;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.game.ui.Utils.CrashHandler;
import com.game.ui.Utils.utils;
import com.game.ui.Views.MyLayout;
import com.game.ui.Views.mySurfaceView;

public class App extends Application implements Application.ActivityLifecycleCallbacks {
private static App sApp;
public static boolean IsRun = false;
//private static Context context;

public static Activity GameContext;//游戏Activity上下文
// private String PackageName="SGameRealActivity";
private String PackageName="MainActivity";//调试菜单用 写对应的游戏Activity,或者编译后改也行
public static App GetApp(){
return sApp;
}

private static mySurfaceView surfaceView;//显示菜单的view
private static MyLayout myLayout;//容器view
private static View gameview;//游戏原本的view


@Override
public void onCreate() {
super.onCreate();
sApp = this;
//注册Activity监控
this.registerActivityLifecycleCallbacks(this);
//错误处理
CrashHandler.init(this);
//so加载 顺便把包路径传过去
GLES3JNILib.setFilePath(getFilesDir().getAbsolutePath());
}


@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
//当Activity第一次被运行时调用此方法,可用于加载布局视图,获取控件命名空间等一些初始化工作


}

@Override
public void onActivityStarted(@NonNull Activity activity) {
//表示Activity正在被启动,已经从不可见到可见状态(不是指用户可见,指Activity在后台运行,没有出现在前台),但还是无法与用户进行交互。
if (activity.getClass().getSimpleName().equals(PackageName)){

}

}

@Override
public void onActivityResumed(@NonNull Activity activity) {
//表示Activity已经变为可见状态了,并且出现在前台工作了,也就是指用户可见了
//判断Activity名字 显示
if (activity.getClass().getSimpleName().equals(PackageName)){
GameContext=activity;
//Toast.makeText(activity,"开始运行"+activity.getClass().getSimpleName(),Toast.LENGTH_LONG).show();
if (surfaceView==null) {
//surface初始化
surfaceView = new mySurfaceView(GameContext);
surfaceView.setZOrderOnTop(true);//置顶
//surfaceView.setZOrderMediaOverlay(true);
surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

//容器初始化
if (myLayout==null){
myLayout = new MyLayout(GameContext);
LinearLayout.LayoutParams relLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
myLayout.setLayoutParams(relLayoutParams);
gameview=utils.getContentView(activity);//获取游戏原来的view组
utils.getContentViewGrout(activity).removeAllViews();//清除原来activity的所有view
myLayout.addView(gameview);//然后在容器里面添加原来的view
myLayout.addView(surfaceView);//添加附加层view
}else {
return;
}




activity.setContentView(myLayout);//把容器设置成activity的默认布局

}
IsRun=true;


}
}

@Override
public void onActivityPaused(@NonNull Activity activity) {
//表示Activity正在暂停,但Activity依然可见,可以执行一些轻量级操作,但一般不会进行太多操作,因为这样会影响用户体验。
}

@Override
public void onActivityStopped(@NonNull Activity activity) {
//表示Activity已经暂停,
IsRun=false;
}

@Override
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {

}

@Override
public void onActivityDestroyed(@NonNull Activity activity) {
//表示活动即将被销毁。
//判断Activity名字 销毁
if (activity.getClass().getSimpleName().equals(PackageName)){
surfaceView=null;
gameview=null;
myLayout=null;
GameContext=null;
}
}
}
53 changes: 53 additions & 0 deletions app/src/main/java/com/game/ui/GLES3JNILib.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.game.ui;

import android.view.InputEvent;
import android.view.Surface;

public class GLES3JNILib {

static {
System.loadLibrary("mui");
//System.loadLibrary("imgui");
}


public static native void setFilePath(String ph);

//public static native void setSDdir(String ph);

public static native void surfaceDestroyed();

public static native void surfaceChange(int width, int high);

public static native void surfaceCreate(Surface surface, int width, int high);

//public static native CallData[] GetImguiwinsize();
// public static native float[] GetImguiwinsize(float x,float y);
//public static native void MotionEventClick(int Event_getAction, float PosX, float PosY);
public static native boolean MotionEventClick(int Event_getAction, float PosX, float PosY);

public static native void inputcharOnJNI(String msg);

public static native void sendKeyEvent_JNI(int action, int code);

public static native void finishComposingText_JNI();

//public static native void setmOrientation(int orientation);
// public static native Boolean sendKeyEvent(InputEvent inputEvent);

public static native int Select_all();

public static native String Cut();

public static native void Paste(String data);

public static native String Copy();

public static native void sendDelKey(int code);

//public static native void ActivityState(boolean state);


// public static native void StrTest(String s);

}
52 changes: 52 additions & 0 deletions app/src/main/java/com/game/ui/Launcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.game.ui;

import android.app.Activity;
import android.graphics.PixelFormat;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.game.ui.Utils.utils;
import com.game.ui.Views.MyLayout;
import com.game.ui.Views.mySurfaceView;

public class Launcher {
public static Activity GameContext;//游戏Activity上下文


private static mySurfaceView surfaceView;//显示菜单的view
private static MyLayout myLayout;//容器view
private static View gameview;//游戏原本的view

///另一种启动方法
public static void Init(@NonNull Activity activity) {
GLES3JNILib.setFilePath(activity.getFilesDir().getAbsolutePath());
GameContext = activity;
//Toast.makeText(activity,"开始运行"+activity.getClass().getSimpleName(),Toast.LENGTH_LONG).show();
if (surfaceView == null) {
//surface初始化
surfaceView = new mySurfaceView(activity);
surfaceView.setZOrderOnTop(true);//置顶
//surfaceView.setZOrderMediaOverlay(true);
surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

//容器初始化
if (myLayout == null) {
myLayout = new MyLayout(GameContext);
LinearLayout.LayoutParams relLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
myLayout.setLayoutParams(relLayoutParams);
gameview = utils.getContentView(activity);//获取游戏原来的view组
utils.getContentViewGrout(activity).removeAllViews();//清除原来activity的所有view
myLayout.addView(gameview);//然后在容器里面添加原来的view
myLayout.addView(surfaceView);//添加附加层view
activity.setContentView(myLayout);//把容器设置成activity的默认布局
} else {
return;
}



}
}
}
Loading

0 comments on commit 230d4f5

Please sign in to comment.