Browse Source

* Fix compilation, add timer api (needed for cursor)

Michaël Van Canneyt 2 months ago
parent
commit
024040f2f2
1 changed files with 12 additions and 10 deletions
  1. 12 10
      demo/WebHost/fresnelhost.lpr

+ 12 - 10
demo/WebHost/fresnelhost.lpr

@@ -3,8 +3,8 @@ program fresnelhost;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  BrowserConsole, BrowserApp, JS, Classes, SysUtils, Web, wasihostapp, wasienv, fresnel.pas2js.wasmapi,
-  wasizenfs, libzenfs, libzenfsdom, types;
+  BrowserConsole, BrowserApp, JS, Classes, SysUtils, Web, wasihostapp, wasienv, fresnel.web.pas2js.wasmapi,
+  wasizenfs, libzenfs, libzenfsdom, types, wasm.pas2js.timer ;
 
 
 var
 var
   wasmFilename : string; external name 'wasmFilename';
   wasmFilename : string; external name 'wasmFilename';
@@ -15,7 +15,8 @@ type
 
 
   TFresnelHostApplication = class(TBrowserWASIHostApplication)
   TFresnelHostApplication = class(TBrowserWASIHostApplication)
   Private
   Private
-    FFresnelAPI : TWasmFresnelApi;
+    FFresnelAPI : TWasmFresnelWebApi;
+    FTimerAPI : TWasmTimerAPI;
     FS :TWASIZenFS;
     FS :TWASIZenFS;
     procedure DoShowConsole(Event: TJSEvent);
     procedure DoShowConsole(Event: TJSEvent);
     procedure OnAfterStart(Sender: TObject; aDescriptor: TWebAssemblyStartDescriptor);
     procedure OnAfterStart(Sender: TObject; aDescriptor: TWebAssemblyStartDescriptor);
@@ -24,16 +25,14 @@ type
     procedure DoRun; override;
     procedure DoRun; override;
     procedure RunWasm ; async;
     procedure RunWasm ; async;
     function LoadFiles: Integer; async;
     function LoadFiles: Integer; async;
-    Property FresnelAPI : TWasmFresnelApi Read FFresnelAPI;
+    Property FresnelAPI : TWasmFresnelWebApi Read FFresnelAPI;
   end;
   end;
 
 
 { TFresnelHostApplication }
 { TFresnelHostApplication }
 
 
 procedure TFresnelHostApplication.OnAfterStart(Sender: TObject; aDescriptor: TWebAssemblyStartDescriptor);
 procedure TFresnelHostApplication.OnAfterStart(Sender: TObject; aDescriptor: TWebAssemblyStartDescriptor);
 begin
 begin
-  Writeln('Start process loop');
-  FFresnelApi.ProcessMessages;
-  Writeln('Started process loop');
+  Writeln('Wasm initialized, control now goes to Javascript event loop');
 end;
 end;
 
 
 procedure TFresnelHostApplication.DoShowConsole(Event: TJSEvent);
 procedure TFresnelHostApplication.DoShowConsole(Event: TJSEvent);
@@ -45,9 +44,12 @@ end;
 constructor TFresnelHostApplication.Create(aOwner: TComponent);
 constructor TFresnelHostApplication.Create(aOwner: TComponent);
 begin
 begin
   inherited Create(aOwner);
   inherited Create(aOwner);
-  FFresnelApi:=TWasmFresnelApi.Create(WasiEnvironment);
+  FFresnelApi:=TWasmFresnelWebApi.Create(WasiEnvironment);
   FFresnelAPI.LogAPICalls:=False;
   FFresnelAPI.LogAPICalls:=False;
-  FFresnelAPI.CanvasParent:=TJSHTMLElement(document.getElementById('desktop'));
+  FFresnelAPI.UseWordColors:=True;
+  FFresnelAPI.WindowsParentRoot:=TJSHTMLElement(document.getElementById('desktop'));
+  FFresnelAPI.UseKeyMap:=True;
+  FTimerAPI:=TWasmTimerAPI.Create(WasiEnvironment);
   RunEntryFunction:='_initialize';
   RunEntryFunction:='_initialize';
   GetHTMLElement('cbconsole').AddEventListener('click',@DoShowConsole);
   GetHTMLElement('cbconsole').AddEventListener('click',@DoShowConsole);
 end;
 end;
@@ -62,7 +64,7 @@ function TFresnelHostApplication.LoadFiles: Integer;
 
 
 const
 const
   Files : TStringDynArray =
   Files : TStringDynArray =
-       ('image.png','style1.css','style2.css');
+       ('style1.css','style2.css');
 var
 var
   Res: TPreLoadFilesResult;
   Res: TPreLoadFilesResult;
   I : Integer;
   I : Integer;