mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-19 09:39:25 -04:00
- Refactored the function name from calculateMcScale to getMcScale since we changed how it behaves
- Optimized auto scale operations - Removed some junk I've put there myself - Getting a value will load the setting list if not done already.
This commit is contained in:
parent
7b52d539e2
commit
4fcfbd2ab8
@ -666,7 +666,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
MCOptionUtils.set("overrideWidth", ""+CallbackBridge.windowWidth);
|
MCOptionUtils.set("overrideWidth", ""+CallbackBridge.windowWidth);
|
||||||
MCOptionUtils.set("overrideHeight", ""+CallbackBridge.windowHeight);
|
MCOptionUtils.set("overrideHeight", ""+CallbackBridge.windowHeight);
|
||||||
MCOptionUtils.save();
|
MCOptionUtils.save();
|
||||||
calculateMcScale();
|
getMcScale();
|
||||||
// Should we do that?
|
// Should we do that?
|
||||||
if (!isCalled) {
|
if (!isCalled) {
|
||||||
isCalled = true;
|
isCalled = true;
|
||||||
@ -698,7 +698,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
CallbackBridge.windowWidth = (int)(width*scaleFactor);
|
CallbackBridge.windowWidth = (int)(width*scaleFactor);
|
||||||
CallbackBridge.windowHeight = (int)(height*scaleFactor);
|
CallbackBridge.windowHeight = (int)(height*scaleFactor);
|
||||||
CallbackBridge.sendUpdateWindowSize((int)(width*scaleFactor),(int)(height*scaleFactor));
|
CallbackBridge.sendUpdateWindowSize((int)(width*scaleFactor),(int)(height*scaleFactor));
|
||||||
calculateMcScale();
|
getMcScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1171,29 +1171,27 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculateMcScale() {
|
public void getMcScale() {
|
||||||
int scale = 1;
|
//Get the scale stored in game files, used auto scale if found or if the stored scaled is bigger than the authorized size.
|
||||||
while (CallbackBridge.physicalWidth / (scale + 1) >= 320 && CallbackBridge.physicalHeight / (scale + 1) >= 240) {
|
this.guiScale = Integer.parseInt(MCOptionUtils.get("guiScale"));
|
||||||
scale++;
|
|
||||||
|
int scale = Math.max(Math.min(CallbackBridge.windowWidth / 320, CallbackBridge.windowHeight / 240), 1);
|
||||||
|
if(scale < this.guiScale || guiScale == 0){
|
||||||
|
this.guiScale = scale;
|
||||||
}
|
}
|
||||||
this.guiScale = scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int handleGuiBar(int x, int y) {
|
public int handleGuiBar(int x, int y) {
|
||||||
if (!CallbackBridge.isGrabbing()) return -1;
|
if (!CallbackBridge.isGrabbing()) return -1;
|
||||||
|
|
||||||
int mcGuiScale = Integer.parseInt(MCOptionUtils.get("guiScale"));
|
int barHeight = mcscale(20);
|
||||||
if(mcGuiScale == 0) mcGuiScale = (Math.min(CallbackBridge.windowHeight, CallbackBridge.windowWidth)/240);
|
int barWidth = mcscale(180);
|
||||||
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 barX = (CallbackBridge.physicalWidth / 2) - (barWidth / 2);
|
||||||
int barY = CallbackBridge.physicalHeight - barHeight;
|
int barY = CallbackBridge.physicalHeight - barHeight;
|
||||||
if (x < barX || x >= barX + barWidth || y < barY || y >= barY + barHeight) {
|
if (x < barX || x >= barX + barWidth || y < barY || y >= barY + barHeight) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return hotbarKeys[((x - barX) / mcscale((45 * mcGuiScale) / 9)) % 9];
|
return hotbarKeys[((x - barX) / mcscale(180 / 9)) % 9];
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public int handleGuiBar(int x, int y, MotionEvent e) {
|
public int handleGuiBar(int x, int y, MotionEvent e) {
|
||||||
|
@ -111,6 +111,7 @@ public class MainActivity extends BaseMainActivity {
|
|||||||
public void onEvent(int i, @Nullable String s) {
|
public void onEvent(int i, @Nullable String s) {
|
||||||
//FIXME Make sure the multithreading nature of this event doesn't cause any problems ?
|
//FIXME Make sure the multithreading nature of this event doesn't cause any problems ?
|
||||||
MCOptionUtils.load();
|
MCOptionUtils.load();
|
||||||
|
getMcScale();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fileObserver.startWatching();
|
fileObserver.startWatching();
|
||||||
|
@ -41,6 +41,9 @@ public class MCOptionUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String get(String key){
|
public static String get(String key){
|
||||||
|
if (mLineList == null){
|
||||||
|
load();
|
||||||
|
}
|
||||||
for (int i = 0; i < mLineList.size(); i++) {
|
for (int i = 0; i < mLineList.size(); i++) {
|
||||||
String line = mLineList.get(i);
|
String line = mLineList.get(i);
|
||||||
if (line.startsWith(key + ":")) {
|
if (line.startsWith(key + ":")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user