mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
multiple changes
- load plugins when loading a game - moved plugins scripts to resources/plugins (for pyinstaller) - removed vanilla JTAC and JTAC_smoke options and settings GUI - call JtacAutolasePlugin in armor.py - made a dictionary of INSTALLED_PLUGINS - removed NIOD from the VEAF plugin
This commit is contained in:
parent
3c4ccd7d57
commit
ec6fc076de
4
.gitignore
vendored
4
.gitignore
vendored
@ -21,5 +21,5 @@ logs/
|
|||||||
qt_ui/logs/liberation.log
|
qt_ui/logs/liberation.log
|
||||||
|
|
||||||
*.psd
|
*.psd
|
||||||
plugin/custom/__plugins.lst
|
resources/plugins/custom/__plugins.lst
|
||||||
plugin/custom/*.lua
|
resources/plugins/custom/*.lua
|
||||||
|
|||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -5,3 +5,6 @@
|
|||||||
[submodule "plugin/veaf"]
|
[submodule "plugin/veaf"]
|
||||||
path = plugin/veaf
|
path = plugin/veaf
|
||||||
url = https://github.com/VEAF/dcs-liberation-veaf-framework
|
url = https://github.com/VEAF/dcs-liberation-veaf-framework
|
||||||
|
[submodule "resources/plugins/veaf"]
|
||||||
|
path = resources/plugins/veaf
|
||||||
|
url = https://github.com/VEAF/dcs-liberation-veaf-framework
|
||||||
|
|||||||
@ -28,6 +28,7 @@ from .event.event import Event, UnitsDeliveryEvent
|
|||||||
from .event.frontlineattack import FrontlineAttackEvent
|
from .event.frontlineattack import FrontlineAttackEvent
|
||||||
from .infos.information import Information
|
from .infos.information import Information
|
||||||
from .settings import Settings
|
from .settings import Settings
|
||||||
|
from plugin import INSTALLED_PLUGINS
|
||||||
|
|
||||||
COMMISION_UNIT_VARIETY = 4
|
COMMISION_UNIT_VARIETY = 4
|
||||||
COMMISION_LIMITS_SCALE = 1.5
|
COMMISION_LIMITS_SCALE = 1.5
|
||||||
@ -217,6 +218,11 @@ class Game:
|
|||||||
|
|
||||||
def on_load(self) -> None:
|
def on_load(self) -> None:
|
||||||
ObjectiveDistanceCache.set_theater(self.theater)
|
ObjectiveDistanceCache.set_theater(self.theater)
|
||||||
|
|
||||||
|
# set the settings in all plugins
|
||||||
|
for pluginName in INSTALLED_PLUGINS:
|
||||||
|
plugin = INSTALLED_PLUGINS[pluginName]
|
||||||
|
plugin.setSettings(self.settings)
|
||||||
|
|
||||||
def pass_turn(self, no_action=False):
|
def pass_turn(self, no_action=False):
|
||||||
logging.info("Pass turn")
|
logging.info("Pass turn")
|
||||||
|
|||||||
@ -148,7 +148,8 @@ class Operation:
|
|||||||
|
|
||||||
if pluginName == None:
|
if pluginName == None:
|
||||||
pluginName = "custom"
|
pluginName = "custom"
|
||||||
plugin_path = Path("./plugin",pluginName)
|
plugin_path = Path("./resources/plugins",pluginName)
|
||||||
|
logging.debug(f"plugin_path = {plugin_path}")
|
||||||
|
|
||||||
if scriptFile != None:
|
if scriptFile != None:
|
||||||
scriptFile_path = Path(plugin_path, scriptFile)
|
scriptFile_path = Path(plugin_path, scriptFile)
|
||||||
@ -468,7 +469,8 @@ dcsLiberation.TargetPoints = {
|
|||||||
# Inject Plugins Lua Scripts and data
|
# Inject Plugins Lua Scripts and data
|
||||||
self.listOfPluginsScripts = []
|
self.listOfPluginsScripts = []
|
||||||
|
|
||||||
for plugin in INSTALLED_PLUGINS:
|
for pluginName in INSTALLED_PLUGINS:
|
||||||
|
plugin = INSTALLED_PLUGINS[pluginName]
|
||||||
plugin.injectScripts(self)
|
plugin.injectScripts(self)
|
||||||
plugin.injectConfiguration(self)
|
plugin.injectConfiguration(self)
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
from plugin import INSTALLED_PLUGINS
|
||||||
|
|
||||||
class Settings:
|
class Settings:
|
||||||
|
|
||||||
@ -24,8 +25,6 @@ class Settings:
|
|||||||
self.sams = True # Legacy parameter do not use
|
self.sams = True # Legacy parameter do not use
|
||||||
self.cold_start = False # Legacy parameter do not use
|
self.cold_start = False # Legacy parameter do not use
|
||||||
self.version = None
|
self.version = None
|
||||||
self.include_jtac_if_available = True
|
|
||||||
self.jtac_smoke_on = True
|
|
||||||
|
|
||||||
# Performance oriented
|
# Performance oriented
|
||||||
self.perf_red_alert_state = True
|
self.perf_red_alert_state = True
|
||||||
@ -42,5 +41,9 @@ class Settings:
|
|||||||
|
|
||||||
# LUA Plugins system
|
# LUA Plugins system
|
||||||
self.plugins = {}
|
self.plugins = {}
|
||||||
|
for pluginName in INSTALLED_PLUGINS:
|
||||||
|
plugin = INSTALLED_PLUGINS[pluginName]
|
||||||
|
plugin.setSettings(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,7 @@ from gen.ground_forces.ai_ground_planner import (
|
|||||||
from .callsigns import callsign_for_support_unit
|
from .callsigns import callsign_for_support_unit
|
||||||
from .conflictgen import Conflict
|
from .conflictgen import Conflict
|
||||||
from .ground_forces.combat_stance import CombatStance
|
from .ground_forces.combat_stance import CombatStance
|
||||||
|
from plugin import INSTALLED_PLUGINS
|
||||||
|
|
||||||
SPREAD_DISTANCE_FACTOR = 0.1, 0.3
|
SPREAD_DISTANCE_FACTOR = 0.1, 0.3
|
||||||
SPREAD_DISTANCE_SIZE_FACTOR = 0.1
|
SPREAD_DISTANCE_SIZE_FACTOR = 0.1
|
||||||
@ -139,7 +140,8 @@ class GroundConflictGenerator:
|
|||||||
self.plan_action_for_groups(self.enemy_stance, enemy_groups, player_groups, self.conflict.heading - 90, self.conflict.to_cp, self.conflict.from_cp)
|
self.plan_action_for_groups(self.enemy_stance, enemy_groups, player_groups, self.conflict.heading - 90, self.conflict.to_cp, self.conflict.from_cp)
|
||||||
|
|
||||||
# Add JTAC
|
# Add JTAC
|
||||||
if "has_jtac" in self.game.player_faction and self.game.player_faction["has_jtac"] and self.game.settings.include_jtac_if_available:
|
useJTAC = INSTALLED_PLUGINS and INSTALLED_PLUGINS["JtacAutolasePlugin"] and INSTALLED_PLUGINS["JtacAutolasePlugin"].isEnabled()
|
||||||
|
if "has_jtac" in self.game.player_faction and self.game.player_faction["has_jtac"] and useJTAC:
|
||||||
n = "JTAC" + str(self.conflict.from_cp.id) + str(self.conflict.to_cp.id)
|
n = "JTAC" + str(self.conflict.from_cp.id) + str(self.conflict.to_cp.id)
|
||||||
code = 1688 - len(self.jtacs)
|
code = 1688 - len(self.jtacs)
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,8 @@ from .veaf_plugin import VeafPlugin
|
|||||||
from .jtacautolase_plugin import JtacAutolasePlugin
|
from .jtacautolase_plugin import JtacAutolasePlugin
|
||||||
from .liberation_plugin import LiberationPlugin
|
from .liberation_plugin import LiberationPlugin
|
||||||
|
|
||||||
INSTALLED_PLUGINS=[
|
INSTALLED_PLUGINS={
|
||||||
VeafPlugin(),
|
"VeafPlugin": VeafPlugin(),
|
||||||
JtacAutolasePlugin(),
|
"JtacAutolasePlugin": JtacAutolasePlugin(),
|
||||||
LiberationPlugin()
|
"LiberationPlugin": LiberationPlugin(),
|
||||||
]
|
}
|
||||||
|
|||||||
@ -15,16 +15,18 @@ class BasePlugin():
|
|||||||
def setupUI(self, settingsWindow, row:int):
|
def setupUI(self, settingsWindow, row:int):
|
||||||
self.settings = settingsWindow.game.settings
|
self.settings = settingsWindow.game.settings
|
||||||
|
|
||||||
if not self.nameInSettings in self.settings.plugins:
|
|
||||||
self.settings.plugins[self.nameInSettings] = self.enabledDefaultValue
|
|
||||||
|
|
||||||
self.uiWidget = QCheckBox()
|
self.uiWidget = QCheckBox()
|
||||||
self.uiWidget.setChecked(self.settings.plugins[self.nameInSettings])
|
self.uiWidget.setChecked(self.isEnabled())
|
||||||
self.uiWidget.toggled.connect(lambda: self.applySetting(settingsWindow))
|
self.uiWidget.toggled.connect(lambda: self.applySetting(settingsWindow))
|
||||||
|
|
||||||
settingsWindow.pluginsGroupLayout.addWidget(QLabel(self.nameInUI), row, 0)
|
settingsWindow.pluginsGroupLayout.addWidget(QLabel(self.nameInUI), row, 0)
|
||||||
settingsWindow.pluginsGroupLayout.addWidget(self.uiWidget, row, 1, Qt.AlignRight)
|
settingsWindow.pluginsGroupLayout.addWidget(self.uiWidget, row, 1, Qt.AlignRight)
|
||||||
|
|
||||||
|
def setSettings(self, settings):
|
||||||
|
self.settings = settings
|
||||||
|
if not self.nameInSettings in self.settings.plugins:
|
||||||
|
self.settings.plugins[self.nameInSettings] = self.enabledDefaultValue
|
||||||
|
|
||||||
def applySetting(self, settingsWindow):
|
def applySetting(self, settingsWindow):
|
||||||
self.settings.plugins[self.nameInSettings] = self.uiWidget.isChecked()
|
self.settings.plugins[self.nameInSettings] = self.uiWidget.isChecked()
|
||||||
self.enabled = self.settings.plugins[self.nameInSettings]
|
self.enabled = self.settings.plugins[self.nameInSettings]
|
||||||
@ -38,4 +40,9 @@ class BasePlugin():
|
|||||||
return self.isEnabled()
|
return self.isEnabled()
|
||||||
|
|
||||||
def isEnabled(self) -> bool:
|
def isEnabled(self) -> bool:
|
||||||
|
if not self.settings:
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.setSettings(self.settings) # create the necessary settings keys if needed
|
||||||
|
|
||||||
return self.settings != None and self.settings.plugins[self.nameInSettings]
|
return self.settings != None and self.settings.plugins[self.nameInSettings]
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class JtacAutolasePlugin(BasePlugin):
|
|||||||
#Allow spawn option
|
#Allow spawn option
|
||||||
nameInUI_useSmoke:str = "JTACs use smoke"
|
nameInUI_useSmoke:str = "JTACs use smoke"
|
||||||
nameInSettings_useSmoke:str = "plugin.jtacAutolase.useSmoke"
|
nameInSettings_useSmoke:str = "plugin.jtacAutolase.useSmoke"
|
||||||
|
enabledDefaultValue_useSmoke:bool = True
|
||||||
|
|
||||||
def setupUI(self, settingsWindow, row:int):
|
def setupUI(self, settingsWindow, row:int):
|
||||||
# call the base method to add the plugin selection checkbox
|
# call the base method to add the plugin selection checkbox
|
||||||
@ -42,6 +43,12 @@ class JtacAutolasePlugin(BasePlugin):
|
|||||||
pluginEnabled = self.uiWidget.isChecked()
|
pluginEnabled = self.uiWidget.isChecked()
|
||||||
self.optionsGroup.setEnabled(pluginEnabled)
|
self.optionsGroup.setEnabled(pluginEnabled)
|
||||||
|
|
||||||
|
def setSettings(self, settings):
|
||||||
|
# call the base method
|
||||||
|
super().setSettings(settings)
|
||||||
|
if not self.nameInSettings_useSmoke in self.settings.plugins:
|
||||||
|
self.settings.plugins[self.nameInSettings_useSmoke] = self.enabledDefaultValue_useSmoke
|
||||||
|
|
||||||
def applySetting(self, settingsWindow):
|
def applySetting(self, settingsWindow):
|
||||||
# call the base method to apply the plugin selection checkbox value
|
# call the base method to apply the plugin selection checkbox value
|
||||||
super().applySetting(settingsWindow)
|
super().applySetting(settingsWindow)
|
||||||
@ -61,7 +68,7 @@ class JtacAutolasePlugin(BasePlugin):
|
|||||||
|
|
||||||
# add a configuration for JTACAutoLase and start lasing for all JTACs
|
# add a configuration for JTACAutoLase and start lasing for all JTACs
|
||||||
smoke = "local smoke = false"
|
smoke = "local smoke = false"
|
||||||
if self.settings.plugins[self.nameInSettings_useSmoke]:
|
if self.isUseSmoke():
|
||||||
smoke = "local smoke = true"
|
smoke = "local smoke = true"
|
||||||
|
|
||||||
lua = smoke + """
|
lua = smoke + """
|
||||||
@ -78,3 +85,11 @@ class JtacAutolasePlugin(BasePlugin):
|
|||||||
|
|
||||||
operation.injectLuaTrigger(lua, "Setting and starting JTACs")
|
operation.injectLuaTrigger(lua, "Setting and starting JTACs")
|
||||||
|
|
||||||
|
def isUseSmoke(self) -> bool:
|
||||||
|
if not self.settings:
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.setSettings(self.settings) # create the necessary settings keys if needed
|
||||||
|
|
||||||
|
return self.settings.plugins[self.nameInSettings_useSmoke]
|
||||||
|
|
||||||
|
|||||||
@ -18,3 +18,6 @@ class LiberationPlugin(BasePlugin):
|
|||||||
def injectConfiguration(self, operation):
|
def injectConfiguration(self, operation):
|
||||||
if super().injectConfiguration(operation):
|
if super().injectConfiguration(operation):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def isEnabled(self) -> bool:
|
||||||
|
return True # mandatory plugin
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class VeafPlugin(BasePlugin):
|
|||||||
operation.injectPluginScript("veaf", "src\\scripts\\mist.lua", "mist")
|
operation.injectPluginScript("veaf", "src\\scripts\\mist.lua", "mist")
|
||||||
operation.injectPluginScript("veaf", "src\\scripts\\Moose.lua", "moose")
|
operation.injectPluginScript("veaf", "src\\scripts\\Moose.lua", "moose")
|
||||||
operation.injectPluginScript("veaf", "src\\scripts\\CTLD.lua", "ctld")
|
operation.injectPluginScript("veaf", "src\\scripts\\CTLD.lua", "ctld")
|
||||||
operation.injectPluginScript("veaf", "src\\scripts\\NIOD.lua", "niod")
|
#operation.injectPluginScript("veaf", "src\\scripts\\NIOD.lua", "niod")
|
||||||
operation.injectPluginScript("veaf", "src\\scripts\\WeatherMark.lua", "weathermark")
|
operation.injectPluginScript("veaf", "src\\scripts\\WeatherMark.lua", "weathermark")
|
||||||
operation.injectPluginScript("veaf", "src\\scripts\\veaf.lua", "veaf")
|
operation.injectPluginScript("veaf", "src\\scripts\\veaf.lua", "veaf")
|
||||||
operation.injectPluginScript("veaf", "src\\scripts\\dcsUnits.lua", "dcsunits")
|
operation.injectPluginScript("veaf", "src\\scripts\\dcsUnits.lua", "dcsunits")
|
||||||
|
|||||||
@ -183,28 +183,10 @@ class QSettingsWindow(QDialog):
|
|||||||
self.generate_marks.setChecked(self.game.settings.generate_marks)
|
self.generate_marks.setChecked(self.game.settings.generate_marks)
|
||||||
self.generate_marks.toggled.connect(self.applySettings)
|
self.generate_marks.toggled.connect(self.applySettings)
|
||||||
|
|
||||||
|
|
||||||
if not hasattr(self.game.settings, "include_jtac_if_available"):
|
|
||||||
self.game.settings.include_jtac_if_available = True
|
|
||||||
if not hasattr(self.game.settings, "jtac_smoke_on"):
|
|
||||||
self.game.settings.jtac_smoke_on= True
|
|
||||||
|
|
||||||
self.include_jtac_if_available = QCheckBox()
|
|
||||||
self.include_jtac_if_available.setChecked(self.game.settings.include_jtac_if_available)
|
|
||||||
self.include_jtac_if_available.toggled.connect(self.applySettings)
|
|
||||||
|
|
||||||
self.jtac_smoke_on = QCheckBox()
|
|
||||||
self.jtac_smoke_on.setChecked(self.game.settings.jtac_smoke_on)
|
|
||||||
self.jtac_smoke_on.toggled.connect(self.applySettings)
|
|
||||||
|
|
||||||
self.gameplayLayout.addWidget(QLabel("Use Supercarrier Module"), 0, 0)
|
self.gameplayLayout.addWidget(QLabel("Use Supercarrier Module"), 0, 0)
|
||||||
self.gameplayLayout.addWidget(self.supercarrier, 0, 1, Qt.AlignRight)
|
self.gameplayLayout.addWidget(self.supercarrier, 0, 1, Qt.AlignRight)
|
||||||
self.gameplayLayout.addWidget(QLabel("Put Objective Markers on Map"), 1, 0)
|
self.gameplayLayout.addWidget(QLabel("Put Objective Markers on Map"), 1, 0)
|
||||||
self.gameplayLayout.addWidget(self.generate_marks, 1, 1, Qt.AlignRight)
|
self.gameplayLayout.addWidget(self.generate_marks, 1, 1, Qt.AlignRight)
|
||||||
self.gameplayLayout.addWidget(QLabel("Include JTAC (If available)"), 2, 0)
|
|
||||||
self.gameplayLayout.addWidget(self.include_jtac_if_available, 2, 1, Qt.AlignRight)
|
|
||||||
self.gameplayLayout.addWidget(QLabel("Enable JTAC smoke markers"), 3, 0)
|
|
||||||
self.gameplayLayout.addWidget(self.jtac_smoke_on, 3, 1, Qt.AlignRight)
|
|
||||||
|
|
||||||
self.performance = QGroupBox("Performance")
|
self.performance = QGroupBox("Performance")
|
||||||
self.performanceLayout = QGridLayout()
|
self.performanceLayout = QGridLayout()
|
||||||
@ -315,7 +297,8 @@ class QSettingsWindow(QDialog):
|
|||||||
self.pluginsGroup.setLayout(self.pluginsGroupLayout)
|
self.pluginsGroup.setLayout(self.pluginsGroupLayout)
|
||||||
|
|
||||||
row:int = 0
|
row:int = 0
|
||||||
for plugin in INSTALLED_PLUGINS:
|
for pluginName in INSTALLED_PLUGINS:
|
||||||
|
plugin = INSTALLED_PLUGINS[pluginName]
|
||||||
plugin.setupUI(self, row)
|
plugin.setupUI(self, row)
|
||||||
row = row + 1
|
row = row + 1
|
||||||
|
|
||||||
@ -342,8 +325,6 @@ class QSettingsWindow(QDialog):
|
|||||||
self.game.settings.map_coalition_visibility = self.mapVisibiitySelection.currentData()
|
self.game.settings.map_coalition_visibility = self.mapVisibiitySelection.currentData()
|
||||||
self.game.settings.external_views_allowed = self.ext_views.isChecked()
|
self.game.settings.external_views_allowed = self.ext_views.isChecked()
|
||||||
self.game.settings.generate_marks = self.generate_marks.isChecked()
|
self.game.settings.generate_marks = self.generate_marks.isChecked()
|
||||||
self.game.settings.include_jtac_if_available = self.include_jtac_if_available.isChecked()
|
|
||||||
self.game.settings.jtac_smoke_on = self.jtac_smoke_on.isChecked()
|
|
||||||
|
|
||||||
print(self.game.settings.map_coalition_visibility)
|
print(self.game.settings.map_coalition_visibility)
|
||||||
|
|
||||||
|
|||||||
BIN
resources/plugins/doc/0.png
Normal file
BIN
resources/plugins/doc/0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
BIN
resources/plugins/doc/1.png
Normal file
BIN
resources/plugins/doc/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
BIN
resources/plugins/doc/2.png
Normal file
BIN
resources/plugins/doc/2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Loading…
x
Reference in New Issue
Block a user