- Reworked Qt frontend to be fully based on QML (Qtmain.cpp still contains most of the old code as I need to perform additional tests on Maemo/Meego and Linux)
- Modified the download of resources to happen on every platform - Resources are now stored based on the home directory
This commit is contained in:
89
JGE/include/qt/corewrapper.h
Normal file
89
JGE/include/qt/corewrapper.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#ifndef COREWRAPPER_H
|
||||
#define COREWRAPPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtDeclarative>
|
||||
#include <QGraphicsItem>
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JTypes.h"
|
||||
#include "../include/JApp.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
#include "../include/JRenderer.h"
|
||||
#include "../include/JGameLauncher.h"
|
||||
|
||||
|
||||
class WagicCore : public QDeclarativeItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int nominalWidth READ getNominalWidth CONSTANT)
|
||||
Q_PROPERTY(int nominalHeight READ getNominalHeight CONSTANT)
|
||||
Q_PROPERTY(float nominalRatio READ getNominalRatio CONSTANT)
|
||||
Q_PROPERTY(bool active READ getActive WRITE setActive NOTIFY activeChanged)
|
||||
|
||||
public:
|
||||
explicit WagicCore(QDeclarativeItem *parent = 0);
|
||||
virtual ~WagicCore();
|
||||
void initApp();
|
||||
void render(){
|
||||
if(m_engine)
|
||||
m_engine->Render();
|
||||
};
|
||||
|
||||
Q_INVOKABLE void doOK() {
|
||||
doAndEnqueue(JGE_BTN_OK);
|
||||
};
|
||||
Q_INVOKABLE void doNext() {
|
||||
doAndEnqueue(JGE_BTN_PREV);
|
||||
};
|
||||
Q_INVOKABLE void doCancel() {
|
||||
doAndEnqueue(JGE_BTN_SEC);
|
||||
};
|
||||
Q_INVOKABLE void doMenu() {
|
||||
doAndEnqueue(JGE_BTN_MENU);
|
||||
};
|
||||
Q_INVOKABLE void done() {
|
||||
while(m_buttonQueue.size())
|
||||
{
|
||||
m_engine->ReleaseKey(m_buttonQueue.front());
|
||||
m_buttonQueue.pop();
|
||||
}
|
||||
};
|
||||
Q_INVOKABLE void pixelInput(int x, int y);
|
||||
int getNominalHeight(){ return SCREEN_HEIGHT;};
|
||||
int getNominalWidth(){ return SCREEN_WIDTH;};
|
||||
float getNominalRatio() { return ((float)SCREEN_WIDTH / (float)SCREEN_HEIGHT);};
|
||||
bool getActive() { return m_active; };
|
||||
void setActive(bool active);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void resize ( const QRectF &rect);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
|
||||
signals:
|
||||
void activeChanged();
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
void timerEvent( QTimerEvent* );
|
||||
void doAndEnqueue(JButton action) {
|
||||
m_engine->HoldKey_NoRepeat(action);
|
||||
m_buttonQueue.push(action);
|
||||
}
|
||||
|
||||
public:
|
||||
// used mainly to mesure the delta between 2 updates
|
||||
static QElapsedTimer g_startTimer;
|
||||
private:
|
||||
JGE* m_engine;
|
||||
JApp* m_app;
|
||||
JGameLauncher* m_launcher;
|
||||
qint64 m_lastTickCount;
|
||||
std::queue<JButton> m_buttonQueue;
|
||||
int m_timerId;
|
||||
bool m_active;
|
||||
QRect m_viewPort;
|
||||
};
|
||||
QML_DECLARE_TYPE(WagicCore)
|
||||
|
||||
#endif // COREWRAPPER_H
|
||||
@@ -13,6 +13,7 @@
|
||||
class FileDownloader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool done READ isDone NOTIFY downloaded)
|
||||
Q_PROPERTY(qint64 received READ received NOTIFY receivedChanged)
|
||||
public:
|
||||
explicit FileDownloader(QUrl url, QString localPath, QObject *parent = 0);
|
||||
@@ -32,6 +33,7 @@ private slots:
|
||||
|
||||
m_tmp.setAutoRemove(false);
|
||||
|
||||
m_done = true;
|
||||
//emit a signal
|
||||
emit downloaded();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user