- Fixed lightsources to not draw in flat mode and when the lightlevel is 0
- Fixed tile changes not causing a filter update - Cleanup the project file
This commit is contained in:
parent
4f4e9eb0d7
commit
8976774665
|
@ -4,6 +4,7 @@
|
||||||
<Version Value="7"/>
|
<Version Value="7"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
|
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||||
<LRSInOutputDirectory Value="False"/>
|
<LRSInOutputDirectory Value="False"/>
|
||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
|
|
@ -33,17 +33,7 @@ uses
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
SysUtils,
|
SysUtils,
|
||||||
Interfaces, // this includes the LCL widgetset
|
Interfaces, // this includes the LCL widgetset
|
||||||
Forms, LResources, lnetvisual, LazOpenGLContext, UdmNetwork, UfrmMain,
|
Forms, LResources, UdmNetwork;
|
||||||
UfrmLogin, UfrmInitialize, UfrmAccountControl, virtualtreeview_package,
|
|
||||||
multiloglaz, UfrmEditAccount, UfrmDrawSettings, UfrmBoundaries,
|
|
||||||
UfrmElevateSettings, UOverlayUI, UResourceManager, UfrmConfirmation,
|
|
||||||
UfrmMoveSettings, UfrmAbout, UfrmHueSettings, UfrmRadar,
|
|
||||||
UfrmLargeScaleCommand, UfrmVirtualLayer, UfrmFilter,
|
|
||||||
UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl, UPackets,
|
|
||||||
UPacketHandlers, UAdminHandling, UGameResources, ULandscape, UfrmToolWindow,
|
|
||||||
Logging, UTileDataProvider, UMap, UWorldItem, UStatics, UTiledata, UAnimData,
|
|
||||||
UGLFont, UAnimDataProvider, UMulManager, UArtProvider, UTexmapProvider,
|
|
||||||
ULightManager, ULight, ULightProvider;
|
|
||||||
|
|
||||||
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}
|
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}
|
||||||
|
|
||||||
|
|
|
@ -69,12 +69,12 @@ type
|
||||||
protected
|
protected
|
||||||
FX: Integer;
|
FX: Integer;
|
||||||
FY: Integer;
|
FY: Integer;
|
||||||
FZ: smallint;
|
FZ: SmallInt;
|
||||||
FMaterial: TLightMaterial;
|
FMaterial: TLightMaterial;
|
||||||
public
|
public
|
||||||
property X: Integer read FX;
|
property X: Integer read FX;
|
||||||
property Y: Integer read FY;
|
property Y: Integer read FY;
|
||||||
property Z: smallint read FZ;
|
property Z: SmallInt read FZ;
|
||||||
property Material: TLightMaterial read FMaterial;
|
property Material: TLightMaterial read FMaterial;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -89,13 +89,15 @@ type
|
||||||
FLightSources: TLightSources;
|
FLightSources: TLightSources;
|
||||||
FOverlay: TSingleImage;
|
FOverlay: TSingleImage;
|
||||||
FOverlayTexture: GLuint;
|
FOverlayTexture: GLuint;
|
||||||
FLightLevel: byte;
|
FLightLevel: Byte;
|
||||||
FValid: Boolean;
|
FValid: Boolean;
|
||||||
FCalculateOffset: TCalculateOffset;
|
FCalculateOffset: TCalculateOffset;
|
||||||
FLightCache: TLightCache;
|
FLightCache: TLightCache;
|
||||||
function GetLight(AID: Integer): TLightMaterial;
|
function GetLight(AID: Integer): TLightMaterial;
|
||||||
|
procedure SetLightLevel(AValue: Byte);
|
||||||
procedure UpdateOverlay(AScreenRect: TRect);
|
procedure UpdateOverlay(AScreenRect: TRect);
|
||||||
public
|
public
|
||||||
|
property LightLevel: Byte read FLightLevel write SetLightLevel;
|
||||||
procedure UpdateLightMap(ALeft, AWidth, ATop, AHeight: Integer;
|
procedure UpdateLightMap(ALeft, AWidth, ATop, AHeight: Integer;
|
||||||
AScreenBuffer: TScreenBuffer);
|
AScreenBuffer: TScreenBuffer);
|
||||||
procedure Draw(AScreenRect: TRect);
|
procedure Draw(AScreenRect: TRect);
|
||||||
|
@ -112,7 +114,7 @@ constructor TLightManager.Create(ACalculateOffset: TCalculateOffset);
|
||||||
begin
|
begin
|
||||||
FCalculateOffset := ACalculateOffset;
|
FCalculateOffset := ACalculateOffset;
|
||||||
FLightSources := TLightSources.Create(True);
|
FLightSources := TLightSources.Create(True);
|
||||||
FLightLevel := 15; //TODO : 0 ...
|
FLightLevel := 0;
|
||||||
FLightCache := TLightCache.Create(32);
|
FLightCache := TLightCache.Create(32);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -142,6 +144,12 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLightManager.SetLightLevel(AValue: Byte);
|
||||||
|
begin
|
||||||
|
FLightLevel := AValue;
|
||||||
|
FValid := False;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLightManager.UpdateOverlay(AScreenRect: TRect);
|
procedure TLightManager.UpdateOverlay(AScreenRect: TRect);
|
||||||
var
|
var
|
||||||
canvas, lightCanvas: TFastARGB32Canvas;
|
canvas, lightCanvas: TFastARGB32Canvas;
|
||||||
|
@ -157,8 +165,8 @@ begin
|
||||||
color.G := color.R;
|
color.G := color.R;
|
||||||
color.B := color.R;
|
color.B := color.R;
|
||||||
|
|
||||||
FOverlay := TSingleImage.CreateFromParams(AScreenRect.Right, AScreenRect.Bottom,
|
FOverlay := TSingleImage.CreateFromParams(AScreenRect.Right,
|
||||||
ifA8R8G8B8);
|
AScreenRect.Bottom, ifA8R8G8B8);
|
||||||
canvas := TFastARGB32Canvas.CreateForImage(FOverlay);
|
canvas := TFastARGB32Canvas.CreateForImage(FOverlay);
|
||||||
try
|
try
|
||||||
canvas.FillColor32 := color.Color;
|
canvas.FillColor32 := color.Color;
|
||||||
|
@ -224,8 +232,9 @@ begin
|
||||||
begin
|
begin
|
||||||
if ((itemMap[x, y] = nil) or (itemMap[x, y].Z < lightMap[x, y].Z + 3)) or
|
if ((itemMap[x, y] = nil) or (itemMap[x, y].Z < lightMap[x, y].Z + 3)) or
|
||||||
((itemMap[x + 1, y] = nil) or (itemMap[x + 1, y].Z < lightMap[x, y].Z + 3)) or
|
((itemMap[x + 1, y] = nil) or (itemMap[x + 1, y].Z < lightMap[x, y].Z + 3)) or
|
||||||
((itemMap[x + 1, y + 1] = nil) or (itemMap[x + 1, y + 1].Z < lightMap[x, y].Z + 3)) or
|
((itemMap[x + 1, y + 1] = nil) or (itemMap[x + 1, y + 1].Z <
|
||||||
((itemMap[x, y + 1] = nil) or (itemMap[x, y + 1].Z < lightMap[x, y].Z + 3)) then
|
lightMap[x, y].Z + 3)) or ((itemMap[x, y + 1] = nil) or
|
||||||
|
(itemMap[x, y + 1].Z < lightMap[x, y].Z + 3)) then
|
||||||
begin
|
begin
|
||||||
FLightSources.Add(TLightSource.Create(Self, lightMap[x, y]));
|
FLightSources.Add(TLightSource.Create(Self, lightMap[x, y]));
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -2389,6 +2389,7 @@ begin
|
||||||
blockInfo^.Text.Render(blockInfo^.ScreenRect);
|
blockInfo^.Text.Render(blockInfo^.ScreenRect);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if (FLightManager.LightLevel > 0) and not acFlat.Checked then
|
||||||
FLightManager.Draw(oglGameWindow.ClientRect);
|
FLightManager.Draw(oglGameWindow.ClientRect);
|
||||||
FOverlayUI.Draw(oglGameWindow);
|
FOverlayUI.Draw(oglGameWindow);
|
||||||
end;
|
end;
|
||||||
|
@ -2435,7 +2436,7 @@ end;
|
||||||
procedure TfrmMain.OnMapChanged(AMapCell: TMapCell);
|
procedure TfrmMain.OnMapChanged(AMapCell: TMapCell);
|
||||||
begin
|
begin
|
||||||
PrepareMapCell(AMapCell);
|
PrepareMapCell(AMapCell);
|
||||||
ForceUpdateCurrentTile;
|
InvalidateFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.OnNewBlock(ABlock: TBlock);
|
procedure TfrmMain.OnNewBlock(ABlock: TBlock);
|
||||||
|
@ -2461,8 +2462,7 @@ begin
|
||||||
begin
|
begin
|
||||||
PrepareScreenBlock(blockInfo);
|
PrepareScreenBlock(blockInfo);
|
||||||
Exclude(FScreenBufferState, sbsIndexed);
|
Exclude(FScreenBufferState, sbsIndexed);
|
||||||
|
InvalidateFilter;
|
||||||
ForceUpdateCurrentTile;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2477,6 +2477,7 @@ begin
|
||||||
begin
|
begin
|
||||||
PrepareScreenBlock(blockInfo);
|
PrepareScreenBlock(blockInfo);
|
||||||
FRepaintNeeded := True;
|
FRepaintNeeded := True;
|
||||||
|
InvalidateFilter;
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -2492,7 +2493,7 @@ begin
|
||||||
AStaticItem.PrioritySolver := FScreenBuffer.GetSerial;
|
AStaticItem.PrioritySolver := FScreenBuffer.GetSerial;
|
||||||
PrepareScreenBlock(FScreenBuffer.Insert(AStaticItem));
|
PrepareScreenBlock(FScreenBuffer.Insert(AStaticItem));
|
||||||
FRepaintNeeded := True;
|
FRepaintNeeded := True;
|
||||||
ForceUpdateCurrentTile;
|
InvalidateFilter;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2591,11 +2592,11 @@ var
|
||||||
i, tileX, tileY: Integer;
|
i, tileX, tileY: Integer;
|
||||||
virtualTile: TVirtualTile;
|
virtualTile: TVirtualTile;
|
||||||
begin
|
begin
|
||||||
Logger.EnterMethod([lcClient], 'RebuildScreenBuffer');
|
//Logger.EnterMethod([lcClient], 'RebuildScreenBuffer');
|
||||||
|
|
||||||
FDrawDistance := Trunc(Sqrt(oglGameWindow.Width * oglGameWindow.Width +
|
FDrawDistance := Trunc(Sqrt(oglGameWindow.Width * oglGameWindow.Width +
|
||||||
oglGamewindow.Height * oglGamewindow.Height) / 44);
|
oglGamewindow.Height * oglGamewindow.Height) / 44);
|
||||||
Logger.Send([lcClient], 'DrawDistance', FDrawDistance);
|
//Logger.Send([lcClient], 'DrawDistance', FDrawDistance);
|
||||||
|
|
||||||
{$HINTS off}{$WARNINGS off}
|
{$HINTS off}{$WARNINGS off}
|
||||||
if FX - FDrawDistance < 0 then FLowOffsetX := -FX else FLowOffsetX := -FDrawDistance;
|
if FX - FDrawDistance < 0 then FLowOffsetX := -FX else FLowOffsetX := -FDrawDistance;
|
||||||
|
@ -2612,7 +2613,7 @@ begin
|
||||||
|
|
||||||
if frmVirtualLayer.cbShowLayer.Checked then
|
if frmVirtualLayer.cbShowLayer.Checked then
|
||||||
begin
|
begin
|
||||||
Logger.Send([lcClient, lcDebug], 'Preparing Virtual Layer');
|
//Logger.Send([lcClient, lcDebug], 'Preparing Virtual Layer');
|
||||||
|
|
||||||
if FVLayerMaterial = nil then
|
if FVLayerMaterial = nil then
|
||||||
FVLayerMaterial := TSimpleMaterial.Create(FVLayerImage);
|
FVLayerMaterial := TSimpleMaterial.Create(FVLayerImage);
|
||||||
|
@ -2657,7 +2658,7 @@ begin
|
||||||
FVirtualTiles.Delete(i);
|
FVirtualTiles.Delete(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Logger.Send([lcClient, lcDebug], 'VirtualTiles', FVirtualTiles.Count);
|
//Logger.Send([lcClient, lcDebug], 'VirtualTiles', FVirtualTiles.Count);
|
||||||
|
|
||||||
FLandscape.FillDrawList(FScreenBuffer, FX + FLowOffsetX, FY + FLowOffsetY,
|
FLandscape.FillDrawList(FScreenBuffer, FX + FLowOffsetX, FY + FLowOffsetY,
|
||||||
FRangeX, FRangeY, tbTerrain.Down, tbStatics.Down, acNoDraw.Checked,
|
FRangeX, FRangeY, tbTerrain.Down, tbStatics.Down, acNoDraw.Checked,
|
||||||
|
@ -2671,7 +2672,7 @@ begin
|
||||||
FScreenBuffer.UpdateShortcuts;
|
FScreenBuffer.UpdateShortcuts;
|
||||||
FScreenBufferState := [sbsValid, sbsIndexed];
|
FScreenBufferState := [sbsValid, sbsIndexed];
|
||||||
|
|
||||||
Logger.ExitMethod([lcClient], 'RebuildScreenBuffer');
|
//Logger.ExitMethod([lcClient], 'RebuildScreenBuffer');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.UpdateCurrentTile;
|
procedure TfrmMain.UpdateCurrentTile;
|
||||||
|
@ -2689,13 +2690,13 @@ procedure TfrmMain.UpdateCurrentTile(AX, AY: Integer);
|
||||||
var
|
var
|
||||||
blockInfo: PBlockInfo;
|
blockInfo: PBlockInfo;
|
||||||
begin
|
begin
|
||||||
Logger.EnterMethod([lcClient, lcDebug], 'UpdateCurrentTile');
|
//Logger.EnterMethod([lcClient, lcDebug], 'UpdateCurrentTile');
|
||||||
FOverlayUI.ActiveArrow := FOverlayUI.HitTest(AX, AY);
|
FOverlayUI.ActiveArrow := FOverlayUI.HitTest(AX, AY);
|
||||||
if FOverlayUI.ActiveArrow > -1 then
|
if FOverlayUI.ActiveArrow > -1 then
|
||||||
begin
|
begin
|
||||||
Logger.Send([lcClient, lcDebug], 'Overlay active');
|
//Logger.Send([lcClient, lcDebug], 'Overlay active');
|
||||||
CurrentTile := nil;
|
CurrentTile := nil;
|
||||||
Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
|
//Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2705,7 +2706,7 @@ begin
|
||||||
else
|
else
|
||||||
CurrentTile := nil;
|
CurrentTile := nil;
|
||||||
|
|
||||||
Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
|
//Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.UpdateFilter;
|
procedure TfrmMain.UpdateFilter;
|
||||||
|
@ -2732,7 +2733,9 @@ begin
|
||||||
end;
|
end;
|
||||||
Include(FScreenBufferState, sbsFiltered);
|
Include(FScreenBufferState, sbsFiltered);
|
||||||
|
|
||||||
//TODO : Check lightlevel first
|
ForceUpdateCurrentTile;
|
||||||
|
|
||||||
|
if (FLightManager.LightLevel > 0) and not acFlat.Checked then
|
||||||
FLightManager.UpdateLightMap(FX + FLowOffsetX, FRangeX + 1, FY + FLowOffsetY,
|
FLightManager.UpdateLightMap(FX + FLowOffsetX, FRangeX + 1, FY + FLowOffsetY,
|
||||||
FRangeY + 1, FScreenBuffer);
|
FRangeY + 1, FScreenBuffer);
|
||||||
end;
|
end;
|
||||||
|
@ -2841,7 +2844,7 @@ var
|
||||||
cell: TMapCell;
|
cell: TMapCell;
|
||||||
i, tileX, tileY: Integer;
|
i, tileX, tileY: Integer;
|
||||||
begin
|
begin
|
||||||
Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
|
//Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
|
||||||
|
|
||||||
//If the current tile is nil, but we still have a selected tile, the
|
//If the current tile is nil, but we still have a selected tile, the
|
||||||
//procedure is pointless - the selection should stay intact.
|
//procedure is pointless - the selection should stay intact.
|
||||||
|
@ -2853,7 +2856,7 @@ begin
|
||||||
selectedRect := GetSelectedRect;
|
selectedRect := GetSelectedRect;
|
||||||
|
|
||||||
//clean up old ghost tiles
|
//clean up old ghost tiles
|
||||||
Logger.Send([lcClient, lcDebug], 'Cleaning ghost tiles');
|
//Logger.Send([lcClient, lcDebug], 'Cleaning ghost tiles');
|
||||||
for i := FVirtualTiles.Count - 1 downto 0 do
|
for i := FVirtualTiles.Count - 1 downto 0 do
|
||||||
begin
|
begin
|
||||||
item := FVirtualTiles[i];
|
item := FVirtualTiles[i];
|
||||||
|
@ -2863,7 +2866,7 @@ begin
|
||||||
FVirtualTiles.Delete(i);
|
FVirtualTiles.Delete(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Logger.Send([lcClient, lcDebug], 'FSelection', FSelection);
|
//Logger.Send([lcClient, lcDebug], 'FSelection', FSelection);
|
||||||
for tileX := FSelection.Left to FSelection.Right do
|
for tileX := FSelection.Left to FSelection.Right do
|
||||||
for tileY := FSelection.Top to FSelection.Bottom do
|
for tileY := FSelection.Top to FSelection.Bottom do
|
||||||
if not IsInRect(tileX, tileY, selectedRect) then
|
if not IsInRect(tileX, tileY, selectedRect) then
|
||||||
|
@ -2881,8 +2884,8 @@ begin
|
||||||
blockInfo := nil;
|
blockInfo := nil;
|
||||||
if (SelectedTile <> nil) and (CurrentTile <> SelectedTile) then
|
if (SelectedTile <> nil) and (CurrentTile <> SelectedTile) then
|
||||||
begin
|
begin
|
||||||
Logger.Send([lcClient, lcDebug], 'Multiple Targets');
|
{Logger.Send([lcClient, lcDebug], 'Multiple Targets');
|
||||||
Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect);
|
Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect);}
|
||||||
//set new ghost tiles
|
//set new ghost tiles
|
||||||
if acDraw.Checked then
|
if acDraw.Checked then
|
||||||
for tileX := selectedRect.Left to selectedRect.Right do
|
for tileX := selectedRect.Left to selectedRect.Right do
|
||||||
|
@ -2895,7 +2898,7 @@ begin
|
||||||
selectedRect) and not acDraw.Checked);
|
selectedRect) and not acDraw.Checked);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Logger.Send([lcClient, lcDebug], 'Single Target');
|
//Logger.Send([lcClient, lcDebug], 'Single Target');
|
||||||
if acDraw.Checked and not IsInRect(CurrentTile.X, CurrentTile.Y,
|
if acDraw.Checked and not IsInRect(CurrentTile.X, CurrentTile.Y,
|
||||||
FSelection) then
|
FSelection) then
|
||||||
AddGhostTile(CurrentTile.X, CurrentTile.Y, CurrentTile);
|
AddGhostTile(CurrentTile.X, CurrentTile.Y, CurrentTile);
|
||||||
|
@ -2907,8 +2910,8 @@ begin
|
||||||
end;
|
end;
|
||||||
FSelection := selectedRect;
|
FSelection := selectedRect;
|
||||||
end;
|
end;
|
||||||
Logger.Send([lcClient, lcDebug], 'Virtual Tiles', FVirtualTiles.Count);
|
{Logger.Send([lcClient, lcDebug], 'Virtual Tiles', FVirtualTiles.Count);
|
||||||
Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');
|
Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.OnTileRemoved(ATile: TMulBlock);
|
procedure TfrmMain.OnTileRemoved(ATile: TMulBlock);
|
||||||
|
|
Loading…
Reference in New Issue