diff --git a/lib/stateManagement/openFiles/types/WtaWtpData.dart b/lib/stateManagement/openFiles/types/WtaWtpData.dart index 53f98f4..3b06fa4 100644 --- a/lib/stateManagement/openFiles/types/WtaWtpData.dart +++ b/lib/stateManagement/openFiles/types/WtaWtpData.dart @@ -167,6 +167,7 @@ class WtaWtpTextures with HasUuid, Undoable implements Disposable { final OpenFileId file; final String wtaPath; final String? wtpPath; + final ValueNotifier?> wtpDatsPath = ValueNotifier(null); final bool isWtb; final int wtaVersion; final ValueListNotifier textures; @@ -175,6 +176,19 @@ class WtaWtpTextures with HasUuid, Undoable implements Disposable { WtaWtpTextures(this.file, this.wtaPath, this.wtpPath, this.isWtb, this.wtaVersion, this.textures, this.useFlagsSimpleMode, this.hasAnySimpleModeFlags) { textures.addListener(_onPropChange); + + if (wtpPath != null) { + List reversePaths = []; + reversePaths.add(wtpPath!); + var remainingPath = dirname(wtpPath!); + while (datExtensions.any((ext) => basename(remainingPath).endsWith(ext))) { + reversePaths.add(remainingPath); + remainingPath = dirname(remainingPath); + if (basename(remainingPath) == datSubExtractDir) + remainingPath = dirname(remainingPath); + } + wtpDatsPath.value = reversePaths.reversed.toList(); + } } static Future fromWtaWtp(OpenFileId file, String wtaPath, String? wtpPath, String extractDir, bool isWtb) async { @@ -278,6 +292,7 @@ class WtaWtpTextures with HasUuid, Undoable implements Disposable { @override void dispose() { textures.dispose(); + wtpDatsPath.dispose(); } @override diff --git a/lib/widgets/filesView/types/genericTable/tableEditor.dart b/lib/widgets/filesView/types/genericTable/tableEditor.dart index df2a9a0..e2719b0 100644 --- a/lib/widgets/filesView/types/genericTable/tableEditor.dart +++ b/lib/widgets/filesView/types/genericTable/tableEditor.dart @@ -82,6 +82,7 @@ class _RowConfigIndexed { mixin CustomTableConfig { late final String name; + Widget? subTitleWidget; late final List columnNames; late final List columnFlex; late final NumberProp rowCount; @@ -198,12 +199,22 @@ class _TableEditorState extends ChangeNotifierState { Row( children: [ Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - widget.config.name, - style: Theme.of(context).textTheme.titleLarge, - ), + child: Row( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + widget.config.name, + style: Theme.of(context).textTheme.titleLarge, + ), + ), + if (widget.config.subTitleWidget != null) ...[ + const SizedBox(width: 10), + Expanded( + child: widget.config.subTitleWidget! + ), + ] + ], ), ), _makeExportDropdown(), diff --git a/lib/widgets/filesView/types/wtaWtpEditor.dart b/lib/widgets/filesView/types/wtaWtpEditor.dart index 2124c2e..84bbb09 100644 --- a/lib/widgets/filesView/types/wtaWtpEditor.dart +++ b/lib/widgets/filesView/types/wtaWtpEditor.dart @@ -8,6 +8,7 @@ import 'package:path/path.dart'; import '../../../fileTypeUtils/textures/ddsConverter.dart'; import '../../../stateManagement/Property.dart'; import '../../../stateManagement/events/statusInfo.dart'; +import '../../../stateManagement/hierarchy/FileHierarchy.dart'; import '../../../stateManagement/listNotifier.dart'; import '../../../stateManagement/openFiles/types/WtaWtpData.dart'; import '../../../utils/utils.dart'; @@ -34,6 +35,7 @@ class _TexturesTableConfig with CustomTableConfig { _TexturesTableConfig(this.file, String name, this.texData) : textures = texData.textures { this.name = name; + subTitleWidget = _WtpDatPaths(wtpDatsPath: texData.wtpDatsPath); columnNames = [ "ID", "PNG", "Path", "", "", if (texData.hasAnySimpleModeFlags) @@ -272,3 +274,48 @@ class __TexturePreviewState extends ChangeNotifierState<_TexturePreview> { ); } } + +class _WtpDatPaths extends ChangeNotifierWidget { + final ValueNotifier?> wtpDatsPath; + + _WtpDatPaths({required this.wtpDatsPath}) : super(notifier: wtpDatsPath); + + @override + State<_WtpDatPaths> createState() => __WtpDatPathsState(); +} + +class __WtpDatPathsState extends ChangeNotifierState<_WtpDatPaths> { + void _openDat(String path) async { + var file = await openHierarchyManager.openFile(path); + if (file == null) + return; + openHierarchyManager.setSelectedEntry(file); + showToast("Opened ${basename(path)} to sidebar"); + } + + @override + Widget build(BuildContext context) { + var paths = widget.wtpDatsPath.value; + if (paths == null) + return const SizedBox.shrink(); + return Row( + children: [ + const Text("WTP inside DTT: "), + for (var path in paths) + if (path != paths.last) ...[ + Flexible( + child: TextButton( + onPressed: () => _openDat(path), + child: Text(basename(path), overflow: TextOverflow.ellipsis), + ), + ), + Text(" > ", style: TextStyle(fontWeight: FontWeight.w900),), + ] + else + Flexible( + child: Text(basename(path), overflow: TextOverflow.ellipsis), + ), + ], + ); + } +}