Skip to content

Commit

Permalink
Merge pull request #16 from MasterLaplace/13-implement-laplace-launcher
Browse files Browse the repository at this point in the history
13 Implement Laplace Launcher
  • Loading branch information
MasterLaplace authored Oct 17, 2023
2 parents c54b2e2 + e157c6b commit 01fccd2
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 99 deletions.
40 changes: 20 additions & 20 deletions Launcher/src/SceneManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,49 +51,49 @@ def InitUI(self):
def HomePage(self)-> Widgets:
layout = QVBoxLayout()

layout.addWidget(Widgets.createLabel(0, 0, 'Welcome to Engine-3D Launcher'))
layout.addWidget(Widgets.createButton(0, 0, 0, 0, 'Create a new project', self.ShowCreateProject))
layout.addWidget(Widgets.createButton(0, 0, 0, 0, 'Open a project (config.xml)', self.ShowFileDialog))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Welcome to Engine-3D Launcher'))
layout.addWidget(Widgets.CreateButton([0, 0], [0, 0], 'Create a new project', self.ShowCreateProject))
layout.addWidget(Widgets.CreateButton([0, 0], [0, 0], 'Open a project (config.xml)', self.ShowFileDialog))
self.xml_text = QTextEdit(self)
self.xml_text.setReadOnly(True)
layout.addWidget(self.xml_text)
self.run_button = Widgets.createButton(0, 0, 0, 0, 'Launch project', self.ShowRunProject)
self.run_button = Widgets.CreateButton([0, 0], [0, 0], 'Launch project', self.ShowRunProject)
self.run_button.setEnabled(False)
layout.addWidget(self.run_button)
layout.addWidget(Widgets.createButton(0, 0, 0, 0, 'Credits', self.ShowCredits))
layout.addWidget(Widgets.CreateButton([0, 0], [0, 0], 'Credits', self.ShowCredits))

return Widgets(layout)

def CreateProjectPage(self)-> Widgets:
layout = QVBoxLayout()

layout.addWidget(Widgets.createLabel(0, 0, 'Engine-3D Create Project:'))
layout.addWidget(Widgets.createLabel(0, 0, 'Project name:'))
layout.addWidget(Widgets.createLineEdit(0, 0, 0, 0, self.ChangeProjectName))
layout.addWidget(Widgets.createLabel(0, 0, 'Graphycal API:'))
layout.addWidget(Widgets.createComboBox(0, 0, 0, 0, ['sdl2', 'CSFML', 'SFML', 'OpenGL', 'Vulkan'], self.ChangeProjectGraphycal))
layout.addWidget(Widgets.createLabel(0, 0, 'Engine-3D version:'))
layout.addWidget(Widgets.createComboBox(0, 0, 0, 0, ['0.2.0', '0.1.0'], self.ChangeProjectVersion))
layout.addWidget(Widgets.createButton(0, 0, 0, 0, 'Create', self.CreateProject))
layout.addWidget(Widgets.createButton(0, 0, 50, 50, 'Home', self.ShowHome))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Engine-3D Create Project:'))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Project name:'))
layout.addWidget(Widgets.CreateLineEdit([0, 0], [0, 0], self.ChangeProjectName))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Graphycal API:'))
layout.addWidget(Widgets.CreateComboBox([0, 0], [0, 0], ['sdl2', 'CSFML', 'SFML', 'OpenGL', 'Vulkan'], self.ChangeProjectGraphycal))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Engine-3D version:'))
layout.addWidget(Widgets.CreateComboBox([0, 0], [0, 0], ['0.2.0', '0.1.0'], self.ChangeProjectVersion))
layout.addWidget(Widgets.CreateButton([0, 0], [0, 0], 'Create', self.CreateProject))
layout.addWidget(Widgets.CreateButton([0, 0], [0, 0], 'Home', self.ShowHome))

return Widgets(layout)

def SettingsPage(self)-> Widgets:
layout = QVBoxLayout()

layout.addWidget(Widgets.createLabel(0, 0, 'Engine-3D Settings:'))
layout.addWidget(Widgets.createButton(0, 0, 50, 50, 'Home', self.ShowHome))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Engine-3D Settings:'))
layout.addWidget(Widgets.CreateButton([0, 0], [0, 0], 'Home', self.ShowHome))

return Widgets(layout)

def CreditsPage(self)-> Widgets:
layout = QVBoxLayout()

layout.addWidget(Widgets.createLabel(0, 0, 'Engine-3D Credits:'))
layout.addWidget(Widgets.createLabel(0, 0, __CREDITS__))
layout.addWidget(Widgets.createLabel(0, 0, 'Engine-3D Launcher version: ' + __VERSION__))
layout.addWidget(Widgets.createButton(0, 0, 50, 50, 'Home', self.ShowHome))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Engine-3D Credits:'))
layout.addWidget(Widgets.CreateLabel([0, 0], __CREDITS__))
layout.addWidget(Widgets.CreateLabel([0, 0], 'Engine-3D Launcher version: ' + __VERSION__))
layout.addWidget(Widgets.CreateButton([0, 0], [0, 0], 'Home', self.ShowHome))

return Widgets(layout)

Expand Down
124 changes: 51 additions & 73 deletions Launcher/src/Widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,20 @@ def __init__(self, layout: QVBoxLayout):
self.setLayout(layout)

@staticmethod
def createSlider(ax: int, ay: int, aw: int, ah: int, min: int, max: int, step: int, value: int, func: object)-> QSlider:
def CreateSlider(pos: list[int], size: list[int], min: int, max: int, step: int, value: int, func: object)-> QSlider:
"""_summary_ Creates a slider with the given parameters
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
min (int): _description_ minimum value
max (int): _description_ maximum value
step (int): _description_ step value
value (int): _description_ initial value
func (object): _description_ function to call when value changes
"""
slider = QSlider()
slider.setGeometry(ax, ay, aw, ah)
slider.setGeometry(pos[0], pos[1], size[0], size[1])
slider.setOrientation(Qt.Horizontal)
slider.setMinimum(min)
slider.setMaximum(max)
Expand All @@ -59,77 +57,70 @@ def createSlider(ax: int, ay: int, aw: int, ah: int, min: int, max: int, step: i
return slider

@staticmethod
def createButton(ax: int, ay: int, aw: int, ah: int, text: str, func: object)-> QPushButton:
def CreateButton(pos: list[int], size: list[int], text: str, func: object)-> QPushButton:
"""_summary_ Creates a button in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
text (str): _description_ text to show
func (object): _description_ function to call when clicked
"""
button = QPushButton(text)
button.setGeometry(ax, ay, aw, ah)
button.setGeometry(pos[0], pos[1], size[0], size[1])
button.clicked.connect(func)
return button

@staticmethod
def createLabel(ax: int, ay: int, text: str)-> QLabel:
def CreateLabel(pos: list[int], text: str)-> QLabel:
"""_summary_ Creates a label in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
text (str): _description_ text to show
pos (list[int]): _description_ position
t_ext (str): _description_ text to show
"""
my_text = QLabel(text)
my_text.move(ax, ay)
my_text.move(pos[0], pos[1])
my_text.setAlignment(Qt.AlignCenter)
return my_text

@staticmethod
def createLineEdit( ax: int, ay: int, aw: int, ah: int, func: object)-> QLineEdit:
def CreateLineEdit(pos: list[int], size: list[int], func: object)-> QLineEdit:
"""_summary_ Creates a line edit in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
func (object): _description_ function to call when text changes
Returns:
_type_: _description_ text
Examples:
>>> def changeText(text):
>>> def ChangeText(text):
>>> print(text)
>>>
>>> line_edit = Widgets.createLineEdit(0, 0, 100, 30, changeText)
"""
line_edit = QLineEdit()
line_edit.setGeometry(ax, ay, aw, ah)
line_edit.setGeometry(pos[0], pos[1], size[0], size[1])
line_edit.textChanged.connect(func)
return line_edit

@staticmethod
def createTable(ax: int, ay: int, aw: int, ah: int, rows: int, columns: int, headers: list, items: list)-> QTableWidget:
def CreateTable(pos: list[int], size: list[int], rows: int, columns: int, headers: list, items: list)-> QTableWidget:
"""_summary_ Creates a table in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
rows (int): _description_ rows
columns (int): _description_ columns
headers (list): _description_ headers
items (list): _description_ items to show in the table
"""
table_widget = QTableWidget()
table_widget.setGeometry(ax, ay, aw, ah)
table_widget.setGeometry(pos[0], pos[1], size[0], size[1])
table_widget.setRowCount(rows)
table_widget.setColumnCount(columns)
table_widget.setHorizontalHeaderLabels(headers)
Expand All @@ -139,90 +130,80 @@ def createTable(ax: int, ay: int, aw: int, ah: int, rows: int, columns: int, hea
return table_widget

@staticmethod
def createComboBox(ax: int, ay: int, aw: int, ah: int, items: list, func: object)-> QComboBox:
def CreateComboBox(pos: list[int], size: list[int], items: list, func: object)-> QComboBox:
"""_summary_ Creates a combo box in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
items (list): _description_ items to show in the combo box
func (object): _description_ function to call when item changes
"""
combo_box = QComboBox()
combo_box.setGeometry(ax, ay, aw, ah)
combo_box.setGeometry(pos[0], pos[1], size[0], size[1])
combo_box.addItems(items)
combo_box.currentTextChanged.connect(func)
return combo_box

@staticmethod
def createCheckBox(ax: int, ay: int, aw: int, ah: int, text: str, func: object)-> QCheckBox:
def CreateCheckBox(pos: list[int], size: list[int], text: str, func: object)-> QCheckBox:
"""_summary_ Creates a check box in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
text (str): _description_ text to show
func (object): _description_ function to call when checked
"""
check_box = QCheckBox(text, )
check_box.setGeometry(ax, ay, aw, ah)
check_box.setGeometry(pos[0], pos[1], size[0], size[1])
check_box.stateChanged.connect(func)
return check_box

@staticmethod
def createRadioButton(ax: int, ay: int, aw: int, ah: int, text: str, func: object)-> QRadioButton:
def CreateRadioButton(pos: list[int], size: list[int], text: str, func: object)-> QRadioButton:
"""_summary_ Creates a radio button in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
text (str): _description_ text to show
func (object): _description_ function to call when checked
"""
radio_button = QRadioButton(text, )
radio_button.setGeometry(ax, ay, aw, ah)
radio_button.setGeometry(pos[0], pos[1], size[0], size[1])
radio_button.toggled.connect(func)
return radio_button

@staticmethod
def createProgressBar(ax: int, ay: int, aw: int, ah: int, value: int)-> QProgressBar:
def CreateProgressBar(pos: list[int], size: list[int], value: int)-> QProgressBar:
"""_summary_ Creates a progress bar in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
value (int): _description_ initial value
"""
progress_bar = QProgressBar()
progress_bar.setGeometry(ax, ay, aw, ah)
progress_bar.setGeometry(pos[0], pos[1], size[0], size[1])
progress_bar.setValue(value)
return progress_bar

@staticmethod
def createSpinBox(ax: int, ay: int, aw: int, ah: int, min: int, max: int, step: int, value: int, func: object)-> QSpinBox:
def CreateSpinBox(pos: list[int], size: list[int], min: int, max: int, step: int, value: int, func: object)-> QSpinBox:
"""_summary_ Creates a spin box in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
min (int): _description_ minimum value
max (int): _description_ maximum value
step (int): _description_ step value
value (int): _description_ initial value
func (object): _description_ function to call when value changes
"""
spin_box = QSpinBox()
spin_box.setGeometry(ax, ay, aw, ah)
spin_box.setGeometry(pos[0], pos[1], size[0], size[1])
spin_box.setMinimum(min)
spin_box.setMaximum(max)
spin_box.setSingleStep(step)
Expand All @@ -231,22 +212,20 @@ def createSpinBox(ax: int, ay: int, aw: int, ah: int, min: int, max: int, step:
return spin_box

@staticmethod
def createDial(ax: int, ay: int, aw: int, ah: int, min: int, max: int, step: int, value: int, func: object)-> QDial:
def CreateDial(pos: list[int], size: list[int], min: int, max: int, step: int, value: int, func: object)-> QDial:
"""_summary_ Creates a dial in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
size (list[int]): _description_ size
min (int): _description_ minimum value
max (int): _description_ maximum value
step (int): _description_ step value
value (int): _description_ initial value
func (object): _description_ function to call when value changes
"""
dial = QDial()
dial.setGeometry(ax, ay, aw, ah)
dial.setGeometry(pos[0], pos[1], size[0], size[1])
dial.setMinimum(min)
dial.setMaximum(max)
dial.setSingleStep(step)
Expand All @@ -255,22 +234,21 @@ def createDial(ax: int, ay: int, aw: int, ah: int, min: int, max: int, step: int
return dial

@staticmethod
def createLCDNumber(ax: int, ay: int, aw: int, ah: int, value: int)-> QLCDNumber:
def CreateLCDNumber(pos: list[int], size: list[int], value: int)-> QLCDNumber:
"""_summary_ Creates a LCD number in the window
Args:
ax (int): _description_ x position
ay (int): _description_ y position
aw (int): _description_ width
ah (int): _description_ height
pos (list[int]): _description_ position
a_w (int): _description_ width
_ ah (int): _description_ height
"""
lcd_number = QLCDNumber()
lcd_number.setGeometry(ax, ay, aw, ah)
lcd_number.setGeometry(pos[0], pos[1], size[0], size[1])
lcd_number.display(value)
return lcd_number

@staticmethod
def createMenuBar()-> QMenuBar:
def CreateMenuBar()-> QMenuBar:
"""_summary_ Creates a menu bar in the window
"""
menu_bar = QMenuBar()
Expand Down
12 changes: 6 additions & 6 deletions Launcher/src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from SceneManager import *

def main():
parser = ParseArgument()
args = parser.parse()
app = QApplication(sys.argv)
window = SceneManager(fullscreen=args.fullscreen)
window.show()
sys.exit(app.exec_())
parser = ParseArgument()
args = parser.parse()
app = QApplication(sys.argv)
window = SceneManager(fullscreen=args.fullscreen)
window.show()
sys.exit(app.exec_())

if __name__ == '__main__':
main()

0 comments on commit 01fccd2

Please sign in to comment.