--- a/hedgewars/ArgParsers.pas Fri Dec 22 23:59:03 2017 +0100
+++ b/hedgewars/ArgParsers.pas Sun Dec 24 00:44:16 2017 +0100
@@ -322,14 +322,14 @@
var tmpInt: LongInt;
begin
- paramIndex:= {$IFDEF HWLIBRARY}0{$ELSE}1{$ENDIF};
- paramTotal:= ParamCount; //-1 because pascal enumeration is inclusive
+ paramIndex:= 0;
+ paramTotal:= ParamCount;
WriteLn(stdout, 'total parameters: ' + inttostr(paramTotal));
tmpInt:= 0;
while (tmpInt <= paramTotal) do
begin
- WriteLn(stdout, inttostr(tmpInt) + ': ' + {$IFDEF HWLIBRARY}argv[tmpInt]{$ELSE}paramCount(tmpInt){$ENDIF});
+ WriteLn(stdout, inttostr(tmpInt) + ': ' + argv[tmpInt]);
inc(tmpInt);
end;
--- a/hedgewars/hwLibrary.pas Fri Dec 22 23:59:03 2017 +0100
+++ b/hedgewars/hwLibrary.pas Sun Dec 24 00:44:16 2017 +0100
@@ -35,9 +35,6 @@
, uVariables
, uSound
, uCommands
- , uUtils
- , uLocale
- {$IFDEF ANDROID}, jni{$ENDIF}
, uFLTypes
, uFLIPC
, uPhysFSLayer
@@ -47,60 +44,6 @@
{$INCLUDE "config.inc"}
-// retrieve protocol information
-procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl;
-begin
- netProto^:= cNetProtoVersion;
- versionStr^:= cVersionString;
-end;
-
-function HW_versionString: PChar; cdecl;
-begin
- exit(cVersionString + '-r' + cRevisionString + ' (' + cHashString + ')');
-end;
-
-// equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup
-procedure HW_terminate(closeFrontend: boolean); cdecl;
-begin
- closeFrontend:= closeFrontend; // avoid hint
- ParseCommand('forcequit', true);
-end;
-
-function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl;
-begin
- HW_getWeaponNameByIndex:= (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
-end;
-
-(*function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl;
-begin
- HW_getWeaponCaptionByIndex:= (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId]));
-end;
-
-function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl;
-begin
- HW_getWeaponDescriptionByIndex:= (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId]));
-end;*)
-
-function HW_getNumberOfWeapons: LongInt; cdecl;
-begin
- HW_getNumberOfWeapons:= ord(high(TAmmoType));
-end;
-
-function HW_getMaxNumberOfHogs: LongInt; cdecl;
-begin
- HW_getMaxNumberOfHogs:= cMaxHHIndex + 1;
-end;
-
-function HW_getMaxNumberOfTeams: LongInt; cdecl;
-begin
- HW_getMaxNumberOfTeams:= cMaxTeams;
-end;
-
-procedure HW_memoryWarningCallback; cdecl;
-begin
- ReleaseSound(false);
-end;
-
procedure flibInit(localPrefix, userPrefix: PChar); cdecl;
begin
initIPC;
@@ -113,42 +56,12 @@
freeIPC;
end;
-{$IFDEF ANDROID}
-function JNI_HW_versionInfoNet(env: PJNIEnv; obj: JObject):JInt;cdecl;
-begin
- env:= env; // avoid hint
- obj:= obj; // avoid hint
- JNI_HW_versionInfoNet:= cNetProtoVersion;
-end;
-
-function JNI_HW_versionInfoVersion(env: PJNIEnv; obj: JObject):JString; cdecl;
-var envderef : JNIEnv;
-begin
- obj:= obj; // avoid hint
- envderef:= @env;
- JNI_HW_versionInfoVersion := envderef^.NewStringUTF(env, PChar(cVersionString));
-end;
-
-procedure JNI_HW_GenLandPreview(env: PJNIEnv; c: JClass; port: JInt); cdecl;
-begin
- GenLandPreview(port);
-end;
-
-exports
- JNI_HW_versionInfoNet name Java_Prefix+'HWversionInfoNetProto',
- JNI_HW_versionInfoVersion name Java_Prefix+'HWversionInfoVersion',
- JNI_HW_GenLandPreview name Java_Prefix + 'HWGenLandPreview',
- HW_getNumberOfweapons name Java_Prefix + 'HWgetNumberOfWeapons',
- HW_getMaxNumberOfHogs name Java_Prefix + 'HWgetMaxNumberOfHogs',
- HW_getMaxNumberOfTeams name Java_Prefix + 'HWgetMaxNumberOfTeams',
- Game;
-{$ELSE}
exports
registerUIMessagesCallback,
flibInit,
- flibFree
+ flibFree,
+ queueExecution
;
-{$ENDIF}
begin
end.
--- a/hedgewars/uFLIPC.pas Fri Dec 22 23:59:03 2017 +0100
+++ b/hedgewars/uFLIPC.pas Sun Dec 24 00:44:16 2017 +0100
@@ -12,26 +12,19 @@
//function ipcReadFromEngine: shortstring;
//function ipcCheckFromEngine: boolean;
-procedure ipcToNet(s: shortstring);
-procedure ipcToNetRaw(p: pointer; len: Longword);
-
procedure ipcToFrontend(s: shortstring);
procedure ipcToFrontendRaw(p: pointer; len: Longword);
function ipcReadFromFrontend: TIPCMessage;
function ipcCheckFromFrontend: boolean;
procedure registerIPCCallback(p: pointer; f: TIPCCallback);
-procedure registerNetCallback(p: pointer; f: TIPCCallback);
implementation
var callbackPointerF: pointer;
callbackFunctionF: TIPCCallback;
callbackListenerThreadF: PSDL_Thread;
- callbackPointerN: pointer;
- callbackFunctionN: TIPCCallback;
- callbackListenerThreadN: PSDL_Thread;
- queueFrontend, queueEngine, queueNet: PIPCQueue;
+ queueFrontend, queueEngine: PIPCQueue;
procedure ipcSend(var s: TIPCMessage; queue: PIPCQueue);
var pmsg: PIPCMessage;
@@ -174,14 +167,6 @@
SDL_UnlockMutex(q^.mut);
end;
-procedure ipcToNet(s: shortstring);
-var msg: TIPCMessage;
-begin
- msg.str:= s;
- msg.buf:= nil;
- ipcSend(msg, queueNet)
-end;
-
procedure ipcToEngineRaw(p: pointer; len: Longword);
var msg: TIPCMessage;
begin
@@ -202,16 +187,6 @@
ipcSend(msg, queueFrontend)
end;
-procedure ipcToNetRaw(p: pointer; len: Longword);
-var msg: TIPCMessage;
-begin
- msg.str[0]:= #0;
- msg.len:= len;
- msg.buf:= GetMem(len);
- Move(p^, msg.buf^, len);
- ipcSend(msg, queueNet)
-end;
-
function ipcReadFromEngine: TIPCMessage;
begin
ipcReadFromEngine:= ipcRead(queueFrontend)
@@ -222,11 +197,6 @@
ipcReadFromFrontend:= ipcRead(queueEngine)
end;
-function ipcReadToNet: TIPCMessage;
-begin
- ipcReadToNet:= ipcRead(queueNet)
-end;
-
function ipcCheckFromEngine: boolean;
begin
ipcCheckFromEngine:= ipcCheck(queueFrontend)
@@ -253,22 +223,6 @@
until false
end;
-function netListener(p: pointer): Longint; cdecl; export;
-var msg: TIPCMessage;
-begin
- netListener:= 0;
- repeat
- msg:= ipcReadToNet();
- if msg.buf = nil then
- callbackFunctionN(callbackPointerN, @msg.str[1], byte(msg.str[0]))
- else
- begin
- callbackFunctionN(callbackPointerN, msg.buf, msg.len);
- FreeMem(msg.buf, msg.len)
- end
- until false
-end;
-
procedure registerIPCCallback(p: pointer; f: TIPCCallback);
begin
callbackPointerF:= p;
@@ -276,13 +230,6 @@
callbackListenerThreadF:= SDL_CreateThread(@engineListener, 'engineListener', nil);
end;
-procedure registerNetCallback(p: pointer; f: TIPCCallback);
-begin
- callbackPointerN:= p;
- callbackFunctionN:= f;
- callbackListenerThreadN:= SDL_CreateThread(@netListener, 'netListener', nil);
-end;
-
function createQueue: PIPCQueue;
var q: PIPCQueue;
begin
@@ -308,7 +255,6 @@
begin
queueFrontend:= createQueue;
queueEngine:= createQueue;
- queueNet:= createQueue;
callbackPointerF:= nil;
callbackListenerThreadF:= nil;
@@ -317,10 +263,8 @@
procedure freeIPC;
begin
//FIXME SDL_KillThread(callbackListenerThreadF);
- //FIXME SDL_KillThread(callbackListenerThreadN);
destroyQueue(queueFrontend);
destroyQueue(queueEngine);
- destroyQueue(queueNet);
end;
end.
--- a/hedgewars/uFLRunQueue.pas Fri Dec 22 23:59:03 2017 +0100
+++ b/hedgewars/uFLRunQueue.pas Sun Dec 24 00:44:16 2017 +0100
@@ -3,10 +3,9 @@
uses uFLTypes;
procedure queueExecution(var config: TGameConfig);
-procedure passFlibEvent(p: pointer); cdecl;
implementation
-uses uFLGameConfig, hwengine, uFLThemes, uFLUICallback, uFLIPC;
+uses hwengine, uFLUICallback, uFLIPC;
var runQueue: PGameConfig = nil;
@@ -56,7 +55,7 @@
runQueue:= pConfig;
ipcSetEngineBarrier();
- sendConfig(pConfig);
+ //sendConfig(pConfig);
nextRun
end else
begin
@@ -75,19 +74,9 @@
end;
ipcSetEngineBarrier();
- sendConfig(pConfig);
+ //sendConfig(pConfig);
t^.nextConfig:= pConfig
end;
end;
-procedure passFlibEvent(p: pointer); cdecl;
-begin
- case TFLIBEvent(p^) of
- flibGameFinished: begin
- cleanupConfig;
- nextRun
- end;
- end;
-end;
-
end.
--- a/qmlfrontend/CMakeLists.txt Fri Dec 22 23:59:03 2017 +0100
+++ b/qmlfrontend/CMakeLists.txt Sun Dec 24 00:44:16 2017 +0100
@@ -8,6 +8,6 @@
find_package(Qt5 COMPONENTS Core Quick REQUIRED)
-add_executable(${PROJECT_NAME} "main.cpp" "qml.qrc" "hwengine.cpp" "hwengine.h" "flib.h")
+add_executable(${PROJECT_NAME} "main.cpp" "qml.qrc" "hwengine.cpp" "hwengine.h" "gameconfig.cpp" "gameconfig.h" "flib.h")
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Quick)
--- a/qmlfrontend/Page1.qml Fri Dec 22 23:59:03 2017 +0100
+++ b/qmlfrontend/Page1.qml Sun Dec 24 00:44:16 2017 +0100
@@ -1,7 +1,9 @@
import QtQuick 2.7
+import Hedgewars.Engine 1.0
Page1Form {
button1.onClicked: {
- console.log("Button Pressed. Entered text: " + textField1.text);
+ console.log("Button clicked")
+ HWEngine.getPreview()
}
}
--- a/qmlfrontend/Page1Form.ui.qml Fri Dec 22 23:59:03 2017 +0100
+++ b/qmlfrontend/Page1Form.ui.qml Sun Dec 24 00:44:16 2017 +0100
@@ -3,7 +3,6 @@
import QtQuick.Layouts 1.3
Item {
- property alias textField1: textField1
property alias button1: button1
RowLayout {
@@ -11,14 +10,9 @@
anchors.topMargin: 20
anchors.top: parent.top
- TextField {
- id: textField1
- placeholderText: qsTr("Text Field")
- }
-
Button {
id: button1
- text: qsTr("Press Me")
+ text: qsTr("Run")
}
}
}
--- a/qmlfrontend/flib.h Fri Dec 22 23:59:03 2017 +0100
+++ b/qmlfrontend/flib.h Sun Dec 24 00:44:16 2017 +0100
@@ -8,62 +8,26 @@
#endif
enum MessageType {
- MSG_RENDERINGPREVIEW
- , MSG_PREVIEW
- , MSG_PREVIEWHOGCOUNT
- , MSG_ADDPLAYINGTEAM
- , MSG_REMOVEPLAYINGTEAM
- , MSG_ADDTEAM
- , MSG_REMOVETEAM
- , MSG_TEAMCOLOR
- , MSG_HEDGEHOGSNUMBER
- , MSG_NETDATA
- , MSG_TONET
- , MSG_FLIBEVENT
- , MSG_CONNECTED
- , MSG_DISCONNECTED
- , MSG_ADDLOBBYCLIENT
- , MSG_REMOVELOBBYCLIENT
- , MSG_LOBBYCHATLINE
- , MSG_ADDROOMCLIENT
- , MSG_REMOVEROOMCLIENT
- , MSG_ROOMCHATLINE
- , MSG_ADDROOM
- , MSG_UPDATEROOM
- , MSG_REMOVEROOM
- , MSG_ERROR
- , MSG_WARNING
- , MSG_MOVETOLOBBY
- , MSG_MOVETOROOM
- , MSG_NICKNAME
- , MSG_SEED
- , MSG_THEME
- , MSG_SCRIPT
- , MSG_FEATURESIZE
- , MSG_MAPGEN
- , MSG_MAP
- , MSG_MAZESIZE
- , MSG_TEMPLATE
- , MSG_AMMO
- , MSG_SCHEME
+ MSG_RENDERINGPREVIEW,
+ MSG_PREVIEW,
+ MSG_PREVIEWHOGCOUNT,
};
-typedef union string255_
- {
- struct {
- unsigned char s[256];
- };
- struct {
- unsigned char len;
- unsigned char str[255];
- };
- } string255;
+typedef union string255_ {
+ struct {
+ unsigned char s[256];
+ };
+ struct {
+ unsigned char len;
+ unsigned char str[255];
+ };
+} string255;
-typedef void RunEngine_t(int argc, const char ** argv);
-typedef void registerUIMessagesCallback_t(void * context, void (*)(void * context, MessageType mt, const char * msg, uint32_t len));
-typedef void flibInit_t(const char * localPrefix, const char * userPrefix);
+typedef void RunEngine_t(int argc, const char** argv);
+typedef void registerUIMessagesCallback_t(void* context, void (*)(void* context, MessageType mt, const char* msg, uint32_t len));
+typedef void flibInit_t(const char* localPrefix, const char* userPrefix);
typedef void flibFree_t();
-typedef void passFlibEvent_t(const char * data);
+typedef void passFlibEvent_t(const char* data);
#ifdef __cplusplus
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/qmlfrontend/gameconfig.cpp Sun Dec 24 00:44:16 2017 +0100
@@ -0,0 +1,6 @@
+#include "gameconfig.h"
+
+GameConfig::GameConfig(QObject *parent) : QObject(parent)
+{
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/qmlfrontend/gameconfig.h Sun Dec 24 00:44:16 2017 +0100
@@ -0,0 +1,17 @@
+#ifndef GAMECONFIG_H
+#define GAMECONFIG_H
+
+#include <QObject>
+
+class GameConfig : public QObject
+{
+ Q_OBJECT
+public:
+ explicit GameConfig(QObject *parent = nullptr);
+
+signals:
+
+public slots:
+};
+
+#endif // GAMECONFIG_H
\ No newline at end of file
--- a/qmlfrontend/hwengine.cpp Fri Dec 22 23:59:03 2017 +0100
+++ b/qmlfrontend/hwengine.cpp Sun Dec 24 00:44:16 2017 +0100
@@ -67,3 +67,14 @@
}
}
}
+
+void HWEngine::getPreview()
+{
+ int argc;
+ const char** argv;
+ flibRunEngine(argc, argv);
+}
+
+void HWEngine::runQuickGame()
+{
+}
--- a/qmlfrontend/hwengine.h Fri Dec 22 23:59:03 2017 +0100
+++ b/qmlfrontend/hwengine.h Sun Dec 24 00:44:16 2017 +0100
@@ -1,9 +1,11 @@
#ifndef HWENGINE_H
#define HWENGINE_H
+#include <QList>
#include <QObject>
#include "flib.h"
+#include "gameconfig.h"
class QQmlEngine;
@@ -18,6 +20,9 @@
static void exposeToQML();
+ Q_INVOKABLE void getPreview();
+ Q_INVOKABLE void runQuickGame();
+
signals:
void previewIsRendering();
void previewImageChanged();
@@ -27,6 +32,7 @@
private:
QQmlEngine* m_engine;
+ QList<GameConfig> m_runQueue;
static void guiMessagesCallback(void* context, MessageType mt, const char* msg, uint32_t len);