diff --git a/.gitignore b/.gitignore index 3a7a8d3..d9db6a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin +src .DS_Store .idea diff --git a/buildozer.spec b/buildozer.spec new file mode 100644 index 0000000..3e6c9ca --- /dev/null +++ b/buildozer.spec @@ -0,0 +1,239 @@ +[app] + +# (str) Title of your application +title = justCheckers + +# (str) Package name +package.name = justcheckers + +# (str) Package domain (needed for android/ios packaging) +package.domain = org.justcheckers + +# (str) Source code where the main.py live +source.dir = . + +# (list) Source files to include (let empty to include all the files) +source.include_exts = py,png,jpg,kv,atlas,md + +# (list) List of inclusions using pattern matching +#source.include_patterns = assets/*,images/*.png + +# (list) Source files to exclude (let empty to not exclude anything) +#source.exclude_exts = spec + +# (list) List of directory to exclude (let empty to not exclude anything) +#source.exclude_dirs = tests, bin + +# (list) List of exclusions using pattern matching +#source.exclude_patterns = license,images/*/*.jpg + +# (str) Application versioning (method 1) +version = 0.3.0 + +# (str) Application versioning (method 2) +# version.regex = __version__ = ['"](.*)['"] +# version.filename = %(source.dir)s/main.py + +# (list) Application requirements +# comma seperated e.g. requirements = sqlite3,kivy +requirements = kivy,hostpython2,docutils + +# (str) Custom source folders for requirements +# Sets custom source for any requirements with recipes +# requirements.source.kivy = ../../kivy + +# (list) Garden requirements +#garden_requirements = + +# (str) Presplash of the application +presplash.filename = %(source.dir)s/images/splash.png + +# (str) Icon of the application +icon.filename = %(source.dir)s/images/icon.png + +# (str) Supported orientation (one of landscape, portrait or all) +orientation = landscape + +# (list) List of service to declare +#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY + +# +# OSX Specific +# + +# +# author = © Copyright Info + +# +# Android specific +# + +# (bool) Indicate if the application should be fullscreen or not +fullscreen = 1 + +# (list) Permissions +android.permissions = INTERNET + +# (int) Android API to use +android.api = 19 + +# (int) Minimum API required +android.minapi = 9 + +# (int) Android SDK version to use +android.sdk = 20 + +# (str) Android NDK version to use +android.ndk = 9c + +# (bool) Use --private data storage (True) or --dir public storage (False) +android.private_storage = True + +# (str) Android NDK directory (if empty, it will be automatically downloaded.) +#android.ndk_path = + +# (str) Android SDK directory (if empty, it will be automatically downloaded.) +#android.sdk_path = + +# (str) ANT directory (if empty, it will be automatically downloaded.) +#android.ant_path = + +# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github) +#android.p4a_dir = + +# (str) The directory in which python-for-android should look for your own build recipes (if any) +#p4a.local_recipes = + +# (str) Filename to the hook for p4a +#p4a.hook = + +# (list) python-for-android whitelist +#android.p4a_whitelist = + +# (bool) If True, then skip trying to update the Android sdk +# This can be useful to avoid excess Internet downloads or save time +# when an update is due and you just want to test/build your package +# android.skip_update = False + +# (str) Bootstrap to use for android builds (android_new only) +# android.bootstrap = sdl2 + +# (str) Android entry point, default is ok for Kivy-based app +#android.entrypoint = org.renpy.android.PythonActivity + +# (list) List of Java .jar files to add to the libs so that pyjnius can access +# their classes. Don't add jars that you do not need, since extra jars can slow +# down the build process. Allows wildcards matching, for example: +# OUYA-ODK/libs/*.jar +#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar + +# (list) List of Java files to add to the android project (can be java or a +# directory containing the files) +#android.add_src = + +# (str) python-for-android branch to use, if not master, useful to try +# not yet merged features. +#android.branch = master + +# (str) OUYA Console category. Should be one of GAME or APP +# If you leave this blank, OUYA support will not be enabled +#android.ouya.category = GAME + +# (str) Filename of OUYA Console icon. It must be a 732x412 png image. +#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png + +# (str) XML file to include as an intent filters in tag +#android.manifest.intent_filters = + +# (list) Android additionnal libraries to copy into libs/armeabi +#android.add_libs_armeabi = libs/android/*.so +#android.add_libs_armeabi_v7a = libs/android-v7/*.so +#android.add_libs_x86 = libs/android-x86/*.so +#android.add_libs_mips = libs/android-mips/*.so + +# (bool) Indicate whether the screen should stay on +# Don't forget to add the WAKE_LOCK permission if you set this to True +#android.wakelock = False + +# (list) Android application meta-data to set (key=value format) +#android.meta_data = + +# (list) Android library project to add (will be added in the +# project.properties automatically.) +#android.library_references = + +# (str) Android logcat filters to use +#android.logcat_filters = *:S python:D + +# (bool) Copy library instead of making a libpymodules.so +#android.copy_libs = 1 + +# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86 +android.arch = armeabi-v7a + +# +# iOS specific +# + +# (str) Path to a custom kivy-ios folder +#ios.kivy_ios_dir = ../kivy-ios + +# (str) Name of the certificate to use for signing the debug version +# Get a list of available identities: buildozer ios list_identities +#ios.codesign.debug = "iPhone Developer: ()" + +# (str) Name of the certificate to use for signing the release version +#ios.codesign.release = %(ios.codesign.debug)s + + +[buildozer] + +# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output)) +log_level = 2 + +# (int) Display warning if buildozer is run as root (0 = False, 1 = True) +warn_on_root = 1 + +# (str) Path to build artifact storage, absolute or relative to spec file +# build_dir = ./.buildozer + +# (str) Path to build output (i.e. .apk, .ipa) storage +# bin_dir = ./bin + +# ----------------------------------------------------------------------------- +# List as sections +# +# You can define all the "list" as [section:key]. +# Each line will be considered as a option to the list. +# Let's take [app] / source.exclude_patterns. +# Instead of doing: +# +#[app] +#source.exclude_patterns = license,data/audio/*.wav,data/images/original/* +# +# This can be translated into: +# +#[app:source.exclude_patterns] +#license +#data/audio/*.wav +#data/images/original/* +# + + +# ----------------------------------------------------------------------------- +# Profiles +# +# You can extend section / key with a profile +# For example, you want to deploy a demo version of your application without +# HD content. You could first change the title to add "(demo)" in the name +# and extend the excluded directories to remove the HD content. +# +#[app@demo] +#title = My Application (demo) +# +#[app:source.exclude_patterns@demo] +#images/hd/* +# +# Then, invoke the command line with the "demo" profile: +# +#buildozer --profile demo android debug diff --git a/justcheckers/justcheckers.kv b/justcheckers/justcheckers.kv index 75521a8..94275dc 100644 --- a/justcheckers/justcheckers.kv +++ b/justcheckers/justcheckers.kv @@ -83,13 +83,43 @@ ScreenManager: : name: 'info' + documentation: "credits" Image: source: 'images/backdrop.jpg' BoxLayout: + orientation: "vertical" Label: - text: "Info" - Button: - text: "Back to Menu" - on_press: - root.manager.transition.direction = 'right' - root.manager.current = 'menu' + size_hint_y: 0.1 + RstDocument: + source: "justcheckers/assets/{}.md".format(root.documentation) + size_hint_y: 0.75 + size_hint_x: 0.9 + pos_hint: {'center_x': 0.5} + Label: + size_hint_y: 0.1 + BoxLayout: + orientation: "horizontal" + size_hint_x: 0.9 + size_hint_y: 0.1 + pos_hint: {'center_x': 0.5} + Button: + text: "Back to Menu" + on_press: + root.manager.transition.direction = 'right' + root.manager.current = 'menu' + ToggleButton: + id: toggle_credits + text: "Credits" + state: "down" if root.documentation == 'credits' else "normal" + group: "info" + on_state: + if self.state == 'down': root.documentation = 'credits' + ToggleButton + id: toggle_license + text: "License" + group: "info" + state: "down" if root.documentation == 'license' else "normal" + on_state: + if self.state == 'down': root.documentation = 'license' + Label: + size_hint_y: 0.1 diff --git a/justcheckers/ui/__init__.py b/justcheckers/ui/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/justcheckers/ui/game_view.py b/justcheckers/ui/game_view.py deleted file mode 100644 index a8f0c98..0000000 --- a/justcheckers/ui/game_view.py +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright (c) 2014 Dorian Pula -# -# 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 . -# -# Please share and enjoy! -# - -from PySide import QtGui -from PySide import QtCore - - -class GameBoardWidget(QtGui.QGraphicsView): - def __init__(self, scene): - super(GameBoardWidget, self).__init__(scene) - self.scene = scene - - def create_checker_board(self): - - redness = QtGui.QBrush(color=QtCore.Qt.darkRed) - redness_pen = QtGui.QPen(color=QtCore.Qt.darkRed) - self.scene.addRect(10, 10, 50, 50, pen=redness_pen, brush=redness) - self.scene.addText('Hello world...') - - # TODO Add in number of captured pieces and whose turn it is. - - -class GameView(QtGui.QWidget): - """Game viewer for the game's license, etc.""" - - # TODO Setup functional testing with PySide.QtTest - - def __init__(self): - super(GameView, self).__init__() - self.setup_components() - - def setup_components(self): - self.game_board_scene = QtGui.QGraphicsScene() - self.game_board = GameBoardWidget(self.game_board_scene) - - self.game_board.create_checker_board() - self.game_board.show() - - - exit_button = QtGui.QPushButton('Back to Menu', self) - exit_button.setFixedHeight(50) - exit_button.clicked.connect(self.switch_to_menu_view) - - widget_layout = QtGui.QVBoxLayout(self) - widget_layout.addWidget(self.game_board) - - button_row = QtGui.QHBoxLayout(self) - button_row.addWidget(exit_button) - - widget_layout.addLayout(button_row) - - self.setLayout(widget_layout) - - def switch_to_menu_view(self): - self.parentWidget().setCurrentIndex(0) diff --git a/justcheckers/ui/info_view.py b/justcheckers/ui/info_view.py deleted file mode 100644 index 6c44f8f..0000000 --- a/justcheckers/ui/info_view.py +++ /dev/null @@ -1,84 +0,0 @@ -# -# Copyright (c) 2014 Dorian Pula -# -# 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 . -# -# Please share and enjoy! -# - -import codecs - -import markdown -from PySide import QtGui -from PySide import QtWebKit - -from justcheckers.ui import util - - -class InfoView(QtGui.QWidget): - """Info viewer for the game's license, etc.""" - - # TODO Setup functional testing with PySide.QtTest - - def __init__(self): - super(InfoView, self).__init__() - self.setup_components() - - def setup_components(self): - - self.info_viewer = QtWebKit.QWebView(self) - about_html = self.generate_html_from_markdown('credits.md') - self.info_viewer.setHtml(about_html) - - exit_button = QtGui.QPushButton('Back to Menu', self) - exit_button.setFixedHeight(50) - exit_button.clicked.connect(self.switch_to_menu_view) - - credits_button = QtGui.QPushButton('Credits', self) - credits_button.setFixedHeight(50) - credits_button.clicked.connect(self.display_about_info) - - license_button = QtGui.QPushButton('License', self) - license_button.setFixedHeight(50) - license_button.clicked.connect(self.display_license_info) - - widget_layout = QtGui.QVBoxLayout(self) - widget_layout.addWidget(self.info_viewer) - - button_row = QtGui.QHBoxLayout(self) - button_row.addWidget(exit_button) - button_row.addWidget(credits_button) - button_row.addWidget(license_button) - - widget_layout.addLayout(button_row) - - self.setLayout(widget_layout) - - def switch_to_menu_view(self): - self.parentWidget().setCurrentIndex(0) - - def display_about_info(self): - about_html = self.generate_html_from_markdown('credits.md') - self.info_viewer.setHtml(about_html) - - def display_license_info(self): - license_html = self.generate_html_from_markdown('license.md') - self.info_viewer.setHtml(license_html) - - def generate_html_from_markdown(self, filename): - file_path = util.path_to_asset(filename, asset_type=util.TEXT_ASSETS) - with codecs.open(file_path, mode='r', encoding='utf-8') as markdown_file: - text = markdown_file.read() - return markdown.markdown(text) - diff --git a/justcheckers/ui/util.py b/justcheckers/ui/util.py deleted file mode 100644 index da26272..0000000 --- a/justcheckers/ui/util.py +++ /dev/null @@ -1,15 +0,0 @@ -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) diff --git a/main.py b/main.py new file mode 100644 index 0000000..ea2f2da --- /dev/null +++ b/main.py @@ -0,0 +1,5 @@ +from justcheckers import app + + +if __name__ == '__main__': + app.JustCheckersApp().run() diff --git a/requirements.txt b/requirements.txt index 40f3fac..25250c1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ Markdown==2.4.1 # Core logic enum34==0.9.19 +docutils