From 4d100d1ffdbcab70e3856c7454d11719e28e4f7e Mon Sep 17 00:00:00 2001 From: Vishal Date: Wed, 22 Jan 2025 23:51:41 +0530 Subject: [PATCH] Updating manual_camera to api 9 --- plugins/utilities.json | 1 + plugins/utilities/manual_camera.py | 47 ++++++++++++++++-------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index ad514bc..a538eee 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -238,6 +238,7 @@ } ], "versions": { + "1.1.0": null, "1.0.0": { "api_version": 8, "commit_sha": "c26342d", diff --git a/plugins/utilities/manual_camera.py b/plugins/utilities/manual_camera.py index cb944b4..d244795 100644 --- a/plugins/utilities/manual_camera.py +++ b/plugins/utilities/manual_camera.py @@ -1,4 +1,4 @@ -# ba_meta require api 8 +# ba_meta require api 9 ################### # Credits - Droopy#3730. # @@ -10,16 +10,20 @@ from __future__ import annotations import _babase import babase -import bascenev1 as bs import bauiv1 as bui -from bauiv1lib.mainmenu import MainMenuWindow +from bauiv1lib.ingamemenu import InGameMenuWindow -class Manual_camera_window: - def __init__(self): - self._root_widget = bui.containerwidget( - on_outside_click_call=None, - size=(0, 0)) +class Manual_camera_window(bui.MainWindow): + def __init__(self, origin_widget): + super().__init__( + root_widget=bui.containerwidget( + on_outside_click_call=None, + size=(0, 0) + ), + transition='in_scale', + origin_widget=origin_widget, + ) button_size = (50, 50) self._text = bui.textwidget(parent=self._root_widget, scale=0.65, @@ -149,15 +153,10 @@ class Manual_camera_window: button_type='square', autoselect=True, position=(520, -100), - on_activate_call=self._close) + on_activate_call=self.main_window_back) bui.containerwidget(edit=self._root_widget, cancel_button=self._done) - def _close(self): - bui.containerwidget(edit=self._root_widget, - transition=('out_scale')) - MainMenuWindow() - def _change_camera_position(self, direction): camera = _babase.get_camera_position() x = camera[0] @@ -212,7 +211,7 @@ class Manual_camera_window: _babase.set_camera_target(x, y, z) -old_refresh_in_game = MainMenuWindow._refresh_in_game +old_refresh_in_game = InGameMenuWindow._refresh_in_game def my_refresh_in_game(self, *args, **kwargs): @@ -224,19 +223,23 @@ def my_refresh_in_game(self, *args, **kwargs): size=(70, 50), button_type='square', label='Manual\nCamera', - text_scale=1.5, - on_activate_call=self._manual_camera) + text_scale=1.5) + + bui.buttonwidget(edit=camera_button, + on_activate_call=bui.Call(self._manual_camera, camera_button) return value -def _manual_camera(self): - bui.containerwidget(edit=self._root_widget, transition='out_scale') - Manual_camera_window() +def _manual_camera(self, widget): + if not self.main_window_has_control(): + return + + self.main_window_replace(Manual_camera_window(origin_widget=widget)) # ba_meta export plugin class ByDroopy(babase.Plugin): def __init__(self): - MainMenuWindow._refresh_in_game = my_refresh_in_game - MainMenuWindow._manual_camera = _manual_camera + InGameMenuWindow._refresh_in_game = my_refresh_in_game + InGameMenuWindow._manual_camera = _manual_camera \ No newline at end of file