mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
Mouse speed editor in settings + ingame
This commit is contained in:
parent
c0437cd432
commit
54d09b53a1
8 changed files with 98 additions and 4 deletions
|
|
@ -161,6 +161,9 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
case R.id.nav_debug: toggleDebug();
|
||||
break;
|
||||
case R.id.nav_customkey: dialogSendCustomKey();
|
||||
break;
|
||||
case R.id.nav_mousespd: adjustMouseSpeedLive();
|
||||
break;
|
||||
}
|
||||
//Toast.makeText(MainActivity.this, menuItem.getTitle() + ":" + menuItem.getItemId(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
|
@ -317,8 +320,8 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE: // 2
|
||||
mouseX = Math.max(0, Math.min(displayMetrics.widthPixels, mouseX + x - prevX));
|
||||
mouseY = Math.max(0, Math.min(displayMetrics.heightPixels, mouseY + y - prevY));
|
||||
mouseX = Math.max(0, Math.min(displayMetrics.widthPixels, mouseX + (x - prevX)*LauncherPreferences.PREF_MOUSESPEED));
|
||||
mouseY = Math.max(0, Math.min(displayMetrics.heightPixels, mouseY + (y - prevY)*LauncherPreferences.PREF_MOUSESPEED));
|
||||
mouse_x = (int) (mouseX * scaleFactor);
|
||||
mouse_y = (int) (mouseY * scaleFactor);
|
||||
placeMouseAt(mouseX, mouseY);
|
||||
|
|
@ -1226,5 +1229,46 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
}
|
||||
return hotbarKeys[((x - barX) / mcscale(180 / 9)) % 9];
|
||||
}
|
||||
int tmpMouseSpeed;
|
||||
|
||||
public void adjustMouseSpeedLive() {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(this);
|
||||
b.setTitle(R.string.mcl_setting_title_mousespeed);
|
||||
View v = LayoutInflater.from(this).inflate(R.layout.live_mouse_speed_editor,null);
|
||||
final SeekBar sb = v.findViewById(R.id.mouseSpeed);
|
||||
final TextView tv = v.findViewById(R.id.mouseSpeedTV);
|
||||
sb.setMax(275);
|
||||
tmpMouseSpeed = (int) ((LauncherPreferences.PREF_MOUSESPEED*100));
|
||||
sb.setProgress(tmpMouseSpeed-25);
|
||||
tv.setText(tmpMouseSpeed +" %");
|
||||
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
tmpMouseSpeed = i+25;
|
||||
tv.setText(tmpMouseSpeed +" %");
|
||||
}
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
});
|
||||
b.setView(v);
|
||||
b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
LauncherPreferences.PREF_MOUSESPEED = ((float)tmpMouseSpeed)/100f;
|
||||
LauncherPreferences.DEFAULT_PREF.edit().putInt("mousespeed",tmpMouseSpeed).commit();
|
||||
dialogInterface.dismiss();
|
||||
System.gc();
|
||||
}
|
||||
});
|
||||
b.setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
System.gc();
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,12 @@ public class LauncherPreferenceFragment extends PreferenceFragmentCompat impleme
|
|||
CustomSeekBarPreference seek5 = (CustomSeekBarPreference) findPreference("resolutionRatio");
|
||||
seek5.setMin(25);
|
||||
seek5.setSuffix(" %");
|
||||
|
||||
|
||||
CustomSeekBarPreference seek6 = (CustomSeekBarPreference) findPreference("mousespeed");
|
||||
seek6.setMin(25);
|
||||
seek6.setValue((int)(LauncherPreferences.PREF_MOUSESPEED*100f));
|
||||
seek6.setMax(300);
|
||||
seek6.setSuffix(" %");
|
||||
// #724 bug fix
|
||||
if (seek5.getValue() < 25) {
|
||||
seek5.setValue(100);
|
||||
|
|
|
|||
|
|
@ -26,13 +26,15 @@ public class LauncherPreferences
|
|||
public static String PREF_VERSION_REPOS = "https://launchermeta.mojang.com/mc/game/version_manifest_v2.json";
|
||||
public static boolean PREF_CHECK_LIBRARY_SHA = true;
|
||||
public static boolean PREF_DISABLE_GESTURES = false;
|
||||
public static float PREF_MOUSESPEED = 1f;
|
||||
public static void loadPreferences() {
|
||||
PREF_BUTTONSIZE = DEFAULT_PREF.getInt("buttonscale", 100);
|
||||
PREF_MOUSESCALE = DEFAULT_PREF.getInt("mousescale", 100);
|
||||
PREF_MOUSESPEED = ((float)DEFAULT_PREF.getInt("mousespeed",100))/100f;
|
||||
PREF_FREEFORM = DEFAULT_PREF.getBoolean("freeform", false);
|
||||
PREF_HIDE_SIDEBAR = DEFAULT_PREF.getBoolean("hideSidebar", false);
|
||||
PREF_IGNORE_NOTCH = DEFAULT_PREF.getBoolean("ignoreNotch", false);
|
||||
PREF_BACK_TO_RIGHT_MOUSE = DEFAULT_PREF.getBoolean("backToRightMouse", true);
|
||||
PREF_BACK_TO_RIGHT_MOUSE = DEFAULT_PREF.getBoolean("backToRightMouse", false);
|
||||
PREF_BUTTON_FLAT = DEFAULT_PREF.getBoolean("flatButtonStyle", false);
|
||||
PREF_VERTYPE_RELEASE = DEFAULT_PREF.getBoolean("vertype_release", true);
|
||||
PREF_VERTYPE_SNAPSHOT = DEFAULT_PREF.getBoolean("vertype_snapshot", false);
|
||||
|
|
|
|||
BIN
app_pojavlauncher/src/main/res/drawable/mouse_pointer_spd.png
Normal file
BIN
app_pojavlauncher/src/main/res/drawable/mouse_pointer_spd.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/mouseSpeed"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/mouseSpeedTV"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mouseSpeedTV"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -12,4 +12,7 @@
|
|||
<item
|
||||
android:id="@+id/nav_customkey"
|
||||
android:title="@string/control_customkey" />
|
||||
<item
|
||||
android:id="@+id/nav_mousespd"
|
||||
android:title="@string/mcl_setting_title_mousespeed" />
|
||||
</menu>
|
||||
|
|
|
|||
|
|
@ -213,4 +213,6 @@
|
|||
<string name="dl_library_sha_pass">Library %s is fine and usable</string>
|
||||
<string name="mcl_disable_gestures">Disable gestures</string>
|
||||
<string name="mcl_disable_gestures_subtitle">Disables gestures, such as hold to break block, and tap to place a block.</string>
|
||||
<string name="mcl_setting_title_mousespeed">Mouse Speed</string>
|
||||
<string name="mcl_setting_subtitle_mousespeed">Changes the speed of the software mouse</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -104,6 +104,13 @@
|
|||
app2:icon="@drawable/mouse_pointer_1"
|
||||
app2:selectable="false"
|
||||
app2:showSeekBarValue="true" />
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="mousespeed"
|
||||
android:summary="@string/mcl_setting_subtitle_mousespeed"
|
||||
android:title="@string/mcl_setting_title_mousespeed"
|
||||
app2:icon="@drawable/mouse_pointer_spd"
|
||||
app2:selectable="false"
|
||||
app2:showSeekBarValue="true" />
|
||||
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue