Move app and game debug log into app module.
Remove old Java log class.
This commit is contained in:
parent
b80009850e
commit
aace9864c2
|
@ -1,74 +0,0 @@
|
|||
/*****************************************************************************
|
||||
GameLoop.java - Main controlling class for the justCheckers game.
|
||||
*****************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of justCheckers.
|
||||
|
||||
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/>.
|
||||
*****************************************************************************/
|
||||
|
||||
package org.justcheckers.common;
|
||||
|
||||
// TODO Resolve this with separation of various platform setups...
|
||||
//import org.justcheckers.android.R;
|
||||
//
|
||||
//import android.app.Activity;
|
||||
//import android.os.Build;
|
||||
//import android.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Functions for logging errors and gathering statistics.
|
||||
*
|
||||
* @author Dorian Pula
|
||||
*/
|
||||
public abstract class LoggingAndStatistics {
|
||||
|
||||
/**
|
||||
* Logs information about the program. Displays the game's header and
|
||||
* relevant system properties at runtime.
|
||||
*/
|
||||
public static void logApplicationInfo(String gameVersion, String gameWebsite) {
|
||||
|
||||
// TODO Fix
|
||||
// String gameVersion = caller.getString(R.string.app_version);
|
||||
// String gameWebsite = caller.getString(R.string.project_website);
|
||||
String appInfo = "justCheckers -- Version:" + gameVersion
|
||||
+ " - Website: " + gameWebsite;
|
||||
|
||||
// TODO Clean up...
|
||||
Logger log = LoggerFactory.getLogger(LoggingAndStatistics.class);
|
||||
log.info("ApplInfo", appInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs information about the device and system, the app is
|
||||
* running on.
|
||||
*/
|
||||
public static void logDeviceAndSystemInfo() {
|
||||
|
||||
// System properties.
|
||||
// String sysList = "SDK version: " + Build.VERSION.RELEASE
|
||||
// + " - API: " + Build.VERSION.SDK_INT
|
||||
// + " - Device: " + Build.MANUFACTURER + " " + Build.MODEL;
|
||||
// TODO Fix
|
||||
String sysList = "FIXME";
|
||||
|
||||
Logger log = LoggerFactory.getLogger(LoggingAndStatistics.class);
|
||||
log.info("DevSysInfo", sysList);
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
__version__ = '0.3'
|
||||
__version__ = '0.3.0'
|
||||
|
|
|
@ -17,20 +17,43 @@
|
|||
# Please share and enjoy!
|
||||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PySide import QtGui
|
||||
|
||||
import justcheckers
|
||||
from justcheckers.ui.window import DesktopGameWindow
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point into the app."""
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
log_system_and_game_info()
|
||||
view = DesktopGameWindow()
|
||||
view.show()
|
||||
app.exec_()
|
||||
sys.exit()
|
||||
|
||||
|
||||
def log_system_and_game_info():
|
||||
"""Logs information about the game and system running the game."""
|
||||
LOG.info('justCheckers -- v{}'.format(justcheckers.__version__))
|
||||
|
||||
message = 'I am running on {os}.\nMy screen is {height}x{width}'
|
||||
geometry = QtGui.QDesktopWidget().availableGeometry()
|
||||
|
||||
os_sys = sys.platform
|
||||
if sys.platform == 'posix':
|
||||
os_name, _, _, _, os_arch = os.uname()
|
||||
os_sys = '{name} {arch}'.format(name=os_name, arch=os_arch)
|
||||
|
||||
LOG.info(message.format(os=os_sys, height=geometry.height(), width=geometry.width()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -17,21 +17,14 @@
|
|||
# Please share and enjoy!
|
||||
#
|
||||
|
||||
"""
|
||||
Main window for the game.
|
||||
|
||||
:copyright: Copyright 2013, Dorian Pula <dorian.pula@amber-penguin-software.ca>
|
||||
:license: GPL v3+
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
|
||||
|
||||
class MainMenuView(QtGui.QWidget):
|
||||
"""Main menu for the game."""
|
||||
|
||||
# TODO Setup functional testing with PySide.QtTest
|
||||
|
||||
def __init__(self):
|
||||
|
@ -40,7 +33,6 @@ class MainMenuView(QtGui.QWidget):
|
|||
|
||||
def setup_components(self):
|
||||
"""Setup the components that make up the widget."""
|
||||
print(self.get_system_info())
|
||||
self.new_game = QtGui.QPushButton('&New Game', self)
|
||||
self.open_game = QtGui.QPushButton('&Open Game', self)
|
||||
self.save_game = QtGui.QPushButton('&Save Game', self)
|
||||
|
@ -63,19 +55,6 @@ class MainMenuView(QtGui.QWidget):
|
|||
widget_layout.addStretch()
|
||||
self.setLayout(widget_layout)
|
||||
|
||||
@staticmethod
|
||||
def get_system_info():
|
||||
"""Retrieve information about the system."""
|
||||
message = 'I am running on {os}.\nMy screen is {height}x{width}'
|
||||
geometry = QtGui.QDesktopWidget().availableGeometry()
|
||||
|
||||
os_sys = sys.platform
|
||||
if sys.platform == 'posix':
|
||||
os_name, _, _, _, os_arch = os.uname()
|
||||
os_sys = '{name} {arch}'.format(name=os_name, arch=os_arch)
|
||||
|
||||
return message.format(os=os_sys, height=geometry.height(), width=geometry.width())
|
||||
|
||||
def exit_app(self):
|
||||
"""Exits the application."""
|
||||
QtCore.QCoreApplication.instance().exit()
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
# Please share and enjoy!
|
||||
#
|
||||
|
||||
"""
|
||||
Main window for the game.
|
||||
|
||||
:copyright: Copyright 2013, Dorian Pula <dorian.pula@amber-penguin-software.ca>
|
||||
:license: GPL v3+
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from PySide import QtGui
|
||||
|
@ -32,6 +25,7 @@ from justcheckers.ui.menu_view import MainMenuView
|
|||
|
||||
|
||||
class DesktopGameWindow(QtGui.QMainWindow):
|
||||
"""Main window for the game."""
|
||||
# TODO Setup functional testing with PySide.QtTest
|
||||
|
||||
def __init__(self):
|
||||
|
@ -45,6 +39,7 @@ class DesktopGameWindow(QtGui.QMainWindow):
|
|||
self.center()
|
||||
|
||||
def add_backdrop(self):
|
||||
"""Adds a backdrop image to the game."""
|
||||
tile = QtGui.QPixmap(self.path_to_asset('backdrop.jpg'))
|
||||
palette = QtGui.QPalette()
|
||||
palette.setBrush(QtGui.QPalette.Background, tile)
|
||||
|
|
Loading…
Reference in New Issue