Skip to content

Commit

Permalink
Launcher: button default size, game exit
Browse files Browse the repository at this point in the history
  • Loading branch information
glKarin committed Sep 29, 2024
1 parent 27a7e27 commit dee6ce2
Show file tree
Hide file tree
Showing 32 changed files with 655 additions and 87 deletions.
2 changes: 1 addition & 1 deletion Q3E/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'

String[] ABIFILTERS = [
"armeabi-v7a",
//"armeabi-v7a",
"arm64-v8a"
/*, "armeabi", "x86", "x86_64"*/
]
Expand Down
28 changes: 28 additions & 0 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3E.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.n0n3m4.q3e;

import android.view.Surface;
import android.util.Log;
import android.os.Build;

public final class Q3E
{
public static Q3EMain activity;
public static Surface surface;

public static Q3EView gameView;
public static Q3EControlView controlView;

public static void Finish()
{
Log.i(Q3EGlobals.CONST_Q3E_LOG_TAG, "Finish activity......");
if(null != activity && !activity.isFinishing())
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
activity.finishAffinity();
else
activity.finish();
}
Log.i(Q3EGlobals.CONST_Q3E_LOG_TAG, "Finish activity done");
System.exit(0);
}
}
71 changes: 39 additions & 32 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3ECallbackObj.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,62 +260,69 @@ public void InitGUIInterface(Activity context)

public void ShowToast(String text)
{
if(null != gui)
//if(null != gui)
gui.Toast(text);
}

public void CloseVKB()
{
if (null != vw)
{
vw.post(new Runnable() {
@Override
public void run() {
Q3EUtils.CloseVKB(vw);
}
});
}
vw.post(new Runnable() {
@Override
public void run() {
Q3EUtils.CloseVKB(vw);
}
});
}

public void OpenVKB()
{
if (null != vw)
{
vw.post(new Runnable() {
@Override
public void run() {
Q3EUtils.OpenVKB(vw);
}
});
}
vw.post(new Runnable() {
@Override
public void run() {
Q3EUtils.OpenVKB(vw);
}
});
}

public void ToggleToolbar(boolean on)
{
if (null != vw)
{
vw.ToggleToolbar(on);
}
vw.ToggleToolbar(on);
}


public void OpenURL(String url)
{
if (null != vw)
vw.post(new Runnable()
{
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
vw.getContext().startActivity(intent);
}
@Override
public void run()
{
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
vw.getContext().startActivity(intent);
}
});
}

public int OpenDialog(String title, String message, String[] buttons)
{
if(null != gui)
//if(null != gui)
return gui.MessageDialog(title, message, buttons);
else
return Q3EGUI.DIALOG_ERROR;
//else return Q3EGUI.DIALOG_ERROR;
}

public void Finish()
{
if(null == Q3E.activity || Q3E.activity.isFinishing())
return;
Q3E.activity.runOnUiThread(new Runnable() {
@Override
public void run()
{
Q3E.Finish();
}
});
}

public void SetupSmoothJoystick(boolean enable)
Expand Down
8 changes: 2 additions & 6 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EControlView.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,8 @@ private boolean HandleBackPress()
Toast.makeText(getContext(), R.string.click_back_again_to_exit, Toast.LENGTH_LONG).show();
else if (m_pressBackCount == Q3EGlobals.CONST_DOUBLE_PRESS_BACK_TO_EXIT_COUNT)
{
m_renderView.Shutdown();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
((Activity) getContext()).finishAffinity();
else
((Activity) getContext()).finish();
System.exit(0);
//m_renderView.Shutdown();
Q3E.Finish();
return true;
}
return res;
Expand Down
2 changes: 1 addition & 1 deletion Q3E/src/main/java/com/n0n3m4/q3e/Q3EGameHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void InitGlobalEnv()

if (!Q3EUtils.q3ei.IsInitGame()) // not from GameLauncher::startActivity
{
Q3EUtils.q3ei.standalone = preferences.getBoolean(Q3EPreference.GAME_STANDALONE_DIRECTORY, false);
Q3EUtils.q3ei.standalone = preferences.getBoolean(Q3EPreference.GAME_STANDALONE_DIRECTORY, true);

Q3EKeyCodes.InitD3Keycodes();

Expand Down
31 changes: 19 additions & 12 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,24 @@

public class Q3EMain extends Activity
{
private Q3ECallbackObj mAudio;
private Q3EView mGLSurfaceView;
private Q3ECallbackObj mAudio;
private Q3EView mGLSurfaceView;
// k
private boolean m_hideNav = true;
private int m_runBackground = 1;
private int m_renderMemStatus = 0;
private Q3EControlView mControlGLSurfaceView;
private KDebugTextView memoryUsageText;
private boolean m_coverEdges = true;
private boolean m_hideNav = true;
private int m_runBackground = 1;
private int m_renderMemStatus = 0;
private Q3EControlView mControlGLSurfaceView;
private KDebugTextView memoryUsageText;
private boolean m_coverEdges = true;
@SuppressLint("StaticFieldLeak")
public static Q3EGameHelper gameHelper;
public static Q3EGameHelper gameHelper;

@SuppressLint("ResourceType")
@Override
public void onCreate(Bundle savedInstanceState)
{
Q3E.activity = this;

gameHelper = new Q3EGameHelper();
gameHelper.SetContext(this);

Expand Down Expand Up @@ -152,8 +154,13 @@ public void onAttachedToWindow()
@Override
protected void onDestroy()
{
Q3E.activity = null;
Q3E.gameView = null;
Q3E.controlView = null;

if (null != mGLSurfaceView)
mGLSurfaceView.Shutdown();

super.onDestroy();
if (null != mAudio)
mAudio.OnDestroy();
Expand Down Expand Up @@ -268,16 +275,16 @@ private void InitGUI()
Q3EUtils.isOuya = false;

if (mAudio == null)
{
mAudio = new Q3ECallbackObj();
mAudio.InitGUIInterface(this);
}
mAudio.InitGUIInterface(this);
Q3EUtils.q3ei.callbackObj = mAudio;
Q3EJNI.setCallbackObject(mAudio);
if (mGLSurfaceView == null)
mGLSurfaceView = new Q3EView(this);
Q3E.gameView = mGLSurfaceView;
if (mControlGLSurfaceView == null)
mControlGLSurfaceView = new Q3EControlView(this);
Q3E.controlView = mControlGLSurfaceView;
mAudio.vw = mControlGLSurfaceView;
mControlGLSurfaceView.EnableGyroscopeControl(Q3EUtils.q3ei.view_motion_control_gyro);
float gyroXSens = preferences.getFloat(Q3EPreference.pref_harm_view_motion_gyro_x_axis_sens, Q3EControlView.GYROSCOPE_X_AXIS_SENS);
Expand Down
1 change: 1 addition & 0 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EPreference.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public final class Q3EPreference
public static final String LOAD_LOCAL_ENGINE_LIB = "harm_load_local_engine_lib";
public static final String THEME = "harm_theme";
public static final String EVENT_QUEUE = "harm_event_queue"; // 0 - java 1 - native
public static final String AUTOSAVE_BUTTON_SETTINGS = "harm_autosave_button_settings";

public static float GetFloatFromString(Context context, String name, float defVal)
{
Expand Down
51 changes: 47 additions & 4 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EUiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class Q3EUiConfig extends Activity
private Q3EUiView vw;
//k
private boolean m_hideNav = true;
private boolean m_autoSave = false;

@Override
protected void onCreate(Bundle savedInstanceState)
Expand All @@ -84,6 +85,7 @@ protected void onCreate(Bundle savedInstanceState)

super.onCreate(savedInstanceState);
Q3ELang.Locale(this);
m_autoSave = preferences.getBoolean(Q3EPreference.AUTOSAVE_BUTTON_SETTINGS, true);

RelativeLayout mainLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams params;
Expand Down Expand Up @@ -116,17 +118,58 @@ public void onClick(View v)
}

@Override
protected void onDestroy()
{
if(m_autoSave)
vw.SaveAll();
super.onDestroy();
}

/* @Override
protected void onPause()
{
vw.SaveAll();
if(m_autoSave)
vw.SaveAll();
super.onPause();
}
}*/

@Override
public void onBackPressed()
{
vw.SaveAll();
super.onBackPressed();
if(!m_autoSave && vw.IsModified())
{
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
switch(which)
{
case DialogInterface.BUTTON_POSITIVE:
vw.SaveAll();
dialog.dismiss();
finish();
break;
case DialogInterface.BUTTON_NEGATIVE:
dialog.dismiss();
finish();
break;
case DialogInterface.BUTTON_NEUTRAL:
default:
dialog.dismiss();
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.warning);
builder.setMessage(R.string.button_setting_has_changed_can_you_save_it);
builder.setPositiveButton(R.string.yes, listener);
builder.setNegativeButton(R.string.no, listener);
builder.setNeutralButton(R.string.cancel, listener);
AlertDialog dialog = builder.create();
dialog.show();
}
else
super.onBackPressed();
}

//k
Expand Down
18 changes: 18 additions & 0 deletions Q3E/src/main/java/com/n0n3m4/q3e/Q3EUiView.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class Q3EUiView extends GLSurfaceView implements GLSurfaceView.Renderer
private int m_numGridLineVertex = 0;
private Toast m_info;
private final Object m_gridLock = new Object();
private boolean m_edited = false;

public Q3EUiView(Context context)
{
Expand Down Expand Up @@ -172,6 +173,7 @@ public void RefreshTgt(FingerUi fn)
fn.target = newb;
touch_elements.set(touch_elements.indexOf(tmp), newb);
paint_elements.set(paint_elements.indexOf(tmp), newb);
m_edited = true;
}
else if (fn.target instanceof Joystick)
{
Expand All @@ -180,6 +182,7 @@ else if (fn.target instanceof Joystick)
fn.target = newj;
touch_elements.set(touch_elements.indexOf(tmp), newj);
paint_elements.set(paint_elements.indexOf(tmp), newj);
m_edited = true;
}
else if (fn.target instanceof Slider)
{
Expand All @@ -188,6 +191,7 @@ else if (fn.target instanceof Slider)
fn.target = news;
touch_elements.set(touch_elements.indexOf(tmp), news);
paint_elements.set(paint_elements.indexOf(tmp), news);
m_edited = true;
}
//k
else if (fn.target instanceof Disc)
Expand All @@ -197,6 +201,7 @@ else if (fn.target instanceof Disc)
fn.target = newd;
touch_elements.set(touch_elements.indexOf(tmp), newd);
paint_elements.set(paint_elements.indexOf(tmp), newd);
m_edited = true;
}

PrintInfo(fn);
Expand Down Expand Up @@ -353,6 +358,7 @@ else if (touchListener instanceof Disc)
}
}
mEdtr.commit();
m_edited = false;
}

UiLoader uildr;
Expand Down Expand Up @@ -641,6 +647,7 @@ public void UpdateOnScreenButtonsOpacity(float alpha)
{
p.alpha = alpha;
}
m_edited = true;
}
}

Expand Down Expand Up @@ -705,6 +712,7 @@ else if (p instanceof Disc)
if (null != finger && finger.target == touchListener)
finger.target = newTL;
}
m_edited = true;
}
}

Expand Down Expand Up @@ -829,4 +837,14 @@ else if(diffabsa == diffabsb)
Log.i("Q3EUiView", "GetPerfectGridSize -> " + res);
return res;
}

public void SetModified()
{
m_edited = true;
}

public boolean IsModified()
{
return m_edited;
}
}
Loading

0 comments on commit dee6ce2

Please sign in to comment.