mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 00:59:35 -04:00
Menu button
This commit is contained in:
parent
a197b906a2
commit
c4880416e6
@ -44,7 +44,7 @@ import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
|
|||||||
import org.lwjgl.glfw.*;
|
import org.lwjgl.glfw.*;
|
||||||
import android.net.*;
|
import android.net.*;
|
||||||
|
|
||||||
public class MainActivity extends BaseActivity {
|
public class MainActivity extends BaseActivity implements ControlButtonMenuListener{
|
||||||
public static volatile ClipboardManager GLOBAL_CLIPBOARD;
|
public static volatile ClipboardManager GLOBAL_CLIPBOARD;
|
||||||
public static final String INTENT_MINECRAFT_VERSION = "intent_version";
|
public static final String INTENT_MINECRAFT_VERSION = "intent_version";
|
||||||
|
|
||||||
@ -116,6 +116,7 @@ public class MainActivity extends BaseActivity {
|
|||||||
protected void initLayout(int resId) {
|
protected void initLayout(int resId) {
|
||||||
setContentView(resId);
|
setContentView(resId);
|
||||||
bindValues();
|
bindValues();
|
||||||
|
mControlLayout.setMenuListener(this);
|
||||||
|
|
||||||
mDrawerPullButton.setOnClickListener(v -> drawerLayout.openDrawer(navDrawer));
|
mDrawerPullButton.setOnClickListener(v -> drawerLayout.openDrawer(navDrawer));
|
||||||
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||||
@ -210,6 +211,7 @@ public class MainActivity extends BaseActivity {
|
|||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
Tools.showError(this, th);
|
Tools.showError(this, th);
|
||||||
}
|
}
|
||||||
|
mDrawerPullButton.setVisibility(mControlLayout.hasMenuButton() ? View.GONE : View.VISIBLE);
|
||||||
mControlLayout.toggleControlVisible();
|
mControlLayout.toggleControlVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,6 +407,7 @@ public class MainActivity extends BaseActivity {
|
|||||||
minecraftProfile.controlFile == null
|
minecraftProfile.controlFile == null
|
||||||
? LauncherPreferences.PREF_DEFAULTCTRL_PATH
|
? LauncherPreferences.PREF_DEFAULTCTRL_PATH
|
||||||
: Tools.CTRLMAP_PATH + "/" + minecraftProfile.controlFile);
|
: Tools.CTRLMAP_PATH + "/" + minecraftProfile.controlFile);
|
||||||
|
mDrawerPullButton.setVisibility(mControlLayout.hasMenuButton() ? View.GONE : View.VISIBLE);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Tools.showError(this,e);
|
Tools.showError(this,e);
|
||||||
}
|
}
|
||||||
@ -515,4 +518,9 @@ public class MainActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClickedMenu() {
|
||||||
|
drawerLayout.openDrawer(navDrawer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package net.kdt.pojavlaunch.customcontrols;
|
||||||
|
|
||||||
|
public interface ControlButtonMenuListener {
|
||||||
|
void onClickedMenu();
|
||||||
|
}
|
@ -29,6 +29,7 @@ public class ControlData {
|
|||||||
public static final int SPECIALBTN_MOUSEMID = -6;
|
public static final int SPECIALBTN_MOUSEMID = -6;
|
||||||
public static final int SPECIALBTN_SCROLLUP = -7;
|
public static final int SPECIALBTN_SCROLLUP = -7;
|
||||||
public static final int SPECIALBTN_SCROLLDOWN = -8;
|
public static final int SPECIALBTN_SCROLLDOWN = -8;
|
||||||
|
public static final int SPECIALBTN_MENU = -9;
|
||||||
|
|
||||||
private static ControlData[] SPECIAL_BUTTONS;
|
private static ControlData[] SPECIAL_BUTTONS;
|
||||||
private static String[] SPECIAL_BUTTON_NAME_ARRAY;
|
private static String[] SPECIAL_BUTTON_NAME_ARRAY;
|
||||||
@ -65,7 +66,8 @@ public class ControlData {
|
|||||||
|
|
||||||
new ControlData("MID", new int[]{SPECIALBTN_MOUSEMID}, "${margin}", "${margin}"),
|
new ControlData("MID", new int[]{SPECIALBTN_MOUSEMID}, "${margin}", "${margin}"),
|
||||||
new ControlData("SCROLLUP", new int[]{SPECIALBTN_SCROLLUP}, "${margin}", "${margin}"),
|
new ControlData("SCROLLUP", new int[]{SPECIALBTN_SCROLLUP}, "${margin}", "${margin}"),
|
||||||
new ControlData("SCROLLDOWN", new int[]{SPECIALBTN_SCROLLDOWN}, "${margin}", "${margin}")
|
new ControlData("SCROLLDOWN", new int[]{SPECIALBTN_SCROLLDOWN}, "${margin}", "${margin}"),
|
||||||
|
new ControlData("MENU", new int[]{SPECIALBTN_MENU}, "${margin}", "${margin}")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ public class ControlLayout extends FrameLayout {
|
|||||||
|
|
||||||
private EditControlPopup mControlPopup = null;
|
private EditControlPopup mControlPopup = null;
|
||||||
private ControlHandleView mHandleView;
|
private ControlHandleView mHandleView;
|
||||||
|
private ControlButtonMenuListener mMenuListener;
|
||||||
public ActionRow actionRow = null;
|
public ActionRow actionRow = null;
|
||||||
|
|
||||||
public ControlLayout(Context ctx) {
|
public ControlLayout(Context ctx) {
|
||||||
@ -367,4 +368,22 @@ public class ControlLayout extends FrameLayout {
|
|||||||
mLayout.save(path);
|
mLayout.save(path);
|
||||||
} catch (IOException e) {Log.e("ControlLayout", "Failed to save the layout at:" + path);}
|
} catch (IOException e) {Log.e("ControlLayout", "Failed to save the layout at:" + path);}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasMenuButton() {
|
||||||
|
for(ControlInterface controlInterface : getButtonChildren()){
|
||||||
|
for (int keycode : controlInterface.getProperties().keycodes) {
|
||||||
|
if (keycode == ControlData.SPECIALBTN_MENU) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuListener(ControlButtonMenuListener menuListener) {
|
||||||
|
this.mMenuListener = menuListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyAppMenu() {
|
||||||
|
if(mMenuListener != null) mMenuListener.onClickedMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import android.view.*;
|
|||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
|
||||||
|
|
||||||
|
import net.kdt.pojavlaunch.customcontrols.ControlButtonMenuListener;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
||||||
import net.kdt.pojavlaunch.customcontrols.handleview.*;
|
import net.kdt.pojavlaunch.customcontrols.handleview.*;
|
||||||
@ -22,12 +23,14 @@ import static org.lwjgl.glfw.CallbackBridge.sendMouseButton;
|
|||||||
public class ControlButton extends TextView implements ControlInterface {
|
public class ControlButton extends TextView implements ControlInterface {
|
||||||
private final Paint mRectPaint = new Paint();
|
private final Paint mRectPaint = new Paint();
|
||||||
protected ControlData mProperties;
|
protected ControlData mProperties;
|
||||||
|
private final ControlLayout mControlLayout;
|
||||||
|
|
||||||
protected boolean mIsToggled = false;
|
protected boolean mIsToggled = false;
|
||||||
protected boolean mIsPointerOutOfBounds = false;
|
protected boolean mIsPointerOutOfBounds = false;
|
||||||
|
|
||||||
public ControlButton(ControlLayout layout, ControlData properties) {
|
public ControlButton(ControlLayout layout, ControlData properties) {
|
||||||
super(layout.getContext());
|
super(layout.getContext());
|
||||||
|
mControlLayout = layout;
|
||||||
setGravity(Gravity.CENTER);
|
setGravity(Gravity.CENTER);
|
||||||
setAllCaps(true);
|
setAllCaps(true);
|
||||||
setTextColor(Color.WHITE);
|
setTextColor(Color.WHITE);
|
||||||
@ -183,6 +186,7 @@ public class ControlButton extends TextView implements ControlInterface {
|
|||||||
sendKeyPress(keycode, CallbackBridge.getCurrentMods(), isDown);
|
sendKeyPress(keycode, CallbackBridge.getCurrentMods(), isDown);
|
||||||
CallbackBridge.setModifiers(keycode, isDown);
|
CallbackBridge.setModifiers(keycode, isDown);
|
||||||
}else{
|
}else{
|
||||||
|
Log.i("punjabilauncher", "sendSpecialKey("+keycode+","+isDown+")");
|
||||||
sendSpecialKey(keycode, isDown);
|
sendSpecialKey(keycode, isDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,6 +225,9 @@ public class ControlButton extends TextView implements ControlInterface {
|
|||||||
case ControlData.SPECIALBTN_SCROLLUP:
|
case ControlData.SPECIALBTN_SCROLLUP:
|
||||||
if (!isDown) CallbackBridge.sendScroll(0, -1d);
|
if (!isDown) CallbackBridge.sendScroll(0, -1d);
|
||||||
break;
|
break;
|
||||||
|
case ControlData.SPECIALBTN_MENU:
|
||||||
|
mControlLayout.notifyAppMenu();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user