Skip to content

feat: マップ設定の自動生成機能およびマップ名を自動で修正する機能の実装#143

Merged
fltuna merged 5 commits intofltuna:mainfrom
2vg:feat/uru/auto-map-config
Jun 25, 2025
Merged

feat: マップ設定の自動生成機能およびマップ名を自動で修正する機能の実装#143
fltuna merged 5 commits intofltuna:mainfrom
2vg:feat/uru/auto-map-config

Conversation

@2vg
Copy link
Copy Markdown
Collaborator

@2vg 2vg commented May 20, 2025

このPRでは以下のふたつの機能を実装します

  1. プラグインロード時にマップ設定を自動生成する機能

    • プラグイン設定に新たにWorkshopCollectionIdsが追加されました
    • 配列にコレクションIDがあれば、そのコレクションをSteamに確認しに行き、自動でマップ設定を生成します
    • vpkとしてのマップ名は取得できないので、タイトルをマップ名として、ワークショップIDとともにdefault.tomlベースでマップ設定を作ろうとします(なければdefault.tomlを生成するときの値)
    • 複数のコレクションIDを設定可能です
    • もしタイトルが奇妙な文字から始まる場合は、workshop_map_...のようにフォールバックされた名前をマップ名として使用します(後で手動で直す必要あり)
    • マップ設定は、configディレクトリの場合はsynced_workshopmapsというディレクトリに各マップ設定を保存するようにしています
  2. マップスタート時にマップ名を自動修正する機能

    • マップの開始時、Server.MapNameとマップ設定のマップ名が一致しなければ設定のマップ名を修正しようとします
    • 正しいマップ名と判断されれば特に何もしません
    • 主に上記の機能において自動生成されたマップ設定のための機能で、両方を一緒に使用することが望ましいです

Copy link
Copy Markdown
Owner

@fltuna fltuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正が必要かも!って点をまとめておいた!

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これに関してはフレームワーク側でUtilを提供しているから、それを使ってくれると嬉しいかも!

https://github.com/fltuna/TNCSSPluginFoundation/blob/main/TNCSSPluginFoundation/Utils/Other/ForceFullUpdate.cs

Copy link
Copy Markdown
Collaborator Author

@2vg 2vg Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilの方はstaticがついててインスタンス化できへん!
解決した

Comment on lines +78 to +81
string configDir = Path.Combine(Plugin.ModuleDirectory, "config");
string mapsDir = Path.Combine(configDir, "maps");
string oldFilePath = Path.Combine(mapsDir, $"{mapConfig.MapName}.toml");
string newFilePath = Path.Combine(mapsDir, $"{mapName}.toml");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここのpath、設定ファイルは人によっては$ModuleDir/config/maps.tomlにあったり、$ModuleDir/config/ze_maps/ze_xxxxみたいだったり様々だから、特定のマップ名で保存するとキーの競合が起きてコンフィグロードできなくなるかも

newMapConfig.ProhibitAdminNomination = defaultMapConfig.ProhibitAdminNomination;
newMapConfig.DaysAllowed = defaultMapConfig.DaysAllowed ?? new List<DayOfWeek>();
newMapConfig.AllowedTimeRanges = defaultMapConfig.AllowedTimeRanges ?? new List<ITimeRange>();
newMapConfig.GroupSettingsArray = defaultMapConfig.GroupSettingsArray ?? new List<string> { "default" };
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GroupSettingsはこの場合は空で大丈夫!

newMapConfig.ProhibitAdminNomination = false;
newMapConfig.DaysAllowed = new List<DayOfWeek>();
newMapConfig.AllowedTimeRanges = new List<ITimeRange>();
newMapConfig.GroupSettingsArray = new List<string> { "default" };
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GroupSettingsはこの場合は空で大丈夫!

Comment on lines +184 to +188
Directory.CreateDirectory(configDir); // Ensure directory exists
// Individual map files are typically stored in a 'maps' subdirectory within 'config'
string mapsDir = Path.Combine(configDir, "maps");
Directory.CreateDirectory(mapsDir);
string filePath = Path.Combine(mapsDir, $"{validMapName}.toml");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここも別のところで少し触れたように、設定ファイルは、人によっては$ModuleDir/config/maps.tomlにあったり、$ModuleDir/config/ze_maps/ze_xxxxみたいだったり様々だから、特定のマップ名で保存するとキーの競合が起きてコンフィグロードできなくなるかも

@2vg
Copy link
Copy Markdown
Collaborator Author

2vg commented May 26, 2025

TODO: 先週末が忙しかったので今週末に対応

@2vg
Copy link
Copy Markdown
Collaborator Author

2vg commented Jun 7, 2025

ビルド確認済み、ビルド時の警告もないことを確認済み

@2vg 2vg marked this pull request as draft June 7, 2025 14:49
@2vg
Copy link
Copy Markdown
Collaborator Author

2vg commented Jun 7, 2025

自鯖で試したら挙動がちょっと怪しいので一旦レビュー下げます

@2vg
Copy link
Copy Markdown
Collaborator Author

2vg commented Jun 7, 2025

直ったと思うので再度Open

@2vg 2vg marked this pull request as ready for review June 7, 2025 15:21
Copy link
Copy Markdown
Owner

@fltuna fltuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

見た感じ特に問題ないのでマージします! 問題発生したらその都度修正ということで!

@fltuna fltuna merged commit 41f7f46 into fltuna:main Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants