mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
New Game Wizard with Qt UI
This commit is contained in:
parent
b66bf4cc36
commit
dc91f5004e
125
game/db.py
125
game/db.py
@ -99,6 +99,10 @@ PRICES = {
|
||||
E_3A: 8,
|
||||
C_130: 8,
|
||||
|
||||
# WW2
|
||||
P_51D_30_NA: 3,
|
||||
P_51D: 3,
|
||||
|
||||
# armor
|
||||
Armor.APC_MTLB: 4,
|
||||
Armor.ARV_MTLB_U_BOMAN: 5,
|
||||
@ -187,9 +191,12 @@ UNIT_BY_TASK = {
|
||||
F_14B,
|
||||
F_16C_bl_52d,
|
||||
M_2000C,
|
||||
Mirage_2000_5
|
||||
Mirage_2000_5,
|
||||
P_51D_30_NA,
|
||||
P_51D
|
||||
],
|
||||
CAS: [
|
||||
F_86F_Sabre,
|
||||
MiG_15bis,
|
||||
MiG_19P,
|
||||
L_39ZA,
|
||||
@ -379,76 +386,46 @@ country : DCS Country name
|
||||
|
||||
"""
|
||||
FACTIONS = {
|
||||
"Russia 2010": {
|
||||
"country": "Russia",
|
||||
"side":"red",
|
||||
"units": [
|
||||
AJS37,
|
||||
MiG_23MLD,
|
||||
Su_25,
|
||||
Su_27,
|
||||
Su_33,
|
||||
MiG_21Bis,
|
||||
MiG_29A,
|
||||
MiG_29S,
|
||||
|
||||
Su_25T,
|
||||
Su_34,
|
||||
Su_24MR,
|
||||
L_39ZA,
|
||||
"Russia 1955": {
|
||||
"country": "Russia",
|
||||
"side": "red",
|
||||
"units": [
|
||||
MiG_15bis,
|
||||
|
||||
IL_76MD,
|
||||
IL_78M,
|
||||
An_26B,
|
||||
An_30M,
|
||||
Yak_40,
|
||||
A_50,
|
||||
|
||||
Ka_50,
|
||||
SA342M,
|
||||
UH_1H,
|
||||
Mi_8MT,
|
||||
|
||||
AirDefence.SPAAA_ZSU_23_4_Shilka,
|
||||
AirDefence.SAM_SA_9_Strela_1_9P31,
|
||||
AirDefence.SAM_SA_8_Osa_9A33,
|
||||
AirDefence.AAA_ZU_23_Closed,
|
||||
AirDefence.SAM_SA_19_Tunguska_2S6,
|
||||
AirDefence.SAM_SA_6_Kub_LN_2P25,
|
||||
AirDefence.SAM_SA_3_S_125_LN_5P73,
|
||||
AirDefence.SAM_SA_11_Buk_LN_9A310M1,
|
||||
|
||||
Armor.APC_BTR_80,
|
||||
Armor.MBT_T_90,
|
||||
Armor.MBT_T_80U,
|
||||
Armor.MBT_T_72B,
|
||||
|
||||
Armor.ARV_BRDM_2,
|
||||
Armor.ARV_MTLB_U_BOMAN,
|
||||
Armor.APC_MTLB,
|
||||
Armor.MBT_T_55,
|
||||
|
||||
Unarmed.Transport_Ural_375,
|
||||
Unarmed.Transport_UAZ_469,
|
||||
Infantry.Soldier_AK,
|
||||
|
||||
CV_1143_5_Admiral_Kuznetsov,
|
||||
Bulk_cargo_ship_Yakushev,
|
||||
Dry_cargo_ship_Ivanov,
|
||||
Tanker_Elnya_160,
|
||||
Tanker_Elnya_160
|
||||
]
|
||||
},
|
||||
|
||||
"Russia 1988": {
|
||||
"Russia 1965": {
|
||||
"country": "Russia",
|
||||
"side": "red",
|
||||
"units": [
|
||||
|
||||
MiG_23MLD,
|
||||
MiG_25PD,
|
||||
MiG_29A,
|
||||
MiG_29S,
|
||||
MiG_31,
|
||||
Su_27,
|
||||
|
||||
Su_24M,
|
||||
Su_24MR,
|
||||
Su_25,
|
||||
MiG_15bis,
|
||||
MiG_19P,
|
||||
MiG_21Bis,
|
||||
|
||||
IL_76MD,
|
||||
IL_78M,
|
||||
@ -459,7 +436,6 @@ FACTIONS = {
|
||||
A_50,
|
||||
|
||||
Mi_8MT,
|
||||
Mi_24V,
|
||||
|
||||
AirDefence.AAA_ZU_23_Closed,
|
||||
AirDefence.SAM_SA_6_Kub_LN_2P25,
|
||||
@ -467,6 +443,7 @@ FACTIONS = {
|
||||
|
||||
Armor.ARV_BRDM_2,
|
||||
Armor.APC_BTR_80,
|
||||
Armor.ARV_BTR_RD,
|
||||
Armor.IFV_BMD_1,
|
||||
Armor.IFV_BMP_1,
|
||||
Armor.MBT_T_55,
|
||||
@ -528,13 +505,21 @@ FACTIONS = {
|
||||
]
|
||||
},
|
||||
|
||||
"Russia 1965": {
|
||||
"Russia 1988": {
|
||||
"country": "Russia",
|
||||
"side": "red",
|
||||
"units": [
|
||||
MiG_15bis,
|
||||
MiG_19P,
|
||||
MiG_21Bis,
|
||||
|
||||
MiG_23MLD,
|
||||
MiG_25PD,
|
||||
MiG_29A,
|
||||
MiG_29S,
|
||||
MiG_31,
|
||||
Su_27,
|
||||
|
||||
Su_24M,
|
||||
Su_24MR,
|
||||
Su_25,
|
||||
|
||||
IL_76MD,
|
||||
IL_78M,
|
||||
@ -545,6 +530,7 @@ FACTIONS = {
|
||||
A_50,
|
||||
|
||||
Mi_8MT,
|
||||
Mi_24V,
|
||||
|
||||
AirDefence.AAA_ZU_23_Closed,
|
||||
AirDefence.SAM_SA_6_Kub_LN_2P25,
|
||||
@ -552,7 +538,6 @@ FACTIONS = {
|
||||
|
||||
Armor.ARV_BRDM_2,
|
||||
Armor.APC_BTR_80,
|
||||
Armor.ARV_BTR_RD,
|
||||
Armor.IFV_BMD_1,
|
||||
Armor.IFV_BMP_1,
|
||||
Armor.MBT_T_55,
|
||||
@ -568,35 +553,53 @@ FACTIONS = {
|
||||
]
|
||||
},
|
||||
|
||||
"Russia 1955": {
|
||||
"Russia 2010": {
|
||||
"country": "Russia",
|
||||
"side": "red",
|
||||
"side":"red",
|
||||
"units": [
|
||||
MiG_15bis,
|
||||
AJS37,
|
||||
MiG_23MLD,
|
||||
Su_25,
|
||||
Su_27,
|
||||
Su_33,
|
||||
MiG_29S,
|
||||
|
||||
Su_25T,
|
||||
Su_34,
|
||||
Su_24MR,
|
||||
L_39ZA,
|
||||
|
||||
IL_76MD,
|
||||
IL_78M,
|
||||
An_26B,
|
||||
An_30M,
|
||||
Yak_40,
|
||||
A_50,
|
||||
|
||||
Ka_50,
|
||||
Mi_8MT,
|
||||
|
||||
AirDefence.SPAAA_ZSU_23_4_Shilka,
|
||||
AirDefence.SAM_SA_9_Strela_1_9P31,
|
||||
AirDefence.SAM_SA_8_Osa_9A33,
|
||||
AirDefence.AAA_ZU_23_Closed,
|
||||
AirDefence.SAM_SA_19_Tunguska_2S6,
|
||||
AirDefence.SAM_SA_6_Kub_LN_2P25,
|
||||
AirDefence.SAM_SA_3_S_125_LN_5P73,
|
||||
AirDefence.SAM_SA_11_Buk_LN_9A310M1,
|
||||
|
||||
Armor.ARV_BRDM_2,
|
||||
Armor.ARV_MTLB_U_BOMAN,
|
||||
Armor.APC_MTLB,
|
||||
Armor.MBT_T_55,
|
||||
Armor.APC_BTR_80,
|
||||
Armor.MBT_T_90,
|
||||
Armor.MBT_T_80U,
|
||||
Armor.MBT_T_72B,
|
||||
|
||||
Unarmed.Transport_Ural_375,
|
||||
Unarmed.Transport_UAZ_469,
|
||||
Infantry.Soldier_AK,
|
||||
|
||||
CV_1143_5_Admiral_Kuznetsov,
|
||||
Bulk_cargo_ship_Yakushev,
|
||||
Dry_cargo_ship_Ivanov,
|
||||
Tanker_Elnya_160
|
||||
Tanker_Elnya_160,
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
@ -86,10 +86,6 @@ PLAYER_BUDGET_BASE = 14
|
||||
PLAYER_BUDGET_IMPORTANCE_LOG = 2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Game:
|
||||
settings = None # type: Settings
|
||||
budget = PLAYER_BUDGET_INITIAL
|
||||
|
||||
@ -14,7 +14,7 @@ if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# Splash screen setup
|
||||
pixmap = QPixmap("../resources/ui/splash_screen.png")
|
||||
pixmap = QPixmap("./resources/ui/splash_screen.png")
|
||||
splash = QSplashScreen(pixmap)
|
||||
splash.show()
|
||||
|
||||
|
||||
@ -36,18 +36,22 @@ ICONS: Dict[str, QPixmap] = {}
|
||||
|
||||
def load_icons():
|
||||
|
||||
ICONS["New"] = QPixmap("../resources/ui/misc/new.png")
|
||||
ICONS["Open"] = QPixmap("../resources/ui/misc/open.png")
|
||||
ICONS["Save"] = QPixmap("../resources/ui/misc/save.png")
|
||||
ICONS["New"] = QPixmap("./resources/ui/misc/new.png")
|
||||
ICONS["Open"] = QPixmap("./resources/ui/misc/open.png")
|
||||
ICONS["Save"] = QPixmap("./resources/ui/misc/save.png")
|
||||
|
||||
ICONS["Dawn"] = QPixmap("../resources/ui/daytime/dawn.png")
|
||||
ICONS["Day"] = QPixmap("../resources/ui/daytime/day.png")
|
||||
ICONS["Dusk"] = QPixmap("../resources/ui/daytime/dusk.png")
|
||||
ICONS["Night"] = QPixmap("../resources/ui/daytime/night.png")
|
||||
ICONS["Money"] = QPixmap("../resources/ui/misc/money_icon.png")
|
||||
ICONS["Ordnance"] = QPixmap("../resources/ui/misc/ordnance_icon.png")
|
||||
ICONS["Terrain_Caucasus"] = QPixmap("./resources/ui/terrain_caucasus.gif")
|
||||
ICONS["Terrain_Persian_Gulf"] = QPixmap("./resources/ui/terrain_pg.gif")
|
||||
ICONS["Terrain_Nevada"] = QPixmap("./resources/ui/terrain_nevada.gif")
|
||||
|
||||
ICONS["target"] = QPixmap("../resources/ui/ground_assets/target.png")
|
||||
ICONS["cleared"] = QPixmap("../resources/ui/ground_assets/cleared.png")
|
||||
ICONS["Dawn"] = QPixmap("./resources/ui/daytime/dawn.png")
|
||||
ICONS["Day"] = QPixmap("./resources/ui/daytime/day.png")
|
||||
ICONS["Dusk"] = QPixmap("./resources/ui/daytime/dusk.png")
|
||||
ICONS["Night"] = QPixmap("./resources/ui/daytime/night.png")
|
||||
ICONS["Money"] = QPixmap("./resources/ui/misc/money_icon.png")
|
||||
ICONS["Ordnance"] = QPixmap("./resources/ui/misc/ordnance_icon.png")
|
||||
|
||||
ICONS["target"] = QPixmap("./resources/ui/ground_assets/target.png")
|
||||
ICONS["cleared"] = QPixmap("./resources/ui/ground_assets/cleared.png")
|
||||
for category in CATEGORY_MAP.keys():
|
||||
ICONS[category] = QPixmap("../resources/ui/ground_assets/" + category + ".png")
|
||||
ICONS[category] = QPixmap("./resources/ui/ground_assets/" + category + ".png")
|
||||
|
||||
@ -27,7 +27,7 @@ class QLiberationMap(QGraphicsView):
|
||||
"ally_sam_ranges": True
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, game: Game):
|
||||
super(QLiberationMap, self).__init__()
|
||||
QLiberationMap.instance = self
|
||||
|
||||
@ -37,7 +37,6 @@ class QLiberationMap(QGraphicsView):
|
||||
self.setMaximumHeight(2160)
|
||||
self._zoom = 0
|
||||
self.init_scene()
|
||||
game = persistency.restore_game()
|
||||
self.loadGame(game)
|
||||
|
||||
def init_scene(self):
|
||||
@ -58,10 +57,13 @@ class QLiberationMap(QGraphicsView):
|
||||
scene = self.scene()
|
||||
self.reload_scene()
|
||||
|
||||
def setGame(self, game: Game):
|
||||
self.loadGame(game)
|
||||
|
||||
def reload_scene(self):
|
||||
scene = self.scene()
|
||||
scene.clear()
|
||||
scene.addPixmap(QPixmap("../resources/" + self.game.theater.overview_image))
|
||||
scene.addPixmap(QPixmap("./resources/" + self.game.theater.overview_image))
|
||||
for cp in self.game.theater.controlpoints:
|
||||
|
||||
pos = self._transform_point(cp.position)
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
from PySide2.QtGui import QIcon
|
||||
from PySide2.QtWidgets import QWidget, QPushButton, QHBoxLayout, QVBoxLayout, QMenuBar, QMainWindow, QAction, QToolBar
|
||||
from PySide2.QtWidgets import QWidget, QPushButton, QHBoxLayout, QVBoxLayout, QMenuBar, QMainWindow, QAction, QToolBar, \
|
||||
QFrame
|
||||
import webbrowser
|
||||
|
||||
from qt_ui.uiconstants import URLS
|
||||
from qt_ui.windows.QLiberationMap import QLiberationMap
|
||||
import qt_ui.uiconstants as CONST
|
||||
from qt_ui.windows.QNewGameWizard import NewGameWizard
|
||||
from userdata import persistency
|
||||
from game import Game
|
||||
|
||||
class QLiberationWindow(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
super(QLiberationWindow, self).__init__()
|
||||
self.game = persistency.restore_game()
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
@ -18,44 +23,50 @@ class QLiberationWindow(QMainWindow):
|
||||
self.setWindowTitle("DCS Liberation")
|
||||
self.setWindowIcon(QIcon("../resources/icon.png"))
|
||||
self.statusBar().showMessage('Ready')
|
||||
|
||||
|
||||
self.initActions()
|
||||
self.init_menubar()
|
||||
self.init_toolbar()
|
||||
|
||||
okButton = QPushButton("OK")
|
||||
cancelButton = QPushButton("Cancel")
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addStretch(1)
|
||||
"""hbox.addWidget(okButton)
|
||||
hbox.addWidget(cancelButton)"""
|
||||
|
||||
self.liberation_map = QLiberationMap()
|
||||
|
||||
self.liberation_map = QLiberationMap(self.game)
|
||||
hbox.addWidget(self.liberation_map)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
vbox.addStretch(1)
|
||||
vbox.setMargin(0)
|
||||
frame = QFrame()
|
||||
frame.setFrameShape(frame.Box)
|
||||
vbox.addWidget(frame)
|
||||
vbox.addLayout(hbox)
|
||||
|
||||
central_widget = QWidget()
|
||||
central_widget.setLayout(vbox)
|
||||
self.setCentralWidget(central_widget)
|
||||
|
||||
def initActions(self):
|
||||
self.newGameAction = QAction("New Game", self)
|
||||
self.newGameAction.setIcon(QIcon(CONST.ICONS["New"]))
|
||||
self.newGameAction.triggered.connect(self.newGame)
|
||||
|
||||
self.saveGameAction = QAction("Save", self)
|
||||
self.saveGameAction.setIcon(QIcon(CONST.ICONS["Save"]))
|
||||
self.saveGameAction.triggered.connect(self.saveGame)
|
||||
|
||||
def init_toolbar(self):
|
||||
self.tool_bar = self.addToolBar("File")
|
||||
self.tool_bar.addAction(QIcon(CONST.ICONS["New"]), "New")
|
||||
self.tool_bar.addAction(self.newGameAction)
|
||||
self.tool_bar.addAction(QIcon(CONST.ICONS["Open"]), "Open")
|
||||
self.tool_bar.addAction(QIcon(CONST.ICONS["Save"]), "Save")
|
||||
|
||||
self.tool_bar.addAction(self.saveGameAction)
|
||||
|
||||
def init_menubar(self):
|
||||
self.menu = self.menuBar()
|
||||
|
||||
file_menu = self.menu.addMenu("File")
|
||||
file_menu.addAction(QIcon(CONST.ICONS["New"]), "New Game")
|
||||
file_menu.addAction(self.newGameAction)
|
||||
file_menu.addAction(QIcon(CONST.ICONS["Open"]), "Open")
|
||||
file_menu.addAction(QIcon(CONST.ICONS["Save"]), "Save")
|
||||
file_menu.addAction(self.saveGameAction)
|
||||
file_menu.addAction("Save As")
|
||||
|
||||
help_menu = self.menu.addMenu("Help")
|
||||
@ -87,3 +98,16 @@ class QLiberationWindow(QMainWindow):
|
||||
displayMenu.addAction(tg_go_visibility)
|
||||
displayMenu.addAction(tg_cp_visibility)
|
||||
displayMenu.addAction(tg_line_visibility)
|
||||
|
||||
def newGame(self):
|
||||
wizard = NewGameWizard(self)
|
||||
wizard.show()
|
||||
wizard.accepted.connect(lambda : self.setGame(wizard.generatedGame))
|
||||
|
||||
def saveGame(self):
|
||||
print("Saving game")
|
||||
persistency.save_game(self.game)
|
||||
|
||||
def setGame(self, game: Game):
|
||||
self.game = game
|
||||
self.liberation_map.setGame(game)
|
||||
|
||||
282
qt_ui/windows/QNewGameWizard.py
Normal file
282
qt_ui/windows/QNewGameWizard.py
Normal file
@ -0,0 +1,282 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from PySide2 import QtGui, QtWidgets
|
||||
from dcs.task import CAP, CAS
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game import db, Game
|
||||
from theater import start_generator, persiangulf, nevada, caucasus, ConflictTheater
|
||||
from userdata.logging import version_string
|
||||
|
||||
|
||||
class NewGameWizard(QtWidgets.QWizard):
|
||||
def __init__(self, parent=None):
|
||||
super(NewGameWizard, self).__init__(parent)
|
||||
|
||||
self.addPage(IntroPage())
|
||||
self.addPage(FactionSelection())
|
||||
self.addPage(TheaterConfiguration())
|
||||
self.addPage(MiscOptions())
|
||||
self.addPage(ConclusionPage())
|
||||
|
||||
self.setPixmap(QtWidgets.QWizard.WatermarkPixmap,
|
||||
QtGui.QPixmap('./resources/ui/wizard/watermark1.png'))
|
||||
self.setWizardStyle(QtWidgets.QWizard.ModernStyle)
|
||||
|
||||
self.setWindowTitle("New Game")
|
||||
self.generatedGame = None
|
||||
|
||||
def accept(self):
|
||||
blueFaction = [c for c in db.FACTIONS if db.FACTIONS[c]["side"] == "blue"][self.field("blueFaction")]
|
||||
redFaction = [c for c in db.FACTIONS if db.FACTIONS[c]["side"] == "red"][self.field("redFaction")]
|
||||
playerIsBlue = self.field("playerIsBlue")
|
||||
isTerrainPg = self.field("isTerrainPg")
|
||||
isTerrainNttr = self.field("isTerrainNttr")
|
||||
timePeriod = db.TIME_PERIODS[list(db.TIME_PERIODS.keys())[self.field("timePeriod")]]
|
||||
sams = self.field("sams")
|
||||
midGame = self.field("midGame")
|
||||
multiplier = self.field("multiplier")
|
||||
|
||||
player_name = playerIsBlue and blueFaction or redFaction
|
||||
enemy_name = playerIsBlue and redFaction or blueFaction
|
||||
|
||||
if isTerrainPg:
|
||||
conflicttheater = persiangulf.PersianGulfTheater()
|
||||
elif isTerrainNttr:
|
||||
conflicttheater = nevada.NevadaTheater()
|
||||
else:
|
||||
conflicttheater = caucasus.CaucasusTheater()
|
||||
|
||||
print("player_name, enemy_name, conflicttheater, sams, midGame, multiplier, timePeriod")
|
||||
print(player_name, enemy_name, conflicttheater, sams, midGame, multiplier, timePeriod)
|
||||
self.generatedGame = self.start_new_game(player_name, enemy_name, conflicttheater, sams, midGame, multiplier,
|
||||
timePeriod)
|
||||
|
||||
super(NewGameWizard, self).accept()
|
||||
|
||||
def start_new_game(self, player_name: str, enemy_name: str, conflicttheater: ConflictTheater, sams: bool,
|
||||
midgame: bool, multiplier: float, period: datetime):
|
||||
|
||||
if midgame:
|
||||
for i in range(0, int(len(conflicttheater.controlpoints) / 2)):
|
||||
conflicttheater.controlpoints[i].captured = True
|
||||
|
||||
start_generator.generate_inital_units(conflicttheater, enemy_name, sams, multiplier)
|
||||
start_generator.generate_groundobjects(conflicttheater)
|
||||
game = Game(player_name=player_name,
|
||||
enemy_name=enemy_name,
|
||||
theater=conflicttheater,
|
||||
start_date=period)
|
||||
game.budget = int(game.budget * multiplier)
|
||||
game.settings.multiplier = multiplier
|
||||
game.settings.sams = sams
|
||||
game.settings.version = version_string()
|
||||
|
||||
if midgame:
|
||||
game.budget = game.budget * 4 * len(list(conflicttheater.conflicts()))
|
||||
|
||||
return game
|
||||
|
||||
|
||||
class IntroPage(QtWidgets.QWizardPage):
|
||||
def __init__(self, parent=None):
|
||||
super(IntroPage, self).__init__(parent)
|
||||
|
||||
self.setTitle("Introduction")
|
||||
self.setPixmap(QtWidgets.QWizard.WatermarkPixmap,
|
||||
QtGui.QPixmap('./resources/ui/wizard/watermark1.png'))
|
||||
|
||||
label = QtWidgets.QLabel("This wizard will help you setup a new game.\n\n"
|
||||
"Please make sure you saved and backed up your previous game before going through.")
|
||||
label.setWordWrap(True)
|
||||
|
||||
layout = QtWidgets.QVBoxLayout()
|
||||
layout.addWidget(label)
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
class FactionSelection(QtWidgets.QWizardPage):
|
||||
def __init__(self, parent=None):
|
||||
super(FactionSelection, self).__init__(parent)
|
||||
|
||||
self.setTitle("Faction selection")
|
||||
self.setSubTitle("\nChoose the two opposing factions and select the player side.")
|
||||
self.setPixmap(QtWidgets.QWizard.LogoPixmap,
|
||||
QtGui.QPixmap('./resources/ui/wizard/logo1.png'))
|
||||
|
||||
self.setMinimumHeight(250)
|
||||
|
||||
blues = [c for c in db.FACTIONS if db.FACTIONS[c]["side"] == "blue"]
|
||||
reds = [c for c in db.FACTIONS if db.FACTIONS[c]["side"] == "red"]
|
||||
|
||||
# Create form
|
||||
blueFaction = QtWidgets.QLabel("Blue Faction :")
|
||||
self.blueFactionSelect = QtWidgets.QComboBox()
|
||||
for f in blues:
|
||||
self.blueFactionSelect.addItem(f)
|
||||
blueFaction.setBuddy(self.blueFactionSelect)
|
||||
|
||||
redFaction = QtWidgets.QLabel("Red Faction :")
|
||||
self.redFactionSelect = QtWidgets.QComboBox()
|
||||
for r in reds:
|
||||
self.redFactionSelect.addItem(r)
|
||||
redFaction.setBuddy(self.redFactionSelect)
|
||||
|
||||
sideGroup = QtWidgets.QGroupBox("Player Side")
|
||||
blueforRadioButton = QtWidgets.QRadioButton("BLUEFOR")
|
||||
redforRadioButton = QtWidgets.QRadioButton("REDFOR")
|
||||
blueforRadioButton.setChecked(True)
|
||||
|
||||
# Unit Preview
|
||||
self.blueSideRecap = QtWidgets.QLabel("")
|
||||
self.blueSideRecap.setFont(QtGui.QFont("Arial", italic=True))
|
||||
self.blueSideRecap.setWordWrap(True)
|
||||
self.redSideRecap = QtWidgets.QLabel("")
|
||||
self.redSideRecap.setFont(QtGui.QFont("Arial", italic=True))
|
||||
self.redSideRecap.setWordWrap(True)
|
||||
|
||||
# Link form fields
|
||||
self.registerField('blueFaction', self.blueFactionSelect)
|
||||
self.registerField('redFaction', self.redFactionSelect)
|
||||
self.registerField('playerIsBlue', blueforRadioButton)
|
||||
self.registerField('playerIsRed', redforRadioButton)
|
||||
|
||||
# Build layout
|
||||
sideGroupLayout = QtWidgets.QVBoxLayout()
|
||||
sideGroupLayout.addWidget(blueforRadioButton)
|
||||
sideGroupLayout.addWidget(redforRadioButton)
|
||||
sideGroup.setLayout(sideGroupLayout)
|
||||
|
||||
layout = QtWidgets.QGridLayout()
|
||||
layout.addWidget(blueFaction, 0, 0)
|
||||
layout.addWidget(self.blueFactionSelect, 0, 1)
|
||||
layout.addWidget(self.blueSideRecap, 1, 0, 1, 2)
|
||||
layout.addWidget(redFaction, 2, 0)
|
||||
layout.addWidget(self.redFactionSelect, 2, 1)
|
||||
layout.addWidget(self.redSideRecap, 3, 0, 1, 2)
|
||||
layout.addWidget(sideGroup, 4, 0, 1, 2)
|
||||
self.setLayout(layout)
|
||||
self.updateUnitRecap()
|
||||
|
||||
self.blueFactionSelect.activated.connect(self.updateUnitRecap)
|
||||
self.redFactionSelect.activated.connect(self.updateUnitRecap)
|
||||
|
||||
def updateUnitRecap(self):
|
||||
red_units = db.FACTIONS[self.redFactionSelect.currentText()]["units"]
|
||||
blue_units = db.FACTIONS[self.blueFactionSelect.currentText()]["units"]
|
||||
|
||||
blue_txt = ""
|
||||
for u in blue_units:
|
||||
if u in db.UNIT_BY_TASK[CAP] or u in db.UNIT_BY_TASK[CAS]:
|
||||
blue_txt = blue_txt + u.id + ", "
|
||||
blue_txt = blue_txt + "\n"
|
||||
self.blueSideRecap.setText(blue_txt)
|
||||
|
||||
red_txt = ""
|
||||
for u in red_units:
|
||||
if u in db.UNIT_BY_TASK[CAP] or u in db.UNIT_BY_TASK[CAS]:
|
||||
red_txt = red_txt + u.id + ", "
|
||||
red_txt = red_txt + "\n"
|
||||
self.redSideRecap.setText(red_txt)
|
||||
|
||||
|
||||
class TheaterConfiguration(QtWidgets.QWizardPage):
|
||||
def __init__(self, parent=None):
|
||||
super(TheaterConfiguration, self).__init__(parent)
|
||||
|
||||
self.setTitle("Theater configuration")
|
||||
self.setSubTitle("\nChoose a terrain and time period for this game.")
|
||||
self.setPixmap(QtWidgets.QWizard.LogoPixmap,
|
||||
QtGui.QPixmap('./resources/ui/wizard/logo1.png'))
|
||||
|
||||
# Terrain selection
|
||||
terrainGroup = QtWidgets.QGroupBox("Terrain")
|
||||
terrainCaucasus = QtWidgets.QRadioButton("Caucasus")
|
||||
terrainCaucasus.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Caucasus"]))
|
||||
terrainPg = QtWidgets.QRadioButton("Persian Gulf")
|
||||
terrainPg.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Persian_Gulf"]))
|
||||
terrainNttr = QtWidgets.QRadioButton("Nevada")
|
||||
terrainNttr.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Nevada"]))
|
||||
terrainCaucasus.setChecked(True)
|
||||
|
||||
# Time Period
|
||||
timeGroup = QtWidgets.QGroupBox("Time Period")
|
||||
timePeriod = QtWidgets.QLabel("Start date :")
|
||||
timePeriodSelect = QtWidgets.QComboBox()
|
||||
for r in db.TIME_PERIODS:
|
||||
timePeriodSelect.addItem(r)
|
||||
timePeriod.setBuddy(timePeriodSelect)
|
||||
timePeriodSelect.setCurrentIndex(21)
|
||||
|
||||
# Register fields
|
||||
self.registerField('isTerrainCaucasus', terrainCaucasus)
|
||||
self.registerField('isTerrainPg', terrainPg)
|
||||
self.registerField('isTerrainNttr', terrainNttr)
|
||||
self.registerField('timePeriod', timePeriodSelect)
|
||||
|
||||
# Build layout
|
||||
terrainGroupLayout = QtWidgets.QVBoxLayout()
|
||||
terrainGroupLayout.addWidget(terrainCaucasus)
|
||||
terrainGroupLayout.addWidget(terrainPg)
|
||||
terrainGroupLayout.addWidget(terrainNttr)
|
||||
terrainGroup.setLayout(terrainGroupLayout)
|
||||
|
||||
timeGroupLayout = QtWidgets.QGridLayout()
|
||||
timeGroupLayout.addWidget(timePeriod, 0, 0)
|
||||
timeGroupLayout.addWidget(timePeriodSelect, 0, 1)
|
||||
timeGroup.setLayout(timeGroupLayout)
|
||||
|
||||
layout = QtWidgets.QGridLayout()
|
||||
layout.setColumnMinimumWidth(0, 20)
|
||||
layout.addWidget(terrainGroup)
|
||||
layout.addWidget(timeGroup)
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
class MiscOptions(QtWidgets.QWizardPage):
|
||||
def __init__(self, parent=None):
|
||||
super(MiscOptions, self).__init__(parent)
|
||||
|
||||
self.setTitle("Miscellaneous settings")
|
||||
self.setSubTitle("\nOthers settings for the game.")
|
||||
self.setPixmap(QtWidgets.QWizard.LogoPixmap,
|
||||
QtGui.QPixmap('./resources/ui/wizard/logo1.png'))
|
||||
|
||||
sams = QtWidgets.QCheckBox()
|
||||
sams.setChecked(True)
|
||||
midGame = QtWidgets.QCheckBox()
|
||||
multiplier = QtWidgets.QSpinBox()
|
||||
multiplier.setMinimum(1)
|
||||
multiplier.setMaximum(5)
|
||||
|
||||
self.registerField('sams', sams)
|
||||
self.registerField('midGame', midGame)
|
||||
self.registerField('multiplier', multiplier)
|
||||
|
||||
layout = QtWidgets.QGridLayout()
|
||||
layout.addWidget(QtWidgets.QLabel("With SAM Systems :"), 0, 0)
|
||||
layout.addWidget(sams, 0, 1)
|
||||
layout.addWidget(QtWidgets.QLabel("Start at mid game"), 1, 0)
|
||||
layout.addWidget(midGame, 1, 1)
|
||||
layout.addWidget(QtWidgets.QLabel("Ennemy forces multiplier"), 2, 0)
|
||||
layout.addWidget(multiplier, 2, 1)
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
class ConclusionPage(QtWidgets.QWizardPage):
|
||||
def __init__(self, parent=None):
|
||||
super(ConclusionPage, self).__init__(parent)
|
||||
|
||||
self.setTitle("Conclusion")
|
||||
self.setSubTitle("\n\n")
|
||||
self.setPixmap(QtWidgets.QWizard.WatermarkPixmap,
|
||||
QtGui.QPixmap('./resources/ui/wizard/watermark2.png'))
|
||||
|
||||
self.label = QtWidgets.QLabel("Click 'Finish' to generate and start the new game.")
|
||||
self.label.setWordWrap(True)
|
||||
|
||||
layout = QtWidgets.QVBoxLayout()
|
||||
layout.addWidget(self.label)
|
||||
self.setLayout(layout)
|
||||
6
qt_ui/windows/QTopPanel.py
Normal file
6
qt_ui/windows/QTopPanel.py
Normal file
@ -0,0 +1,6 @@
|
||||
from PySide2.QtWidgets import QFrame
|
||||
|
||||
|
||||
class QTopPanel(QFrame):
|
||||
|
||||
pass
|
||||
BIN
resources/ui/wizard/logo1.png
Normal file
BIN
resources/ui/wizard/logo1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
resources/ui/wizard/watermark1.png
Normal file
BIN
resources/ui/wizard/watermark1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
BIN
resources/ui/wizard/watermark2.png
Normal file
BIN
resources/ui/wizard/watermark2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
Loading…
x
Reference in New Issue
Block a user