diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 82a36e77d01bcc8aecca718b0d6539a875976a7a..82256a81a0ea3692debe27236dc52789f3361b27 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
showMapCurPos: Boolean = false;
showLayersWindow: Boolean = false;
showOutlineWindow: Boolean = false;
- oldShowLayersWindow: Boolean = false;
- oldShowOutlineWindow: Boolean = false;
// ////////////////////////////////////////////////////////////////////////// //
{$INCLUDE g_holmes.inc}
winOutlines: THTopWindow = nil;
-procedure createOptionsWindow ();
-var
- llb: THCtlCBListBox;
-begin
- llb := THCtlCBListBox.Create(0, 0);
- llb.appendItem('map grid', @showGrid);
- llb.appendItem('cursor position on map', @showMapCurPos);
- llb.appendItem('monster info', @showMonsInfo);
- llb.appendItem('monster LOS to player', @showMonsLOS2Plr);
- llb.appendItem('monster cells (SLOW!)', @showAllMonsCells);
- llb.appendItem('', nil);
- llb.appendItem('layers window', @showLayersWindow);
- llb.appendItem('outline window', @showOutlineWindow);
- winOptions := THTopWindow.Create('Holmes Options', 100, 100);
- winOptions.escClose := true;
- winOptions.appendChild(llb);
-end;
-
+procedure winLayersClosed (me: THControl; dummy: Integer); begin showLayersWindow := false; end;
+procedure winOutlinesClosed (me: THControl; dummy: Integer); begin showOutlineWindow := false; end;
procedure createLayersWindow ();
var
winLayers := THTopWindow.Create('visible', 10, 10);
winLayers.escClose := true;
winLayers.appendChild(llb);
+ winLayers.closeCB := winLayersClosed;
end;
llb.appendItem('acid2', @g_ol_rlayer_acid2);
llb.appendItem('water', @g_ol_rlayer_water);
llb.appendItem('foreground', @g_ol_rlayer_fore);
- llb.appendItem('', nil);
+ llb.appendItem('OPTIONS', nil);
llb.appendItem('fill walls', @g_ol_fill_walls);
- llb.appendItem('', nil);
- llb.appendItem('slow''n''nice', @g_ol_nice);
+ llb.appendItem('contours', @g_ol_nice);
winOutlines := THTopWindow.Create('outlines', 100, 10);
winOutlines.escClose := true;
winOutlines.appendChild(llb);
+ winOutlines.closeCB := winOutlinesClosed;
+end;
+
+
+procedure toggleLayersWindow (me: THControl; checked: Integer);
+begin
+ if showLayersWindow then
+ begin
+ if (winLayers = nil) then createLayersWindow();
+ uiAddWindow(winLayers);
+ end
+ else
+ begin
+ uiRemoveWindow(winLayers);
+ end;
+end;
+
+
+procedure toggleOutlineWindow (me: THControl; checked: Integer);
+begin
+ if showOutlineWindow then
+ begin
+ if (winOutlines = nil) then createOutlinesWindow();
+ uiAddWindow(winOutlines);
+ end
+ else
+ begin
+ uiRemoveWindow(winOutlines);
+ end;
+end;
+
+
+procedure createOptionsWindow ();
+var
+ llb: THCtlCBListBox;
+begin
+ llb := THCtlCBListBox.Create(0, 0);
+ llb.appendItem('map grid', @showGrid);
+ llb.appendItem('cursor position on map', @showMapCurPos);
+ llb.appendItem('monster info', @showMonsInfo);
+ llb.appendItem('monster LOS to player', @showMonsLOS2Plr);
+ llb.appendItem('monster cells (SLOW!)', @showAllMonsCells);
+ llb.appendItem('WINDOWS', nil);
+ llb.appendItem('layers window', @showLayersWindow, toggleLayersWindow);
+ llb.appendItem('outline window', @showOutlineWindow, toggleOutlineWindow);
+ winOptions := THTopWindow.Create('Holmes Options', 100, 100);
+ winOptions.escClose := true;
+ winOptions.appendChild(llb);
end;
end;
end;
+var
+ lsx: Integer = -1;
+ lex: Integer = -1;
+ lsy: Integer = -1;
+
+ procedure flushLine ();
+ begin
+ if (lsy > 0) and (lsx > 0) then
+ begin
+ if (lex = lsx) then
+ begin
+ glBegin(GL_POINTS);
+ glVertex2f(lsx-1+vpx+0.37, lsy-1+vpy+0.37);
+ glEnd();
+ end
+ else
+ begin
+ glBegin(GL_LINES);
+ glVertex2f(lsx-1+vpx+0.37, lsy-1+vpy+0.37);
+ glVertex2f(lex-0+vpx+0.37, lsy-1+vpy+0.37);
+ glEnd();
+ end;
+ end;
+ lsx := -1;
+ lex := -1;
+ end;
+
+ procedure startLine (y: Integer);
+ begin
+ flushLine();
+ lsy := y;
+ end;
+
+ procedure putPixel (x: Integer);
+ begin
+ if (x < 1) then exit;
+ if (lex+1 <> x) then flushLine();
+ if (lsx < 0) then lsx := x;
+ lex := x;
+ end;
+
procedure drawEdges ();
var
x, y: Integer;
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POLYGON_SMOOTH);
glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
- glBegin(GL_POINTS);
for y := 1 to vph do
begin
a := @edgeBmp[y*(gWinSizeX+4)+1];
+ startLine(y);
for x := 1 to vpw do
begin
if (a[0] <> 0) then
(a[-(gWinSizeX+4)-1] = 0) or (a[-(gWinSizeX+4)+1] = 0) or
(a[gWinSizeX+4-1] = 0) or (a[gWinSizeX+4+1] = 0) then
begin
- glVertex2f(x-1+vpx+0.37, y-1+vpy+0.37);
+ putPixel(x);
end;
end;
Inc(a);
end;
+ flushLine();
end;
- glEnd();
end;
procedure drawFilledWalls ();
var
- x, y, sx, ex: Integer;
+ x, y: Integer;
a: PByte;
- procedure drawLine ();
- begin
- if (sx >= 0) then
- begin
- glVertex2f(sx-1+vpx+0.37, y-1+vpy+0.37);
- glVertex2f(ex+vpx+0.37, y-1+vpy+0.37);
- end;
- sx := -1;
- ex := -1;
- end;
begin
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POLYGON_SMOOTH);
glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
- glBegin(GL_LINES);
for y := 1 to vph do
begin
a := @edgeBmp[y*(gWinSizeX+4)+1];
- sx := -1;
- ex := -1;
+ startLine(y);
for x := 1 to vpw do
begin
- if (a[0] <> 0) then
- begin
- if (ex+1 <> x) then drawLine();
- if (sx < 0) then
- begin
- sx := x;
- ex := x;
- end
- else
- begin
- ex := x;
- end;
- end;
+ if (a[0] <> 0) then putPixel(x);
Inc(a);
end;
- drawLine();
+ flushLine();
end;
- glEnd();
end;
procedure doWallsOld (parr: array of TPanel; ptype: Word; ar, ag, ab: Integer);
begin
result := true;
showLayersWindow := not showLayersWindow;
+ toggleLayersWindow(nil, 0);
exit;
end;
// C-O: toggle outlines window
begin
result := true;
showOutlineWindow := not showOutlineWindow;
+ toggleOutlineWindow(nil, 0);
exit;
end;
// F1: toggle options window
// ////////////////////////////////////////////////////////////////////////// //
procedure g_Holmes_Draw ();
begin
- if (oldShowLayersWindow <> showLayersWindow) then
- begin
- oldShowLayersWindow := showLayersWindow;
- if showLayersWindow then
- begin
- if (winLayers = nil) then createLayersWindow();
- uiAddWindow(winLayers);
- end
- else
- begin
- uiRemoveWindow(winLayers);
- end;
- end
- else
- begin
- showLayersWindow := uiVisibleWindow(winLayers);
- oldShowLayersWindow := showLayersWindow;
- end;
-
- if (oldShowOutlineWindow <> showOutlineWindow) then
- begin
- oldShowOutlineWindow := showOutlineWindow;
- if showOutlineWindow then
- begin
- if (winOutlines = nil) then createOutlinesWindow();
- uiAddWindow(winOutlines);
- end
- else
- begin
- uiRemoveWindow(winOutlines);
- end;
- end
- else
- begin
- showOutlineWindow := uiVisibleWindow(winOutlines);
- oldShowOutlineWindow := showOutlineWindow;
- end;
-
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);