Skip to content

Commit

Permalink
Upload all the new code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee authored and Lee committed Jul 8, 2015
1 parent 73829dd commit b3009f5
Show file tree
Hide file tree
Showing 32 changed files with 4,641 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "phoenix-backend"]
path = phoenix-backend
url = https://github.com/team-phoenix/phoenix-backend
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Phoenix
=======

A super-slick libretro frontend powered by Qt5. Dead-simple to use, Phoenix features both a powerful library system to organize your classic game collection, along with a set of up-to-date emulators to play them right within the app!

We've designed Phoenix with the hope that it'll be perfect for everyone, whether you're someone who hardly plays videogames, a hardcore gamer, a speedrunner, or even a homebrew programmer!

[![Build Status](https://secure.travis-ci.org/team-phoenix/Phoenix.png)](http://travis-ci.org/team-phoenix/Phoenix)

<b>Phoenix is still under early development. Don't expect everything to work!<b>

![Screenshot](https://github.com/team-phoenix/Phoenix/raw/master/assets/Phoenix.gif)

-----------

A message for developers
--------

**We need you!** We're looking for C/C++/QML programmers to help us build Phoenix.
Check out our [Wiki](https://github.com/team-phoenix/Phoenix/wiki) for build instructions, ways to contact the lead developers and more!
28 changes: 28 additions & 0 deletions common.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}

export(INSTALLS)

96 changes: 96 additions & 0 deletions frontend/frontend.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
TEMPLATE += app

QT += qml quick widgets concurrent sql multimedia

CONFIG += c++11 lib_bundle

#Inlcude backend path
INCLUDEPATH += ../phoenix-backend ../phoenix-backend/input

LIBS += -L../phoenix-backend -lphoenix-backend
LIBS += -lsamplerate

win32 {
CONFIG -= windows
QMAKE_LFLAGS += $$QMAKE_LFLAGS_WINDOWS

LIBS += -LC:/SDL2/lib
LIBS += -lmingw32 -lSDL2main -lSDL2 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid

DEFINES += SDL_WIN
INCLUDEPATH += C:/SDL2/include C:/msys64/mingw64/include/SDL2 C:/msys64/mingw32/include/SDL2


CONFIG(debug, debug|release) {
depends.path = $$OUT_PWD/debug
depends.files += C:/SDL2/bin/SDL2.dll
depends.files += $${PWD}/metadata/openvgdb.sqlite

}

CONFIG(release, debug|release) {
depends.path = $$OUT_PWD/release
depends.files += C:/SDL2/bin/SDL2.dll
depends.files += $${PWD}/metadata/openvgdb.sqlite
}

INSTALLS += depends
RC_FILE = ../phoenix.rc
}

else {
LIBS += -lSDL2
INCLUDEPATH += /usr/local/include /usr/local/include/SDL2 # Homebrew (OS X)
INCLUDEPATH += /opt/local/include /opt/local/include/SDL2 # MacPorts (OS X)
INCLUDEPATH += /usr/include /usr/include/SDL2 # Linux
QMAKE_CXXFLAGS +=
QMAKE_LFLAGS += -L/usr/local/lib -L/opt/local/lib
}

linux {

CONFIG( debug, debug|release ) {
depends.path = $$OUT_PWD/debug
depends.files += $${PWD}/metadata/openvgdb.sqlite
}


CONFIG(release, debug|release) {
depends.path = $$OUT_PWD/release
depends.files += $${PWD}/metadata/openvgdb.sqlite
}

INSTALLS += depends

}

INCLUDEPATH += include include/library

SOURCES += src/main.cpp \
src/library/librarymodel.cpp \
src/library/libraryinternaldatabase.cpp \
src/library/platforms.cpp \
src/library/metadatadatabase.cpp

HEADERS += include/library/librarymodel.h \
include/library/libraryinternaldatabase.h \
include/library/libretro_cores_info_map.h \
include/library/platforms.h \
include/library/metadatadatabase.h


# Will build the final executable in the main project directory.
TARGET = ../phoenix

# Check if the config file exists
include( ../common.pri )

RESOURCES += qml/qml.qrc \
qml/Theme/theme.qrc

macx {
depends.files += $${PWD}/metadata/openvgdb.sqlite
depends.path = Contents/MacOS

QMAKE_BUNDLE_DATA += depends
}
49 changes: 49 additions & 0 deletions frontend/include/library/libraryinternaldatabase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef LIBRARYINTERNALDATABASE_H
#define LIBRARYINTERNALDATABASE_H

#include <QString>
#include <QSqlDatabase>
#include <QSqlError>
#include <QDebug>
#include <QSqlQuery>

namespace Library {

class LibraryInternalDatabase {

public:

static const QString tableVersion;
static const QString databaseName;
static const QString tableName;

LibraryInternalDatabase();

~LibraryInternalDatabase();

QSqlDatabase &database();

// opens the internal QSqlDatabase.
void open();

// Returns the schema verison.
int version() const;

// Returns the absolute path of the
// underlying SQL database.
QString filePath() const;

private:
QSqlDatabase db;

// Creates the table.
bool createSchema();

// Populates the database with dummy entries for testing purposes.
bool loadFixtures();

QString mFilePath;
};
}

#endif // LIBRARYINTERNALDATABASE_H
191 changes: 191 additions & 0 deletions frontend/include/library/librarymodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#ifndef LIBRARYMODEL_H
#define LIBRARYMODEL_H

#include <QSqlTableModel>
#include <QVariant>
#include <QHash>
#include <QUrl>
#include <QMutex>
#include <QFileInfo>
#include <QThread>

#include "libraryinternaldatabase.h"
#include "libretro_cores_info_map.h"
#include "platforms.h"
#include "metadatadatabase.h"

namespace Library {

class LibraryModel : public QSqlTableModel {
Q_OBJECT
Q_PROPERTY( int count READ count NOTIFY countChanged )
Q_PROPERTY( bool recursiveScan READ recursiveScan WRITE setRecursiveScan
NOTIFY recursiveScanChanged )

Q_PROPERTY( qreal progress READ progress NOTIFY progressChanged )
Q_PROPERTY( QString message READ message WRITE setMessage NOTIFY messageChanged )

public:

// GameImportData is used to import game files into the SQL database.
// This is a a simple data grouping to simplify signals and slots

struct GameImportData {
qreal importProgress;
QString system;
QString timePlayed;
QString title;
QString filePath;
};

using QSqlTableModel::setFilter;

explicit LibraryModel( LibraryInternalDatabase &db, QObject *parent = 0 );

~LibraryModel();

// Model Roles
enum GameRoles {
TitleRole = Qt::UserRole + 1,
SystemRole,
TimePlayedRole,
ArtworkRole,
FileNameRole,
SystemPathRole,
RowIDRole,
};

// Getters
bool select();
bool cancelScan();

// QML Getters
int count() const;
qreal progress() const;
bool recursiveScan() const;
QString message() const;

// QML Setters
void setRecursiveScan( const bool scan );
void setMessage( const QString message );

// Subclass Setters.
QVariantMap get( int inx );
QVariant data( const QModelIndex &index, int role ) const;

// Subclass Getters
QHash<int, QByteArray> roleNames() const;

public slots:
// Removes 1 row from the SQL model.
bool remove( int row, int count = 1 );

// Starts the import progress. The url is a folder or
// file that the user wants to import.
void append( const QUrl url );

// clear removes every SQL row in the database permanently.
void clear();

// updateCount() reads the SQL database and updates the count()
// function with how many entries are actually in the databaes.
// This is important for creating our own scrollbar.
void updateCount();

// Filters the SQL model based on a SQL query.
// This is used to filter games in the BoxartGrid
void setFilter( QString filter
, QVariantList params
, bool preserveCurrentFilter );

// Cancels the import progress if the mScanFilesThread is running.
void cancel();

void sync();

void startMetaDataScan();

void updateUknownMetadata();

void resumeMetadataScan();

private slots:

// handleFilesFound runs on the main QML thread, and is
// where the SQL query statement is created and executed.
void handleFilesFound( const GameImportData importData );

// This function is connected to the mScanFilesThread.
// This iterates through the mImportUrl, if the url is
// a folder, and emits the filesFound signal.

// findFiles is needed to run directly on the mScanFilesThread
// so make sure that this signal is connected with a Qt::DirectionConnection;
// this is because the LibraryModel is not moved into the mScanFilesThread,
// nor should it be.
void findFiles();

// This needs to be run on the main thread.
void setMetadata( const GameMetaData metaData );

signals:
void countChanged();
void messageChanged();
void recursiveScanChanged();
void progressChanged();
void fileFound( const GameImportData importData );
void cancelScanChanged( const bool cancel );
void calculateCheckSum( GameMetaData metaData );

private:
// Normal Variables
QStringList mFileFilter;
QHash<int, QByteArray> mRoleNames;
QVariantList params;
QMutex scanMutex;
// Used to find metadata for any game.
MetaDataDatabase mMetaDataDatabse;
int lastUpdatedRowID;

// Is true when the startMetaDataScan() function has started and
// is false when it's completeled. This is used to syncronize the
// setMetadata() function.
bool mMetaDataEmitted;

// This thread is started when a user wants to import
// a games folder. Currently, the thread quits whenever the
// user cancels and import, or the import finishes.
QThread mScanFilesThread;

// This thread is started when metadata, such as artwork, is being found for a game.
QThread mGetMetadataThread;

// mImportUrl is the url of the folder or file that is
// being scanned and imported.
QUrl mImportUrl;
bool mCancelScan;

// QML Variables
int qmlCount;
bool qmlRecursiveScan;
qreal qmlProgress;
QString qmlMessage;

// QML Setters
void setProgress( const qreal progress );

// Normal Setters
void setCancelScan( const bool scan );


// Helper Functions
void checkHeaderOffsets( const QFileInfo &fileInfo, QString &platform );
bool getCueFileInfo( QFileInfo &fileInfo );


};


}

#endif // LIBRARYMODEL_H
Loading

0 comments on commit b3009f5

Please sign in to comment.