Skip to content

Commit d5b0724

Browse files
committed
feat: more background colors
1 parent 8642ad0 commit d5b0724

File tree

10 files changed

+92
-13
lines changed

10 files changed

+92
-13
lines changed

hh_creator/main_window.py

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from PyQt5 import QtCore, QtGui, QtWidgets
77
from PyQt5.QtCore import pyqtSlot
8+
from PyQt5.QtWidgets import QMessageBox
89

910
from . import config
1011
from .animations import Animations
@@ -58,6 +59,9 @@ def __init__(self, show_new_hh_dialog: bool = True):
5859

5960
self.full_screen_widget = None
6061

62+
self.background_color = "black"
63+
self.webcam = "plain"
64+
6165
self.graphics_view: QtWidgets.QGraphicsView = self.widgets["graphicsView"]
6266

6367
self.hand_history: Union[None, HandHistory] = None
@@ -80,6 +84,7 @@ def __init__(self, show_new_hh_dialog: bool = True):
8084
self.state = self.State.LAUNCH
8185

8286
self.current_filename = None
87+
self.update_background()
8388
if show_new_hh_dialog:
8489
self.on_actionNew_triggered()
8590

@@ -323,19 +328,43 @@ def on_actionTableBlue_triggered(self):
323328

324329
@pyqtSlot()
325330
def on_actionWebcamPlain_triggered(self):
326-
self.scene.change_background("plain")
331+
self.webcam = "plain"
332+
self.update_background()
327333

328334
@pyqtSlot()
329335
def on_actionWebcamBoth_triggered(self):
330-
self.scene.change_background("both")
336+
self.webcam = "both"
337+
self.update_background()
331338

332339
@pyqtSlot()
333340
def on_actionWebcamLeft_triggered(self):
334-
self.scene.change_background("left")
341+
self.webcam = "left"
342+
self.update_background()
335343

336344
@pyqtSlot()
337345
def on_actionWebcamRight_triggered(self):
338-
self.scene.change_background("right")
346+
self.webcam = "right"
347+
self.update_background()
348+
349+
@pyqtSlot()
350+
def on_actionBackgroundBlack_triggered(self):
351+
self.background_color = "black"
352+
self.update_background()
353+
354+
@pyqtSlot()
355+
def on_actionBackgroundViolet_triggered(self):
356+
self.background_color = "violet"
357+
self.update_background()
358+
359+
@pyqtSlot()
360+
def on_actionBackgroundBlue_triggered(self):
361+
self.background_color = "blue"
362+
self.update_background()
363+
364+
@pyqtSlot()
365+
def on_actionBackgroundRed_triggered(self):
366+
self.background_color = "red"
367+
self.update_background()
339368

340369
@pyqtSlot()
341370
def on_actionBackBlue_triggered(self):
@@ -494,6 +523,20 @@ def update_buttons(self):
494523

495524
start.setEnabled(True)
496525

526+
def update_background(self):
527+
file_name = f"{self.background_color}-{self.webcam}"
528+
try:
529+
self.scene.change_background(file_name)
530+
except FileNotFoundError:
531+
msg = QMessageBox()
532+
msg.setIcon(QMessageBox.Critical)
533+
msg.setText("Image non trouvée")
534+
msg.setInformativeText(
535+
f"Il manque un fichier pour avoir ce fond: {file_name}"
536+
)
537+
msg.setWindowTitle("Erreur")
538+
msg.exec_()
539+
497540

498541
class FullScreenView(QtWidgets.QGraphicsView, KeyboardShortcutsMixin):
499542
def __init__(self, main_window: MainWindow, scene: TableScene):
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
252 KB
Loading
137 KB
Loading
194 KB
Loading

hh_creator/resource/ui/MainWindow.ui

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,31 @@
127127
<addaction name="actionBackRed"/>
128128
<addaction name="actionBackBlue"/>
129129
</widget>
130+
<widget class="QMenu" name="menuBackground">
131+
<property name="title">
132+
<string>Couleur du fond</string>
133+
</property>
134+
<addaction name="actionBackgroundBlack"/>
135+
<addaction name="actionBackgroundViolet"/>
136+
<addaction name="actionBackgroundBlue"/>
137+
<addaction name="actionBackgroundRed"/>
138+
</widget>
130139
<widget class="QMenu" name="menuWebcam">
131140
<property name="title">
132141
<string>Webcam</string>
133142
</property>
134-
<addaction name="actionLeft"/>
135-
<addaction name="actionRight"/>
136-
<addaction name="actionBoth"/>
137-
<addaction name="actionSans"/>
143+
<addaction name="actionWebcamLeft"/>
144+
<addaction name="actionWebcamRight"/>
145+
<addaction name="actionWebcamBoth"/>
146+
<addaction name="actionWebcamSans"/>
138147
</widget>
139148
<addaction name="actionFullScreen"/>
140149
<addaction name="separator"/>
141150
<addaction name="actionChooseHero"/>
142151
<addaction name="actionHideHandsBeforeShowdown"/>
143152
<addaction name="separator"/>
144153
<addaction name="menuTable"/>
154+
<addaction name="menuBackground"/>
145155
<addaction name="menuWebcam"/>
146156
<addaction name="menuCardsBack"/>
147157
<addaction name="separator"/>
@@ -244,22 +254,22 @@
244254
<string>Cacher mains avant showdown</string>
245255
</property>
246256
</action>
247-
<action name="actionLeft">
257+
<action name="actionWebcamLeft">
248258
<property name="text">
249259
<string>Gauche</string>
250260
</property>
251261
</action>
252-
<action name="actionRight">
262+
<action name="actionWebcamRight">
253263
<property name="text">
254264
<string>Droite</string>
255265
</property>
256266
</action>
257-
<action name="actionBoth">
267+
<action name="actionWebcamBoth">
258268
<property name="text">
259269
<string>Les deux</string>
260270
</property>
261271
</action>
262-
<action name="actionSans">
272+
<action name="actionWebcamSans">
263273
<property name="text">
264274
<string>Sans</string>
265275
</property>
@@ -274,6 +284,26 @@
274284
<string>Restaurer la configuration par défaut</string>
275285
</property>
276286
</action>
287+
<action name="actionBackgroundBlack">
288+
<property name="text">
289+
<string>Noir</string>
290+
</property>
291+
</action>
292+
<action name="actionBackgroundViolet">
293+
<property name="text">
294+
<string>Violet</string>
295+
</property>
296+
</action>
297+
<action name="actionBackgroundBlue">
298+
<property name="text">
299+
<string>Bleu</string>
300+
</property>
301+
</action>
302+
<action name="actionBackgroundRed">
303+
<property name="text">
304+
<string>Rouge</string>
305+
</property>
306+
</action>
277307
<action name="actionOpenGL">
278308
<property name="checkable">
279309
<bool>true</bool>

hh_creator/scene.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ def _get_player_item_from_hh_position(self, position: hh.Position):
137137

138138
def _create_background(self):
139139
table_item = Image.get(Path("table") / config.config["look"].get("table"))
140-
background = Image.get(Path("background") / config.config["look"].get("webcam"))
140+
webcam = config.config["look"].get("webcam")
141+
if "-" not in webcam:
142+
webcam = f"black-{webcam}"
143+
try:
144+
background = Image.get(Path("background") / webcam)
145+
except FileNotFoundError:
146+
background = Image.get(Path("background") / "black-plain")
141147

142148
shadow = QtWidgets.QGraphicsDropShadowEffect()
143149
shadow.setBlurRadius(config.config["look"].getfloat("TABLE_SHADOW_RADIUS"))

0 commit comments

Comments
 (0)