Add otion to ignore the empty install dir warning message

Adds a do not show again checkbox to the empty install dir warning popup on lib start. This only appears when the install dir is empty to prevent mission scripting replacement.

Also adds a warning message to the log when the dir is empty. Will help to identify this in bug reports.
This commit is contained in:
RndName 2022-01-22 13:05:04 +01:00
parent b312242cb8
commit 93a0db3112
No known key found for this signature in database
GPG Key ID: 5EF516FD9537F7C0
2 changed files with 46 additions and 14 deletions

View File

@ -22,6 +22,7 @@ def init():
global __dcs_saved_game_directory
global __dcs_installation_directory
global __last_save_file
global __ignore_empty_install_directory
if PREFERENCES_PATH.exists():
try:
@ -31,14 +32,19 @@ def init():
__dcs_saved_game_directory = pref_data["saved_game_dir"]
__dcs_installation_directory = pref_data["dcs_install_dir"]
__last_save_file = pref_data.get("last_save_file", "")
__ignore_empty_install_directory = pref_data.get(
"ignore_empty_install_directory", False
)
is_first_start = False
except KeyError:
__dcs_saved_game_directory = ""
__dcs_installation_directory = ""
__last_save_file = ""
__ignore_empty_install_directory = False
is_first_start = True
else:
__last_save_file = ""
__ignore_empty_install_directory = False
try:
__dcs_saved_game_directory = (
dcs.installation.get_dcs_saved_games_directory()
@ -76,10 +82,12 @@ def save_config():
global __dcs_saved_game_directory
global __dcs_installation_directory
global __last_save_file
global __ignore_empty_install_directory
pref_data = {
"saved_game_dir": __dcs_saved_game_directory,
"dcs_install_dir": __dcs_installation_directory,
"last_save_file": __last_save_file,
"ignore_empty_install_directory": __ignore_empty_install_directory,
}
PREFERENCES_PATH.parent.mkdir(exist_ok=True, parents=True)
with PREFERENCES_PATH.open("w") as prefs:
@ -96,6 +104,16 @@ def get_saved_game_dir():
return __dcs_saved_game_directory
def ignore_empty_install_directory():
global __ignore_empty_install_directory
return __ignore_empty_install_directory
def set_ignore_empty_install_directory(value: bool):
global __ignore_empty_install_directory
__ignore_empty_install_directory = value
def get_last_save_file():
global __last_save_file
print(__last_save_file)

View File

@ -9,7 +9,7 @@ from typing import Optional
from PySide2 import QtWidgets
from PySide2.QtCore import Qt
from PySide2.QtGui import QPixmap
from PySide2.QtWidgets import QApplication, QSplashScreen
from PySide2.QtWidgets import QApplication, QSplashScreen, QCheckBox
from dcs.payloads import PayloadDirectories
from game import Game, VERSION, persistency
@ -99,20 +99,29 @@ def run_ui(game: Optional[Game]) -> None:
# 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."
"<br/><br/>To solve this problem, you can set the Installation directory "
"within the preferences menu. You can also manually edit or replace the "
"following file:"
"<br/><br/><strong>&lt;dcs_installation_directory&gt;/Scripts/MissionScripting.lua</strong>"
"<br/><br/>The easiest way to do it is to replace the original file with the file in dcs-liberation distribution (&lt;dcs_liberation_installation&gt;/resources/scripts/MissionScripting.lua)."
"<br/><br/>You can find more information on how to manually change this file in the Liberation Wiki (Page: Dedicated Server Guide) on GitHub.</p>",
QtWidgets.QMessageBox.StandardButton.Ok,
logging.warning(
"DCS Installation directory is empty. MissionScripting file will not be replaced!"
)
if not liberation_install.ignore_empty_install_directory():
ignore_checkbox = QCheckBox("Do not show again")
ignore_checkbox.stateChanged.connect(set_ignore_empty_install_directory)
message_box = QtWidgets.QMessageBox(parent=splash)
message_box.setIcon(QtWidgets.QMessageBox.Icon.Warning)
message_box.setWindowTitle("No DCS installation directory.")
message_box.setText(
"The DCS Installation directory is not set correctly. "
"This will prevent DCS Liberation to work properly as the MissionScripting "
"file will not be modified."
"<br/><br/>To solve this problem, you can set the Installation directory "
"within the preferences menu. You can also manually edit or replace the "
"following file:"
"<br/><br/><strong>&lt;dcs_installation_directory&gt;/Scripts/MissionScripting.lua</strong>"
"<br/><br/>The easiest way to do it is to replace the original file with the file in dcs-liberation distribution (&lt;dcs_liberation_installation&gt;/resources/scripts/MissionScripting.lua)."
"<br/><br/>You can find more information on how to manually change this file in the Liberation Wiki (Page: Dedicated Server Guide) on GitHub.</p>"
)
message_box.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
message_box.setCheckBox(ignore_checkbox)
message_box.exec_()
# Replace DCS Mission scripting file to allow DCS Liberation to work
try:
liberation_install.replace_mission_scripting_file()
@ -274,6 +283,11 @@ def create_game(
return game
def set_ignore_empty_install_directory(value: bool) -> None:
liberation_install.set_ignore_empty_install_directory(value)
liberation_install.save_config()
def lint_all_weapon_data() -> None:
for weapon in WeaponGroup.named("Unknown").weapons:
logging.warning(f"No weapon data for {weapon}: {weapon.clsid}")