Skip to content

Commit 5001f80

Browse files
committed
Configure Windows build
1 parent 0e5b6f1 commit 5001f80

3 files changed

Lines changed: 145 additions & 133 deletions

File tree

src/BF2WebAdmin.Server/BF2WebAdmin.Server.csproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
<DockerfileTag>bf2-webadmin</DockerfileTag>
1515
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
1616
<LangVersion>default</LangVersion>
17+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
18+
<SelfContained>true</SelfContained>
19+
<PublishSingleFile>true</PublishSingleFile>
20+
<UseAppHost>true</UseAppHost>
21+
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
22+
23+
<!-- Complains about config files -->
24+
<!-- <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>-->
25+
<!-- Not prepared for trimming yet, trims too much -->
26+
<!--<PublishTrimmed>true</PublishTrimmed>-->
27+
</PropertyGroup>
28+
29+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
30+
<BlazorWebAssemblyOmitDebugProxyOutput>true</BlazorWebAssemblyOmitDebugProxyOutput>
1731
</PropertyGroup>
1832

1933
<!--<PropertyGroup>
@@ -55,8 +69,6 @@
5569
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.2" />
5670
<PackageReference Include="Polly" Version="8.5.2" />
5771
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
58-
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0006" />
59-
<PackageReference Include="SkiaSharp" Version="2.88.2" />
6072
<PackageReference Include="StackExchange.Redis" Version="2.6.66" />
6173
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
6274
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.4" />
Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,103 @@
1-
using BF2WebAdmin.Common.Entities.Game;
2-
using SkiaSharp;
3-
4-
namespace BF2WebAdmin.Server;
5-
6-
public class MapStatsRenderer
7-
{
8-
public static Stream GetMapMovementPathImage(string map, IEnumerable<(Position, Rotation)> movementPath1, IEnumerable<(Position, Rotation)> movementPath2)
9-
{
10-
if (movementPath1 == null || !movementPath1.Any())
11-
return null;
12-
if (movementPath2 == null || !movementPath2.Any())
13-
return null;
14-
15-
// crate a surface
16-
var info = new SKImageInfo(700, 700);
17-
using var surface = SKSurface.Create(info);
18-
19-
// the the canvas and properties
20-
var canvas = surface.Canvas;
21-
22-
// make sure the canvas is blank
23-
canvas.Clear(SKColors.White);
24-
25-
var mapBackground = SKBitmap.Decode($"Assets/{map}.png");
26-
var customOffset = GetCustomMapOffset(map);
27-
var imageOffset = new SKPoint(
28-
(info.Width / 2f) - (mapBackground.Width / 2f) + customOffset.x,
29-
(info.Height / 2f) - (mapBackground.Height / 2f) + customOffset.y
30-
);
31-
canvas.DrawBitmap(mapBackground, imageOffset);
32-
33-
// US heli path
34-
var paint1 = new SKPaint
35-
{
36-
Color = SKColors.Blue,
37-
IsAntialias = true,
38-
Style = SKPaintStyle.Stroke,
39-
};
40-
var path1 = new SKPath();
41-
path1.MoveTo(ToImageCoordinates(movementPath1.First().Item1));
42-
foreach (var (pos, _) in movementPath1)
43-
{
44-
path1.LineTo(ToImageCoordinates(pos));
45-
}
46-
canvas.DrawPath(path1, paint1);
47-
48-
// China heli path
49-
var paint2 = new SKPaint
50-
{
51-
Color = SKColors.Red,
52-
IsAntialias = true,
53-
Style = SKPaintStyle.Stroke,
54-
};
55-
var path2 = new SKPath();
56-
path2.MoveTo(ToImageCoordinates(movementPath2.First().Item1));
57-
foreach (var (pos, _) in movementPath2)
58-
{
59-
path1.LineTo(ToImageCoordinates(pos));
60-
}
61-
canvas.DrawPath(path2, paint2);
62-
63-
// draw some text
64-
var paint = new SKPaint
65-
{
66-
Color = SKColors.White,
67-
IsAntialias = true,
68-
Style = SKPaintStyle.Fill,
69-
TextAlign = SKTextAlign.Center,
70-
TextSize = 32
71-
};
72-
var textPosition = new SKPoint(info.Width / 2, 40);
73-
//var coord = new SKPoint(info.Width / 2, (info.Height + paint.TextSize) / 2);
74-
canvas.DrawText("Round movements", textPosition, paint);
75-
76-
// save the file
77-
using var image = surface.Snapshot();
78-
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
79-
using var stream = File.OpenWrite("output.png");
80-
data.SaveTo(stream);
81-
82-
var result = new MemoryStream();
83-
data.SaveTo(result);
84-
return result;
85-
86-
SKPoint ToImageCoordinates(Position pos)
87-
{
88-
return new SKPoint(
89-
(float)pos.X + (info.Width / 2f) + customOffset.x,
90-
(float)pos.Y + (info.Height / 2f) + customOffset.y
91-
);
92-
}
93-
}
94-
95-
private static (float x, float y) GetCustomMapOffset(string map)
96-
{
97-
return map switch
98-
{
99-
//"dalian_2_v_2" => (30, -130),
100-
_ => (0, 0)
101-
};
102-
}
103-
}
1+
// using BF2WebAdmin.Common.Entities.Game;
2+
// using SkiaSharp;
3+
//
4+
// namespace BF2WebAdmin.Server;
5+
//
6+
// public class MapStatsRenderer
7+
// {
8+
// public static Stream GetMapMovementPathImage(string map, IEnumerable<(Position, Rotation)> movementPath1, IEnumerable<(Position, Rotation)> movementPath2)
9+
// {
10+
// if (movementPath1 == null || !movementPath1.Any())
11+
// return null;
12+
// if (movementPath2 == null || !movementPath2.Any())
13+
// return null;
14+
//
15+
// // crate a surface
16+
// var info = new SKImageInfo(700, 700);
17+
// using var surface = SKSurface.Create(info);
18+
//
19+
// // the the canvas and properties
20+
// var canvas = surface.Canvas;
21+
//
22+
// // make sure the canvas is blank
23+
// canvas.Clear(SKColors.White);
24+
//
25+
// var mapBackground = SKBitmap.Decode($"Assets/{map}.png");
26+
// var customOffset = GetCustomMapOffset(map);
27+
// var imageOffset = new SKPoint(
28+
// (info.Width / 2f) - (mapBackground.Width / 2f) + customOffset.x,
29+
// (info.Height / 2f) - (mapBackground.Height / 2f) + customOffset.y
30+
// );
31+
// canvas.DrawBitmap(mapBackground, imageOffset);
32+
//
33+
// // US heli path
34+
// var paint1 = new SKPaint
35+
// {
36+
// Color = SKColors.Blue,
37+
// IsAntialias = true,
38+
// Style = SKPaintStyle.Stroke,
39+
// };
40+
// var path1 = new SKPath();
41+
// path1.MoveTo(ToImageCoordinates(movementPath1.First().Item1));
42+
// foreach (var (pos, _) in movementPath1)
43+
// {
44+
// path1.LineTo(ToImageCoordinates(pos));
45+
// }
46+
// canvas.DrawPath(path1, paint1);
47+
//
48+
// // China heli path
49+
// var paint2 = new SKPaint
50+
// {
51+
// Color = SKColors.Red,
52+
// IsAntialias = true,
53+
// Style = SKPaintStyle.Stroke,
54+
// };
55+
// var path2 = new SKPath();
56+
// path2.MoveTo(ToImageCoordinates(movementPath2.First().Item1));
57+
// foreach (var (pos, _) in movementPath2)
58+
// {
59+
// path1.LineTo(ToImageCoordinates(pos));
60+
// }
61+
// canvas.DrawPath(path2, paint2);
62+
//
63+
// // draw some text
64+
// var paint = new SKPaint
65+
// {
66+
// Color = SKColors.White,
67+
// IsAntialias = true,
68+
// Style = SKPaintStyle.Fill,
69+
// TextAlign = SKTextAlign.Center,
70+
// TextSize = 32
71+
// };
72+
// var textPosition = new SKPoint(info.Width / 2, 40);
73+
// //var coord = new SKPoint(info.Width / 2, (info.Height + paint.TextSize) / 2);
74+
// canvas.DrawText("Round movements", textPosition, paint);
75+
//
76+
// // save the file
77+
// using var image = surface.Snapshot();
78+
// using var data = image.Encode(SKEncodedImageFormat.Png, 100);
79+
// using var stream = File.OpenWrite("output.png");
80+
// data.SaveTo(stream);
81+
//
82+
// var result = new MemoryStream();
83+
// data.SaveTo(result);
84+
// return result;
85+
//
86+
// SKPoint ToImageCoordinates(Position pos)
87+
// {
88+
// return new SKPoint(
89+
// (float)pos.X + (info.Width / 2f) + customOffset.x,
90+
// (float)pos.Y + (info.Height / 2f) + customOffset.y
91+
// );
92+
// }
93+
// }
94+
//
95+
// private static (float x, float y) GetCustomMapOffset(string map)
96+
// {
97+
// return map switch
98+
// {
99+
// //"dalian_2_v_2" => (30, -130),
100+
// _ => (0, 0)
101+
// };
102+
// }
103+
// }

src/BF2WebAdmin.Server/Modules/BF2/ChopperMayhemModule.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using BF2WebAdmin.Server.Commands.BF2;
44
using BF2WebAdmin.Server.Constants;
55
using BF2WebAdmin.Server.Extensions;
6-
using SixLabors.ImageSharp;
76

87
namespace BF2WebAdmin.Server.Modules.BF2;
98

@@ -166,33 +165,34 @@ private async Task OnChatMessageAsync(Message message)
166165
}
167166
}
168167

169-
if (message.Text == ".nudes")
170-
{
171-
var startX = 900;
172-
var startZ = 310;
173-
var distanceX = 12.5;
174-
var distanceZ = 11.5;
175-
var i2 = 0;
176-
177-
var rotation = Rotation.Neutral;
178-
using var image = Image.Load(@"C:\Users\Alex\Pictures\bf2text.png");
179-
for (var ix = 0; ix < image.Width; ix++)
180-
{
181-
for (var iy = 0; iy < image.Height; iy++)
182-
{
183-
var pixel = image[ix, iy];
184-
if (pixel.A == 0)
185-
continue;
186-
187-
Logger.LogInformation("Pixel found at {x},{y}", ix, iy);
188-
189-
var xPos = startX - ix * distanceX;
190-
var zPos = startZ - iy * distanceZ;
191-
await Task.Delay(100);
192-
SpawnObject("concrete_pillar_wall", new Position(xPos, zPos, -320), rotation, false);
193-
}
194-
}
195-
}
168+
// SixLabors.SkiaSharp
169+
// if (message.Text == ".nudes")
170+
// {
171+
// var startX = 900;
172+
// var startZ = 310;
173+
// var distanceX = 12.5;
174+
// var distanceZ = 11.5;
175+
// var i2 = 0;
176+
//
177+
// var rotation = Rotation.Neutral;
178+
// using var image = Image.Load(@"C:\Users\Alex\Pictures\bf2text.png");
179+
// for (var ix = 0; ix < image.Width; ix++)
180+
// {
181+
// for (var iy = 0; iy < image.Height; iy++)
182+
// {
183+
// var pixel = image[ix, iy];
184+
// if (pixel.A == 0)
185+
// continue;
186+
//
187+
// Logger.LogInformation("Pixel found at {x},{y}", ix, iy);
188+
//
189+
// var xPos = startX - ix * distanceX;
190+
// var zPos = startZ - iy * distanceZ;
191+
// await Task.Delay(100);
192+
// SpawnObject("concrete_pillar_wall", new Position(xPos, zPos, -320), rotation, false);
193+
// }
194+
// }
195+
// }
196196
}
197197

198198
public async ValueTask HandleAsync(MapChangedEvent e)

0 commit comments

Comments
 (0)