mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 15:48:26 -04:00
A lot of bug fixes in custom controls
- Re-load control when unnecessary. - Able to edit PRI and SEC while playing. - Unable to move camera while holding a button. - Probably more(?)
This commit is contained in:
parent
f0a72d76d4
commit
3a30915a51
@ -24,7 +24,7 @@ android {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 26
|
||||
versionCode 156236
|
||||
versionName "3.3.0b_6408b_20201119"
|
||||
versionName "3.3.0b_6408b_20201122"
|
||||
multiDexEnabled true //important
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
String[] oldSpecialArr = ControlData.buildSpecialButtonArray();
|
||||
final String[] specialArr = new String[oldSpecialArr.length];
|
||||
for (int i = 0; i < specialArr.length; i++) {
|
||||
specialArr[i] = "SPECIAL_" + oldSpecialArr[i];
|
||||
specialArr[i] = "SPECIAL_" + oldSpecialArr[specialArr.length - i - 1];
|
||||
}
|
||||
|
||||
adapter.addAll(specialArr);
|
||||
@ -111,7 +111,7 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
||||
spinnerKeycode.setAdapter(adapter);
|
||||
if (properties.keycode < 0) {
|
||||
spinnerKeycode.setSelection(0 - properties.keycode);
|
||||
spinnerKeycode.setSelection(properties.keycode + specialArr.length);
|
||||
} else {
|
||||
spinnerKeycode.setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycode) + specialArr.length);
|
||||
}
|
||||
|
@ -20,12 +20,10 @@ public class CustomControlsActivity extends BaseActivity
|
||||
private DrawerLayout drawerLayout;
|
||||
private NavigationView navDrawer;
|
||||
private ControlLayout ctrlLayout;
|
||||
private CustomControls mCtrl;
|
||||
|
||||
|
||||
private SharedPreferences mPref;
|
||||
|
||||
public boolean isModified = false;
|
||||
|
||||
private String selectedName = "new_control";
|
||||
|
||||
@Override
|
||||
@ -66,14 +64,10 @@ public class CustomControlsActivity extends BaseActivity
|
||||
}
|
||||
});
|
||||
|
||||
mCtrl = new CustomControls();
|
||||
|
||||
ctrlLayout.setActivity(this);
|
||||
ctrlLayout.setModifiable(true);
|
||||
|
||||
loadControl(LauncherPreferences.PREF_DEFAULTCTRL_PATH);
|
||||
|
||||
ctrlLayout.loadLayout(mCtrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,7 +90,7 @@ public class CustomControlsActivity extends BaseActivity
|
||||
Tools.showError(this, th);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void dialogSelectDefaultCtrl() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.customctrl_selectdefault);
|
||||
@ -203,8 +197,7 @@ public class CustomControlsActivity extends BaseActivity
|
||||
|
||||
private void loadControl(String path) {
|
||||
try {
|
||||
mCtrl = Tools.GLOBAL_GSON.fromJson(Tools.read(path), CustomControls.class);
|
||||
ctrlLayout.loadLayout(mCtrl);
|
||||
ctrlLayout.loadLayout(path);
|
||||
|
||||
selectedName = new File(path).getName();
|
||||
// Remove `.json`
|
||||
|
@ -7,9 +7,10 @@ import android.widget.*;
|
||||
import net.kdt.pojavlaunch.customcontrols.*;
|
||||
import net.kdt.pojavlaunch.prefs.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
import java.io.*;
|
||||
import com.google.gson.*;
|
||||
|
||||
public class CustomCtrlMainActivity extends BaseMainActivity {
|
||||
private CustomControls mControl;
|
||||
private ControlLayout mControlLayout;
|
||||
|
||||
private View.OnClickListener mClickListener;
|
||||
@ -99,21 +100,15 @@ public class CustomCtrlMainActivity extends BaseMainActivity {
|
||||
= mTouchListener;
|
||||
|
||||
mControlLayout = findViewById(R.id.main_control_layout);
|
||||
mControl = new CustomControls();
|
||||
try {
|
||||
mControlLayout.loadLayout(LauncherPreferences.PREF_DEFAULTCTRL_PATH);
|
||||
} catch (Throwable th) {
|
||||
Tools.showError(this, th);
|
||||
}
|
||||
|
||||
mControlLayout.setModifiable(false);
|
||||
loadControl(LauncherPreferences.PREF_DEFAULTCTRL_PATH);
|
||||
mControlLayout.loadLayout(mControl);
|
||||
|
||||
// toggleGui(null);
|
||||
mControlLayout.toggleControlVisible();
|
||||
}
|
||||
|
||||
private void loadControl(String path) {
|
||||
try {
|
||||
mControl = Tools.GLOBAL_GSON.fromJson(Tools.read(path), CustomControls.class);
|
||||
mControlLayout.loadLayout(mControl);
|
||||
} catch (Exception e) {
|
||||
Tools.showError(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,17 +106,18 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View p1) {
|
||||
if (!mCanTriggerLongClick) return false;
|
||||
|
||||
if (mHandleView.isShowing()) {
|
||||
mHandleView.hide();
|
||||
} else {
|
||||
if (getParent() != null) {
|
||||
((ControlLayout) getParent()).hideAllHandleViews();
|
||||
if (mCanTriggerLongClick) {
|
||||
if (mHandleView.isShowing()) {
|
||||
mHandleView.hide();
|
||||
} else {
|
||||
if (getParent() != null) {
|
||||
((ControlLayout) getParent()).hideAllHandleViews();
|
||||
}
|
||||
mHandleView.show();
|
||||
}
|
||||
mHandleView.show();
|
||||
}
|
||||
return true;
|
||||
|
||||
return mCanTriggerLongClick;
|
||||
}
|
||||
|
||||
private float moveX, moveY;
|
||||
@ -145,8 +146,6 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
if (mGestureDetector.onTouchEvent(event)) {
|
||||
mCanTriggerLongClick = true;
|
||||
@ -173,9 +172,9 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setModifiable(boolean z) {
|
||||
|
@ -7,6 +7,7 @@ import com.google.gson.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import android.support.v7.app.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
public class ControlLayout extends FrameLayout
|
||||
{
|
||||
@ -32,17 +33,19 @@ public class ControlLayout extends FrameLayout
|
||||
}
|
||||
}
|
||||
|
||||
public void loadLayout(String jsonPath) {
|
||||
try {
|
||||
loadLayout(Tools.GLOBAL_GSON.fromJson(Tools.read(jsonPath), CustomControls.class));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void loadLayout(String jsonPath) throws IOException, JsonSyntaxException {
|
||||
loadLayout(Tools.GLOBAL_GSON.fromJson(Tools.read(jsonPath), CustomControls.class));
|
||||
}
|
||||
|
||||
public void loadLayout(CustomControls controlLayout) {
|
||||
mLayout = controlLayout;
|
||||
removeAllViews();
|
||||
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
if (getChildAt(i) instanceof ControlButton) {
|
||||
removeViewAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (ControlData button : controlLayout.mControlDataList) {
|
||||
button.isHideable = button.keycode != ControlData.SPECIALBTN_TOGGLECTRL && button.keycode != ControlData.SPECIALBTN_VIRTUALMOUSE;
|
||||
addControlView(button);
|
||||
|
@ -13,31 +13,31 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<net.kdt.pojavlaunch.MinecraftGLView
|
||||
android:id="@+id/main_game_render_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/main_touchpad"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_height="27dp"
|
||||
android:layout_width="18dp"
|
||||
android:src="@drawable/mouse_pointer"
|
||||
android:id="@+id/main_mouse_pointer"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<net.kdt.pojavlaunch.customcontrols.ControlLayout
|
||||
android:id="@+id/main_control_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<net.kdt.pojavlaunch.MinecraftGLView
|
||||
android:id="@+id/main_game_render_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/main_touchpad"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_height="27dp"
|
||||
android:layout_width="18dp"
|
||||
android:src="@drawable/mouse_pointer"
|
||||
android:id="@+id/main_mouse_pointer"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</net.kdt.pojavlaunch.customcontrols.ControlLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
Loading…
x
Reference in New Issue
Block a user