mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Make the starting budget text editable.
This commit is contained in:
parent
b0a176a22c
commit
1ac062653d
@ -2,7 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List, Optional
|
||||||
|
|
||||||
from PySide2 import QtGui, QtWidgets
|
from PySide2 import QtGui, QtWidgets
|
||||||
from PySide2.QtCore import QItemSelectionModel, QPoint, Qt
|
from PySide2.QtCore import QItemSelectionModel, QPoint, Qt
|
||||||
@ -295,6 +295,44 @@ class TheaterConfiguration(QtWidgets.QWizardPage):
|
|||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
|
||||||
|
class CurrencySpinner(QtWidgets.QSpinBox):
|
||||||
|
def __init__(self, minimum: Optional[int] = None,
|
||||||
|
maximum: Optional[int] = None,
|
||||||
|
initial: Optional[int] = None) -> None:
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
if minimum is not None:
|
||||||
|
self.setMinimum(minimum)
|
||||||
|
if maximum is not None:
|
||||||
|
self.setMaximum(maximum)
|
||||||
|
if initial is not None:
|
||||||
|
self.setValue(initial)
|
||||||
|
|
||||||
|
def textFromValue(self, val: int) -> str:
|
||||||
|
return f"${val}"
|
||||||
|
|
||||||
|
|
||||||
|
class BudgetInputs(QtWidgets.QGridLayout):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.addWidget(QtWidgets.QLabel("Starting money"), 0, 0)
|
||||||
|
|
||||||
|
minimum = 0
|
||||||
|
maximum = 5000
|
||||||
|
initial = 650
|
||||||
|
|
||||||
|
slider = QtWidgets.QSlider(Qt.Horizontal)
|
||||||
|
slider.setMinimum(minimum)
|
||||||
|
slider.setMaximum(maximum)
|
||||||
|
slider.setValue(initial)
|
||||||
|
self.starting_money = CurrencySpinner(minimum, maximum, initial)
|
||||||
|
slider.valueChanged.connect(lambda x: self.starting_money.setValue(x))
|
||||||
|
self.starting_money.valueChanged.connect(lambda x: slider.setValue(x))
|
||||||
|
|
||||||
|
self.addWidget(slider, 1, 0)
|
||||||
|
self.addWidget(self.starting_money, 1, 1)
|
||||||
|
|
||||||
|
|
||||||
class MiscOptions(QtWidgets.QWizardPage):
|
class MiscOptions(QtWidgets.QWizardPage):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(MiscOptions, self).__init__(parent)
|
super(MiscOptions, self).__init__(parent)
|
||||||
@ -327,16 +365,6 @@ class MiscOptions(QtWidgets.QWizardPage):
|
|||||||
no_enemy_navy = QtWidgets.QCheckBox()
|
no_enemy_navy = QtWidgets.QCheckBox()
|
||||||
self.registerField('no_enemy_navy', no_enemy_navy)
|
self.registerField('no_enemy_navy', no_enemy_navy)
|
||||||
|
|
||||||
# Economy settings
|
|
||||||
economySettingsGroup = QtWidgets.QGroupBox("Economy")
|
|
||||||
starting_money_slider = QtWidgets.QSlider(Qt.Horizontal)
|
|
||||||
starting_money_slider.setMinimum(0)
|
|
||||||
starting_money_slider.setMaximum(5000)
|
|
||||||
starting_money_slider.setValue(650)
|
|
||||||
starting_money_label = QtWidgets.QLabel("$650M")
|
|
||||||
starting_money_slider.valueChanged.connect(lambda x: starting_money_label.setText("${}M".format(x)))
|
|
||||||
self.registerField('starting_money', starting_money_slider)
|
|
||||||
|
|
||||||
layout = QtWidgets.QGridLayout()
|
layout = QtWidgets.QGridLayout()
|
||||||
layout.addWidget(QtWidgets.QLabel("Start at mid game"), 1, 0)
|
layout.addWidget(QtWidgets.QLabel("Start at mid game"), 1, 0)
|
||||||
layout.addWidget(midGame, 1, 1)
|
layout.addWidget(midGame, 1, 1)
|
||||||
@ -357,11 +385,10 @@ class MiscOptions(QtWidgets.QWizardPage):
|
|||||||
generatorLayout.addWidget(no_enemy_navy, 5, 1)
|
generatorLayout.addWidget(no_enemy_navy, 5, 1)
|
||||||
generatorSettingsGroup.setLayout(generatorLayout)
|
generatorSettingsGroup.setLayout(generatorLayout)
|
||||||
|
|
||||||
economyLayout = QtWidgets.QGridLayout()
|
budget_inputs = BudgetInputs()
|
||||||
economyLayout.addWidget(QtWidgets.QLabel("Starting money"), 0, 0)
|
economySettingsGroup = QtWidgets.QGroupBox("Economy")
|
||||||
economyLayout.addWidget(starting_money_slider, 1, 0)
|
economySettingsGroup.setLayout(budget_inputs)
|
||||||
economyLayout.addWidget(starting_money_label, 1, 1)
|
self.registerField('starting_money', budget_inputs.starting_money)
|
||||||
economySettingsGroup.setLayout(economyLayout)
|
|
||||||
|
|
||||||
mlayout = QVBoxLayout()
|
mlayout = QVBoxLayout()
|
||||||
mlayout.addWidget(miscSettingsGroup)
|
mlayout.addWidget(miscSettingsGroup)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user