hedgewars/uFLUICallback.pas
author sheepluva
Sun, 01 May 2016 21:09:45 +0200
branchqmlfrontend
changeset 11792 bcba7938ccb5
parent 10951 89a7f617e091
child 11832 8c71c5a1172f
permissions -rw-r--r--
qmlfrontend/map-preview: add hog count display thingy (only displays "?" for now)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10951
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     1
unit uFLUICallback;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     2
interface
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     3
uses uFLTypes;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     4
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     5
procedure registerUIMessagesCallback(p: pointer; f: TUICallback); cdecl;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     6
procedure sendUI(msgType: TMessageType; msg: PChar; len: Longword);
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     7
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     8
implementation
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
     9
uses uFLIPC;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    10
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    11
var uiCallbackPointer: pointer;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    12
    uiCallbackFunction: TUICallback;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    13
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    14
procedure engineMessageCallback(p: pointer; msg: PChar; len: Longword);
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    15
begin
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    16
    if len = 128 * 256 then uiCallbackFunction(uiCallbackPointer, mtPreview, msg, len)
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    17
end;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    18
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    19
procedure registerUIMessagesCallback(p: pointer; f: TUICallback); cdecl;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    20
begin
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    21
    uiCallbackPointer:= p;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    22
    uiCallbackFunction:= f;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    23
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    24
    registerIPCCallback(nil, @engineMessageCallback)
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    25
end;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    26
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    27
procedure sendUI(msgType: TMessageType; msg: PChar; len: Longword);
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    28
begin
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    29
    uiCallbackFunction(uiCallbackPointer, msgType, msg, len)
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    30
end;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    31
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    32
end.