Generating code from a validator + saving file

master
Jaka Perovšek 2023-12-15 22:32:19 +01:00
parent ca878de953
commit 1fce5f2d69
2 changed files with 1019 additions and 1002 deletions

View File

@ -21,9 +21,11 @@ def change_font_size(label: QLabel | QLineEdit, factor: float) -> QLabel:
class OptionsWidget(QWidget):
def __init__(self):
def __init__(self, parent: QWidget):
super().__init__()
self.parent = parent
options = [("Buffs", "Some songs affect the characters with strengthen\nand haste afflictions."),
("De-buffs", "Some songs affect the characters with psychosis \naffliction."),
("Walkmans", "Include personal music players (walkmans)"),
@ -112,9 +114,11 @@ class OptionsWidget(QWidget):
class EditorWidget(QWidget):
def __init__(self):
def __init__(self, parent: QWidget):
super().__init__()
self.parent = parent
self.tapes_yaml = Path("../source/tapes.yaml")
self.filename_string = f"<tt style=\"font-family: consolas;\"><b>{self.tapes_yaml.name}</b></tt>"
@ -133,6 +137,7 @@ class EditorWidget(QWidget):
self.save_code_pushbutton = QPushButton()
self.save_code_pushbutton.setIcon(QIcon("./icons/ic_save_24px.svg"))
self.save_code_pushbutton.setToolTip("Save setup")
self.save_code_pushbutton.clicked.connect(self.save_file)
self.transfer_to_validator_pushbutton = QPushButton()
self.transfer_to_validator_pushbutton.setIcon(QIcon("./icons/ic_keyboard_double_arrow_right_24px.svg"))
self.transfer_to_validator_pushbutton.setToolTip("Apply the code.")
@ -175,6 +180,10 @@ class EditorWidget(QWidget):
text = fp.read()
self.editor.setPlainText(text)
def save_file(self):
with open(self.tapes_yaml, "w+", encoding="utf-8") as fp:
fp.write(self.editor.toPlainText())
def open_file(self):
os.startfile(self.tapes_yaml)
@ -202,7 +211,6 @@ class EditorWidget(QWidget):
class ProcessEditWidget(QWidget):
# TODO: move process to another part in yaml
def __init__(self, tape: dict):
super().__init__()
@ -527,13 +535,16 @@ class TapeListWidget(QWidget):
class ValidationWidget(QWidget):
def __init__(self):
def __init__(self, parent: QWidget):
super().__init__()
self.parent = parent
self.tapes = self.load_tapes()
self.transfer_to_code_pushbutton = QPushButton()
self.transfer_to_code_pushbutton.setIcon(QIcon("./icons/ic_keyboard_double_arrow_left_24px.svg"))
self.transfer_to_code_pushbutton.setToolTip("Update the code")
self.transfer_to_code_pushbutton.clicked.connect(self.save_tapes)
self.jump_spinbox = QSpinBox()
#self.search_lineedit = QLineEdit()
#self.search_lineedit.setPlaceholderText("Search ...")
@ -571,12 +582,18 @@ class ValidationWidget(QWidget):
self.setMinimumWidth(470)
self.setMaximumWidth(470)
import tempfile
def load_tapes(self):
with open("../source/tapes.yaml", encoding="utf-8") as fp:
tapes = yaml.safe_load(fp)
return tapes
def save_tapes(self):
yaml_text = yaml.safe_dump(self.tapes, sort_keys=False, allow_unicode=True).replace("\n-", "\n\n-")
self.parent.editor_widget.editor.setPlainText(yaml_text)
def jump_to_tape(self, tape_number):
scrollbar = self.scroll.verticalScrollBar()
@ -676,13 +693,13 @@ class MainWidget(QWidget):
layout = QHBoxLayout()
options = OptionsWidget()
editor = EditorWidget()
validation = ValidationWidget()
self.options_widget = OptionsWidget(self)
self.editor_widget = EditorWidget(self)
self.validation_widget = ValidationWidget(self)
# install = InstallWidget()
layout.addWidget(options)
layout.addWidget(editor)
layout.addWidget(validation)
layout.addWidget(self.options_widget)
layout.addWidget(self.editor_widget)
layout.addWidget(self.validation_widget)
# layout.addWidget(install)
self.setLayout(layout)

View File

@ -2,10 +2,10 @@
name: Blank Tape
source: ./source/original_audio/blank.ogg
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -33,10 +33,10 @@
name: DMX - X Gon Give It To Ya
source: https://www.youtube.com/watch?v=vkOJ9uNj9EY
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -66,10 +66,10 @@
name: DMX Carnage Cut
source: https://www.youtube.com/watch?v=vkOJ9uNj9EY
process:
start: "00:00:27.0"
end: "00:00:00.0"
start: '00:00:27.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -99,10 +99,10 @@
name: Vampire Dance Club
source: https://www.youtube.com/watch?v=cNOP2t9FObw
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.04
@ -132,10 +132,10 @@
name: Atari Teenage Riot - SPEED
source: https://www.youtube.com/watch?v=plAr3adKbyc
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -165,10 +165,10 @@
name: Dragostea Din Tei
source: https://www.youtube.com/watch?v=zxbufWzX1NA
process:
start: "00:00:01.4"
end: "00:00:00.0"
start: '00:00:01.4'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -198,10 +198,10 @@
name: Kenny Larkin - Java
source: https://www.youtube.com/watch?v=PoaLz0UK6KY
process:
start: "00:01:28.0"
end: "00:06:50.0"
start: '00:01:28.0'
end: '00:06:50.0'
volume: 2
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -231,10 +231,10 @@
name: Menace Ruine - Dark Mother
source: https://www.youtube.com/watch?v=0XpL0LwYC0s
process:
start: "00:01:12.0"
end: "00:02:49.0"
start: '00:01:12.0'
end: '00:02:49.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -264,10 +264,10 @@
name: Sewer Goddess - Chained To The Edge Of Existence
source: https://www.youtube.com/watch?v=GfdfzslZ1GY
process:
start: "00:02:20.0"
end: "00:04:32.0"
start: '00:02:20.0'
end: '00:04:32.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -297,10 +297,10 @@
name: Urfaust - Die Kalte Teufelsfaust
source: https://www.youtube.com/watch?v=mjHaJq1BTQ4
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 3
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -330,10 +330,10 @@
name: Rainbow Stalin
source: https://www.youtube.com/watch?v=zab9cluVJa0
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -365,10 +365,10 @@
name: Альянс - На заре
source: https://www.youtube.com/watch?v=tUBVEKzsZ-k
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 3
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -398,10 +398,10 @@
name: Termiti - Vjeran pas
source: https://www.youtube.com/watch?v=QO3fQvTF5Lo
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 3
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -431,10 +431,10 @@
name: Morbidi I Mnoći - Put
source: https://www.youtube.com/watch?v=18Ku0EaiS88
process:
start: "00:00:00.0"
end: "00:04:18.0"
start: '00:00:00.0'
end: '00:04:18.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -464,10 +464,10 @@
name: Doodle Let Me Go
source: https://www.youtube.com/watch?v=CNQt86A2Kow
process:
start: "00:00:00.0"
end: "00:02:45.0"
start: '00:00:00.0'
end: '00:02:45.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -497,10 +497,10 @@
name: Rolling Down To Old Maui
source: https://www.youtube.com/watch?v=P7GC9KsvkDI
process:
start: "00:00:00.0"
end: "00:03:20.0"
start: '00:00:00.0'
end: '00:03:20.0'
volume: 6
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -530,10 +530,10 @@
name: Roll the Old Chariot
source: https://www.youtube.com/watch?v=-CuyLbC2TZo
process:
start: "00:00:00.0"
end: "00:02:33.0"
start: '00:00:00.0'
end: '00:02:33.0'
volume: 6
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -563,10 +563,10 @@
name: Weigh, Hey and up She Rises
source: https://www.youtube.com/watch?v=1YSltK-10zk
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 6
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -596,10 +596,10 @@
name: Roll Northumbria
source: https://www.youtube.com/watch?v=-d3XHQVMHDM
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -629,10 +629,10 @@
name: 15 Men and a Bottle of Rum
source: https://www.youtube.com/watch?v=nzcv5TJkJBA
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 6
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -662,10 +662,10 @@
name: Biosphere - Daphnis 26
source: https://www.youtube.com/watch?v=l0h4Q-0GV-U
process:
start: "00:04:11.0"
end: "00:05:51.0"
start: '00:04:11.0'
end: '00:05:51.0'
volume: 3
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -695,10 +695,10 @@
name: Bedouin - Set The Control For The Heart Of The Sun
source: https://www.youtube.com/watch?v=d8vetnC1jYo
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 3
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -728,10 +728,10 @@
name: Dead Meadow - Me and the Devil Blues
source: https://www.youtube.com/watch?v=HejsUs-IND8
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 6
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.02
@ -761,10 +761,10 @@
name: Hardbass
source: https://www.youtube.com/watch?v=BnTW6fZz-1E
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -796,10 +796,10 @@
name: Come out and Fight
source: https://www.youtube.com/watch?v=OT0yoo9B2Bc
process:
start: "00:00:00.0"
end: "00:02:35.0"
start: '00:00:00.0'
end: '00:02:35.0'
volume: 2
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -829,10 +829,10 @@
name: Aphex Twin - Tha
source: https://www.youtube.com/watch?v=N3G7JPTVVEQ
process:
start: "00:00:00.0"
end: "00:04:08.8"
start: '00:00:00.0'
end: '00:04:08.8'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -862,10 +862,10 @@
name: Led Zeppelin - Immigrant Song
source: https://www.youtube.com/watch?v=y8OtzJtp-EM
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 3
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -893,10 +893,10 @@
name: The Hunt for Red October
source: https://www.youtube.com/watch?v=YEt41bYQBgE
process:
start: "00:01:24.0"
end: "00:00:00.0"
start: '00:01:24.0'
end: '00:00:00.0'
volume: 10
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -926,10 +926,10 @@
name: Шугейз-принцесса
source: https://www.youtube.com/watch?v=j3NG8UScSiA
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -959,10 +959,10 @@
name: УБИЙЦЫ - Россия
source: https://www.youtube.com/watch?v=DJVb9yvI3Go
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -992,8 +992,8 @@
name: Inka - Schritte (08080 remix)
source: ./source/original_audio/schritte_08080.ogg
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: Anžiček remix
spawn:
@ -1025,10 +1025,10 @@
name: Inka - Schritte
source: https://www.youtube.com/watch?v=vkuqR6skYHg
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -1056,8 +1056,8 @@
name: Neznani Rock Fotri
source: ./source/original_audio/wacky_tape.ogg
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: Made by a broken cassette player
spawn:
@ -1087,8 +1087,8 @@
name: 08080 - Minor Threat
source: ./source/original_audio/08080_minor_threat.ogg
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: Original song by 08080
spawn:
@ -1120,8 +1120,8 @@
name: 08080 - Canyon's Joyride
source: ./source/original_audio/08080_canyons_joyride.ogg
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: Original song by 08080
spawn:
@ -1153,10 +1153,10 @@
name:
source: https://www.youtube.com/watch?v=1-emQo-7O3Y
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -1186,10 +1186,10 @@
name: Boards of Canada - The Devil Is in the Details
source: https://www.youtube.com/watch?v=wxPLzms6Coc
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -1219,10 +1219,10 @@
name: L.O.T.I.O.N. Multinational Corporation - Alphabrain
source: https://www.youtube.com/watch?v=P6js2T8EB0c
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.05
@ -1252,10 +1252,10 @@
name: Smoke City - Underwater Love
source: https://www.youtube.com/watch?v=HuLjsW8XhY4
process:
start: "00:00:00.0"
end: "00:06:46.0"
start: '00:00:00.0'
end: '00:06:46.0'
volume: 0
note: ""
note: ''
spawn:
- location: outpostcrewcabinet
probability: 0.02
@ -1283,10 +1283,10 @@
name: The Room
source: https://www.youtube.com/watch?v=NZfox7y8VAg
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 12
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.03
@ -1316,10 +1316,10 @@
name: Kiss The Anus Of A Black Cat - The Shadows Are You
source: https://www.youtube.com/watch?v=Dn2hOxuLY8M
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.04
@ -1349,10 +1349,10 @@
name: Balans - Sam Naprej
source: https://www.youtube.com/watch?v=JqqXdF6DP6U
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.04
@ -1382,10 +1382,10 @@
name: Dio - Holy Diver
source: https://youtu.be/1Obtf6ftDc8
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.04
@ -1419,10 +1419,10 @@
name: Meshuggah - Rational Gaze
source: https://www.youtube.com/watch?v=rkrjE4QRsys
process:
start: "00:00:00.0"
end: "00:05:15.0"
start: '00:00:00.0'
end: '00:05:15.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.04
@ -1452,10 +1452,10 @@
name: Death Grips - The Cage
source: https://www.youtube.com/watch?v=mokXWBN89oo
process:
start: "00:00:00.0"
end: "00:00:00.0"
start: '00:00:00.0'
end: '00:00:00.0'
volume: 0
note: ""
note: ''
spawn:
- location: abandonedcrewcab
probability: 0.04