mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 09:07:48 -04:00
Custom controls changes
- Add key combination: Alt, Control, Shift. - Add new special button: middle mouse. - Allow rename a special button.
This commit is contained in:
parent
c25b7bd768
commit
dd6d080b4e
@ -94,8 +94,6 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
|
||||
@Override
|
||||
public void onShow(DialogInterface dialogInterface) {
|
||||
final LinearLayout normalBtnLayout = dialog.findViewById(R.id.controlsetting_normalbtnlayout);
|
||||
|
||||
final EditText editName = dialog.findViewById(R.id.controlsetting_edit_name);
|
||||
editName.setText(properties.name);
|
||||
|
||||
@ -117,18 +115,6 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
} else {
|
||||
spinnerKeycode.setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycode) + specialArr.length);
|
||||
}
|
||||
spinnerKeycode.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
|
||||
normalBtnLayout.setVisibility(id < specialArr.length ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapter){
|
||||
// Unused
|
||||
}
|
||||
});
|
||||
|
||||
final CheckBox checkHidden = dialog.findViewById(R.id.controlsetting_checkbox_hidden);
|
||||
checkHidden.setChecked(properties.hidden);
|
||||
@ -155,6 +141,15 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
}
|
||||
});
|
||||
|
||||
final CheckBox checkHoldAlt = dialog.findViewById(R.id.controlsetting_checkbox_keycombine_alt);
|
||||
checkHoldAlt.setChecked(properties.holdAlt);
|
||||
|
||||
final CheckBox checkHoldControl = dialog.findViewById(R.id.controlsetting_checkbox_keycombine_control);
|
||||
checkHoldControl.setChecked(properties.holdCtrl);
|
||||
|
||||
final CheckBox checkHoldShift = dialog.findViewById(R.id.controlsetting_checkbox_keycombine_shift);
|
||||
checkHoldShift.setChecked(properties.holdShift);
|
||||
|
||||
Button button = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@ -201,6 +196,10 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
properties.isDynamicBtn = checkDynamicPos.isChecked();
|
||||
properties.dynamicX = editDynamicX.getText().toString();
|
||||
properties.dynamicY = editDynamicY.getText().toString();
|
||||
|
||||
properties.holdAlt = checkHoldAlt.isChecked();
|
||||
properties.holdCtrl = checkHoldControl.isChecked();
|
||||
properties.holdShift = checkHoldShift.isChecked();
|
||||
|
||||
if (properties.dynamicX.isEmpty()) {
|
||||
properties.dynamicX = Float.toString(properties.x);
|
||||
@ -219,7 +218,7 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
|
||||
dialog.show();
|
||||
} else if (view == mDeleteTextView) {
|
||||
alert.setMessage(R.string.global_remove + " " + mHandleView.mView.getText() + "?");
|
||||
alert.setMessage(view.getContext().getString(R.string.global_remove) + " " + mHandleView.mView.getText() + "?");
|
||||
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +76,10 @@ public class CustomCtrlMainActivity extends BaseMainActivity implements OnClickL
|
||||
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown);
|
||||
break;
|
||||
|
||||
case ControlData.SPECIALBTN_MOUSEMID:
|
||||
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_MIDDLE, isDown);
|
||||
break;
|
||||
|
||||
case ControlData.SPECIALBTN_MOUSESEC:
|
||||
if (CallbackBridge.isGrabbing()) {
|
||||
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown);
|
||||
|
@ -52,9 +52,6 @@ public class MainActivity extends BaseMainActivity implements OnClickListener, O
|
||||
this.toggleControlButton.setOnClickListener(this);
|
||||
this.zoomButton.setVisibility(mVersionInfo.optifineLib == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
ControlData[] specialButtons = ControlData.getSpecialButtons();
|
||||
specialButtons[1].specialButtonListener = this;
|
||||
|
||||
// toggleGui(null);
|
||||
onClick(toggleControlButton);
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
|
||||
private boolean mCanModify = false;
|
||||
private boolean mCanTriggerLongClick = true;
|
||||
|
||||
private int mMods;
|
||||
|
||||
public ControlButton(Context ctx, ControlData properties) {
|
||||
super(ctx);
|
||||
@ -47,6 +49,14 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
public void setProperties(ControlData properties, boolean changePos) {
|
||||
mProperties = properties;
|
||||
properties.update();
|
||||
|
||||
if (properties.holdAlt) {
|
||||
mMods &= LWJGLGLFWKeycode.GLFW_MOD_ALT;
|
||||
} if (properties.holdCtrl) {
|
||||
mMods &= LWJGLGLFWKeycode.GLFW_MOD_CONTROL;
|
||||
} if (properties.holdShift) {
|
||||
mMods &= LWJGLGLFWKeycode.GLFW_MOD_SHIFT;
|
||||
}
|
||||
|
||||
// com.android.internal.R.string.delete
|
||||
// android.R.string.
|
||||
@ -131,7 +141,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
MainActivity.sendKeyPress(mProperties.keycode, 0, isDown);
|
||||
MainActivity.sendKeyPress(mProperties.keycode, mMods, isDown);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class ControlData implements Cloneable
|
||||
public static final int SPECIALBTN_MOUSEPRI = -3;
|
||||
public static final int SPECIALBTN_MOUSESEC = -4;
|
||||
public static final int SPECIALBTN_VIRTUALMOUSE = -5;
|
||||
public static final int SPECIALBTN_MOUSEMID = -6;
|
||||
|
||||
private static ControlData[] SPECIAL_BUTTONS;
|
||||
private static String[] SPECIAL_BUTTON_NAME_ARRAY;
|
||||
@ -42,6 +43,7 @@ public class ControlData implements Cloneable
|
||||
new ControlData("Keyboard", SPECIALBTN_KEYBOARD, "${margin} * 3 + ${width} * 2", "${margin}", false),
|
||||
new ControlData("GUI", SPECIALBTN_TOGGLECTRL, "${margin}", "${bottom} - ${margin}"),
|
||||
new ControlData("PRI", SPECIALBTN_MOUSEPRI, "${margin}", "${screen_height} - ${margin} * 3 - ${height} * 3"),
|
||||
new ControlData("MID", SPECIALBTN_MOUSEMID, "${margin}", "${margin}"),
|
||||
new ControlData("SEC", SPECIALBTN_MOUSESEC, "${margin} * 3 + ${width} * 2", "${screen_height} - ${margin} * 3 - ${height} * 3"),
|
||||
new ControlData("Mouse", SPECIALBTN_VIRTUALMOUSE, "${right}", "${margin}", false)
|
||||
};
|
||||
|
@ -19,24 +19,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/controlsetting_spinner_lwjglkeycode"/>
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/global_name"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/controlsetting_normalbtnlayout">
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/global_name"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:singleLine="true"
|
||||
android:id="@+id/controlsetting_edit_name"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:singleLine="true"
|
||||
android:id="@+id/controlsetting_edit_name"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
@ -80,6 +72,29 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/customctrl_keycombine"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@string/customctrl_keycombine_alt"
|
||||
android:id="@+id/controlsetting_checkbox_keycombine_alt"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@string/customctrl_keycombine_control"
|
||||
android:id="@+id/controlsetting_checkbox_keycombine_control"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@string/customctrl_keycombine_shift"
|
||||
android:id="@+id/controlsetting_checkbox_keycombine_shift"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
@ -189,10 +189,17 @@
|
||||
<string name="customctrl_keyname">Keycode</string>
|
||||
<string name="customctrl_specialkey">Special Key</string>
|
||||
<string name="customctrl_hidden">Hidden</string>
|
||||
|
||||
<string name="customctrl_dynamicpos">Dynamic position</string>
|
||||
<string name="customctrl_dynamicpos_x">Dynamic X</string>
|
||||
<string name="customctrl_dynamicpos_y">Dynamic Y</string>
|
||||
|
||||
<string name="customctrl_keycombine">Key combination</string>
|
||||
<string name="customctrl_keycombine_alt">Alt</string>
|
||||
<string name="customctrl_keycombine_control">Control</string>
|
||||
<string name="customctrl_keycombine_shift">Shift</string>
|
||||
<string name="customctrl_addbutton">Add button</string>
|
||||
|
||||
<string name="customctrl_selectdefault">Select default Control json</string>
|
||||
|
||||
<!-- Update part (unused now) -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user