diff --git a/qt_ui/liberation_install.py b/qt_ui/liberation_install.py index 0bbcb0b0..341cd45a 100644 --- a/qt_ui/liberation_install.py +++ b/qt_ui/liberation_install.py @@ -112,7 +112,7 @@ def replace_mission_scripting_file(): ) liberation_scripting_path = "./resources/scripts/MissionScripting.lua" backup_scripting_path = "./resources/scripts/MissionScripting.original.lua" - if os.path.isfile(mission_scripting_path): + if install_dir != "" and os.path.isfile(mission_scripting_path): with open(mission_scripting_path, "r") as ms: current_file_content = ms.read() with open(liberation_scripting_path, "r") as libe_ms: @@ -133,5 +133,9 @@ def restore_original_mission_scripting(): ) backup_scripting_path = "./resources/scripts/MissionScripting.original.lua" - if os.path.isfile(backup_scripting_path) and os.path.isfile(mission_scripting_path): + if ( + install_dir != "" + and os.path.isfile(backup_scripting_path) + and os.path.isfile(mission_scripting_path) + ): copyfile(backup_scripting_path, mission_scripting_path) diff --git a/qt_ui/main.py b/qt_ui/main.py index 43cf6e53..26c5cb48 100644 --- a/qt_ui/main.py +++ b/qt_ui/main.py @@ -95,6 +95,22 @@ def run_ui(game: Optional[Game]) -> None: uiconstants.load_aircraft_banners() uiconstants.load_vehicle_banners() + # Show warning if no DCS Installation directory was set + if liberation_install.get_dcs_install_directory() == "": + QtWidgets.QMessageBox.warning( + splash, + "No DCS installation directory.", + "The DCS Installation directory is not set correctly. " + "This will prevent DCS Liberation to work properly as the MissionScripting " + "file will not be modified." + "

To solve this problem, you can set the Installation directory " + "within the preferences menu. You can also manually edit or replace the " + "following file:" + "

<dcs_installation_directory>/Scripts/MissionScripting.lua" + "

The easiest way to do it is to replace the original file with the file in dcs-liberation distribution (<dcs_liberation_installation>/resources/scripts/MissionScripting.lua)." + "

You can find more information on how to manually change this file in the Liberation Wiki (Page: Dedicated Server Guide) on GitHub.

", + QtWidgets.QMessageBox.StandardButton.Ok, + ) # Replace DCS Mission scripting file to allow DCS Liberation to work try: liberation_install.replace_mission_scripting_file() diff --git a/qt_ui/windows/preferences/QLiberationFirstStartWindow.py b/qt_ui/windows/preferences/QLiberationFirstStartWindow.py index 4a300f35..78b898a1 100644 --- a/qt_ui/windows/preferences/QLiberationFirstStartWindow.py +++ b/qt_ui/windows/preferences/QLiberationFirstStartWindow.py @@ -58,6 +58,12 @@ class QLiberationFirstStartWindow(QDialog):

As you click on the button below, the file will be replaced in your DCS installation directory.

+
+

If you leave the DCS Installation Directory empty, DCS Liberation can not automatically replace the MissionScripting.lua and will therefore not work correctly! + In this case, you need to edit the file yourself. The easiest way to do it is to replace the original file with the file in dcs-liberation distribution (<dcs_liberation_installation>/resources/scripts/MissionScripting.lua). +

You can find more information on how to manually change this file in the Liberation Wiki (Page: Dedicated Server Guide) on GitHub.

+ +

Thank you for reading ! diff --git a/qt_ui/windows/preferences/QLiberationPreferences.py b/qt_ui/windows/preferences/QLiberationPreferences.py index 0d41b298..fbfa6770 100644 --- a/qt_ui/windows/preferences/QLiberationPreferences.py +++ b/qt_ui/windows/preferences/QLiberationPreferences.py @@ -22,6 +22,7 @@ class QLiberationPreferences(QFrame): super(QLiberationPreferences, self).__init__() self.saved_game_dir = "" self.dcs_install_dir = "" + self.install_dir_ignore_warning = False self.dcs_install_dir = liberation_install.get_dcs_install_directory() self.saved_game_dir = liberation_install.get_saved_game_dir() @@ -102,17 +103,38 @@ class QLiberationPreferences(QFrame): error_dialog.exec_() return False - if not os.path.isdir(self.dcs_install_dir): + if self.install_dir_ignore_warning and self.dcs_install_dir == "": + warning_dialog = QMessageBox.warning( + self, + "The DCS Installation directory was not set", + "You set an empty DCS Installation directory! " + "

Without this directory, DCS Liberation can not replace the MissionScripting.lua for you and will not work properly. " + "In this case, you need to edit the MissionScripting.lua yourself. The easiest way to do it is to replace the original file (<dcs_installation_directory>/Scripts/MissionScripting.lua) with the file in dcs-liberation distribution (<dcs_liberation_installation>/resources/scripts/MissionScripting.lua)." + "

You can find more information on how to manually change this file in the Liberation Wiki (Page: Dedicated Server Guide) on GitHub.

" + "

Are you sure that you want to leave the installation directory empty?" + "

This is only recommended for expert users!", + QMessageBox.StandardButton.Yes, + QMessageBox.StandardButton.No, + ) + if warning_dialog == QMessageBox.No: + return False + elif not os.path.isdir(self.dcs_install_dir): error_dialog = QMessageBox.critical( self, "Wrong DCS installation directory.", - self.dcs_install_dir + " is not a valid directory", + self.dcs_install_dir + + " is not a valid directory. DCS Liberation requires the installation directory to replace the MissionScripting.lua" + "

If you ignore this Error, DCS Liberation can not work properly and needs your attention. " + "In this case, you need to edit the MissionScripting.lua yourself. The easiest way to do it is to replace the original file (<dcs_installation_directory>/Scripts/MissionScripting.lua) with the file in dcs-liberation distribution (<dcs_liberation_installation>/resources/scripts/MissionScripting.lua)." + "

You can find more information on how to manually change this file in the Liberation Wiki (Page: Dedicated Server Guide) on GitHub.

" + "

This is only recommended for expert users!", + QMessageBox.StandardButton.Ignore, QMessageBox.StandardButton.Ok, ) - error_dialog.exec_() + if error_dialog == QMessageBox.Ignore: + self.install_dir_ignore_warning = True return False - - if not os.path.isdir( + elif not os.path.isdir( os.path.join(self.dcs_install_dir, "Scripts") ) and os.path.isfile(os.path.join(self.dcs_install_dir, "bin", "DCS.exe")): error_dialog = QMessageBox.critical(