From 1f8649c24a88de67a29dca79d8b201f05f9bf986 Mon Sep 17 00:00:00 2001 From: themanyfaceddemon Date: Sat, 24 Aug 2024 13:43:17 +0300 Subject: [PATCH] add warning window --- Code/gui/main_app.py | 40 ++++++++++++++--------------- Code/gui/settings.py | 3 +-- Content/Client/loc/rus/main_app.loc | 7 +++-- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Code/gui/main_app.py b/Code/gui/main_app.py index c0188c0..cc644d2 100644 --- a/Code/gui/main_app.py +++ b/Code/gui/main_app.py @@ -1,12 +1,8 @@ import dearpygui.dearpygui as dpg from dearpygui_async import DearPyGuiAsync -from DMBotTools import Coordinate from systems.loc import Localization as loc -from .conntect import ConnectManager from .fonts import FontManager -from .map import MapRenderer -from .settings import SettingsManager class DMClientApp: @@ -18,26 +14,30 @@ def setup(self): FontManager.load_fonts() dpg.create_viewport(title=loc.get_string("main-app-name"), width=600, height=400) dpg.setup_dearpygui() + self.create_warning_window() + + def create_warning_window(self): + with dpg.window(label="Warning", modal=True, tag="warning_window"): + dpg.add_text(loc.get_string("main_text_warning_window")) + dpg.add_button(label=loc.get_string("yes_warning_window"), callback=self.on_yes) + dpg.add_button(label=loc.get_string("no_warning_window"), callback=self.on_no) + + def on_yes(self, sender, app_data): + dpg.delete_item("warning_window") self.create_main_window() - self.map_renderer = MapRenderer() - self.connect_manager = ConnectManager() - - texture_paths = { - Coordinate(0, 0): "path/to/texture1.png", - Coordinate(1, 0): "path/to/texture2.png", - Coordinate(0, 1): "path/to/texture3.png", - Coordinate(1, 1): "path/to/nonexistent_texture.png", - Coordinate(2, 2): "path/to/texture5.png", - } - self.map_renderer.set_texture_paths(texture_paths) - def create_main_window(self): - with dpg.window(label=loc.get_string("main-window-lable")) as main_window: - dpg.add_button(label=loc.get_string("main-window-open-settings-window"), callback=lambda: SettingsManager.create_settings_window()) - dpg.add_button(label=loc.get_string("main-window-open-map-window"), callback=lambda: self.map_renderer.create_map_window()) - dpg.add_button(label=loc.get_string("main-window-open-connect-window"), callback=lambda: self.connect_manager.create_connect_window()) + def on_no(self, sender, app_data): + self.stop() + def create_main_window(self): + with dpg.window(label="Main", tag="main_window"): + pass + def run(self): dpg.show_viewport() self.dpg_async.run() + dpg.start_dearpygui() dpg.destroy_context() + + def stop(self): + dpg.stop_dearpygui() diff --git a/Code/gui/settings.py b/Code/gui/settings.py index 10063f1..d198b6e 100644 --- a/Code/gui/settings.py +++ b/Code/gui/settings.py @@ -2,8 +2,7 @@ class SettingsManager: - @staticmethod - def create_settings_window(): + def create_settings_window(self): if dpg.does_item_exist("settings_window"): dpg.focus_item("settings_window") return diff --git a/Content/Client/loc/rus/main_app.loc b/Content/Client/loc/rus/main_app.loc index 96649ab..9e4b4f7 100644 --- a/Content/Client/loc/rus/main_app.loc +++ b/Content/Client/loc/rus/main_app.loc @@ -1,6 +1,5 @@ main-app-name = DM-Bot Client -main-window-lable = Главное окно. Оно временно -main-window-open-settings-window = Открыть окно настроек -main-window-open-map-window = Открыть окно карты -main-window-open-connect-window = Открыть окно соединения +main_text_warning_window = Внимание! Использование DM-Bot разрешено только для пользователей, достигших 18-летнего возраста. +yes_warning_window = Мне 18 или более лет +no_warning_window = Мне нет 18 лет