• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


コミットメタ情報

リビジョン8e4c042fed0bcb8e5de35d1cec15c458206e0e0f (tree)
日時2020-06-04 08:04:24
作者melchior <melchior@user...>
コミッターmelchior

ログメッセージ

Working (W.I.P.) snapshots!

変更サマリ

差分

--- a/Automap/Subsystems/AutomapGUIDialog.cs
+++ b/Automap/Subsystems/AutomapGUIDialog.cs
@@ -75,6 +75,10 @@ namespace Automap
7575 txtNoteArea.fixedHeight = 24;
7676 txtNoteArea.fixedWidth = 256;
7777
78+ ElementBounds btnSnapshotArea = btnNoteArea.CopyOffsetedSibling(0, 64, 2, 5);
79+ btnNoteArea.fixedHeight = 24;
80+ btnNoteArea.fixedWidth = 20;
81+
7882
7983 this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
8084 .AddShadedDialogBG(bgBounds)
@@ -86,6 +90,7 @@ namespace Automap
8690 .AddDynamicText("Idle.", CairoFont.WhiteSmallText().WithFontSize(12), EnumTextOrientation.Left, txtStatusBounds, _statusTextKey)
8791 .AddTextInput(txtNoteArea, null, CairoFont.WhiteMediumText().WithFontSize(16), _noteTextKey)
8892 .AddButton("Note:", CreateNote, btnNoteArea, CairoFont.ButtonText())
93+ .AddButton("Snapshot!", TriggerSnapshot, btnSnapshotArea, CairoFont.ButtonText( ))
8994 .Compose();
9095
9196 //Controls for ALL Block & Entity Designators (Enable/Disable) <-- block edits while in 'Run' state
@@ -147,6 +152,15 @@ namespace Automap
147152 return true;//FINDOUT: What does this DO?
148153 }
149154
155+ private bool TriggerSnapshot( )
156+ {
157+ var snappyCmd = new CommandData(CommandType.Snapshot);
158+
159+ capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, snappyCmd);
160+
161+ return true;//FINDOUT: What does this DO?
162+ }
163+
150164 private void AutostartChange(bool startValue)
151165 {
152166 configuration.Autostart = startValue;
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -34,8 +34,8 @@ namespace Automap
3434 private IChunkRenderer ChunkRenderer { get; set; }
3535 private JsonGenerator JsonGenerator { get; set; }
3636
37- private const string _mapPath = @"Maps";
38- private const string _chunkPath = @"Chunks";
37+ internal const string _mapPath = @"Maps";
38+ internal const string _chunkPath = @"Chunks";
3939 private const string _domain = @"automap";
4040 private const string chunkFile_filter = @"*_*.png";
4141 private const string poiFileName = @"poi_binary";
@@ -79,7 +79,7 @@ namespace Automap
7979
8080 //Listen on bus for commands
8181 ClientAPI.Event.RegisterEventBusListener(CommandListener, 1.0, AutomapSystem.AutomapCommandEventKey);
82-
82+ //TODO: recreate as GUI button!
8383 ClientAPI.RegisterCommand("snapshot", "", "", (id, args) => CurrentState = CommandType.Snapshot);
8484
8585 if (configuration.Autostart)
@@ -122,7 +122,7 @@ namespace Automap
122122 IsBackground = true
123123 };
124124
125- snapshot = new Snapshotter(path, _chunkPath, chunkTopMetadata, chunkSize);
125+ snapshot = new Snapshotter(path, chunkTopMetadata, chunkSize,ClientAPI.World.Seed );
126126 snapshotThread = new Thread(Snap)
127127 {
128128 Name = "Snapshot",
--- a/Automap/Subsystems/Snapshot.cs
+++ b/Automap/Subsystems/Snapshot.cs
@@ -5,6 +5,7 @@ using System.IO;
55 using System.Linq;
66 using System.Threading;
77 using System.Threading.Tasks;
8+
89 using Hjg.Pngcs;
910 using Hjg.Pngcs.Chunks;
1011
@@ -12,19 +13,21 @@ namespace Automap
1213 {
1314 public class Snapshotter
1415 {
15- public string path;
16+ public readonly int chunkSize;
17+ public string fileName;
1618 public string chunkPath;
1719 public ColumnsMetadata cols;
18- public int chunkSize;
20+ //TODO: Refactor - so Edges are set at construction time, as ColumnsMetadata is async updating in real time!
1921 public int NorthEdge => cols.North_mostChunk;
2022 public int WestEdge => cols.West_mostChunk;
2123 public int Width => (cols.East_mostChunk - WestEdge + 1);
2224 public int Height => (cols.South_mostChunk - NorthEdge + 1);
2325
24- public Snapshotter(string path, string chunkPath, ColumnsMetadata cols, int chunkSize)
26+
27+ public Snapshotter(string path, ColumnsMetadata cols, int chunkSize, int worldSeed)
2528 {
26- this.path = Path.Combine(path, "snapshot.png");
27- this.chunkPath = Path.Combine(path, chunkPath);
29+ this.fileName = Path.Combine(path, $"snapshot_{worldSeed}_{DateTime.UtcNow:s}.png");
30+ this.chunkPath = Path.Combine(path, AutomapSystem._chunkPath);
2831 this.cols = cols;
2932 this.chunkSize = chunkSize;
3033 }
@@ -40,16 +43,19 @@ namespace Automap
4043 {
4144 var t = new Stopwatch();
4245 t.Start();
46+
4347 Console.WriteLine("snapshot started");
4448
4549 ImageInfo info = new ImageInfo(Width * chunkSize, Height * chunkSize, 8, false);
46- PngWriter snapWriter = FileHelper.CreatePngWriter(path, info, true);
50+ PngWriter snapWriter = FileHelper.CreatePngWriter(fileName, info, true);
4751 PngMetadata meta = snapWriter.GetMetadata( );
4852 meta.SetTimeNow( );
4953 var transparencyChunk = meta.CreateTRNSChunk( );
50- transparencyChunk.SetRGB(0, 0, 0);
51- //meta.SetText("Center_X", coord.X.ToString("D"));
52- //meta.SetText("Center_Y", coord.Y.ToString("D"));
54+ transparencyChunk.SetRGB(0, 0, 0);//CHECK: This is pure black.
55+ meta.SetText("Northmost", NorthEdge.ToString("D"));
56+ meta.SetText("Eastmost", WestEdge.ToString("D"));
57+ meta.SetText("Width", Width.ToString("D"));
58+ meta.SetText("Height", Height.ToString("D"));
5359
5460
5561