diff --git a/README.md b/README.md index 39401e8..a73e437 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -# TUSB ProgressViewer \ No newline at end of file +# TUSB ProgressViewer + +The Unusual SkyBlockという配布ワールドの攻略進捗等を確認できるツールです + +![](https://user-images.githubusercontent.com/25514849/78503623-cadb5300-77a2-11ea-9552-c48ea654ef3a.png) + +## 動作確認済みTUSBバージョン + +- v12.0.9 +- v12.0.8 + +## 機能 + +- どの島を攻略したかの可視化 +- エンドの未破壊スポナーの可視化 +- プレイヤーの各職業レベルの確認 + +## 使い方 + +右上のTUSBアイコンが付いたボタンからTUSBのワールドフォルダを選択すると、ワールドが読み込まれ情報が表示されます + +## ライセンス + +[MIT](LICENSE) diff --git a/TUSB_ProgressViewer/App.xaml b/TUSB_ProgressViewer/App.xaml index df83bbf..c4cc253 100644 --- a/TUSB_ProgressViewer/App.xaml +++ b/TUSB_ProgressViewer/App.xaml @@ -11,6 +11,7 @@ + diff --git a/TUSB_ProgressViewer/Controls/DataViewer.xaml b/TUSB_ProgressViewer/Controls/DataViewer.xaml new file mode 100644 index 0000000..c619aec --- /dev/null +++ b/TUSB_ProgressViewer/Controls/DataViewer.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TUSB_ProgressViewer/Controls/DataViewer.xaml.cs b/TUSB_ProgressViewer/Controls/DataViewer.xaml.cs new file mode 100644 index 0000000..4e30a71 --- /dev/null +++ b/TUSB_ProgressViewer/Controls/DataViewer.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace TUSB_ProgressViewer.Controls +{ + /// + /// DataViewer.xaml の相互作用ロジック + /// + public partial class DataViewer : UserControl + { + public DataViewer() + { + InitializeComponent(); + } + } +} diff --git a/TUSB_ProgressViewer/Controls/EndSpawnerProgress.xaml b/TUSB_ProgressViewer/Controls/EndSpawnerProgress.xaml index a04217d..2b054f6 100644 --- a/TUSB_ProgressViewer/Controls/EndSpawnerProgress.xaml +++ b/TUSB_ProgressViewer/Controls/EndSpawnerProgress.xaml @@ -3,14 +3,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:behavior="clr-namespace:TUSB_ProgressViewer.Behaviors" - xmlns:vm="clr-namespace:TUSB_ProgressViewer.ViewModels" - mc:Ignorable="d"> - - - + xmlns:model="clr-namespace:TUSB_ProgressViewer.Models"> @@ -29,7 +23,7 @@ Height="{Binding ActualHeight, ElementName=map}" HorizontalAlignment="Center" VerticalAlignment="Center" - ItemsSource="{Binding Spawners}"> + ItemsSource="{Binding Source={x:Static model:SpawnersData.Spawners}}"> diff --git a/TUSB_ProgressViewer/Controls/IslandCompleteProgress.xaml b/TUSB_ProgressViewer/Controls/IslandCompleteProgress.xaml index e5407ec..c32be8a 100644 --- a/TUSB_ProgressViewer/Controls/IslandCompleteProgress.xaml +++ b/TUSB_ProgressViewer/Controls/IslandCompleteProgress.xaml @@ -2,15 +2,7 @@ x:Class="TUSB_ProgressViewer.Controls.IslandCompleteProgress" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:TUSB_ProgressViewer.Controls" - xmlns:controls="clr-namespace:TUSB_ProgressViewer.Controls" - xmlns:vm="clr-namespace:TUSB_ProgressViewer.ViewModels" - mc:Ignorable="d"> - - - + xmlns:model="clr-namespace:TUSB_ProgressViewer.Models"> @@ -23,7 +15,7 @@ Height="{Binding ActualHeight, ElementName=map}" HorizontalAlignment="Center" VerticalAlignment="Center" - ItemsSource="{Binding Islands}"> + ItemsSource="{Binding Source={x:Static model:IslandsData.Islands}}"> @@ -32,7 +24,7 @@ - + diff --git a/TUSB_ProgressViewer/Controls/IslandPointer.xaml b/TUSB_ProgressViewer/Controls/IslandPointer.xaml index 5088f6d..654c140 100644 --- a/TUSB_ProgressViewer/Controls/IslandPointer.xaml +++ b/TUSB_ProgressViewer/Controls/IslandPointer.xaml @@ -58,29 +58,5 @@ - diff --git a/TUSB_ProgressViewer/Models/Coordinate.cs b/TUSB_ProgressViewer/Models/Coordinate.cs index 5398e9d..175cddc 100644 --- a/TUSB_ProgressViewer/Models/Coordinate.cs +++ b/TUSB_ProgressViewer/Models/Coordinate.cs @@ -11,8 +11,19 @@ namespace TUSB_ProgressViewer.Models /// public class Coordinate { + /// + /// X座標 + /// public int X { get; } + + /// + /// Y座標 + /// public int Y { get; } + + /// + /// Z座標 + /// public int Z { get; } public Coordinate(int x, int y, int z) diff --git a/TUSB_ProgressViewer/Models/Island.cs b/TUSB_ProgressViewer/Models/Island.cs index c69c182..c5863a1 100644 --- a/TUSB_ProgressViewer/Models/Island.cs +++ b/TUSB_ProgressViewer/Models/Island.cs @@ -1,5 +1,6 @@ using OrangeNBT.World.Anvil; using Prism.Mvvm; +using Reactive.Bindings; using System; using System.Collections.Generic; using System.Linq; @@ -14,6 +15,9 @@ namespace TUSB_ProgressViewer.Models /// public class Island: BindableBase { + /// + /// 島タイプ + /// public IslandType IslandType { get; } /// @@ -24,12 +28,7 @@ public class Island: BindableBase /// /// 選択フラグ /// - public bool IsSelected - { - get => _isSelected; - set => SetProperty(ref _isSelected, value); - } - private bool _isSelected; + public bool IsSelected { get; set; } public Island(IslandType type, AnvilWorld world) { diff --git a/TUSB_ProgressViewer/Models/IslandsData.cs b/TUSB_ProgressViewer/Models/IslandsData.cs new file mode 100644 index 0000000..0fa03b8 --- /dev/null +++ b/TUSB_ProgressViewer/Models/IslandsData.cs @@ -0,0 +1,119 @@ +using Reactive.Bindings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using TUSB_ProgressViewer.Controls; +using TUSB_ProgressViewer.Util; + +namespace TUSB_ProgressViewer.Models +{ + public static class IslandsData + { + /// + /// 島リスト + /// + public static ReactiveCollection Islands { get; } = new ReactiveCollection(); + + /// + /// 島攻略数カウント + /// + public static ReactiveProperty CompletionCount { get; } = new ReactiveProperty(); + + /// + /// 島攻略率 + /// + public static ReactiveProperty CompletionRate { get; } = new ReactiveProperty(); + + /// + /// 島の数 + /// + private const int islandCount = 50; + + /// + /// 島読み込み + /// + /// + public static void Load(ref int count) + { + try + { + Islands.ClearOnScheduler(); + foreach (IslandType type in Enum.GetValues(typeof(IslandType))) + { + var island = new Island(type, World.WorldData); + + // 実際の座標と画像のピクセル数から画像上の島(エンドポータルフレーム)の位置を計算 + // 画像のサイズが変わると壊れます() + var X = (island.IslandType.GetCoordinate().X + 221) / 512.0; + var Z = (island.IslandType.GetCoordinate().Z + 237) / 512.0; + + // 別ディメンションは特殊な位置なので個別指定 + switch (island.IslandType) + { + case IslandType.TheUnderworld: + X = 47 / 256.0; + Z = 234 / 256.0; + break; + case IslandType.TheNether: + X = 128 / 256.0; + Z = 234 / 256.0; + break; + case IslandType.GulliversLand: + X = 183 / 256.0; + Z = 234 / 256.0; + break; + case IslandType.Cloudia: + X = 43 / 256.0; + Z = 246 / 256.0; + break; + case IslandType.TableMountain: + X = 82 / 256.0; + Z = 246 / 256.0; + break; + case IslandType.TocultColde: + X = 157 / 256.0; + Z = 246 / 256.0; + break; + case IslandType.TheEnd: + X = 218 / 256.0; + Z = 246 / 256.0; + break; + } + + Application.Current.Dispatcher.Invoke(() => + { + Islands.Add(new IslandPointer() + { + IslandName = island.IslandType.GetName(), + Center = new Point(X, Z), + IsComplete = island.IsComplete + }); + + CompletionCount.Value = Islands.Where(x => x.IsComplete).Count(); + CompletionRate.Value = (CompletionCount.Value / (double)islandCount) * 100; + }); + + World.LoadingProgress.Value = (++count / 297.0) * 100; + } + } + catch + { + Reset(); + throw; + } + } + + /// + /// データをリセット + /// + public static void Reset() + { + Islands.ClearOnScheduler(); + CompletionCount.Value = 0; + CompletionRate.Value = 0; + } + } +} diff --git a/TUSB_ProgressViewer/Models/Player.cs b/TUSB_ProgressViewer/Models/Player.cs new file mode 100644 index 0000000..1f9bece --- /dev/null +++ b/TUSB_ProgressViewer/Models/Player.cs @@ -0,0 +1,58 @@ +using Prism.Mvvm; +using Reactive.Bindings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TUSB_ProgressViewer.Models +{ + public class Player : BindableBase + { + /// + /// ユーザー名 + /// + public string Name { get; } + + /// + /// 剣士レベル + /// + public int KnightLevel { get; set; } + + /// + /// 忍者レベル + /// + public int NinjaLevel { get; set; } + + /// + /// 狩人レベル + /// + public int ArcherLevel { get; set; } + + /// + /// 白魔道士レベル + /// + public int WhiteMageLevel { get; set; } + + /// + /// 黒魔道士レベル + /// + public int BlackMageLevel { get; set; } + + /// + /// 召喚士レベル + /// + public int SummonerLevel { get; set; } + + /// + /// 選択中フラグ + /// + public bool IsSelected { get; set; } + + public Player(string name) + { + Name = name; + } + } +} diff --git a/TUSB_ProgressViewer/Models/ScoreData.cs b/TUSB_ProgressViewer/Models/ScoreData.cs new file mode 100644 index 0000000..d5f7862 --- /dev/null +++ b/TUSB_ProgressViewer/Models/ScoreData.cs @@ -0,0 +1,81 @@ +using OrangeNBT.NBT; +using OrangeNBT.NBT.IO; +using Reactive.Bindings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace TUSB_ProgressViewer.Models +{ + public static class ScoreData + { + /// + /// プレイヤーデータのリスト + /// + public static ReactiveCollection Players { get; } = new ReactiveCollection(); + + /// + /// プレイヤーの数 + /// + public static ReactiveProperty PlayerCount { get; } = new ReactiveProperty(); + + /// + /// スコアデータ読み込み + /// + public static void Load() + { + var data = NBTFile.FromFile($@"{World.Path.Value}\data\scoreboard.dat")["data"] as TagCompound; + var PlayerScores = data["PlayerScores"] as TagList; + + // 複数のスコアオブジェクトを持っているエンティティ名を抽出 + // #100を除いてユーザー名だと思われる + // ソースは俺 + var users = PlayerScores.Value + .Select(x => ((x as TagCompound)["Name"] as TagString).Value) + .GroupBy(x => x) + .Where(x => x.Count() > 1) + .Select(x => x.Key) + .Where(x => x != "#100") + .ToList(); + + var list = PlayerScores.Value + .Where(x => users.Contains(((x as TagCompound)["Name"] as TagString).Value)) + .GroupBy(x => ((x as TagCompound)["Name"] as TagString).Value) + .ToList(); + + foreach (var user in list) + { + Application.Current.Dispatcher.Invoke(() => + { + var userData = new Player(user.Key); + Players.Add(userData); + PlayerCount.Value++; + + foreach (var tag in user) + { + var name = ((tag as TagCompound)["Objective"] as TagString).Value; + var value = ((tag as TagCompound)["Score"] as TagInt).Value; + if (name == "KnightLevel") userData.KnightLevel = value; + if (name == "NinjaLevel") userData.NinjaLevel = value; + if (name == "ArcherLevel") userData.ArcherLevel = value; + if (name == "WhiteMageLevel") userData.WhiteMageLevel = value; + if (name == "BlackMageLevel") userData.BlackMageLevel = value; + if (name == "SummonerLevel") userData.SummonerLevel = value; + } + }); + } + } + + /// + /// データをリセット + /// + public static void Reset() + { + Players.ClearOnScheduler(); + PlayerCount.Value = 0; + } + } +} diff --git a/TUSB_ProgressViewer/Models/Spawner.cs b/TUSB_ProgressViewer/Models/Spawner.cs index a4b55c7..8da285c 100644 --- a/TUSB_ProgressViewer/Models/Spawner.cs +++ b/TUSB_ProgressViewer/Models/Spawner.cs @@ -10,7 +10,14 @@ namespace TUSB_ProgressViewer.Models { public class Spawner { + /// + /// 座標 + /// public Coordinate Coordinate { get; set; } + + /// + /// 破壊フラグ + /// public bool IsBroken { get; set; } public Spawner(Coordinate coordinate, AnvilWorld world) diff --git a/TUSB_ProgressViewer/Models/SpawnersData.cs b/TUSB_ProgressViewer/Models/SpawnersData.cs new file mode 100644 index 0000000..0484bf0 --- /dev/null +++ b/TUSB_ProgressViewer/Models/SpawnersData.cs @@ -0,0 +1,333 @@ +using Reactive.Bindings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using TUSB_ProgressViewer.Controls; + +namespace TUSB_ProgressViewer.Models +{ + public static class SpawnersData + { + /// + /// スポナーリスト + /// + public static ReactiveCollection Spawners { get; } = new ReactiveCollection(); + + /// + /// スポナー破壊数カウント + /// + public static ReactiveProperty BrokenCount { get; } = new ReactiveProperty(); + + /// + /// スポナー破壊率 + /// + public static ReactiveProperty BrokenRate { get; } = new ReactiveProperty(); + + /// + /// スポナー座標リスト + /// + private static readonly Coordinate[] _spawnerCoordinates = new Coordinate[247] + { + new Coordinate(74, 49, -10), + new Coordinate(74, 49, 10), + new Coordinate(64, 57, 5), + new Coordinate(55, 62, 5), + new Coordinate(41, 56, 5), + new Coordinate(31, 58, 5), + new Coordinate(18, 61, 5), + new Coordinate(9, 58, 5), + new Coordinate(-6, 51, -7), + new Coordinate(-7, 58, 5), + new Coordinate(-8, 67, 19), + new Coordinate(-27, 65, 18), + new Coordinate(-29, 51, 6), + new Coordinate(-31, 51, -7), + new Coordinate(-34, 62, 5), + new Coordinate(-35, 42, 18), + new Coordinate(-39, 62, 5), + new Coordinate(-52, 58, 10), + new Coordinate(-55, 45, 18), + new Coordinate(-59, 58, 6), + new Coordinate(-61, 64, 14), + new Coordinate(-63, 49, 18), + new Coordinate(-70, 61, 2), + new Coordinate(-71, 61, 18), + new Coordinate(-78, 61, 18), + new Coordinate(-95, 66, 4), + new Coordinate(-95, 65, 21), + new Coordinate(-105, 68, 13), + new Coordinate(-107, 61, -4), + new Coordinate(-107, 61, 31), + new Coordinate(-118, 63, 3), + new Coordinate(-118, 63, 23), + new Coordinate(-128, 63, 5), + new Coordinate(-128, 63, 21), + new Coordinate(-139, 63, 5), + new Coordinate(-139, 63, 21), + new Coordinate(-149, 63, 1), + new Coordinate(-149, 63, 25), + new Coordinate(-159, 63, 11), + new Coordinate(-159, 63, 15), + new Coordinate(-165, 63, -7), + new Coordinate(-165, 63, 33), + new Coordinate(-168, 63, 13), + new Coordinate(-183, 63, 0), + new Coordinate(-197, 68, 14), + new Coordinate(-198, 67, 28), + new Coordinate(-207, 58, 1), + new Coordinate(-207, 70, 13), + new Coordinate(-212, 58, 25), + new Coordinate(-222, 75, -4), + new Coordinate(-228, 66, 8), + new Coordinate(-236, 66, 2), + new Coordinate(-236, 64, 10), + new Coordinate(-236, 63, 12), + new Coordinate(-236, 64, 14), + new Coordinate(-236, 66, 22), + new Coordinate(-244, 66, 17), + new Coordinate(-252, 63, 29), + new Coordinate(-261, 63, 0), + new Coordinate(-265, 65, 11), + new Coordinate(-278, 63, 28), + new Coordinate(-279, 61, 9), + new Coordinate(-291, 63, -1), + new Coordinate(-296, 64, 14), + new Coordinate(-301, 65, 20), + new Coordinate(-304, 61, -5), + new Coordinate(-306, 63, 28), + new Coordinate(-313, 63, 11), + new Coordinate(-319, 62, -4), + new Coordinate(-326, 61, 15), + new Coordinate(-328, 60, 2), + new Coordinate(-333, 60, 28), + new Coordinate(-344, 59, 2), + new Coordinate(-353, 60, 24), + new Coordinate(-358, 60, 11), + new Coordinate(-367, 67, 12), + new Coordinate(-378, 64, 0), + new Coordinate(-382, 64, 19), + new Coordinate(-396, 66, 5), + new Coordinate(-395, 65, -4), + new Coordinate(-401, 65, 31), + new Coordinate(-407, 66, 24), + new Coordinate(-413, 67, 31), + new Coordinate(-414, 67, -3), + new Coordinate(-415, 68, 14), + new Coordinate(-428, 64, -12), + new Coordinate(-432, 64, 29), + new Coordinate(-434, 64, 2), + new Coordinate(-435, 64, 1), + new Coordinate(-443, 63, 18), + new Coordinate(-451, 63, 2), + new Coordinate(-458, 63, 25), + new Coordinate(-463, 61, 14), + new Coordinate(-469, 63, 0), + new Coordinate(-478, 63, 18), + new Coordinate(-496, 64, -12), + new Coordinate(-500, 63, 39), + new Coordinate(-518, 63, -15), + new Coordinate(-528, 63, 2), + new Coordinate(-525, 63, 43), + new Coordinate(-532, 63, 22), + new Coordinate(-544, 66, -9), + new Coordinate(-546, 66, -11), + new Coordinate(-546, 78, 32), + new Coordinate(-548, 78, 34), + new Coordinate(-562, 63, -10), + new Coordinate(-563, 76, 14), + new Coordinate(-565, 76, 16), + new Coordinate(-566, 63, -15), + new Coordinate(-569, 68, -8), + new Coordinate(-570, 67, 31), + new Coordinate(-571, 63, 37), + new Coordinate(-577, 63, 32), + new Coordinate(-579, 63, 4), + new Coordinate(-582, 63, -13), + new Coordinate(-583, 63, 16), + new Coordinate(-587, 63, 33), + new Coordinate(-600, 66, 9), + new Coordinate(-600, 66, 15), + new Coordinate(-610, 66, -6), + new Coordinate(-610, 66, 30), + new Coordinate(-615, 66, 5), + new Coordinate(-615, 66, 19), + new Coordinate(-618, 66, 43), + new Coordinate(-619, 66, -19), + new Coordinate(-622, 66, 12), + new Coordinate(-624, 66, 10), + new Coordinate(-624, 66, 12), + new Coordinate(-624, 66, 14), + new Coordinate(-625, 66, 2), + new Coordinate(-625, 66, 23), + new Coordinate(-626, 66, 12), + new Coordinate(-627, 66, -11), + new Coordinate(-627, 66, 35), + new Coordinate(-644, 66, 3), + new Coordinate(-644, 66, 21), + new Coordinate(-647, 66, 12), + new Coordinate(-790, 66, -4), + new Coordinate(-790, 66, 28), + new Coordinate(-802, 66, 12), + new Coordinate(-829, 76, -1), + new Coordinate(-829, 76, 26), + new Coordinate(-830, 76, 12), + new Coordinate(-881, 96, 1), + new Coordinate(-881, 96, 12), + new Coordinate(-881, 96, 23), + new Coordinate(-907, 106, 0), + new Coordinate(-907, 106, 12), + new Coordinate(-907, 106, 26), + new Coordinate(-933, 116, -5), + new Coordinate(-933, 116, 3), + new Coordinate(-933, 116, 12), + new Coordinate(-933, 116, 21), + new Coordinate(-933, 116, 29), + new Coordinate(-960, 106, 1), + new Coordinate(-960, 106, 8), + new Coordinate(-960, 106, 16), + new Coordinate(-960, 106, 23), + new Coordinate(-984, 96, 4), + new Coordinate(-984, 96, 21), + new Coordinate(-985, 96, 12), + new Coordinate(-1011, 86, -2), + new Coordinate(-1011, 86, 26), + new Coordinate(-1013, 86, 12), + new Coordinate(-1037, 76, 3), + new Coordinate(-1037, 76, 21), + new Coordinate(-1039, 76, 12), + new Coordinate(-1069, 66, 12), + new Coordinate(-1076, 66, -4), + new Coordinate(-1076, 66, 28), + new Coordinate(-1083, 66, 12), + new Coordinate(-1090, 66, 5), + new Coordinate(-1090, 66, 19), + new Coordinate(-1109, 74, -3), + new Coordinate(-1109, 74, 27), + new Coordinate(-1115, 66, -7), + new Coordinate(-1115, 66, 31), + new Coordinate(-1118, 67, 12), + new Coordinate(-1130, 66, 0), + new Coordinate(-1130, 66, 8), + new Coordinate(-1130, 66, 16), + new Coordinate(-1130, 66, 24), + new Coordinate(-1143, 66, 12), + new Coordinate(-1145, 66, -3), + new Coordinate(-1145, 66, 27), + new Coordinate(-1153, 73, 5), + new Coordinate(-1153, 73, 19), + new Coordinate(-1154, 73, -8), + new Coordinate(-1154, 73, 32), + new Coordinate(-1155, 149, -20), + new Coordinate(-1155, 149, 44), + new Coordinate(-1252, 80, -8), + new Coordinate(-1256, 80, -10), + new Coordinate(-1260, 89, 4), + new Coordinate(-1298, 95, 56), + new Coordinate(-1302, 95, 58), + new Coordinate(-1307, 99, 41), + new Coordinate(-1364, 114, -3), + new Coordinate(-1365, 114, 20), + new Coordinate(-1376, 163, 5), + new Coordinate(-1376, 114, 9), + new Coordinate(-1376, 163, 13), + new Coordinate(-1377, 127, -5), + new Coordinate(-1377, 114, 1), + new Coordinate(-1377, 156, 9), + new Coordinate(-1377, 114, 17), + new Coordinate(-1377, 127, 23), + new Coordinate(-1387, 163, 5), + new Coordinate(-1387, 156, 9), + new Coordinate(-1387, 163, 13), + new Coordinate(-1388, 114, -2), + new Coordinate(-1388, 206, 9), + new Coordinate(-1388, 114, 21), + new Coordinate(-1391, 127, -8), + new Coordinate(-1391, 127, 26), + new Coordinate(-1393, 156, 4), + new Coordinate(-1393, 156, 14), + new Coordinate(-1399, 163, 5), + new Coordinate(-1399, 163, 13), + new Coordinate(-1411, 202, 3), + new Coordinate(-1412, 198, 10), + new Coordinate(-1419, 151, -9), + new Coordinate(-1419, 192, -9), + new Coordinate(-1419, 198, -9), + new Coordinate(-1419, 198, 27), + new Coordinate(-1425, 157, 22), + new Coordinate(-1427, 114, -1), + new Coordinate(-1427, 114, 19), + new Coordinate(-1428, 157, 33), + new Coordinate(-1432, 145, -14), + new Coordinate(-1433, 187, -11), + new Coordinate(-1437, 184, -15), + new Coordinate(-1440, 142, -17), + new Coordinate(-1442, 159, 33), + new Coordinate(-1447, 139, -9), + new Coordinate(-1448, 120, 28), + new Coordinate(-1453, 131, 10), + new Coordinate(-1455, 179, -15), + new Coordinate(-1456, 178, -9), + new Coordinate(-1456, 114, 2), + new Coordinate(-1456, 114, 16), + new Coordinate(-1456, 164, 27), + new Coordinate(-1457, 169, 12), + new Coordinate(-1459, 127, 12), + new Coordinate(-1460, 176, -5), + new Coordinate(-1463, 131, 4), + new Coordinate(-1463, 173, 4) + }; + + /// + /// スポナー読み込み + /// + /// + public static void Load(ref int count) + { + try + { + Spawners.ClearOnScheduler(); + foreach (Coordinate coor in _spawnerCoordinates) + { + // 実際の座標と画像のピクセル数から画像上のスポナー位置を計算 + // 画像のサイズが変わると壊れます() + var X = (coor.X + 1502.5) / 1664; + var Z = (coor.Z + 114.5) / 247; + + var isBroken = new Spawner(coor, World.WorldData).IsBroken; + + Application.Current.Dispatcher.Invoke(() => + { + Spawners.Add(new SpawnerPointer() + { + Center = new Point(X, Z), + IsBroken = isBroken + }); + + BrokenCount.Value = Spawners.Where(x => x.IsBroken).Count(); + BrokenRate.Value = (BrokenCount.Value / 247.0) * 100; + }); + + World.LoadingProgress.Value = (++count / 297.0) * 100; + } + } + catch + { + Reset(); + throw; + } + } + + /// + /// データをリセット + /// + public static void Reset() + { + Spawners.ClearOnScheduler(); + BrokenCount.Value = 0; + BrokenRate.Value = 0; + } + } +} diff --git a/TUSB_ProgressViewer/Models/World.cs b/TUSB_ProgressViewer/Models/World.cs index aba17cc..80aa42b 100644 --- a/TUSB_ProgressViewer/Models/World.cs +++ b/TUSB_ProgressViewer/Models/World.cs @@ -1,13 +1,14 @@ -using OrangeNBT.World.Anvil; +using OrangeNBT.NBT; +using OrangeNBT.NBT.IO; +using OrangeNBT.World.Anvil; using Reactive.Bindings; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; -using TUSB_ProgressViewer.Controls; -using TUSB_ProgressViewer.Util; namespace TUSB_ProgressViewer.Models { @@ -39,307 +40,27 @@ public static class World /// /// 読込中フラグ /// - public static ReactiveProperty IsBusy { get; } = new ReactiveProperty(); + public static ReactiveProperty IsLoading { get; } = new ReactiveProperty(); /// /// エラーフラグ /// public static ReactiveProperty IsError { get; } = new ReactiveProperty(); - /// - /// 島リスト - /// - public static ReactiveCollection Islands { get; } = new ReactiveCollection(); - - /// - /// 島攻略数カウント - /// - public static ReactiveProperty CompletionCount { get; } = new ReactiveProperty(); - - /// - /// 島攻略率 - /// - public static ReactiveProperty CompletionRate { get; } = new ReactiveProperty(); - - /// - /// スポナーリスト - /// - public static ReactiveCollection Spawners { get; } = new ReactiveCollection(); - - /// - /// スポナー破壊数カウント - /// - public static ReactiveProperty BrokenCount { get; } = new ReactiveProperty(); - - /// - /// スポナー破壊率 - /// - public static ReactiveProperty BrokenRate { get; } = new ReactiveProperty(); - - /// - /// スポナー座標リスト - /// - private static Coordinate[] _spawnerCoordinates = new Coordinate[247] - { - new Coordinate(74, 49, -10), - new Coordinate(74, 49, 10), - new Coordinate(64, 57, 5), - new Coordinate(55, 62, 5), - new Coordinate(41, 56, 5), - new Coordinate(31, 58, 5), - new Coordinate(18, 61, 5), - new Coordinate(9, 58, 5), - new Coordinate(-6, 51, -7), - new Coordinate(-7, 58, 5), - new Coordinate(-8, 67, 19), - new Coordinate(-27, 65, 18), - new Coordinate(-29, 51, 6), - new Coordinate(-31, 51, -7), - new Coordinate(-34, 62, 5), - new Coordinate(-35, 42, 18), - new Coordinate(-39, 62, 5), - new Coordinate(-52, 58, 10), - new Coordinate(-55, 45, 18), - new Coordinate(-59, 58, 6), - new Coordinate(-61, 64, 14), - new Coordinate(-63, 49, 18), - new Coordinate(-70, 61, 2), - new Coordinate(-71, 61, 18), - new Coordinate(-78, 61, 18), - new Coordinate(-95, 66, 4), - new Coordinate(-95, 65, 21), - new Coordinate(-105, 68, 13), - new Coordinate(-107, 61, -4), - new Coordinate(-107, 61, 31), - new Coordinate(-118, 63, 3), - new Coordinate(-118, 63, 23), - new Coordinate(-128, 63, 5), - new Coordinate(-128, 63, 21), - new Coordinate(-139, 63, 5), - new Coordinate(-139, 63, 21), - new Coordinate(-149, 63, 1), - new Coordinate(-149, 63, 25), - new Coordinate(-159, 63, 11), - new Coordinate(-159, 63, 15), - new Coordinate(-165, 63, -7), - new Coordinate(-165, 63, 33), - new Coordinate(-168, 63, 13), - new Coordinate(-183, 63, 0), - new Coordinate(-197, 68, 14), - new Coordinate(-198, 67, 28), - new Coordinate(-207, 58, 1), - new Coordinate(-207, 70, 13), - new Coordinate(-212, 58, 25), - new Coordinate(-222, 75, -4), - new Coordinate(-228, 66, 8), - new Coordinate(-236, 66, 2), - new Coordinate(-236, 64, 10), - new Coordinate(-236, 63, 12), - new Coordinate(-236, 64, 14), - new Coordinate(-236, 66, 22), - new Coordinate(-244, 66, 17), - new Coordinate(-252, 63, 29), - new Coordinate(-261, 63, 0), - new Coordinate(-265, 65, 11), - new Coordinate(-278, 63, 28), - new Coordinate(-279, 61, 9), - new Coordinate(-291, 63, -1), - new Coordinate(-296, 64, 14), - new Coordinate(-301, 65, 20), - new Coordinate(-304, 61, -5), - new Coordinate(-306, 63, 28), - new Coordinate(-313, 63, 11), - new Coordinate(-319, 62, -4), - new Coordinate(-326, 61, 15), - new Coordinate(-328, 60, 2), - new Coordinate(-333, 60, 28), - new Coordinate(-344, 59, 2), - new Coordinate(-353, 60, 24), - new Coordinate(-358, 60, 11), - new Coordinate(-367, 67, 12), - new Coordinate(-378, 64, 0), - new Coordinate(-382, 64, 19), - new Coordinate(-396, 66, 5), - new Coordinate(-395, 65, -4), - new Coordinate(-401, 65, 31), - new Coordinate(-407, 66, 24), - new Coordinate(-413, 67, 31), - new Coordinate(-414, 67, -3), - new Coordinate(-415, 68, 14), - new Coordinate(-428, 64, -12), - new Coordinate(-432, 64, 29), - new Coordinate(-434, 64, 2), - new Coordinate(-435, 64, 1), - new Coordinate(-443, 63, 18), - new Coordinate(-451, 63, 2), - new Coordinate(-458, 63, 25), - new Coordinate(-463, 61, 14), - new Coordinate(-469, 63, 0), - new Coordinate(-478, 63, 18), - new Coordinate(-496, 64, -12), - new Coordinate(-500, 63, 39), - new Coordinate(-518, 63, -15), - new Coordinate(-528, 63, 2), - new Coordinate(-525, 63, 43), - new Coordinate(-532, 63, 22), - new Coordinate(-544, 66, -9), - new Coordinate(-546, 66, -11), - new Coordinate(-546, 78, 32), - new Coordinate(-548, 78, 34), - new Coordinate(-562, 63, -10), - new Coordinate(-563, 76, 14), - new Coordinate(-565, 76, 16), - new Coordinate(-566, 63, -15), - new Coordinate(-569, 68, -8), - new Coordinate(-570, 67, 31), - new Coordinate(-571, 63, 37), - new Coordinate(-577, 63, 32), - new Coordinate(-579, 63, 4), - new Coordinate(-582, 63, -13), - new Coordinate(-583, 63, 16), - new Coordinate(-587, 63, 33), - new Coordinate(-600, 66, 9), - new Coordinate(-600, 66, 15), - new Coordinate(-610, 66, -6), - new Coordinate(-610, 66, 30), - new Coordinate(-615, 66, 5), - new Coordinate(-615, 66, 19), - new Coordinate(-618, 66, 43), - new Coordinate(-619, 66, -19), - new Coordinate(-622, 66, 12), - new Coordinate(-624, 66, 10), - new Coordinate(-624, 66, 12), - new Coordinate(-624, 66, 14), - new Coordinate(-625, 66, 2), - new Coordinate(-625, 66, 23), - new Coordinate(-626, 66, 12), - new Coordinate(-627, 66, -11), - new Coordinate(-627, 66, 35), - new Coordinate(-644, 66, 3), - new Coordinate(-644, 66, 21), - new Coordinate(-647, 66, 12), - new Coordinate(-790, 66, -4), - new Coordinate(-790, 66, 28), - new Coordinate(-802, 66, 12), - new Coordinate(-829, 76, -1), - new Coordinate(-829, 76, 26), - new Coordinate(-830, 76, 12), - new Coordinate(-881, 96, 1), - new Coordinate(-881, 96, 12), - new Coordinate(-881, 96, 23), - new Coordinate(-907, 106, 0), - new Coordinate(-907, 106, 12), - new Coordinate(-907, 106, 26), - new Coordinate(-933, 116, -5), - new Coordinate(-933, 116, 3), - new Coordinate(-933, 116, 12), - new Coordinate(-933, 116, 21), - new Coordinate(-933, 116, 29), - new Coordinate(-960, 106, 1), - new Coordinate(-960, 106, 8), - new Coordinate(-960, 106, 16), - new Coordinate(-960, 106, 23), - new Coordinate(-984, 96, 4), - new Coordinate(-984, 96, 21), - new Coordinate(-985, 96, 12), - new Coordinate(-1011, 86, -2), - new Coordinate(-1011, 86, 26), - new Coordinate(-1013, 86, 12), - new Coordinate(-1037, 76, 3), - new Coordinate(-1037, 76, 21), - new Coordinate(-1039, 76, 12), - new Coordinate(-1069, 66, 12), - new Coordinate(-1076, 66, -4), - new Coordinate(-1076, 66, 28), - new Coordinate(-1083, 66, 12), - new Coordinate(-1090, 66, 5), - new Coordinate(-1090, 66, 19), - new Coordinate(-1109, 74, -3), - new Coordinate(-1109, 74, 27), - new Coordinate(-1115, 66, -7), - new Coordinate(-1115, 66, 31), - new Coordinate(-1118, 67, 12), - new Coordinate(-1130, 66, 0), - new Coordinate(-1130, 66, 8), - new Coordinate(-1130, 66, 16), - new Coordinate(-1130, 66, 24), - new Coordinate(-1143, 66, 12), - new Coordinate(-1145, 66, -3), - new Coordinate(-1145, 66, 27), - new Coordinate(-1153, 73, 5), - new Coordinate(-1153, 73, 19), - new Coordinate(-1154, 73, -8), - new Coordinate(-1154, 73, 32), - new Coordinate(-1155, 149, -20), - new Coordinate(-1155, 149, 44), - new Coordinate(-1252, 80, -8), - new Coordinate(-1256, 80, -10), - new Coordinate(-1260, 89, 4), - new Coordinate(-1298, 95, 56), - new Coordinate(-1302, 95, 58), - new Coordinate(-1307, 99, 41), - new Coordinate(-1364, 114, -3), - new Coordinate(-1365, 114, 20), - new Coordinate(-1376, 163, 5), - new Coordinate(-1376, 114, 9), - new Coordinate(-1376, 163, 13), - new Coordinate(-1377, 127, -5), - new Coordinate(-1377, 114, 1), - new Coordinate(-1377, 156, 9), - new Coordinate(-1377, 114, 17), - new Coordinate(-1377, 127, 23), - new Coordinate(-1387, 163, 5), - new Coordinate(-1387, 156, 9), - new Coordinate(-1387, 163, 13), - new Coordinate(-1388, 114, -2), - new Coordinate(-1388, 206, 9), - new Coordinate(-1388, 114, 21), - new Coordinate(-1391, 127, -8), - new Coordinate(-1391, 127, 26), - new Coordinate(-1393, 156, 4), - new Coordinate(-1393, 156, 14), - new Coordinate(-1399, 163, 5), - new Coordinate(-1399, 163, 13), - new Coordinate(-1411, 202, 3), - new Coordinate(-1412, 198, 10), - new Coordinate(-1419, 151, -9), - new Coordinate(-1419, 192, -9), - new Coordinate(-1419, 198, -9), - new Coordinate(-1419, 198, 27), - new Coordinate(-1425, 157, 22), - new Coordinate(-1427, 114, -1), - new Coordinate(-1427, 114, 19), - new Coordinate(-1428, 157, 33), - new Coordinate(-1432, 145, -14), - new Coordinate(-1433, 187, -11), - new Coordinate(-1437, 184, -15), - new Coordinate(-1440, 142, -17), - new Coordinate(-1442, 159, 33), - new Coordinate(-1447, 139, -9), - new Coordinate(-1448, 120, 28), - new Coordinate(-1453, 131, 10), - new Coordinate(-1455, 179, -15), - new Coordinate(-1456, 178, -9), - new Coordinate(-1456, 114, 2), - new Coordinate(-1456, 114, 16), - new Coordinate(-1456, 164, 27), - new Coordinate(-1457, 169, 12), - new Coordinate(-1459, 127, 12), - new Coordinate(-1460, 176, -5), - new Coordinate(-1463, 131, 4), - new Coordinate(-1463, 173, 4) - }; - /// /// ワールド読み込み /// /// ワールドパス public static void Load(string path) { - if (IsBusy.Value) return; + if (IsLoading.Value) return; + + IslandsData.Reset(); + SpawnersData.Reset(); + ScoreData.Reset(); FolderName.Value = System.IO.Path.GetFileName(path); - IsBusy.Value = true; + IsLoading.Value = true; LoadingProgress.Value = 0; Path.Value = path; @@ -351,96 +72,31 @@ public static void Load(string path) { WorldData = AnvilWorld.Load(path); - // 島 - Islands.ClearOnScheduler(); - foreach (IslandType type in Enum.GetValues(typeof(IslandType))) - { - var island = new Island(type, WorldData); - var x = (island.IslandType.GetCoordinate().X + 221) / 512.0; - var z = (island.IslandType.GetCoordinate().Z + 237) / 512.0; - switch (island.IslandType) - { - case IslandType.TheUnderworld: - x = 47 / 256.0; - z = 234 / 256.0; - break; - case IslandType.TheNether: - x = 128 / 256.0; - z = 234 / 256.0; - break; - case IslandType.GulliversLand: - x = 183 / 256.0; - z = 234 / 256.0; - break; - case IslandType.Cloudia: - x = 43 / 256.0; - z = 246 / 256.0; - break; - case IslandType.TableMountain: - x = 82 / 256.0; - z = 246 / 256.0; - break; - case IslandType.TocultColde: - x = 157 / 256.0; - z = 246 / 256.0; - break; - case IslandType.TheEnd: - x = 218 / 256.0; - z = 246 / 256.0; - break; - } - Application.Current.Dispatcher.Invoke(() => Islands.Add(new IslandPointer() - { - IslandName = island.IslandType.GetName(), - Center = new Point(x, z), - IsComplete = island.IsComplete - })); - - LoadingProgress.Value = (++count / 297.0) * 100; - } - Application.Current.Dispatcher.Invoke(() => - { - CompletionCount.Value = Islands.Where(x => x.IsComplete).Count(); - CompletionRate.Value = (CompletionCount.Value / 50.0) * 100; - }); + IslandsData.Load(ref count); + SpawnersData.Load(ref count); + ScoreData.Load(); - // エンドスポナー - Spawners.ClearOnScheduler(); - foreach (Coordinate coor in _spawnerCoordinates) - { - var x = (coor.X + 1502.5) / 1664; - var z = (coor.Z + 114.5) / 247; - var isBroken = new Spawner(coor, WorldData).IsBroken; - Application.Current.Dispatcher.Invoke(() => Spawners.Add(new SpawnerPointer() - { - Center = new Point(x, z), - IsBroken = isBroken - })); - - LoadingProgress.Value = (++count / 297.0) * 100; - } - Application.Current.Dispatcher.Invoke(() => - { - BrokenCount.Value = Spawners.Where(x => x.IsBroken).Count(); - BrokenRate.Value = (BrokenCount.Value / 247.0) * 100; - }); + // 100%を見せたいからという理由だけで0.3秒遅延させる + System.Threading.Thread.Sleep(300); } catch { Path.Value = null; - Islands.ClearOnScheduler(); - Spawners.ClearOnScheduler(); - CompletionCount.Value = 0; - CompletionRate.Value = 0; - BrokenCount.Value = 0; - BrokenRate.Value = 0; IsError.Value = true; - return; } - finally { IsBusy.Value = false; } + finally + { + IsLoading.Value = false; + } }); } - public static void Reload() => Load(Path.Value); + /// + /// ワールドを再読み込み + /// + public static void Reload() + { + Load(Path.Value); + } } } diff --git a/TUSB_ProgressViewer/Properties/AssemblyInfo.cs b/TUSB_ProgressViewer/Properties/AssemblyInfo.cs index d9612f0..025289b 100644 --- a/TUSB_ProgressViewer/Properties/AssemblyInfo.cs +++ b/TUSB_ProgressViewer/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/TUSB_ProgressViewer/Resources/book.png b/TUSB_ProgressViewer/Resources/book.png new file mode 100644 index 0000000..5c37dd1 Binary files /dev/null and b/TUSB_ProgressViewer/Resources/book.png differ diff --git a/TUSB_ProgressViewer/Resources/bow.png b/TUSB_ProgressViewer/Resources/bow.png new file mode 100644 index 0000000..11b0c7e Binary files /dev/null and b/TUSB_ProgressViewer/Resources/bow.png differ diff --git a/TUSB_ProgressViewer/Resources/carrot_on_a_stick.png b/TUSB_ProgressViewer/Resources/carrot_on_a_stick.png new file mode 100644 index 0000000..35b5e24 Binary files /dev/null and b/TUSB_ProgressViewer/Resources/carrot_on_a_stick.png differ diff --git a/TUSB_ProgressViewer/Resources/iron_sword.png b/TUSB_ProgressViewer/Resources/iron_sword.png new file mode 100644 index 0000000..a48bb17 Binary files /dev/null and b/TUSB_ProgressViewer/Resources/iron_sword.png differ diff --git a/TUSB_ProgressViewer/Resources/snowball.png b/TUSB_ProgressViewer/Resources/snowball.png new file mode 100644 index 0000000..6554024 Binary files /dev/null and b/TUSB_ProgressViewer/Resources/snowball.png differ diff --git a/TUSB_ProgressViewer/Resources/wolf_spawn_egg.png b/TUSB_ProgressViewer/Resources/wolf_spawn_egg.png new file mode 100644 index 0000000..ddc7044 Binary files /dev/null and b/TUSB_ProgressViewer/Resources/wolf_spawn_egg.png differ diff --git a/TUSB_ProgressViewer/Styles/DataViewerStyles.xaml b/TUSB_ProgressViewer/Styles/DataViewerStyles.xaml new file mode 100644 index 0000000..9a7e1b4 --- /dev/null +++ b/TUSB_ProgressViewer/Styles/DataViewerStyles.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TUSB_ProgressViewer/Styles/LoadingViewStyle.xaml b/TUSB_ProgressViewer/Styles/LoadingViewStyle.xaml index d728f32..009d8bd 100644 --- a/TUSB_ProgressViewer/Styles/LoadingViewStyle.xaml +++ b/TUSB_ProgressViewer/Styles/LoadingViewStyle.xaml @@ -1,15 +1,14 @@