mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
- Beta version of a fix to use hotbars on the multiple gui size/resolutions
This commit is contained in:
parent
bbbd0b61e3
commit
7b52d539e2
@ -10,7 +10,6 @@ import android.view.View.*;
|
||||
import android.view.inputmethod.*;
|
||||
import android.widget.*;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.drawerlayout.widget.*;
|
||||
import com.google.android.material.navigation.*;
|
||||
import java.io.*;
|
||||
@ -661,7 +660,8 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
texture.setDefaultBufferSize((int)(width*scaleFactor),(int)(height*scaleFactor));
|
||||
CallbackBridge.windowWidth = (int)(width*scaleFactor);
|
||||
CallbackBridge.windowHeight = (int)(height*scaleFactor);
|
||||
//CallbackBridge.sendUpdateWindowSize((int)(width*scaleFactor),(int)(height*scaleFactor));
|
||||
|
||||
//Load Minecraft options:
|
||||
MCOptionUtils.load();
|
||||
MCOptionUtils.set("overrideWidth", ""+CallbackBridge.windowWidth);
|
||||
MCOptionUtils.set("overrideHeight", ""+CallbackBridge.windowHeight);
|
||||
@ -1025,7 +1025,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
}
|
||||
|
||||
public int mcscale(int input) {
|
||||
return this.guiScale * input;
|
||||
return (int)((this.guiScale * input)/scaleFactor);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1181,15 +1181,19 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
|
||||
public int handleGuiBar(int x, int y) {
|
||||
if (!CallbackBridge.isGrabbing()) return -1;
|
||||
|
||||
int barheight = mcscale(20);
|
||||
int barwidth = mcscale(180);
|
||||
int barx = (CallbackBridge.physicalWidth / 2) - (barwidth / 2);
|
||||
int bary = CallbackBridge.physicalHeight - barheight;
|
||||
if (x < barx || x >= barx + barwidth || y < bary || y >= bary + barheight) {
|
||||
|
||||
int mcGuiScale = Integer.parseInt(MCOptionUtils.get("guiScale"));
|
||||
if(mcGuiScale == 0) mcGuiScale = (Math.min(CallbackBridge.windowHeight, CallbackBridge.windowWidth)/240);
|
||||
mcGuiScale = Math.min(mcGuiScale, (Math.min(CallbackBridge.windowHeight, CallbackBridge.windowWidth)/240));
|
||||
|
||||
int barHeight = mcscale(5 * mcGuiScale);
|
||||
int barWidth = mcscale(45 * mcGuiScale);
|
||||
int barX = (CallbackBridge.physicalWidth / 2) - (barWidth / 2);
|
||||
int barY = CallbackBridge.physicalHeight - barHeight;
|
||||
if (x < barX || x >= barX + barWidth || y < barY || y >= barY + barHeight) {
|
||||
return -1;
|
||||
}
|
||||
return hotbarKeys[((x - barx) / mcscale(180 / 9)) % 9];
|
||||
return hotbarKeys[((x - barX) / mcscale((45 * mcGuiScale) / 9)) % 9];
|
||||
}
|
||||
/*
|
||||
public int handleGuiBar(int x, int y, MotionEvent e) {
|
||||
|
@ -4,8 +4,13 @@ import android.os.*;
|
||||
import android.view.*;
|
||||
import android.view.View.*;
|
||||
import android.widget.*;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.kdt.pojavlaunch.customcontrols.*;
|
||||
import net.kdt.pojavlaunch.prefs.*;
|
||||
import net.kdt.pojavlaunch.utils.MCOptionUtils;
|
||||
|
||||
import org.lwjgl.glfw.*;
|
||||
import java.io.*;
|
||||
import com.google.gson.*;
|
||||
@ -17,6 +22,7 @@ public class MainActivity extends BaseMainActivity {
|
||||
|
||||
private View.OnClickListener mClickListener;
|
||||
private View.OnTouchListener mTouchListener;
|
||||
private FileObserver fileObserver;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -98,6 +104,16 @@ public class MainActivity extends BaseMainActivity {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
fileObserver = new FileObserver(new File(Tools.DIR_GAME_NEW + "/options.txt"), FileObserver.MODIFY) {
|
||||
@Override
|
||||
public void onEvent(int i, @Nullable String s) {
|
||||
//FIXME Make sure the multithreading nature of this event doesn't cause any problems ?
|
||||
MCOptionUtils.load();
|
||||
}
|
||||
};
|
||||
fileObserver.startWatching();
|
||||
|
||||
ControlData[] specialButtons = ControlData.getSpecialButtons();
|
||||
specialButtons[0].specialButtonListener
|
||||
|
@ -39,6 +39,17 @@ public class MCOptionUtils
|
||||
|
||||
mLineList.add(key + ":" + value);
|
||||
}
|
||||
|
||||
public static String get(String key){
|
||||
for (int i = 0; i < mLineList.size(); i++) {
|
||||
String line = mLineList.get(i);
|
||||
if (line.startsWith(key + ":")) {
|
||||
String value = mLineList.get(i);
|
||||
return value.substring(value.indexOf(":")+1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
Loading…
x
Reference in New Issue
Block a user