hedgewars/uFLUICallback.pas
author unc0rr
Sun, 07 Jan 2018 01:21:42 +0100
branchqmlfrontend
changeset 12888 adb1fccc706a
parent 11848 01f88c3b7b66
permissions -rw-r--r--
- ResizeWindow function to pass engine new window size - Remove TabBar to leave more space at the bottom of the screen - ifdef GL_ES in shaders

unit uFLUICallback;
interface
uses uFLTypes;

procedure registerUIMessagesCallback(p: pointer; f: TUICallback); cdecl;
procedure sendUI(msgType: TMessageType; msg: PChar; len: Longword);

implementation
uses uFLIPC;

var uiCallbackPointer: pointer;
    uiCallbackFunction: TUICallback;
    isGame: boolean;

procedure engineMessageCallback(p: pointer; msg: PChar; len: Longword);
begin
    if (len >= 3) and (msg[1] = 'T') then
    begin
        isGame:= msg[2] = 'G';
        exit;
    end;

    if isGame then
    begin
        uiCallbackFunction(uiCallbackPointer, mtToNet, msg, len)
    end
    else begin
        if len = 128 * 256 then
            uiCallbackFunction(uiCallbackPointer, mtPreview, msg, len)
        else if len = 1 then
            uiCallbackFunction(uiCallbackPointer, mtPreviewHogCount, msg, len)
    end;
end;

procedure registerUIMessagesCallback(p: pointer; f: TUICallback); cdecl;
begin
    uiCallbackPointer:= p;
    uiCallbackFunction:= f;

    registerIPCCallback(nil, @engineMessageCallback)
end;

procedure sendUI(msgType: TMessageType; msg: PChar; len: Longword);
begin
    uiCallbackFunction(uiCallbackPointer, msgType, msg, len)
end;

end.