Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions editor_gl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,8 @@ procedure TLocalState.DoRenderSprite(constref ASprite: TGLSprite; x, y, w, h: In
vertex_data: packed array[1..12] of GLfloat;
begin
vertex_data[1] := x; vertex_data[2] := y;
vertex_data[3] := x+w; vertex_data[4] := y;
vertex_data[5] := x+w; vertex_data[6] := y+h;
vertex_data[3] := x+w; vertex_data[4] := y+ifthen(mir<>3, 0, h);
vertex_data[5] := x+w; vertex_data[6] := y+ifthen(mir=3, 0, h);

vertex_data[7] := x; vertex_data[8] := y;
vertex_data[9] := x+w; vertex_data[10] := y+h;
Expand Down
2 changes: 1 addition & 1 deletion editor_str_consts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface

rsRoadTypeNone = 'Delete';
rsRoadTypeDirt = 'Dirt';
rsRoadTypeGrazvel= 'Grazvel';
rsRoadTypeGravel= 'Gravel';
rsRoadTypeCobblestone = 'Cobblestone';

rsRiverTypeNone = 'Delete';
Expand Down
2 changes: 1 addition & 1 deletion editor_types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface
TTerrainType = (dirt=0, sand, grass, snow, swamp, rough, subterra, lava, water, rock{,border=$FF});
TTerrainTypes = set of TTerrainType;
TRiverType = (noRiver=0, clearRiver=1, icyRiver=2, muddyRiver=3, lavaRiver=4);
TRoadType = (noRoad = 0, dirtRoad=1, grazvelRoad=2, cobblestoneRoad=3);
TRoadType = (noRoad = 0, dirtRoad=1, gravelRoad=2, cobblestoneRoad=3);
TPlayer = (red=0, blue, tan, green, orange, purple, teal, pink, none = 255);

TAITactics = (NONE=-1,RANDOM = 0,WARRIOR,BUILDER,EXPLORER);
Expand Down
1 change: 1 addition & 0 deletions main.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@ object fMain: TfMain
Width = 200
Anchors = [akTop, akLeft, akRight, akBottom]
OnMouseDown = MinimapMouseDown
OnMouseMove = MinimapMouseMove
OnPaint = MinimapPaint
end
end
Expand Down
51 changes: 34 additions & 17 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ TfMain = class(TForm)
procedure MapViewPaint(Sender: TObject);
procedure MinimapMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MinimapMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure ObjectsSearchButtonClick(Sender: TObject);
procedure ObjectsSearchChange(Sender: TObject);
procedure ObjectsSearchEditingDone(Sender: TObject);
Expand Down Expand Up @@ -360,6 +362,7 @@ TfMain = class(TForm)
procedure SetZoomIndex(AIndex: Integer);
procedure SetTileSize(ASize: Integer);

procedure MapScrollByMinimap(x,y: integer);
procedure SetMapPosition(APosition:TPoint);
procedure SetMapViewMouse(x,y: integer);

Expand Down Expand Up @@ -896,7 +899,7 @@ procedure TfMain.FormCreate(Sender: TObject);
ObjectsView.SharedControl := RootManager.SharedContext;

RoadType.Items.AddObject(rsRoadTypeDirt, TObject(PtrInt(TRoadType.dirtRoad)));
RoadType.Items.AddObject(rsRoadTypeGrazvel, TObject(PtrInt(TRoadType.grazvelRoad)));
RoadType.Items.AddObject(rsRoadTypeGravel, TObject(PtrInt(TRoadType.gravelRoad)));
RoadType.Items.AddObject(rsRoadTypeCobblestone, TObject(PtrInt(TRoadType.cobblestoneRoad)));
RoadType.Items.AddObject(rsRoadTypeNone, TObject(PtrInt(TRoadType.noRoad)));

Expand Down Expand Up @@ -1618,11 +1621,30 @@ procedure TfMain.MapViewPaint(Sender: TObject);
FMapViewState.FinishFrame;
end;

procedure TfMain.MinimapMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure TfMain.MapScrollByMinimap(x,y: integer);
var
cx,cy: Double;
pos: TPoint;
begin
//set map view center position to mouse pos

cx := x / (Minimap.Width);
cy := y / (Minimap.Height);

pos.x := round(cx * FMap.CurrentLevel.Width);
pos.y := round(cy * FMap.CurrentLevel.Height);

pos.x := pos.x- (FViewTilesH div 2);
pos.y := pos.y- (FViewTilesV div 2);

pos.x := Max(pos.x, 0);
pos.y := Max(pos.y, 0);

SetMapPosition(pos);
end;

procedure TfMain.MinimapMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if not Assigned(FMap) then
begin
Expand All @@ -1631,21 +1653,16 @@ procedure TfMain.MinimapMouseDown(Sender: TObject; Button: TMouseButton;

if (Button = TMouseButton.mbLeft) and ([ssShift,ssCtrl,ssAlt] * Shift = []) then
begin
//set map view center position to mouse pos

cx := X / (Minimap.Width);
cy := Y / (Minimap.Height);

pos.x := round(cx * FMap.CurrentLevel.Width);
pos.y := round(cy * FMap.CurrentLevel.Height);

pos.x := pos.x- (FViewTilesH div 2);
pos.y := pos.y- (FViewTilesV div 2);

pos.x := Max(pos.x, 0);
pos.y := Max(pos.y, 0);
MapScrollByMinimap(X,Y);
end;
end;

SetMapPosition(pos);
procedure TfMain.MinimapMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if ssLeft in Shift then
begin
MapScrollByMinimap(X,Y);
end;
end;

Expand Down