Replicate main menu completely with styling.

This commit is contained in:
Dorian 2017-02-23 08:34:31 -05:00
parent a36a50464c
commit 053430b77c
4 changed files with 49 additions and 98 deletions

2
.gitignore vendored
View File

@ -4,4 +4,4 @@ bin
*.pyc *.pyc
docs/_build docs/_build
justcheckers.ini

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -11,43 +11,58 @@ ScreenManager:
source: 'images/backdrop.jpg' source: 'images/backdrop.jpg'
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
Label:
size_hint_y: 0.1
Image: Image:
source: 'images/frosted_logo.png' source: 'images/logo.png'
size_hint_y: 0.5 size_hint_y: 0.25
allow_stretch: True
canvas.before:
Color:
rgba: 1, 1, 1, 0.5
Rectangle:
pos: self.pos
size: self.size
Label:
size_hint_y: 0.1
BoxLayout:
orientation: "vertical"
size_hint_x: 0.9
pos_hint: {'center_x': 0.5}
Button:
text: "New Game"
size_hint_y: 0.1
on_press:
root.manager.transition.direction = 'left'
root.manager.current = 'game'
Button:
text: "Open Game"
disabled: True
size_hint_y: 0.1
Button:
text: "Save Game"
disabled: True
size_hint_y: 0.1
Button:
text: "About Game"
size_hint_y: 0.1
on_press:
root.manager.transition.direction = 'left'
root.manager.current = 'info'
Button:
text: "Settings"
size_hint_y: 0.1
on_press:
app.open_settings()
Button:
text: "Exit"
size_hint_y: 0.1
on_press:
app.stop()
Label: Label:
text: "Version {}".format(justcheckers.__version__) text: "Version {}".format(justcheckers.__version__)
size_hint_y: 0.1 size_hint_y: 0.1
Button: pos_hint: {'center_x': 0.9}
text: "New Game"
size_hint_x: 0.9
size_hint_y: 0.1
on_press:
root.manager.transition.direction = 'left'
root.manager.current = 'game'
Button:
text: "Open Game"
disabled: True
size_hint_y: 0.1
Button:
text: "Save Game"
disabled: True
size_hint_y: 0.1
Button:
text: "About Game"
size_hint_y: 0.1
on_press:
root.manager.transition.direction = 'left'
root.manager.current = 'info'
Button:
text: "Settings"
size_hint_y: 0.1
on_press:
app.open_settings()
Button:
text: "Exit"
size_hint_y: 0.1
on_press:
app.stop()
<GameScreen@Screen>: <GameScreen@Screen>:

View File

@ -1,64 +0,0 @@
#
# Copyright (c) 2014 Dorian Pula <dorian.pula@amber-penguin-software.ca>
#
# justCheckers is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# justCheckers is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with justCheckers. If not, see <http://www.gnu.org/licenses/>.
#
# Please share and enjoy!
#
from PySide import QtGui
from justcheckers.ui.game_view import GameView
from justcheckers.ui.info_view import InfoView
from justcheckers.ui.menu_view import MainMenuView
from justcheckers.ui import util
class DesktopGameWindow(QtGui.QMainWindow):
"""Main window for the game."""
# TODO Setup functional testing with PySide.QtTest
def __init__(self):
super(DesktopGameWindow, self).__init__()
self.setWindowTitle('justCheckers')
self.setGeometry(300, 300, 800, 600)
self.setWindowIcon(QtGui.QIcon(util.path_to_asset('icon.png')))
self.setup_components()
self.add_backdrop()
self.center()
def add_backdrop(self):
"""Adds a backdrop image to the game."""
tile = QtGui.QPixmap(util.path_to_asset('backdrop.jpg'))
palette = QtGui.QPalette()
palette.setBrush(QtGui.QPalette.Background, tile)
self.setPalette(palette)
def setup_components(self):
"""Setup the components that make up the widget."""
self.view_stack = QtGui.QStackedWidget()
self.view_stack.addWidget(MainMenuView())
self.view_stack.addWidget(InfoView())
self.view_stack.addWidget(GameView())
self.setCentralWidget(self.view_stack)
def center(self):
"""Centers the widget in the middle of the screen."""
widget_rectangle = self.frameGeometry()
center_point = QtGui.QDesktopWidget().availableGeometry().center()
widget_rectangle.moveCenter(center_point)
self.move(widget_rectangle.topLeft())