parent
aace9864c2
commit
bb21cc4577
|
@ -17,10 +17,10 @@
|
|||
# Please share and enjoy!
|
||||
#
|
||||
|
||||
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
|
||||
from justcheckers.ui import util
|
||||
|
||||
class MainMenuView(QtGui.QWidget):
|
||||
"""Main menu for the game."""
|
||||
|
@ -33,19 +33,34 @@ class MainMenuView(QtGui.QWidget):
|
|||
|
||||
def setup_components(self):
|
||||
"""Setup the components that make up the widget."""
|
||||
|
||||
# TODO Create a more compelling looking logo label, well scaled.
|
||||
self.logo_label = QtGui.QLabel('justCheckers', self)
|
||||
logo_pixmap = QtGui.QPixmap(util.path_to_asset('logo.png'))
|
||||
# logo_pixmap.fill(QtGui.QColor(255, 255, 255, 125))
|
||||
|
||||
self.logo_label.setPixmap(logo_pixmap)
|
||||
|
||||
self.new_game = QtGui.QPushButton('&New Game', self)
|
||||
self.new_game.setEnabled(False)
|
||||
self.open_game = QtGui.QPushButton('&Open Game', self)
|
||||
self.open_game.setEnabled(False)
|
||||
self.save_game = QtGui.QPushButton('&Save Game', self)
|
||||
self.save_game.setEnabled(False)
|
||||
# TODO Render buttons greyed out.
|
||||
|
||||
self.about_game = QtGui.QPushButton('About Game', self)
|
||||
self.about_game.setEnabled(False)
|
||||
# TODO Add links to site and display license inside about game widget.
|
||||
self.settings = QtGui.QPushButton('Settings', self)
|
||||
self.settings.setEnabled(False)
|
||||
self.exit_button = QtGui.QPushButton('Exit', self)
|
||||
self.exit_button.clicked.connect(self.exit_app)
|
||||
|
||||
widget_layout = QtGui.QVBoxLayout(self)
|
||||
widget_layout.addStretch()
|
||||
widget_layout.addWidget(self.logo_label)
|
||||
widget_layout.addStretch()
|
||||
widget_layout.addWidget(self.new_game)
|
||||
widget_layout.addWidget(self.open_game)
|
||||
widget_layout.addWidget(self.save_game)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import os
|
||||
|
||||
IMAGE_ASSETS = 'images'
|
||||
TEXT_ASSETS = 'assets'
|
||||
|
||||
|
||||
def path_to_asset(filename, asset_type=IMAGE_ASSETS):
|
||||
"""
|
||||
Helper utility for getting the path to an asset.
|
||||
|
||||
:param filename: The filename of the asset.
|
||||
:param asset_type: The type of asset. Defaults to images.
|
||||
:return: The path to the asset.
|
||||
"""
|
||||
return os.path.join(os.path.dirname(__file__), os.pardir, asset_type.lower(), filename)
|
|
@ -17,12 +17,11 @@
|
|||
# Please share and enjoy!
|
||||
#
|
||||
|
||||
import os
|
||||
|
||||
from PySide import QtGui
|
||||
|
||||
from justcheckers.ui.menu_view import MainMenuView
|
||||
|
||||
from justcheckers.ui import util
|
||||
|
||||
class DesktopGameWindow(QtGui.QMainWindow):
|
||||
"""Main window for the game."""
|
||||
|
@ -33,14 +32,14 @@ class DesktopGameWindow(QtGui.QMainWindow):
|
|||
self.setWindowTitle('justCheckers')
|
||||
self.setGeometry(300, 300, 800, 600)
|
||||
|
||||
self.setWindowIcon(QtGui.QIcon(self.path_to_asset('icon.png')))
|
||||
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(self.path_to_asset('backdrop.jpg'))
|
||||
tile = QtGui.QPixmap(util.path_to_asset('backdrop.jpg'))
|
||||
palette = QtGui.QPalette()
|
||||
palette.setBrush(QtGui.QPalette.Background, tile)
|
||||
self.setPalette(palette)
|
||||
|
@ -58,16 +57,4 @@ class DesktopGameWindow(QtGui.QMainWindow):
|
|||
widget_rectangle.moveCenter(center_point)
|
||||
self.move(widget_rectangle.topLeft())
|
||||
|
||||
IMAGE_ASSETS = 'images'
|
||||
TEXT_ASSETS = 'assets'
|
||||
|
||||
@staticmethod
|
||||
def path_to_asset(filename, asset_type=IMAGE_ASSETS):
|
||||
"""
|
||||
Helper utility for getting the path to an asset.
|
||||
|
||||
:param filename: The filename of the asset.
|
||||
:param asset_type: The type of asset. Defaults to images.
|
||||
:return: The path to the asset.
|
||||
"""
|
||||
return os.path.join(os.path.dirname(__file__), os.pardir, asset_type.lower(), filename)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
# Task management
|
||||
invoke
|
||||
|
||||
# User interface
|
||||
PySide==1.2.2
|
||||
|
||||
# Core logic
|
||||
enum34==0.9.19
|
||||
|
|
Loading…
Reference in New Issue