diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 863072ce1188bf94fb59aed443671c630bae44a2..3dbd62055888d83b5162d569937f09c9e36d3ad0 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
-(* Copyright (C) DooM 2D:Forever Developers
+(* Copyright (C) Doom 2D: Forever Developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
procedure ProcessLoading (forceUpdate: Boolean=false);
procedure ProcessLoading (forceUpdate: Boolean=false);
+// returns `true` if quit event was received
+function g_ProcessMessages (): Boolean;
+
var
gwin_dump_extensions: Boolean = false;
var
gwin_dump_extensions: Boolean = false;
g_console, e_input, g_options, g_game,
g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net,
g_map, g_gfx, g_monsters, g_holmes, xprofiler,
g_console, e_input, g_options, g_game,
g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net,
g_map, g_gfx, g_monsters, g_holmes, xprofiler,
- sdlcarcass, gh_ui;
+ sdlcarcass, fui_ctls;
const
const
- ProgressUpdateMSecs = 100;
+ ProgressUpdateMSecs = 1;//100;
var
h_Wnd: PSDL_Window = nil;
var
h_Wnd: PSDL_Window = nil;
procedure KillGLWindow ();
begin
procedure KillGLWindow ();
begin
- if (h_Wnd <> nil) then
- begin
- if assigned(oglDeinitCB) then oglDeinitCB();
- end;
+ if (h_GL <> nil) then begin if (assigned(oglDeinitCB)) then oglDeinitCB(); end;
if (h_Wnd <> nil) then SDL_DestroyWindow(h_Wnd);
if (h_GL <> nil) then SDL_GL_DeleteContext(h_GL);
h_Wnd := nil;
if (h_Wnd <> nil) then SDL_DestroyWindow(h_Wnd);
if (h_GL <> nil) then SDL_GL_DeleteContext(h_GL);
h_Wnd := nil;
SDL_GL_MakeCurrent(h_Wnd, h_GL);
SDL_ShowCursor(SDL_DISABLE);
SDL_GL_MakeCurrent(h_Wnd, h_GL);
SDL_ShowCursor(SDL_DISABLE);
- if (h_GL <> nil) then
- begin
- if assigned(oglInitCB) then oglInitCB();
- end;
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
+ if (h_GL <> nil) then begin if (assigned(oglInitCB)) then oglInitCB(); end;
{$ENDIF}
result := true;
{$ENDIF}
result := true;
gWinSizeX := gScreenWidth;
gWinSizeY := gScreenHeight;
{$IF not DEFINED(HEADLESS)}
gWinSizeX := gScreenWidth;
gWinSizeY := gScreenHeight;
{$IF not DEFINED(HEADLESS)}
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
e_ResizeWindow(gScreenWidth, gScreenHeight);
g_Game_SetupScreenSize();
g_Menu_Reset();
e_ResizeWindow(gScreenWidth, gScreenHeight);
g_Game_SetupScreenSize();
g_Menu_Reset();
key := ev.key.keysym.scancode;
down := (ev.type_ = SDL_KEYDOWN);
{$IF not DEFINED(HEADLESS)}
key := ev.key.keysym.scancode;
down := (ev.type_ = SDL_KEYDOWN);
{$IF not DEFINED(HEADLESS)}
- if evSDLCB(ev) then
+ if fuiOnSDLEvent(ev) then
begin
// event eaten, but...
if not down then e_KeyUpDown(key, false);
begin
// event eaten, but...
if not down then e_KeyUpDown(key, false);
{$IF not DEFINED(HEADLESS)}
SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_MOUSEMOTION:
{$IF not DEFINED(HEADLESS)}
SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_MOUSEMOTION:
- evSDLCB(ev);
+ fuiOnSDLEvent(ev);
{$ENDIF}
SDL_TEXTINPUT:
{$ENDIF}
SDL_TEXTINPUT:
Utf8ToUnicode(@uc, PChar(ev.text.text), 1);
keychr := Word(uc);
if (keychr > 127) then keychr := Word(wchar2win(WideChar(keychr)));
Utf8ToUnicode(@uc, PChar(ev.text.text), 1);
keychr := Word(uc);
if (keychr > 127) then keychr := Word(wchar2win(WideChar(keychr)));
- CharPress(AnsiChar(keychr));
+ if (keychr > 0) and (keychr <= 255) then CharPress(AnsiChar(keychr));
end;
// other key presses and joysticks are handled in e_input
end;
// other key presses and joysticks are handled in e_input
{$IF not DEFINED(HEADLESS)}
h_Gl := SDL_GL_CreateContext(h_Wnd);
if (h_Gl = nil) then exit;
{$IF not DEFINED(HEADLESS)}
h_Gl := SDL_GL_CreateContext(h_Wnd);
if (h_Gl = nil) then exit;
- if assigned(oglInitCB) then oglInitCB();
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
+ if (assigned(oglInitCB)) then oglInitCB();
{$ENDIF}
e_ResizeWindow(gScreenWidth, gScreenHeight);
{$ENDIF}
e_ResizeWindow(gScreenWidth, gScreenHeight);
while (SDL_PollEvent(@ev) > 0) do
begin
while (SDL_PollEvent(@ev) > 0) do
begin
+ EventHandler(ev);
if (ev.type_ = SDL_QUITEV) then break;
end;
if (ev.type_ = SDL_QUITEV) then break;
end;
+ e_PollJoysticks();
if (ev.type_ = SDL_QUITEV) or (gExit = EXIT_QUIT) then
begin
if (ev.type_ = SDL_QUITEV) or (gExit = EXIT_QUIT) then
begin
begin
if g_Texture_Get('INTER', ID) then
begin
begin
if g_Texture_Get('INTER', ID) then
begin
- e_DrawSize(ID, 0, 0, 0, false, false, gScreenWidth, gScreenHeight)
+ e_DrawSize(ID, 0, 0, 0, false, false, gScreenWidth, gScreenHeight);
+ e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
end
else
begin
end
else
begin
end;
end;
-function ProcessMessage (): Boolean;
+function g_ProcessMessages (): Boolean;
var
var
- i, t: Integer;
ev: TSDL_Event;
begin
result := false;
FillChar(ev, SizeOf(ev), 0);
ev: TSDL_Event;
begin
result := false;
FillChar(ev, SizeOf(ev), 0);
-
while (SDL_PollEvent(@ev) > 0) do
begin
result := EventHandler(ev);
if (ev.type_ = SDL_QUITEV) then exit;
end;
while (SDL_PollEvent(@ev) > 0) do
begin
result := EventHandler(ev);
if (ev.type_ = SDL_QUITEV) then exit;
end;
+ e_PollJoysticks();
+end;
+
+
+function ProcessMessage (): Boolean;
+var
+ i, t: Integer;
+begin
+ result := g_ProcessMessages();
Time := GetTimer();
Time_Delta := Time-Time_Old;
Time := GetTimer();
Time_Delta := Time-Time_Old;
{$ENDIF}
arg: AnsiString;
mdfo: TStream;
{$ENDIF}
arg: AnsiString;
mdfo: TStream;
+ itmp: Integer;
+ valres: Word;
begin
{$IFDEF HEADLESS}
e_NoGraphics := true;
begin
{$IFDEF HEADLESS}
e_NoGraphics := true;
+{$ELSE}
+ if (not g_holmes_imfunctional) then
+ begin
+ uiInitialize();
+ uiContext.font := 'win14';
+ end;
{$ENDIF}
idx := 1;
{$ENDIF}
idx := 1;
{.$ENDIF}
if arg = '--holmes' then begin g_holmes_enabled := true; g_Game_SetDebugMode(); end;
{.$ENDIF}
if arg = '--holmes' then begin g_holmes_enabled := true; g_Game_SetDebugMode(); end;
+
if (arg = '--holmes-ui-scale') or (arg = '-holmes-ui-scale') then
begin
if (idx <= ParamCount) then
begin
if (arg = '--holmes-ui-scale') or (arg = '-holmes-ui-scale') then
begin
if (idx <= ParamCount) then
begin
- if not conParseFloat(gh_ui_scale, ParamStr(idx)) then gh_ui_scale := 1.0;
+ if not conParseFloat(fuiRenderScale, ParamStr(idx)) then fuiRenderScale := 1.0;
+ Inc(idx);
+ end;
+ end;
+
+ if (arg = '--holmes-font') or (arg = '-holmes-font') then
+ begin
+ if (idx <= ParamCount) then
+ begin
+ itmp := 0;
+ val(ParamStr(idx), itmp, valres);
+ {$IFNDEF HEADLESS}
+ if (valres = 0) and (not g_holmes_imfunctional) then
+ begin
+ case itmp of
+ 8: uiContext.font := 'win8';
+ 14: uiContext.font := 'win14';
+ 16: uiContext.font := 'win16';
+ end;
+ end;
+ {$ELSE}
+ // fuck off, fpc!
+ itmp := itmp;
+ valres := valres;
+ {$ENDIF}
Inc(idx);
end;
end;
Inc(idx);
end;
end;