Skip to content

Commit

Permalink
Numerous bugfixes
Browse files Browse the repository at this point in the history
- Fixed hover animations
- Added dynamic resolution scaling

- Need to add curved corner detection, and allow displaying under the camera cutout
  • Loading branch information
macarooni-man committed Feb 11, 2025
1 parent 5d4d851 commit cbf6cc1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion build-tools/buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source.dir = ../source
source.entrypoint = ../source/main.py

# (list) File extensions to include in the package
source.include_exts = py,kv,png,jpg,ico,ttf,otf,gif,webp
source.include_exts = py,kv,png,jpg,ico,ttf,otf,gif,webp,json,wav

# (str) Application version
version = 2.3
Expand Down
9 changes: 5 additions & 4 deletions source/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
os_name = 'windows' if os.name == 'nt' else 'macos' if system().lower() == 'darwin' else 'linux' if os.name == 'posix' else os.name
home = os.getenv("ANDROID_PRIVATE") if is_android else os.path.expanduser('~')
appdata = os.getenv("APPDATA") if os_name == 'windows' else f'{home}/Library/Application Support' if os_name == 'macos' else home
applicationFolder = os.path.join(appdata, ('.auto-mcs' if os_name != 'macos' else 'auto-mcs'))
applicationFolder = os.path.join(appdata, ('auto-mcs' if (os_name == 'macos' or is_android) else '.auto-mcs'))

saveFolder = os.path.join(appdata, '.minecraft', 'saves') if os_name != 'macos' else f"{home}/Library/Application Support/minecraft/saves"
downDir = os.path.join(applicationFolder, 'Downloads')
Expand Down Expand Up @@ -594,7 +594,7 @@ def match_data(s, *a):
return re.sub(r'\$(.*)\$', '\g<1>', text)


# Returns False if less than 500MB free
# Returns False if less than 1GB free
def check_free_space(telepath_data=None):
if telepath_data:
url = f'http://{telepath_data["host"]}:{telepath_data["port"]}/main/check_free_space'
Expand All @@ -607,8 +607,9 @@ def check_free_space(telepath_data=None):
except:
return True

free_space = round(disk_usage('/').free / 1048576)
return free_space > 500
path_to_check = home if is_android else '/'
free_space = round(disk_usage(path_to_check).free / 1048576)
return free_space > 1024

def telepath_busy():
return ignore_close and server_manager.remote_server
Expand Down
50 changes: 23 additions & 27 deletions source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ def update_window_configuration():
DisplayMetrics = autoclass('android.util.DisplayMetrics')
dm = DisplayMetrics()
activity.getWindowManager().getDefaultDisplay().getMetrics(dm)
phone_width = dm.widthPixels
phone_height = dm.heightPixels
phone_width = int(dm.widthPixels)
phone_height = int(dm.heightPixels)

# Set your desired scale factor; e.g., 2.0 will half the resolution.
constants.scale_factor = 1.25
# Set the scale factor dynamically, 2.0 will half the resolution
min_height = 720
constants.scale_factor = phone_height / min_height

# Calculate the virtual resolution.
virtual_width = int(phone_width / constants.scale_factor)
virtual_height = int(phone_height / constants.scale_factor)
virtual_width = round(phone_width / constants.scale_factor)
virtual_height = round(phone_height / constants.scale_factor)
constants.window_size = (virtual_width, virtual_height)

SDLActivity = autoclass('org.libsdl.app.SDLActivity')
Expand All @@ -56,12 +57,25 @@ def update_window_configuration():
layoutParams.height = LayoutParams.MATCH_PARENT
mSurface.setLayoutParams(layoutParams)

# Get default system language
try:
system_locale = autoclass('java.util.Locale').getDefault().getLanguage()

for v in constants.available_locales.values():
if system_locale.startswith(v['code']):
if not constants.app_config.locale:
constants.app_config.locale = v['code']
break
except Exception as e:
print(f'Failed to determine locale: {e}')

if not constants.app_config.locale:
constants.app_config.locale = 'en'


# Create an instance of Runnable, then assign the function attribute.
runnable = Runnable()
runnable.func = update_window_configuration

# Schedule it on the UI thread.
activity.runOnUiThread(runnable)


Expand All @@ -82,25 +96,7 @@ def update_window_configuration():
pass

# os.environ["KIVY_NO_CONSOLELOG"] = "1"


# Get default system language
try:
from locale import getdefaultlocale
system_locale = getdefaultlocale()[0]
if '_' in system_locale:
system_locale = system_locale.split('_')[0]
for v in constants.available_locales.values():
if system_locale.startswith(v['code']):
if not constants.app_config.locale:
constants.app_config.locale = v['code']
break
except Exception as e:
if not constants.is_docker:
print(f'Failed to determine locale: {e}')
if not constants.app_config.locale:
constants.app_config.locale = 'en'

constants.debug = True

# Start the app
launch_automcs()
18 changes: 10 additions & 8 deletions source/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@

# Android settings
if constants.is_android:
from kivy.logger import Logger
constants.debug = True

# Override debug print statements to Logger
if constants.debug:
from kivy.logger import Logger
print = lambda *a: Logger.debug(str(a))

Config.set('graphics', 'width', str(constants.window_size[0]))
Expand Down Expand Up @@ -491,10 +492,11 @@ def on_mouse_pos(self, *args):

# Unhover if Android
if constants.is_android:
current_screen = str(screen_manager.current)
def unhover(*a):
Window.mouse_pos = pos
self.dispatch('on_leave')
Clock.schedule_once(unhover, 0.5)
if current_screen != screen_manager.current:
self.dispatch('on_leave')
Clock.schedule_once(unhover, 0.25)


# Next line to_widget allow to compensate for relative layout
Expand Down Expand Up @@ -6262,7 +6264,7 @@ def click_event(self, *args):

button_pressed = 'ignore'
try:
button_pressed = args[1].button
button_pressed = 'left' if constants.is_android else args[1].button
except:
pass

Expand Down Expand Up @@ -6863,7 +6865,7 @@ def click_event(self, *args):

button_pressed = 'ignore'
try:
button_pressed = args[1].button
button_pressed = 'left' if constants.is_android else args[1].button
except:
pass

Expand Down Expand Up @@ -7913,7 +7915,7 @@ def click_event(self, *args):

button_pressed = 'ignore'
try:
button_pressed = args[1].button
button_pressed = 'left' if constants.is_android else args[1].button
except:
pass

Expand Down

0 comments on commit cbf6cc1

Please sign in to comment.