Commit 51379b56 authored by captnfab's avatar captnfab 🦃
Browse files

Ability to start a new game while in pause

- switch options in menu
- new and updated translations
parent 4762f080
......@@ -242,9 +242,10 @@ class Round:
self.quit = True
elif self.state.stage == self.State.Stage.MENU:
next_stage = self.state.options.get('choice', None)
next_stage_opt = self.state.options.get('opt', {})
old_stage = self.state.options.get('old_stage', None)
if next_stage is self.State.Stage.NEWGAME and old_stage is not None:
self.state.switch(next_stage, restore=True)
self.state.switch(next_stage, **next_stage_opt)
elif next_stage is not None:
self.state.switch(next_stage)
elif self.state.stage in [self.State.Stage.OPTIONS, self.State.Stage.CREDITS]:
......
......@@ -50,17 +50,18 @@ class GuiMenu:
## First meny entry is either sart or resume game
if self.rnd.state.options.get('old_stage', None) is not None:
self.menu_entries.append((
_("Continue the game"), 'r', Stage.NEWGAME,
))
elif self.rnd.state.options.get('old_stage', None) is None:
self.menu_entries.append((
_("Start the game"), 'n', Stage.NEWGAME
))
self.menu_entries += [
(_("Continue the game"), 'r', Stage.NEWGAME, {"restore": True}),
(_("Restart the game"), 'n', Stage.NEWGAME, {"restore": False}),
]
else:
self.menu_entries += [
(_("Start the game"), 'n', Stage.NEWGAME, {"restore": False}),
]
self.menu_entries += [
( _("Manage options"), 'o', Stage.OPTIONS),
( _("See credits"), 'c', Stage.CREDITS),
( _("Quit"), 'q', Stage.QUIT),
(_("Manage options"), 'o', Stage.OPTIONS, {}),
(_("See credits"), 'c', Stage.CREDITS, {}),
(_("Quit"), 'q', Stage.QUIT, {}),
]
......@@ -72,7 +73,7 @@ class GuiMenu:
## Generate menu's sprites
self.menu_sprites = []
for n,(text, key, stage) in enumerate(self.menu_entries):
for n,(text, key, stage, opt) in enumerate(self.menu_entries):
active = menu_font.render(text, 1, ORANGE)
inactive = menu_font.render(text, 1, WHITE)
......@@ -108,14 +109,16 @@ class GuiMenu:
def input(self, event):
if event.type == pygame.MOUSEBUTTONDOWN:
for n, ((rect,inactive,active), (text,key,stage)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
for n, ((rect,inactive,active), (text,key,stage,opt)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
if rect.collidepoint(event.pos):
self.rnd.state.options['choice'] = stage
self.rnd.state.options['opt'] = opt
self.rnd.state.options['needs_redraw'] = True
elif event.type == pygame.KEYDOWN:
for n, (text,key,stage) in enumerate(self.menu_entries):
for n, (text,key,stage,opt) in enumerate(self.menu_entries):
if event.unicode == key:
self.rnd.state.options['choice'] = stage
self.rnd.state.options['opt'] = opt
self.rnd.state.options['needs_redraw'] = True
if event.key == pygame.K_DOWN:
self.menu_index += 1
......@@ -128,9 +131,10 @@ class GuiMenu:
elif event.key == pygame.K_RETURN:
if self.menu_index is not None:
self.rnd.state.options['choice'] = self.menu_entries[self.menu_index][2]
self.rnd.state.options['opt'] = self.menu_entries[self.menu_index][3]
self.rnd.state.options['needs_redraw'] = True
elif event.type == pygame.MOUSEMOTION:
for n, ((rect,inactive,active), (text,key,stage)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
for n, ((rect,inactive,active), (text,key,stage,opt)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
if rect.collidepoint(event.pos):
self.menu_index = n
self.rnd.state.options['needs_redraw'] = True
......@@ -145,9 +149,9 @@ class GuiOptions:
# Precompute menu
self.menu_entries = []
self.menu_entries.append((
_("Menu"), 'm', Stage.MENU,
))
self.menu_entries.append(
(_("Menu"), 'm', Stage.MENU, {})
)
## Reference point for menu
menu_center = (WIDTH//2, int(HEIGHT*0.9))
......@@ -157,7 +161,7 @@ class GuiOptions:
## Generate menu's sprites
self.menu_sprites = []
for n,(text, key, stage) in enumerate(self.menu_entries):
for n,(text, key, stage, opt) in enumerate(self.menu_entries):
active = menu_font.render(text, 1, ORANGE)
inactive = menu_font.render(text, 1, WHITE)
......@@ -316,25 +320,29 @@ class GuiOptions:
def input(self, event):
if event.type == pygame.MOUSEBUTTONDOWN:
for n, ((rect,inactive,active), (text,key,stage)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
for n, ((rect,inactive,active), (text,key,stage,opt)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
if rect.collidepoint(event.pos):
self.rnd.state.options['choice'] = stage
self.rnd.state.options['opt'] = opt
for n,items_sprites in enumerate(self.items_sprites):
for m,(i_r, iaa, iai, iia, iii) in enumerate(items_sprites):
if i_r.collidepoint(event.pos):
self.items_index[n] = m
self.rnd.state.options['needs_redraw'] = True
elif event.type == pygame.KEYDOWN:
for n, (text,key,stage) in enumerate(self.menu_entries):
for n, (text,key,stage,opt) in enumerate(self.menu_entries):
if event.unicode == key:
self.rnd.state.options['choice'] = stage
self.rnd.state.options['opt'] = opt
self.rnd.state.options['needs_redraw'] = True
if event.key == pygame.K_RETURN:
if self.menu_index is not None:
self.rnd.state.options['choice'] = self.menu_entries[self.menu_index][2]
self.rnd.state.options['opt'] = self.menu_entries[self.menu_index][3]
self.rnd.state.options['needs_redraw'] = True
elif event.key == pygame.K_ESCAPE:
self.rnd.state.options['choice'] = Stage.MENU
self.rnd.state.options['opt'] = {}
self.rnd.state.options['needs_redraw'] = True
elif event.key in [pygame.K_DOWN, pygame.K_UP, pygame.K_LEFT, pygame.K_RIGHT]:
self.rnd.state.options['needs_redraw'] = True
......@@ -364,7 +372,7 @@ class GuiOptions:
self.options_index = None
self.menu_index = 0
elif event.type == pygame.MOUSEMOTION:
for n, ((rect,inactive,active), (text,key,stage)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
for n, ((rect,inactive,active), (text,key,stage,opt)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
if rect.collidepoint(event.pos):
self.menu_index = n
self.options_index = None
......@@ -482,8 +490,8 @@ class GuiCredits:
self.menu_entries = []
self.menu_entries.append(
(_("Menu"), 'm', Stage.MENU)
)
(_("Menu"), 'm', Stage.MENU, {})
)
## Reference point for menu
menu_center = (WIDTH//2, 700)
......@@ -493,7 +501,7 @@ class GuiCredits:
## Generate menu's sprites
self.menu_sprites = []
for n,(text, key, stage) in enumerate(self.menu_entries):
for n,(text, key, stage, opt) in enumerate(self.menu_entries):
active = menu_font.render(text, 1, ORANGE)
inactive = menu_font.render(text, 1, WHITE)
......@@ -527,14 +535,16 @@ class GuiCredits:
def input(self, event):
if event.type == pygame.MOUSEBUTTONDOWN:
for n, ((rect,inactive,active), (text,key,stage)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
for n, ((rect,inactive,active), (text,key,stage,opt)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
if rect.collidepoint(event.pos):
self.rnd.state.options['choice'] = stage
self.rnd.state.options['opt'] = opt
self.rnd.state.options['needs_redraw'] = True
elif event.type == pygame.KEYDOWN:
for n, (text,key,stage) in enumerate(self.menu_entries):
for n, (text,key,stage,opt) in enumerate(self.menu_entries):
if event.unicode == key:
self.rnd.state.options['choice'] = stage
self.rnd.state.options['opt'] = opt
self.rnd.state.options['needs_redraw'] = True
if event.key == pygame.K_DOWN:
self.menu_index += 1
......@@ -547,12 +557,14 @@ class GuiCredits:
if event.key == pygame.K_RETURN:
if self.menu_index is not None:
self.rnd.state.options['choice'] = self.menu_entries[self.menu_index][2]
self.rnd.state.options['opt'] = self.menu_entries[self.menu_index][3]
self.rnd.state.options['needs_redraw'] = True
elif event.key == pygame.K_ESCAPE:
self.rnd.state.options['choice'] = Stage.MENU
self.rnd.state.options['choice'] = {}
self.rnd.state.options['needs_redraw'] = True
elif event.type == pygame.MOUSEMOTION:
for n, ((rect,inactive,active), (text,key,stage)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
for n, ((rect,inactive,active), (text,key,stage,opt)) in enumerate(zip(self.menu_sprites, self.menu_entries)):
if rect.collidepoint(event.pos):
self.menu_index = n
self.rnd.state.options['needs_redraw'] = True
......@@ -1735,8 +1747,8 @@ class GuiGameOver:
self.menu_entries = []
self.menu_entries.append(
(_("Continue"), 'c', Stage.CREDITS)
)
(_("Continue"), 'c', Stage.CREDITS, {})
)
## Reference point for menu
menu_bottomright = (WIDTH - 30, HEIGHT - 30)
......@@ -1746,7 +1758,7 @@ class GuiGameOver:
## Generate menu's sprites
self.menu_sprites = []
for n,(text, key, stage) in enumerate(self.menu_entries):
for n,(text, key, stage, opt) in enumerate(self.menu_entries):
active = menu_font.render(text, 1, ORANGE)
inactive = menu_font.render(text, 1, WHITE)
......
......@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2020-12-02 23:18+0100\n"
"POT-Creation-Date: 2020-12-03 13:18+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -15,267 +15,269 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n"
#: capbattleship/pygameui.py:42
#: capbattleship/pygameui.py:45
msgid "Pirate Battleship"
msgstr ""
#: capbattleship/pygameui.py:49 capbattleship/pygameui.py:50
#: capbattleship/pygameui.py:112 capbattleship/pygameui.py:113
#: capbattleship/pygameui.py:54
msgid "Continue the game"
msgstr ""
#: capbattleship/pygameui.py:55
msgid "Restart the game"
msgstr ""
#: capbattleship/pygameui.py:59
msgid "Start the game"
msgstr ""
#: capbattleship/pygameui.py:55 capbattleship/pygameui.py:56
#: capbattleship/pygameui.py:62
msgid "Manage options"
msgstr ""
#: capbattleship/pygameui.py:61 capbattleship/pygameui.py:62
#: capbattleship/pygameui.py:63
msgid "See credits"
msgstr ""
#: capbattleship/pygameui.py:67 capbattleship/pygameui.py:68
#: capbattleship/pygameui.py:64
msgid "Quit"
msgstr ""
#: capbattleship/pygameui.py:105 capbattleship/pygameui.py:106
msgid "Continue the game"
msgstr ""
#: capbattleship/pygameui.py:156 capbattleship/pygameui.py:157
#: capbattleship/pygameui.py:459 capbattleship/pygameui.py:460
#: capbattleship/pygameui.py:153 capbattleship/pygameui.py:493
msgid "Menu"
msgstr ""
#: capbattleship/pygameui.py:176
#: capbattleship/pygameui.py:178
msgid "Difficulty"
msgstr ""
#: capbattleship/pygameui.py:177
#: capbattleship/pygameui.py:179
msgid "Cheat"
msgstr ""
#: capbattleship/pygameui.py:178
#: capbattleship/pygameui.py:180
msgid "Easy"
msgstr ""
#: capbattleship/pygameui.py:179
#: capbattleship/pygameui.py:181
msgid "Normal"
msgstr ""
#: capbattleship/pygameui.py:180
#: capbattleship/pygameui.py:182
msgid "Hard"
msgstr ""
#: capbattleship/pygameui.py:181
#: capbattleship/pygameui.py:183
msgid "Insane"
msgstr ""
#: capbattleship/pygameui.py:184
#: capbattleship/pygameui.py:186
msgid "Notification speed"
msgstr ""
#: capbattleship/pygameui.py:185
#: capbattleship/pygameui.py:187
msgid "Wait"
msgstr ""
#: capbattleship/pygameui.py:186
#: capbattleship/pygameui.py:188
msgid "2s"
msgstr ""
#: capbattleship/pygameui.py:187
#: capbattleship/pygameui.py:189
msgid "1s"
msgstr ""
#: capbattleship/pygameui.py:188
#: capbattleship/pygameui.py:190
msgid "0.5s"
msgstr ""
#: capbattleship/pygameui.py:189
#: capbattleship/pygameui.py:191
msgid "Skip"
msgstr ""
#: capbattleship/pygameui.py:192
#: capbattleship/pygameui.py:194
msgid "Background Music"
msgstr ""
#: capbattleship/pygameui.py:193 capbattleship/pygameui.py:200
#: capbattleship/pygameui.py:205 capbattleship/pygameui.py:210
#: capbattleship/pygameui.py:195 capbattleship/pygameui.py:202
#: capbattleship/pygameui.py:207 capbattleship/pygameui.py:212
msgid "Disabled"
msgstr ""
#: capbattleship/pygameui.py:194
#: capbattleship/pygameui.py:196
msgid "Menu only"
msgstr ""
#: capbattleship/pygameui.py:195
#: capbattleship/pygameui.py:197
msgid "Play once"
msgstr ""
#: capbattleship/pygameui.py:196
#: capbattleship/pygameui.py:198
msgid "Repeat"
msgstr ""
#: capbattleship/pygameui.py:199
#: capbattleship/pygameui.py:201
msgid "Sfx"
msgstr ""
#: capbattleship/pygameui.py:201 capbattleship/pygameui.py:206
#: capbattleship/pygameui.py:212
#: capbattleship/pygameui.py:203 capbattleship/pygameui.py:208
#: capbattleship/pygameui.py:214
msgid "Enabled"
msgstr ""
#: capbattleship/pygameui.py:204
#: capbattleship/pygameui.py:206
msgid "Animations"
msgstr ""
#: capbattleship/pygameui.py:209
#: capbattleship/pygameui.py:211
msgid "Fullscreen"
msgstr ""
#: capbattleship/pygameui.py:211
#: capbattleship/pygameui.py:213
msgid "Windowed"
msgstr ""
#: capbattleship/pygameui.py:367
#: capbattleship/pygameui.py:401
msgid "Source code development (uses python3, pygame), translation (fr, en)"
msgstr ""
#: capbattleship/pygameui.py:373
#: capbattleship/pygameui.py:407
msgid "Graphism, game design (illustrations, ships, VFX, Map)"
msgstr ""
#: capbattleship/pygameui.py:379
#: capbattleship/pygameui.py:413
msgid "100 Golden Hern piece (Coins)"
msgstr ""
#: capbattleship/pygameui.py:385
#: capbattleship/pygameui.py:419
msgid "Mr. Bumble (Inspiration for 3D model)"
msgstr ""
#: capbattleship/pygameui.py:390
#: capbattleship/pygameui.py:424
msgid "Container Pack (Barrels)"
msgstr ""
#: capbattleship/pygameui.py:396
#: capbattleship/pygameui.py:430
msgid "Titan (Music)"
msgstr ""
#: capbattleship/pygameui.py:402
#: capbattleship/pygameui.py:436
msgid "Stone in the water 080117-002 drop (sound effect)"
msgstr ""
#: capbattleship/pygameui.py:408
#: capbattleship/pygameui.py:442
msgid "Canon Gun - Canon sound_01 (sound effect)"
msgstr ""
#: capbattleship/pygameui.py:413
#: capbattleship/pygameui.py:447
msgid "All the testers"
msgstr ""
#: capbattleship/pygameui.py:414
#: capbattleship/pygameui.py:448
msgid "Thanks! (testing, advices, bugs)"
msgstr ""
#: capbattleship/pygameui.py:573
#: capbattleship/pygameui.py:616
msgid "Choose your pirate"
msgstr ""
#: capbattleship/pygameui.py:833 capbattleship/pygameui.py:1268
#: capbattleship/pygameui.py:893 capbattleship/pygameui.py:1315
msgid "Every shipman is only grousing day and night, which drives the captain completely mad. There is one thing you can do to help him unwind, that is be an easy pray. I would advise you not to…"
msgstr ""
#: capbattleship/pygameui.py:833 capbattleship/pygameui.py:1268
#: capbattleship/pygameui.py:893 capbattleship/pygameui.py:1315
msgid "The Anger"
msgstr ""
#: capbattleship/pygameui.py:834 capbattleship/pygameui.py:1269
#: capbattleship/pygameui.py:894 capbattleship/pygameui.py:1316
msgid "The Victory Saber"
msgstr ""
#: capbattleship/pygameui.py:834 capbattleship/pygameui.py:1269
#: capbattleship/pygameui.py:894 capbattleship/pygameui.py:1316
msgid "They were twin brothers, incredibly talentuous swashbucklers, and the fell for a mysterious lady. She said only the most fearsome pirate would be her match. Will you try their cruelty?"
msgstr ""
#: capbattleship/pygameui.py:835 capbattleship/pygameui.py:1270
#: capbattleship/pygameui.py:895 capbattleship/pygameui.py:1317
msgid "The Pirates Storm"
msgstr ""
#: capbattleship/pygameui.py:835 capbattleship/pygameui.py:1270
#: capbattleship/pygameui.py:895 capbattleship/pygameui.py:1317
msgid "This vessel is known for its sneaky attacks during storms. Manœuvrable and fast, no ship can escape her in the raging waters. If the weather is taking a turn for the worse, be sure that you're alone…"
msgstr ""
#: capbattleship/pygameui.py:836 capbattleship/pygameui.py:1271
#: capbattleship/pygameui.py:896 capbattleship/pygameui.py:1318
msgid "Rather than the vessel, 'The Princess' refers to its heartless captain. Famous buccaneer, she is said to be as rich as a king. Well, if she meets you, maybe she well become even richer…"
msgstr ""
#: capbattleship/pygameui.py:836 capbattleship/pygameui.py:1271
#: capbattleship/pygameui.py:896 capbattleship/pygameui.py:1318
msgid "The Princess"
msgstr ""
#: capbattleship/pygameui.py:1257 capbattleship/pygameui.py:1749
#: capbattleship/pygameui.py:1306 capbattleship/pygameui.py:1735
msgid "Shots"
msgstr ""
#: capbattleship/pygameui.py:1258 capbattleship/pygameui.py:1751
#: capbattleship/pygameui.py:1307 capbattleship/pygameui.py:1737
msgid "Miss"
msgstr ""
#: capbattleship/pygameui.py:1259 capbattleship/pygameui.py:1750
#: capbattleship/pygameui.py:1308 capbattleship/pygameui.py:1736
msgid "Hit"
msgstr ""
#: capbattleship/pygameui.py:1260 capbattleship/pygameui.py:1752
#: capbattleship/pygameui.py:1309 capbattleship/pygameui.py:1738
msgid "Sunk"
msgstr ""
#: capbattleship/pygameui.py:1648 capbattleship/pygameui.py:1649
msgid "Continue"
msgstr ""
#: capbattleship/pygameui.py:1666
#: capbattleship/pygameui.py:1695
msgid "You have won."
msgstr ""
#: capbattleship/pygameui.py:1667
#: capbattleship/pygameui.py:1697
msgid "You have lost."
msgstr ""
#: capbattleship/pygameui.py:1807
#: capbattleship/pygameui.py:1750
msgid "Continue"
msgstr ""
#: capbattleship/pygameui.py:1830
msgid "CAP - Pirate Battleship"
msgstr ""
#: capbattleship/pygameui.py:1813
#: capbattleship/pygameui.py:1838
msgid "CPU hit you."
msgstr ""
#: capbattleship/pygameui.py:1814
#: capbattleship/pygameui.py:1839
msgid "CPU missed you."
msgstr ""
#: capbattleship/pygameui.py:1815
#: capbattleship/pygameui.py:1840
msgid "CPU sunk you."
msgstr ""
#: capbattleship/pygameui.py:1817
#: capbattleship/pygameui.py:1841
msgid "You hit CPU."
msgstr ""
#: capbattleship/pygameui.py:1818
#: capbattleship/pygameui.py:1842
msgid "You missed CPU."
msgstr ""
#: capbattleship/pygameui.py:1819
#: capbattleship/pygameui.py:1843
msgid "You sunk CPU."
msgstr ""
#: capbattleship/pygameui.py:1821
#: capbattleship/pygameui.py:1844
msgid "Already shot there."
msgstr ""
#: capbattleship/pygameui.py:1823
#: capbattleship/pygameui.py:1845
msgid "CPU starts."
msgstr ""
#: capbattleship/pygameui.py:1824
#: capbattleship/pygameui.py:1846
msgid "You start."
msgstr ""
......@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: contact@capbattleship.tuxfamily.org\n"
"POT-Creation-Date: 2020-12-02 23:18+0100\n"
"POT-Creation-Date: 2020-12-03 13:18+0100\n"
"PO-Revision-Date: 2020-12-02 01:10+0000\n"
"Last-Translator: Fabien Givors <captnfab+wl@chezlefab.net>\n"
"Language-Team: German <https://hosted.weblate.org/projects/capbattleship/"
......@@ -19,173 +19,176 @@ msgstr ""
"X-Generator: Weblate 4.4-dev\n"
"Generated-By: pygettext.py 1.5\n"
#: capbattleship/pygameui.py:42
#: capbattleship/pygameui.py:45
msgid "Pirate Battleship"
msgstr "Piratenschiffe versenken"
#: capbattleship/pygameui.py:49 capbattleship/pygameui.py:50
#: capbattleship/pygameui.py:112 capbattleship/pygameui.py:113
#: capbattleship/pygameui.py:54
msgid "Continue the game"
msgstr "Die Schlacht beginnen!"
#: capbattleship/pygameui.py:55
#, fuzzy
msgid "Restart the game"
msgstr "Die Schlacht beginnen!"
#: capbattleship/pygameui.py:59
msgid "Start the game"
msgstr "Die Schlacht beginnen!"
#: capbattleship/pygameui.py:55 capbattleship/pygameui.py:56
#: capbattleship/pygameui.py:62
msgid "Manage options"
msgstr "Optionen verwalten"
#: capbattleship/pygameui.py:61 capbattleship/pygameui.py:62
#: capbattleship/pygameui.py:63
msgid "See credits"
msgstr "Beteiligtenliste ansehen"
#: capbattleship/pygameui.py:67 capbattleship/pygameui.py:68
#: capbattleship/pygameui.py:64
msgid "Quit"
msgstr "Zurück zum festen Boden"
#: capbattleship/pygameui.py:105 capbattleship/pygameui.py:106
msgid "Continue the game"
msgstr "Die Schlacht beginnen!"
#: capbattleship/pygameui.py:156 capbattleship/pygameui.py:157
#: capbattleship/pygameui.py:459 capbattleship/pygameui.py:460
#: capbattleship/pygameui.py:153 capbattleship/pygameui.py:493