- Added TTileDataFlag enum

- Added TTileDataFlags set
- Changed TTiledata.Flags to use the TTileDataFlags set
- Added hue highlighting to TfrmMain
- Added TTextureManager.GetStaticMaterial to handle tiledata and hues
This commit is contained in:
2009-12-03 00:04:19 +01:00
parent b90ea02421
commit d5e5510760
7 changed files with 511 additions and 464 deletions

View File

@@ -56,7 +56,7 @@
<MinVersion Major="4" Minor="5" Release="1" Valid="True"/>
</Item5>
</RequiredPackages>
<Units Count="31">
<Units Count="34">
<Unit0>
<Filename Value="CentrED.lpr"/>
<IsPartOfProject Value="True"/>
@@ -253,6 +253,21 @@
<IsPartOfProject Value="True"/>
<UnitName Value="Logging"/>
</Unit30>
<Unit31>
<Filename Value="../UOLib/UStatics.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UStatics"/>
</Unit31>
<Unit32>
<Filename Value="../UOLib/UWorldItem.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UWorldItem"/>
</Unit32>
<Unit33>
<Filename Value="../UOLib/UMap.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UMap"/>
</Unit33>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@@ -1,37 +1,37 @@
(*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2009 Andreas Schneider
*)
program CentrED;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
(*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2009 Andreas Schneider
*)
program CentrED;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, LResources, lnetvisual, LazOpenGLContext, UdmNetwork, UfrmMain,
UfrmLogin, UfrmInitialize, UfrmAccountControl, virtualtreeview_package,
multiloglaz, UfrmEditAccount, UfrmDrawSettings, UfrmBoundaries,
@@ -40,14 +40,14 @@ uses
UfrmLargeScaleCommand, UfrmVirtualLayer, UfrmFilter, UfrmTileInfo,
UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl, UPackets,
UPacketHandlers, UAdminHandling, UGameResources, ULandscape, UfrmToolWindow,
Logging;
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}
begin
{$I CentrED.lrs}
Application.Initialize;
Application.CreateForm(TdmNetwork, dmNetwork);
Application.Run;
end.
Logging, UMap, UWorldItem, UStatics;
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}
begin
{$I CentrED.lrs}
Application.Initialize;
Application.CreateForm(TdmNetwork, dmNetwork);
Application.Run;
end.

View File

@@ -72,15 +72,18 @@ type
TLandTextureManager = class
constructor Create;
destructor Destroy; override;
function GetArtMaterial(ATileID: Word): TMaterial; overload;
function GetArtMaterial(ATileID: Word; AHue: THue;
APartialHue: Boolean): TMaterial; overload;
function GetFlatLandMaterial(ATileID: Word): TMaterial;
function GetTexMaterial(ATileID: Word): TMaterial;
protected
FArtCache: TCacheManager;
FFlatLandArtCache: TCacheManager;
FTexCache: TCacheManager;
public
function GetArtMaterial(ATileID: Word): TMaterial; overload;
function GetArtMaterial(ATileID: Word; AHue: THue;
APartialHue: Boolean): TMaterial; overload;
function GetFlatLandMaterial(ATileID: Word): TMaterial;
function GetStaticMaterial(AStaticItem: TStaticItem;
AOverrideHue: Integer = -1): TMaterial;
function GetTexMaterial(ATileID: Word): TMaterial;
end;
{ TSeperatedStaticBlock }
@@ -205,6 +208,7 @@ type
Normals: PNormals;
State: TScreenState;
Highlighted: Boolean;
HueOverride: Boolean;
Next: PBlockInfo;
end;
@@ -290,7 +294,8 @@ begin
end;
end;
function TLandTextureManager.GetArtMaterial(ATileID: Word; AHue: THue; APartialHue: Boolean): TMaterial;
function TLandTextureManager.GetArtMaterial(ATileID: Word; AHue: THue;
APartialHue: Boolean): TMaterial;
var
artEntry: TArt;
id: Integer;
@@ -330,6 +335,25 @@ begin
end;
end;
function TLandTextureManager.GetStaticMaterial(AStaticItem: TStaticItem;
AOverrideHue: Integer = -1): TMaterial;
var
staticTiledata: TStaticTiledata;
hue: THue;
begin
staticTiledata := ResMan.Tiledata.StaticTiles[AStaticItem.TileID];
if AOverrideHue < 0 then
AOverrideHue := AStaticItem.Hue;
if AOverrideHue > 0 then
hue := ResMan.Hue.Hues[AOverrideHue]
else
hue := nil;
Result := GetArtMaterial($4000 + AStaticItem.TileID, hue,
tdfPartialHue in staticTiledata.Flags);
end;
function TLandTextureManager.GetTexMaterial(ATileID: Word): TMaterial;
var
texEntry: TTexture;
@@ -706,8 +730,8 @@ begin
(staticItem.Hue = staticInfo.Hue) then
begin
if Assigned(FOnStaticDeleted) then FOnStaticDeleted(staticItem);
statics.Delete(i);
staticItem.Delete;
statics.Delete(i);
Break;
end;
@@ -785,8 +809,8 @@ begin
if staticItem <> nil then
begin
if Assigned(FOnStaticDeleted) then FOnStaticDeleted(staticItem);
statics.Remove(staticItem);
staticItem.Delete;
statics.Remove(staticItem);
end;
end;

View File

@@ -1733,8 +1733,6 @@ var
west, south, east: Single;
z: SmallInt;
staticItem: TStaticItem;
hue: THue;
staticTiledata: TStaticTiledata;
begin
//add normals to map tiles and materials where possible
@@ -1806,13 +1804,8 @@ begin
begin
staticItem := TStaticItem(item);
staticTiledata := ResMan.Tiledata.StaticTiles[staticItem.TileID];
if staticItem.Hue > 0 then
hue := ResMan.Hue.Hues[staticItem.Hue - 1]
else
hue := nil;
ABlockInfo^.LowRes := FTextureManager.GetArtMaterial($4000 + staticItem.TileID, hue, (staticTileData.Flags and tdfPartialHue) = tdfPartialHue);
ABlockInfo^.LowRes := FTextureManager.GetStaticMaterial(staticItem);
ABlockInfo^.HueOverride := False;
ABlockInfo^.ScreenRect := Bounds(Trunc(drawX - ABlockInfo^.LowRes.RealWidth / 2),
Trunc(drawY + 44 - ABlockInfo^.LowRes.RealHeight - z * 4),
ABlockInfo^.LowRes.RealWidth,
@@ -2292,6 +2285,27 @@ procedure TfrmMain.UpdateSelection;
var
selectedRect: TRect;
blockInfo: PBlockInfo;
procedure SetHighlight(ABlockInfo: PBlockInfo; AHighlighted: Boolean);
begin
if (ABlockInfo^.Item is TStaticItem) and acHue.Checked then
begin
if ABlockInfo^.HueOverride <> AHighlighted then
begin
ABlockInfo^.HueOverride := AHighlighted;
if AHighlighted then
ABlockInfo^.LowRes := FTextureManager.GetStaticMaterial(
TStaticItem(ABlockInfo^.Item), frmHueSettings.lbHue.ItemIndex)
else
ABlockInfo^.LowRes := FTextureManager.GetStaticMaterial(
TStaticItem(ABlockInfo^.Item));
end;
end else
begin
ABlockInfo^.Highlighted := AHighlighted;
end;
end;
begin
Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
if (CurrentTile <> nil) and (not acSelect.Checked) then
@@ -2303,14 +2317,15 @@ begin
selectedRect := GetSelectedRect;
Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect);
while FScreenBuffer.Iterate(blockInfo) do
if blockInfo^.State = ssNormal then
blockInfo^.Highlighted := PtInRect(selectedRect, Point(blockInfo^.Item.X, blockInfo^.Item.Y));
if (blockInfo^.State = ssNormal) then
SetHighlight(blockInfo, PtInRect(selectedRect,
Point(blockInfo^.Item.X, blockInfo^.Item.Y)));
end else
begin
Logger.Send([lcClient, lcDebug], 'Single Target');
while FScreenBuffer.Iterate(blockInfo) do
if blockInfo^.State = ssNormal then
blockInfo^.Highlighted := (blockInfo^.Item = CurrentTile);
SetHighlight(blockInfo, (blockInfo^.Item = CurrentTile));
end;
end;
Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');

View File

@@ -80,9 +80,9 @@ var
tileData: TTiledata;
prefix, flags: string;
procedure UpdateFlags(AFlag: LongWord; AName: string);
procedure UpdateFlags(AFlag: TTileDataFlag; AName: string);
begin
if tileData.HasFlag(AFlag) then
if AFlag in tileData.Flags then
begin
if flags <> '' then
flags := flags + ', ' + AName
@@ -111,9 +111,9 @@ begin
tileData := ResMan.Tiledata.StaticTiles[ATileID];
end;
if tileData.HasFlag(tdfArticleA) then
if tdfArticleA in tileData.Flags then
prefix := 'a '
else if tileData.HasFlag(tdfArticleAn) then
else if tdfArticleAn in tileData.Flags then
prefix := 'an '
else
prefix := '';