mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Add a plugins page to the NGW.
This commit is contained in:
parent
77f1706cbb
commit
081c97583b
@ -16,6 +16,7 @@ Saves from 6.x are not compatible with 7.0.
|
||||
* **[Modding]** Campaigns which require custom factions can now define those factions directly in the campaign YAML. See Operation Aliied Sword for an example.
|
||||
* **[Modding]** The `mission_types` field in squadron files has been removed. Squadron task capability is now determined by airframe, and the auto-assignable list has always been overridden by the campaign settings.
|
||||
* **[New Game Wizard]** Some game settings are now saved to be reused for the next game. At present this is a small set (just supercarrier and auto-purchase), but it will be expanded later.
|
||||
* **[New Game Wizard]** Lua plugins can now be set while creating a new game.
|
||||
* **[Squadrons]** Squadron-specific mission capability lists no longer restrict players from assigning missions outside the squadron's preferences.
|
||||
|
||||
## Fixes
|
||||
|
||||
@ -75,6 +75,7 @@ class GameGenerator:
|
||||
settings: Settings,
|
||||
generator_settings: GeneratorSettings,
|
||||
mod_settings: ModSettings,
|
||||
lua_plugin_manager: LuaPluginManager,
|
||||
) -> None:
|
||||
self.player = player
|
||||
self.enemy = enemy
|
||||
@ -84,6 +85,7 @@ class GameGenerator:
|
||||
self.generator_settings = generator_settings
|
||||
self.player.apply_mod_settings(mod_settings)
|
||||
self.enemy.apply_mod_settings(mod_settings)
|
||||
self.lua_plugin_manager = lua_plugin_manager
|
||||
|
||||
def generate(self) -> Game:
|
||||
with logged_duration("TGO population"):
|
||||
@ -98,8 +100,7 @@ class GameGenerator:
|
||||
start_date=self.generator_settings.start_date,
|
||||
start_time=self.generator_settings.start_time,
|
||||
settings=self.settings,
|
||||
# TODO: Hoist into NGW so we can expose those options.
|
||||
lua_plugin_manager=LuaPluginManager.load(),
|
||||
lua_plugin_manager=self.lua_plugin_manager,
|
||||
player_budget=self.generator_settings.player_budget,
|
||||
enemy_budget=self.generator_settings.enemy_budget,
|
||||
)
|
||||
|
||||
@ -6,12 +6,21 @@ from typing import List
|
||||
|
||||
from PySide6 import QtGui, QtWidgets
|
||||
from PySide6.QtCore import QDate, QItemSelectionModel, QPoint, Qt, Signal
|
||||
from PySide6.QtWidgets import QCheckBox, QLabel, QTextEdit, QVBoxLayout
|
||||
from PySide6.QtWidgets import (
|
||||
QCheckBox,
|
||||
QLabel,
|
||||
QScrollArea,
|
||||
QTextEdit,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
|
||||
from game.campaignloader.campaign import Campaign, DEFAULT_BUDGET
|
||||
from game.factions import Faction
|
||||
from game.factions.factions import Factions
|
||||
from game.plugins import LuaPlugin, LuaPluginManager
|
||||
from game.plugins.luaplugin import LuaPluginOption
|
||||
from game.settings import Settings
|
||||
from game.theater.start_generator import GameGenerator, GeneratorSettings, ModSettings
|
||||
from qt_ui.widgets.QLiberationCalendar import QLiberationCalendar
|
||||
@ -87,6 +96,8 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
default_settings = Settings()
|
||||
default_settings.merge_player_settings()
|
||||
|
||||
self.lua_plugin_manager = LuaPluginManager.load()
|
||||
|
||||
factions = Factions.load()
|
||||
|
||||
self.campaigns = list(sorted(Campaign.load_each(), key=lambda x: x.name))
|
||||
@ -100,12 +111,14 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
self.addPage(self.faction_selection_page)
|
||||
self.addPage(GeneratorOptions(default_settings))
|
||||
self.difficulty_page = DifficultyAndAutomationOptions(default_settings)
|
||||
self.plugins_page = PluginsPage(self.lua_plugin_manager)
|
||||
|
||||
# Update difficulty page on campaign select
|
||||
self.theater_page.campaign_selected.connect(
|
||||
lambda c: self.difficulty_page.set_campaign_values(c)
|
||||
)
|
||||
self.addPage(self.difficulty_page)
|
||||
self.addPage(self.plugins_page)
|
||||
self.addPage(ConclusionPage())
|
||||
|
||||
self.setPixmap(
|
||||
@ -197,6 +210,7 @@ class NewGameWizard(QtWidgets.QWizard):
|
||||
settings,
|
||||
generator_settings,
|
||||
mod_settings,
|
||||
self.lua_plugin_manager,
|
||||
)
|
||||
self.generatedGame = generator.generate()
|
||||
|
||||
@ -618,6 +632,78 @@ class DifficultyAndAutomationOptions(QtWidgets.QWizardPage):
|
||||
)
|
||||
|
||||
|
||||
class PluginOptionCheckbox(QCheckBox):
|
||||
def __init__(self, option: LuaPluginOption) -> None:
|
||||
super().__init__(option.name)
|
||||
self.option = option
|
||||
self.setChecked(self.option.enabled)
|
||||
self.toggled.connect(self.on_toggle)
|
||||
|
||||
def on_toggle(self, enabled: bool) -> None:
|
||||
self.option.enabled = enabled
|
||||
|
||||
|
||||
class PluginGroupBox(QtWidgets.QGroupBox):
|
||||
def __init__(self, plugin: LuaPlugin) -> None:
|
||||
super().__init__(plugin.name)
|
||||
self.plugin = plugin
|
||||
|
||||
self.setCheckable(True)
|
||||
self.setChecked(self.plugin.enabled)
|
||||
self.toggled.connect(self.on_toggle)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
self.setLayout(layout)
|
||||
|
||||
self.checkboxes = []
|
||||
for option in self.plugin.options:
|
||||
checkbox = PluginOptionCheckbox(option)
|
||||
checkbox.setEnabled(self.plugin.enabled)
|
||||
layout.addWidget(checkbox)
|
||||
self.checkboxes.append(checkbox)
|
||||
|
||||
if not self.plugin.options:
|
||||
layout.addWidget(QLabel("Plugin has no settings."))
|
||||
|
||||
def on_toggle(self, enabled: bool) -> None:
|
||||
self.plugin.enabled = enabled
|
||||
for checkbox in self.checkboxes:
|
||||
checkbox.setEnabled(enabled)
|
||||
|
||||
|
||||
class PluginsPage(QtWidgets.QWizardPage):
|
||||
def __init__(self, lua_plugins_manager: LuaPluginManager, parent=None) -> None:
|
||||
super().__init__(parent)
|
||||
self.lua_plugins_manager = lua_plugins_manager
|
||||
|
||||
self.setTitle("Plugins")
|
||||
self.setSubTitle("Enable plugins with the checkbox next to their name")
|
||||
self.setPixmap(
|
||||
QtWidgets.QWizard.LogoPixmap,
|
||||
QtGui.QPixmap("./resources/ui/wizard/logo1.png"),
|
||||
)
|
||||
|
||||
main_layout = QVBoxLayout()
|
||||
self.setLayout(main_layout)
|
||||
|
||||
scroll_content = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
scroll_content.setLayout(layout)
|
||||
scroll = QScrollArea()
|
||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setWidget(scroll_content)
|
||||
main_layout.addWidget(scroll)
|
||||
|
||||
self.group_boxes = []
|
||||
for plugin in self.lua_plugins_manager.iter_plugins():
|
||||
if plugin.show_in_ui:
|
||||
group_box = PluginGroupBox(plugin)
|
||||
layout.addWidget(group_box)
|
||||
self.group_boxes.append(group_box)
|
||||
|
||||
|
||||
class GeneratorOptions(QtWidgets.QWizardPage):
|
||||
def __init__(self, default_settings: Settings, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user