- Added translucent static tile support (fixes #46)

- Fixed infinite recursion when updating ghost map tiles
This commit is contained in:
Andreas Schneider 2009-12-05 01:24:58 +01:00
parent 833c470cb7
commit dd88d845cd
2 changed files with 51 additions and 37 deletions

View File

@ -211,6 +211,7 @@ type
Highlighted: Boolean; Highlighted: Boolean;
HueOverride: Boolean; HueOverride: Boolean;
CheckRealQuad: Boolean; CheckRealQuad: Boolean;
Translucent: Boolean;
Next: PBlockInfo; Next: PBlockInfo;
end; end;
@ -1211,6 +1212,7 @@ begin
Result^.Normals := nil; Result^.Normals := nil;
Result^.State := ssNormal; Result^.State := ssNormal;
Result^.Highlighted := False; Result^.Highlighted := False;
Result^.Translucent := False;
Result^.Next := nil; Result^.Next := nil;
if FShortCuts[0] = nil then //First element if FShortCuts[0] = nil then //First element
@ -1353,6 +1355,7 @@ begin
Result^.Normals := nil; Result^.Normals := nil;
Result^.State := ssNormal; Result^.State := ssNormal;
Result^.Highlighted := False; Result^.Highlighted := False;
Result^.Translucent := False;
if (FShortCuts[0] = nil) or (CompareWorldItems(AItem, FShortCuts[0]^.Item) < 0) then if (FShortCuts[0] = nil) or (CompareWorldItems(AItem, FShortCuts[0]^.Item) < 0) then
begin begin

View File

@ -304,6 +304,7 @@ type
function GetSelectedRect: TRect; function GetSelectedRect: TRect;
procedure InitRender; procedure InitRender;
procedure InitSize; procedure InitSize;
procedure PrepareMapCell(AMapCell: TMapCell);
procedure PrepareScreenBlock(ABlockInfo: PBlockInfo); procedure PrepareScreenBlock(ABlockInfo: PBlockInfo);
procedure ProcessToolState; procedure ProcessToolState;
procedure ProcessAccessLevel; procedure ProcessAccessLevel;
@ -1785,6 +1786,43 @@ begin
glLoadIdentity; glLoadIdentity;
end; end;
procedure TfrmMain.PrepareMapCell(AMapCell: TMapCell);
var
current, north, east, west: PBlockInfo;
cell: TMapCell;
begin
current := FScreenBuffer.UpdateSortOrder(AMapCell);
if current = nil then
Exit; //off-screen update
PrepareScreenBlock(current);
Exclude(FScreenBufferState, sbsIndexed);
//Find surrounding cells
current := nil;
north := nil;
east := nil;
west := nil;
while ((north = nil) or (east = nil) or (west = nil)) and
FScreenBuffer.Iterate(current) do
begin
if current^.Item is TMapCell then
begin
cell := TMapCell(current^.Item);
if (cell.X = AMapCell.X - 1) and (cell.Y = AMapCell.Y - 1) then
north := current
else if (cell.X = AMapCell.X) and (cell.Y = AMapCell.Y - 1) then
east := current
else if (cell.X = AMapCell.X - 1) and (cell.Y = AMapCell.Y) then
west := current;
end;
end;
if north <> nil then PrepareScreenBlock(north);
if east <> nil then PrepareScreenBlock(east);
if west <> nil then PrepareScreenBlock(west);
end;
procedure TfrmMain.InvalidateFilter; procedure TfrmMain.InvalidateFilter;
begin begin
Exclude(FScreenBufferState, sbsFiltered); Exclude(FScreenBufferState, sbsFiltered);
@ -1939,6 +1977,9 @@ begin
ABlockInfo^.LowRes.RealWidth, ABlockInfo^.LowRes.RealWidth,
ABlockInfo^.LowRes.RealHeight); ABlockInfo^.LowRes.RealHeight);
ABlockInfo^.Translucent := tdfTranslucent in
ResMan.Tiledata.StaticTiles[staticItem.TileID].Flags;
south := ABlockInfo^.LowRes.RealHeight; south := ABlockInfo^.LowRes.RealHeight;
east := ABlockInfo^.LowRes.RealWidth div 2; east := ABlockInfo^.LowRes.RealWidth div 2;
@ -1990,7 +2031,10 @@ begin
SetDarkLights; SetDarkLights;
end; end;
glColor4f(intensity, intensity, intensity, 1.0); if blockInfo^.Translucent then
glColor4f(intensity, intensity, intensity, 0.5)
else
glColor4f(intensity, intensity, intensity, 1.0);
highlight := blockInfo^.Highlighted and item.CanBeEdited; highlight := blockInfo^.Highlighted and item.CanBeEdited;
@ -2048,41 +2092,8 @@ begin
end; end;
procedure TfrmMain.OnMapChanged(AMapCell: TMapCell); procedure TfrmMain.OnMapChanged(AMapCell: TMapCell);
var
current, north, east, west: PBlockInfo;
cell: TMapCell;
begin begin
current := FScreenBuffer.UpdateSortOrder(AMapCell); PrepareMapCell(AMapCell);
if current = nil then
Exit; //off-screen update
PrepareScreenBlock(current);
Exclude(FScreenBufferState, sbsIndexed);
//Find surrounding cells
current := nil;
north := nil;
east := nil;
west := nil;
while ((north = nil) or (east = nil) or (west = nil)) and
FScreenBuffer.Iterate(current) do
begin
if current^.Item is TMapCell then
begin
cell := TMapCell(current^.Item);
if (cell.X = AMapCell.X - 1) and (cell.Y = AMapCell.Y - 1) then
north := current
else if (cell.X = AMapCell.X) and (cell.Y = AMapCell.Y - 1) then
east := current
else if (cell.X = AMapCell.X - 1) and (cell.Y = AMapCell.Y) then
west := current;
end;
end;
if north <> nil then PrepareScreenBlock(north);
if east <> nil then PrepareScreenBlock(east);
if west <> nil then PrepareScreenBlock(west);
ForceUpdateCurrentTile; ForceUpdateCurrentTile;
end; end;
@ -2436,7 +2447,7 @@ procedure TfrmMain.UpdateSelection;
if frmDrawSettings.cbRandomHeight.Checked then if frmDrawSettings.cbRandomHeight.Checked then
cell.GhostZ := cell.GhostZ + Random(frmDrawSettings.seRandomHeight.Value); cell.GhostZ := cell.GhostZ + Random(frmDrawSettings.seRandomHeight.Value);
OnMapChanged(cell); PrepareMapCell(cell);
end; end;
end else end else
begin begin
@ -2508,7 +2519,7 @@ begin
if (cell <> nil) and cell.IsGhost then if (cell <> nil) and cell.IsGhost then
begin begin
cell.IsGhost := False; cell.IsGhost := False;
OnMapChanged(cell); PrepareMapCell(cell);
end; end;
end; end;