summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 08b53e0)
raw | patch | inline | side by side (parent: 08b53e0)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 4 Oct 2017 20:28:29 +0000 (23:28 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 4 Oct 2017 20:31:05 +0000 (23:31 +0300) |
src/flexui/fui_ctls.pas | patch | blob | history | |
src/game/g_holmes.pas | patch | blob | history | |
src/game/g_window.pas | patch | blob | history |
index 38f17fd0c928a893b7bbb1bc75662ea46da8b9ef..26eb5b05770853c06620e6ba91fc0af8e4fc4a29 100644 (file)
--- a/src/flexui/fui_ctls.pas
+++ b/src/flexui/fui_ctls.pas
var
+ uiInsideDispatcher: Boolean = false;
uiTopList: array of TUIControl = nil;
uiGrabCtl: TUIControl = nil;
var
svx, svy, svdx, svdy: Integer;
svscale: Single;
+ odp: Boolean;
begin
processKills();
if (not evt.alive) then exit;
+ odp := uiInsideDispatcher;
+ uiInsideDispatcher := true;
//writeln('ENTER: FUI DISPATCH');
ev := evt;
// normalize mouse coordinates
dispatchTo(uiGetFocusedCtl);
end;
finally
+ uiInsideDispatcher := odp;
if (ev.x = svx) and (ev.y = svy) and (ev.dx = svdx) and (ev.dy = svdy) then
begin
// due to possible precision loss
function uiGetFocusedCtl (): TUIControl;
begin
- if (Length(uiTopList) > 0) and (uiTopList[High(uiTopList)].enabled) then result := uiTopList[High(uiTopList)].mFocused else result := nil;
+ result := nil;
+ if (Length(uiTopList) > 0) and (uiTopList[High(uiTopList)].enabled) then
+ begin
+ result := uiTopList[High(uiTopList)].mFocused;
+ if (result = nil) then result := uiTopList[High(uiTopList)];
+ end;
end;
destructor TUIControl.Destroy ();
var
f, c: Integer;
+ doActivateOtherWin: Boolean = false;
begin
+ if (uiInsideDispatcher) then raise Exception.Create('FlexUI: cannot destroy objects in event dispatcher');
+ if (uiGrabCtl = self) then uiGrabCtl := nil;
+ // just in case, check if this is top-level shit
+ for f := 0 to High(uiTopList) do
+ begin
+ if (uiTopList[f] = self) then
+ begin
+ if (uiGrabCtl <> nil) and (isMyChild(uiGrabCtl)) then uiGrabCtl := nil;
+ for c := f+1 to High(uiTopList) do uiTopList[c-1] := uiTopList[c];
+ SetLength(uiTopList, Length(uiTopList)-1);
+ doActivateOtherWin := true;
+ break;
+ end;
+ end;
+ if (doActivateOtherWin) and (Length(uiTopList) > 0) and (uiTopList[High(uiTopList)].enabled) then
+ begin
+ uiTopList[High(uiTopList)].activated();
+ end;
+ // other checks
if (mParent <> nil) then
begin
setFocused(false);
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 166cb61b7f9039a4c304f55c2c58a8e933085f3f..9c846abac45201b6e72b6a3a18c73db5d5ed8985 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
procedure toggleHelpWindow (arg: Integer=-1);
begin
- if (winHelp = nil) then createHelpWindow();
+ if (winHelp = nil) then
+ begin
+ if (arg = 0) then exit;
+ createHelpWindow();
+ end;
if (arg < 0) then begin if not uiVisibleWindow(winHelp) then uiAddWindow(winHelp) else uiRemoveWindow(winHelp); end
else if (arg = 0) then begin if uiVisibleWindow(winHelp) then uiRemoveWindow(winHelp); end
- else begin if not uiVisibleWindow(winHelp) then uiAddWindow(winHelp); end
+ else begin if (not uiVisibleWindow(winHelp)) then uiAddWindow(winHelp); end;
+ if (not uiVisibleWindow(winHelp)) then FreeAndNil(winHelp);
end;
procedure toggleOptionsWindow (arg: Integer=-1);
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 80e63fd640ae7fce250d3e713d7d6944440cfeb6..e3cecb705cbace841c2c815947f9c5a7f5882b8a 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
SDL_GL_MakeCurrent(h_Wnd, h_GL);
SDL_ShowCursor(SDL_DISABLE);
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
if (h_GL <> nil) then begin if (assigned(oglInitCB)) then oglInitCB(); end;
{$ENDIF}
gWinSizeX := gScreenWidth;
gWinSizeY := gScreenHeight;
{$IF not DEFINED(HEADLESS)}
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
e_ResizeWindow(gScreenWidth, gScreenHeight);
g_Game_SetupScreenSize();
g_Menu_Reset();
{$IF not DEFINED(HEADLESS)}
h_Gl := SDL_GL_CreateContext(h_Wnd);
if (h_Gl = nil) then exit;
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
if (assigned(oglInitCB)) then oglInitCB();
{$ENDIF}