mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
Add a compatibility layer for older builds
This commit is contained in:
parent
68360e7714
commit
2a5ce50834
2 changed files with 45 additions and 16 deletions
|
|
@ -1,12 +1,7 @@
|
||||||
{
|
{
|
||||||
"plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py",
|
"plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py",
|
||||||
"versions": {
|
"versions": {
|
||||||
"1.0.3": {
|
"1.0.3": null,
|
||||||
"api_version": 8,
|
|
||||||
"commit_sha": "f3d874d",
|
|
||||||
"released_on": "02-10-2023",
|
|
||||||
"md5sum": "ab408d977dc7b88530d721d8cc19658d"
|
|
||||||
},
|
|
||||||
"1.0.2": {
|
"1.0.2": {
|
||||||
"api_version": 8,
|
"api_version": 8,
|
||||||
"commit_sha": "818ec65",
|
"commit_sha": "818ec65",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# ba_meta require api 8
|
# ba_meta require api 8
|
||||||
from babase._meta import EXPORT_CLASS_NAME_SHORTCUTS
|
from babase._meta import EXPORT_CLASS_NAME_SHORTCUTS
|
||||||
from baenv import TARGET_BALLISTICA_BUILD as build_number
|
from baenv import TARGET_BALLISTICA_BUILD
|
||||||
import babase
|
import babase
|
||||||
import _babase
|
import _babase
|
||||||
import bauiv1 as bui
|
import bauiv1 as bui
|
||||||
|
|
@ -29,15 +29,46 @@ from datetime import datetime
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
_env = _babase.env()
|
|
||||||
_uiscale = bui.app.ui_v1.uiscale
|
|
||||||
|
|
||||||
|
|
||||||
PLUGIN_MANAGER_VERSION = "1.0.3"
|
PLUGIN_MANAGER_VERSION = "1.0.3"
|
||||||
REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager"
|
REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager"
|
||||||
# Current tag can be changed to "staging" or any other branch in
|
# Current tag can be changed to "staging" or any other branch in
|
||||||
# plugin manager repo for testing purpose.
|
# plugin manager repo for testing purpose.
|
||||||
CURRENT_TAG = "main"
|
CURRENT_TAG = "main"
|
||||||
|
|
||||||
|
|
||||||
|
if TARGET_BALLISTICA_BUILD < 21282:
|
||||||
|
# These attributes have been deprecated as of 1.7.27. For more info see:
|
||||||
|
# https://github.com/efroemling/ballistica/blob/master/CHANGELOG.md#1727-build-21282-api-8-2023-08-30
|
||||||
|
# Adding a compatibility layer here so older builds still work fine.
|
||||||
|
class Dummy:
|
||||||
|
pass
|
||||||
|
|
||||||
|
babase.app.env = Dummy()
|
||||||
|
|
||||||
|
babase.app.env.build_number = babase.app.build_number
|
||||||
|
babase.app.env.device_name = babase.app.device_name
|
||||||
|
babase.app.env.config_file_path = babase.app.config_file_path
|
||||||
|
babase.app.env.version = babase.app.version
|
||||||
|
babase.app.env.debug_build = babase.app.debug_build
|
||||||
|
babase.app.env.test_build = babase.app.test_build
|
||||||
|
babase.app.env.data_directory = babase.app.data_directory
|
||||||
|
babase.app.env.python_directory_user = babase.app.python_directory_user
|
||||||
|
babase.app.env.python_directory_app = babase.app.python_directory_app
|
||||||
|
babase.app.env.python_directory_app_site = babase.app.python_directory_app_site
|
||||||
|
babase.app.env.api_version = babase.app.api_version
|
||||||
|
babase.app.env.on_tv = babase.app.on_tv
|
||||||
|
babase.app.env.vr_mode = babase.app.vr_mode
|
||||||
|
babase.app.env.toolbar_test = babase.app.toolbar_test
|
||||||
|
babase.app.env.arcade_mode = babase.app.arcade_mode
|
||||||
|
babase.app.env.headless_mode = babase.app.arcade_mode
|
||||||
|
babase.app.env.demo_mode = babase.app.demo_mode
|
||||||
|
babase.app.env.protocl_version = babase.app.protocol_version
|
||||||
|
|
||||||
|
|
||||||
|
_env = _babase.env()
|
||||||
|
_uiscale = bui.app.ui_v1.uiscale
|
||||||
|
|
||||||
INDEX_META = "{repository_url}/{content_type}/{tag}/index.json"
|
INDEX_META = "{repository_url}/{content_type}/{tag}/index.json"
|
||||||
HEADERS = {
|
HEADERS = {
|
||||||
"User-Agent": _env["legacy_user_agent_string"],
|
"User-Agent": _env["legacy_user_agent_string"],
|
||||||
|
|
@ -70,6 +101,7 @@ REGEXP = {
|
||||||
}
|
}
|
||||||
DISCORD_URL = "https://ballistica.net/discord"
|
DISCORD_URL = "https://ballistica.net/discord"
|
||||||
|
|
||||||
|
|
||||||
_CACHE = {}
|
_CACHE = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -102,7 +134,6 @@ def send_network_request(request):
|
||||||
|
|
||||||
|
|
||||||
async def async_send_network_request(request):
|
async def async_send_network_request(request):
|
||||||
|
|
||||||
response = await loop.run_in_executor(None, send_network_request, request)
|
response = await loop.run_in_executor(None, send_network_request, request)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
@ -158,6 +189,9 @@ class DNSBlockWorkaround:
|
||||||
Such as Jio, a pretty popular ISP in India has a DNS block on
|
Such as Jio, a pretty popular ISP in India has a DNS block on
|
||||||
raw.githubusercontent.com (sigh..).
|
raw.githubusercontent.com (sigh..).
|
||||||
|
|
||||||
|
References:
|
||||||
|
* https://github.com/orgs/community/discussions/42655
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
-----
|
-----
|
||||||
>>> import urllib.request
|
>>> import urllib.request
|
||||||
|
|
@ -801,7 +835,7 @@ class Plugin:
|
||||||
def latest_compatible_version(self):
|
def latest_compatible_version(self):
|
||||||
if self._latest_compatible_version is None:
|
if self._latest_compatible_version is None:
|
||||||
for number, info in self.info["versions"].items():
|
for number, info in self.info["versions"].items():
|
||||||
if info["api_version"] == babase.app.api_version if build_number < 21282 else babase.app.env.api_version:
|
if info["api_version"] == babase.app.env.api_version:
|
||||||
self._latest_compatible_version = PluginVersion(
|
self._latest_compatible_version = PluginVersion(
|
||||||
self,
|
self,
|
||||||
(number, info),
|
(number, info),
|
||||||
|
|
@ -810,7 +844,7 @@ class Plugin:
|
||||||
break
|
break
|
||||||
if self._latest_compatible_version is None:
|
if self._latest_compatible_version is None:
|
||||||
raise NoCompatibleVersion(
|
raise NoCompatibleVersion(
|
||||||
f"{self.name} has no version compatible with API {babase.app.api_version if build_number < 21282 else babase.app.env.api_version}."
|
f"{self.name} has no version compatible with API {babase.app.env.api_version}."
|
||||||
)
|
)
|
||||||
return self._latest_compatible_version
|
return self._latest_compatible_version
|
||||||
|
|
||||||
|
|
@ -1235,7 +1269,7 @@ class PluginManager:
|
||||||
async def get_update_details(self):
|
async def get_update_details(self):
|
||||||
index = await self.get_index()
|
index = await self.get_index()
|
||||||
for version, info in index["versions"].items():
|
for version, info in index["versions"].items():
|
||||||
if info["api_version"] != babase.app.api_version if build_number < 21282 else babase.app.env.api_version:
|
if info["api_version"] != babase.app.env.api_version:
|
||||||
# No point checking a version of the API game doesn't support.
|
# No point checking a version of the API game doesn't support.
|
||||||
continue
|
continue
|
||||||
if version == PLUGIN_MANAGER_VERSION:
|
if version == PLUGIN_MANAGER_VERSION:
|
||||||
|
|
@ -2072,7 +2106,7 @@ class PluginManagerSettingsWindow(popup.PopupWindow):
|
||||||
size=(0, 0),
|
size=(0, 0),
|
||||||
h_align='center',
|
h_align='center',
|
||||||
v_align='center',
|
v_align='center',
|
||||||
text=f'API Version: {babase.app.api_version if build_number < 21282 else babase.app.env.api_version}',
|
text=f'API Version: {babase.app.env.api_version}',
|
||||||
scale=text_scale * 0.7,
|
scale=text_scale * 0.7,
|
||||||
color=(0.4, 0.8, 1),
|
color=(0.4, 0.8, 1),
|
||||||
maxwidth=width * 0.95)
|
maxwidth=width * 0.95)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue