- Changed the hue change mechanic (store the info in the ScreenBuffer instead of a separate list) (refs #66)
This commit is contained in:
parent
4c76aafe47
commit
abe62e13b8
|
@ -265,6 +265,7 @@ type
|
||||||
State: TScreenState;
|
State: TScreenState;
|
||||||
Highlighted: Boolean;
|
Highlighted: Boolean;
|
||||||
HueOverride: Boolean;
|
HueOverride: Boolean;
|
||||||
|
Hue: Word;
|
||||||
CheckRealQuad: Boolean;
|
CheckRealQuad: Boolean;
|
||||||
Translucent: Boolean;
|
Translucent: Boolean;
|
||||||
WalkRestriction: TWalkRestriction;
|
WalkRestriction: TWalkRestriction;
|
||||||
|
|
|
@ -43,13 +43,13 @@ type
|
||||||
TScreenBufferState = (sbsValid, sbsIndexed, sbsFiltered);
|
TScreenBufferState = (sbsValid, sbsIndexed, sbsFiltered);
|
||||||
TScreenBufferStates = set of TScreenBufferState;
|
TScreenBufferStates = set of TScreenBufferState;
|
||||||
|
|
||||||
|
TBlockInfoList = specialize TFPGList<PBlockInfo>;
|
||||||
|
|
||||||
TGhostTile = class(TStaticItem);
|
TGhostTile = class(TStaticItem);
|
||||||
TPacketList = specialize TFPGObjectList<TPacket>;
|
TPacketList = specialize TFPGObjectList<TPacket>;
|
||||||
TAccessChangedListeners = specialize TFPGList<TAccessChangedListener>;
|
TAccessChangedListeners = specialize TFPGList<TAccessChangedListener>;
|
||||||
TSelectionListeners = specialize TFPGList<TSelectionListener>;
|
TSelectionListeners = specialize TFPGList<TSelectionListener>;
|
||||||
|
|
||||||
THueList = specialize TFPGList<Word>;
|
|
||||||
|
|
||||||
TTileHintInfo = record
|
TTileHintInfo = record
|
||||||
Name: String;
|
Name: String;
|
||||||
Flags: String;
|
Flags: String;
|
||||||
|
@ -334,7 +334,6 @@ type
|
||||||
FSelectionListeners: TSelectionListeners;
|
FSelectionListeners: TSelectionListeners;
|
||||||
FTileHint: TTileHintInfo;
|
FTileHint: TTileHintInfo;
|
||||||
FLightManager: TLightManager;
|
FLightManager: TLightManager;
|
||||||
FHueBuffer: THueList;
|
|
||||||
{ Methods }
|
{ Methods }
|
||||||
procedure BuildTileList;
|
procedure BuildTileList;
|
||||||
function ConfirmAction: Boolean;
|
function ConfirmAction: Boolean;
|
||||||
|
@ -642,15 +641,14 @@ procedure TfrmMain.oglGameWindowMouseUp(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
map: TMapCell;
|
map: TMapCell;
|
||||||
i, hueCount: Integer;
|
i: Integer;
|
||||||
z: ShortInt;
|
z: ShortInt;
|
||||||
blockInfo: PBlockInfo;
|
blockInfo: PBlockInfo;
|
||||||
targetRect: TRect;
|
targetRect: TRect;
|
||||||
offsetX, offsetY: Integer;
|
offsetX, offsetY: Integer;
|
||||||
tile: TWorldItem;
|
tile: TWorldItem;
|
||||||
tileX, tileY, newX, newY: Word;
|
tileX, tileY, newX, newY: Word;
|
||||||
hue: Word;
|
targetBlocks: TBlockInfoList;
|
||||||
targetTiles: TWorldItemList;
|
|
||||||
targetTile: TWorldItem;
|
targetTile: TWorldItem;
|
||||||
begin
|
begin
|
||||||
Logger.EnterMethod([lcClient, lcDebug], 'MouseUp');
|
Logger.EnterMethod([lcClient, lcDebug], 'MouseUp');
|
||||||
|
@ -706,9 +704,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Logger.Send([lcClient, lcDebug], 'Virtual tiles', FVirtualTiles.Count);
|
Logger.Send([lcClient, lcDebug], 'Virtual tiles', FVirtualTiles.Count);
|
||||||
for i := 0 to FVirtualTiles.Count - 1 do
|
for tile in FVirtualTiles do
|
||||||
begin
|
begin
|
||||||
tile := FVirtualTiles[i];
|
|
||||||
if tile is TGhostTile then
|
if tile is TGhostTile then
|
||||||
begin
|
begin
|
||||||
dmNetwork.Send(TInsertStaticPacket.Create(tile.X, tile.Y, tile.Z,
|
dmNetwork.Send(TInsertStaticPacket.Create(tile.X, tile.Y, tile.Z,
|
||||||
|
@ -721,10 +718,18 @@ begin
|
||||||
if (not acMove.Checked) or (SelectedTile <> targetTile) or
|
if (not acMove.Checked) or (SelectedTile <> targetTile) or
|
||||||
(not frmMoveSettings.cbAsk.Checked) or ConfirmAction then
|
(not frmMoveSettings.cbAsk.Checked) or ConfirmAction then
|
||||||
begin
|
begin
|
||||||
targetTiles := TWorldItemList.Create(False);
|
targetBlocks := TBlockInfoList.Create;
|
||||||
if SelectedTile = targetTile then
|
if SelectedTile = targetTile then
|
||||||
begin
|
begin
|
||||||
targetTiles.Add(targetTile)
|
blockInfo := nil;
|
||||||
|
while FScreenBuffer.Iterate(blockInfo) do
|
||||||
|
begin
|
||||||
|
if blockInfo^.Item = targetTile then
|
||||||
|
begin
|
||||||
|
targetBlocks.Add(blockInfo);
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
blockInfo := nil;
|
blockInfo := nil;
|
||||||
|
@ -734,7 +739,7 @@ begin
|
||||||
blockInfo^.Item.CanBeEdited and
|
blockInfo^.Item.CanBeEdited and
|
||||||
IsInRect(blockInfo^.Item.X, blockInfo^.Item.Y, targetRect) then
|
IsInRect(blockInfo^.Item.X, blockInfo^.Item.Y, targetRect) then
|
||||||
begin
|
begin
|
||||||
targetTiles.Add(blockInfo^.Item);
|
targetBlocks.Add(blockInfo);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -743,10 +748,9 @@ begin
|
||||||
begin
|
begin
|
||||||
offsetX := frmMoveSettings.GetOffsetX;
|
offsetX := frmMoveSettings.GetOffsetX;
|
||||||
offsetY := frmMoveSettings.GetOffsetY;
|
offsetY := frmMoveSettings.GetOffsetY;
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
for blockInfo in targetBlocks do
|
||||||
begin
|
begin
|
||||||
tile := targetTiles.Items[i];
|
tile := blockInfo^.Item;
|
||||||
|
|
||||||
if tile is TStaticItem then
|
if tile is TStaticItem then
|
||||||
begin
|
begin
|
||||||
newX := EnsureRange(tile.X + offsetX, 0, FLandscape.CellWidth - 1);
|
newX := EnsureRange(tile.X + offsetX, 0, FLandscape.CellWidth - 1);
|
||||||
|
@ -759,9 +763,9 @@ begin
|
||||||
end;
|
end;
|
||||||
end else if acElevate.Checked then //***** Elevate tile *****//
|
end else if acElevate.Checked then //***** Elevate tile *****//
|
||||||
begin
|
begin
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
for blockInfo in targetBlocks do
|
||||||
begin
|
begin
|
||||||
tile := targetTiles.Items[i];
|
tile := blockInfo^.Item;
|
||||||
|
|
||||||
z := frmElevateSettings.seZ.Value;
|
z := frmElevateSettings.seZ.Value;
|
||||||
if frmElevateSettings.rbRaise.Checked then
|
if frmElevateSettings.rbRaise.Checked then
|
||||||
|
@ -786,10 +790,9 @@ begin
|
||||||
end;
|
end;
|
||||||
end else if acDelete.Checked then //***** Delete tile *****//
|
end else if acDelete.Checked then //***** Delete tile *****//
|
||||||
begin
|
begin
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
for blockInfo in targetBlocks do
|
||||||
begin
|
begin
|
||||||
tile := targetTiles.Items[i];
|
tile := blockInfo^.Item;
|
||||||
|
|
||||||
if tile is TStaticItem then
|
if tile is TStaticItem then
|
||||||
begin
|
begin
|
||||||
FUndoList.Add(TInsertStaticPacket.Create(tile.X, tile.Y,
|
FUndoList.Add(TInsertStaticPacket.Create(tile.X, tile.Y,
|
||||||
|
@ -799,32 +802,24 @@ begin
|
||||||
end;
|
end;
|
||||||
end else if acHue.Checked then //***** Hue tile *****//
|
end else if acHue.Checked then //***** Hue tile *****//
|
||||||
begin
|
begin
|
||||||
hueCount := 0;
|
for blockInfo in targetBlocks do
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
|
||||||
begin
|
begin
|
||||||
tile := targetTiles.Items[i];
|
tile := blockInfo^.Item;
|
||||||
|
|
||||||
if tile is TStaticItem then
|
if blockInfo^.HueOverride and (tile is TStaticItem) then
|
||||||
begin
|
begin
|
||||||
//If a hue is in the buffer (see UpdateSelection), use that, otherwise
|
if TStaticItem(tile).Hue <> blockInfo^.Hue then
|
||||||
//create a new one. (Necessary for random hues.)
|
|
||||||
if hueCount < FHueBuffer.Count then
|
|
||||||
hue := FHueBuffer[hueCount]
|
|
||||||
else
|
|
||||||
hue := frmHueSettings.GetHue;
|
|
||||||
Inc(hueCount);
|
|
||||||
|
|
||||||
if TStaticItem(tile).Hue <> hue then
|
|
||||||
begin
|
begin
|
||||||
FUndoList.Add(THueStaticPacket.Create(tile.X, tile.Y, tile.Z,
|
FUndoList.Add(THueStaticPacket.Create(tile.X, tile.Y, tile.Z,
|
||||||
tile.TileID, hue, TStaticItem(tile).Hue));
|
tile.TileID, blockInfo^.Hue, TStaticItem(tile).Hue));
|
||||||
dmNetwork.Send(THueStaticPacket.Create(TStaticItem(tile), hue));
|
dmNetwork.Send(THueStaticPacket.Create(TStaticItem(tile),
|
||||||
|
blockInfo^.Hue));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
targetTiles.Free;
|
targetBlocks.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -959,8 +954,6 @@ begin
|
||||||
FSelectionListeners := TSelectionListeners.Create;
|
FSelectionListeners := TSelectionListeners.Create;
|
||||||
|
|
||||||
FLastDraw := Now;
|
FLastDraw := Now;
|
||||||
|
|
||||||
FHueBuffer := THueList.Create;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.btnGoToClick(Sender: TObject);
|
procedure TfrmMain.btnGoToClick(Sender: TObject);
|
||||||
|
@ -1311,7 +1304,6 @@ begin
|
||||||
FreeAndNil(FRandomPresetsDoc);
|
FreeAndNil(FRandomPresetsDoc);
|
||||||
FreeAndNil(FAccessChangedListeners);
|
FreeAndNil(FAccessChangedListeners);
|
||||||
FreeAndNil(FSelectionListeners);
|
FreeAndNil(FSelectionListeners);
|
||||||
FreeAndNil(FHueBuffer);
|
|
||||||
|
|
||||||
RegisterPacketHandler($0C, nil);
|
RegisterPacketHandler($0C, nil);
|
||||||
end;
|
end;
|
||||||
|
@ -2853,12 +2845,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.UpdateSelection;
|
procedure TfrmMain.UpdateSelection;
|
||||||
var
|
|
||||||
highlightCount: Integer;
|
|
||||||
|
|
||||||
procedure SetHighlight(ABlockInfo: PBlockInfo; AHighlighted: Boolean);
|
procedure SetHighlight(ABlockInfo: PBlockInfo; AHighlighted: Boolean);
|
||||||
var
|
|
||||||
hue: Word;
|
|
||||||
begin
|
begin
|
||||||
if (ABlockInfo^.Item is TStaticItem) and acHue.Checked then
|
if (ABlockInfo^.Item is TStaticItem) and acHue.Checked then
|
||||||
begin
|
begin
|
||||||
|
@ -2867,26 +2855,15 @@ var
|
||||||
ABlockInfo^.HueOverride := AHighlighted;
|
ABlockInfo^.HueOverride := AHighlighted;
|
||||||
if AHighlighted then
|
if AHighlighted then
|
||||||
begin
|
begin
|
||||||
if highlightCount < FHueBuffer.Count then
|
ABlockInfo^.Hue := frmHueSettings.GetHue;
|
||||||
begin
|
|
||||||
hue := FHueBuffer[highlightCount];
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
hue := frmHueSettings.GetHue;
|
|
||||||
FHueBuffer.Add(hue);
|
|
||||||
end;
|
|
||||||
|
|
||||||
ABlockInfo^.LowRes := FTextureManager.GetStaticMaterial(
|
ABlockInfo^.LowRes := FTextureManager.GetStaticMaterial(
|
||||||
TStaticItem(ABlockInfo^.Item), hue);
|
TStaticItem(ABlockInfo^.Item), ABlockInfo^.Hue);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
ABlockInfo^.LowRes := FTextureManager.GetStaticMaterial(
|
ABlockInfo^.LowRes := FTextureManager.GetStaticMaterial(
|
||||||
TStaticItem(ABlockInfo^.Item));
|
TStaticItem(ABlockInfo^.Item));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if AHighlighted then
|
|
||||||
Inc(highlightCount);
|
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
ABlockInfo^.Highlighted := AHighlighted;
|
ABlockInfo^.Highlighted := AHighlighted;
|
||||||
|
@ -2986,14 +2963,6 @@ begin
|
||||||
else
|
else
|
||||||
selectedRect := GetSelectedRect;
|
selectedRect := GetSelectedRect;
|
||||||
|
|
||||||
if acHue.Checked and (SelectedTile = nil) then
|
|
||||||
begin
|
|
||||||
//Prepare hue buffer
|
|
||||||
FHueBuffer.Clear;
|
|
||||||
end;
|
|
||||||
|
|
||||||
highlightCount := 0;
|
|
||||||
|
|
||||||
//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
|
||||||
|
|
Loading…
Reference in New Issue