11using System . Collections . Generic ;
2- using System . Drawing ;
32using System . Linq ;
4- using Dalamud . Interface ;
3+ using System . Numerics ;
54using Dalamud . Interface . Utility ;
6- using Dalamud . Interface . Utility . Raii ;
7- using Dalamud . Plugin . Services ;
8- using Dalamud . Utility ;
9- using FFXIVClientStructs . FFXIV . Common . Math ;
10- using ImGuiNET ;
115using KamiLib . Window ;
126using Lumina . Excel . GeneratedSheets2 ;
7+ using Mappy . Classes . SelectionWindowComponents ;
8+ using Aetheryte = Lumina . Excel . GeneratedSheets . Aetheryte ;
139using Map = Lumina . Excel . GeneratedSheets . Map ;
14- using TerritoryType = Lumina . Excel . GeneratedSheets . TerritoryType ;
1510
1611namespace Mappy . Windows ;
1712
18- public class MapSelectionWindow : SelectionWindowBase < Map > {
19-
20- private const float Width = 133.5f ;
21-
22- private const float Height = 75.0f ;
13+ public class MapSelectionWindow : SelectionWindowBase < DrawableOption > {
2314
2415 protected override bool AllowMultiSelect => false ;
2516
2617 protected override float SelectionHeight => 75.0f * ImGuiHelpers . GlobalScale ;
2718
28- public MapSelectionWindow ( ) : base ( new Vector2 ( 500.0f , 600 .0f) ) {
29- SelectionOptions = Service . DataManager . GetExcelSheet < Map > ( ) !
19+ public MapSelectionWindow ( ) : base ( new Vector2 ( 500.0f , 800 .0f) ) {
20+ var maps = Service . DataManager . GetExcelSheet < Map > ( ) !
3021 . Where ( map => map is { PlaceName . Row : not 0 , TerritoryType . Value . LoadingImage : not 0 } )
3122 . Where ( map => map is not { PriorityUI : 0 , PriorityCategoryUI : 0 } )
23+ . Select ( map => new MapDrawableOption {
24+ Map = map ,
25+ } )
26+ . OfType < DrawableOption > ( )
3227 . ToList ( ) ;
33- }
34-
35- protected override void DrawSelection ( Map option ) {
36- using var id = ImRaii . PushId ( option . RowId . ToString ( ) ) ;
37-
38- if ( option . TerritoryType . Value is null ) return ;
39-
40- DrawTerritoryImage ( option . TerritoryType . Value , Service . DataManager , Service . TextureProvider ) ;
41- ImGui . SameLine ( ) ;
42-
43- using var contentsFrame = ImRaii . Child ( "contents_frame" , new Vector2 ( ImGui . GetContentRegionAvail ( ) . X , Height * ImGuiHelpers . GlobalScale ) , false , ImGuiWindowFlags . NoInputs ) ;
44- if ( ! contentsFrame ) return ;
45-
46- ImGuiHelpers . ScaledDummy ( 1.0f ) ;
47-
48- using var table = ImRaii . Table ( "data_table" , 2 , ImGuiTableFlags . SizingStretchProp ) ;
49- if ( ! table ) return ;
50-
51- ImGui . TableSetupColumn ( "##column1" , ImGuiTableColumnFlags . None , 2.0f ) ;
52- ImGui . TableSetupColumn ( "##column2" , ImGuiTableColumnFlags . None , 1.0f ) ;
5328
54- var placeName = option . PlaceName . Value ? . Name ?? "Unknown PlaceName" ;
55- var zoneName = option . PlaceNameSub . Value ? . Name ;
56- var regionName = option . PlaceNameRegion . Value ? . Name ;
57-
58- ImGui . TableNextColumn ( ) ;
59- ImGui . TextUnformatted ( placeName ) ;
60-
61- ImGui . TableNextColumn ( ) ;
62- ImGui . TextUnformatted ( option . RowId . ToString ( ) ) ;
63-
64- ImGui . TableNextRow ( ) ;
65- ImGui . TableNextColumn ( ) ;
29+ var poi = Service . DataManager . GetExcelSheet < MapMarker > ( ) !
30+ . Where ( marker => marker . PlaceNameSubtext . Row is not 0 )
31+ . Where ( marker => marker . Icon is 60442 )
32+ . Select ( marker => new PoiDrawableOption {
33+ MapMarker = marker ,
34+ } )
35+ . OfType < DrawableOption > ( )
36+ . ToList ( ) ;
6637
67- using var grayColor = ImRaii . PushColor ( ImGuiCol . Text , KnownColor . DarkGray . Vector ( ) ) ;
68- if ( zoneName is not null && ! zoneName . ToString ( ) . IsNullOrEmpty ( ) && regionName is not null && ! regionName . ToString ( ) . IsNullOrEmpty ( ) ) {
69- ImGui . TextUnformatted ( $ "{ regionName } , { zoneName } ") ;
70- }
71- else if ( zoneName is not null && ! zoneName . ToString ( ) . IsNullOrEmpty ( ) ) {
72- ImGui . TextUnformatted ( $ "{ zoneName } ") ;
73- }
74- else if ( regionName is not null && ! regionName . ToString ( ) . IsNullOrEmpty ( ) ) {
75- ImGui . TextUnformatted ( $ "{ regionName } ") ;
76- }
38+ var aetherytes = Service . DataManager . GetExcelSheet < Aetheryte > ( ) !
39+ . Where ( aetheryte => aetheryte is not { PlaceName . Row : 0 , AethernetName . Row : 0 } )
40+ . Where ( aetheryte => aetheryte is not { AethernetGroup : 0 , Map . Row : 0 } )
41+ . Select ( aetheryte => new AetheryteDrawableOption {
42+ Aetheryte = aetheryte ,
43+ } )
44+ . OfType < DrawableOption > ( )
45+ . ToList ( ) ;
7746
78- ImGui . TableNextColumn ( ) ;
79- ImGui . TextUnformatted ( $ "{ option . Id } ") ;
47+ SelectionOptions = maps
48+ . Concat ( poi )
49+ . Concat ( aetherytes )
50+ . ToList ( ) ;
8051 }
81-
82- protected override IEnumerable < string > GetFilterStrings ( Map option )
83- => [
84- option . PlaceNameRegion . Value ? . Name . ToString ( ) ?? string . Empty ,
85- option . PlaceName . Value ? . Name . ToString ( ) ?? string . Empty ,
86- option . PlaceNameSub . Value ? . Name . ToString ( ) ?? string . Empty ,
87- option . TerritoryType . Value ? . Name . ToString ( ) ?? string . Empty ,
88- option . Id . ToString ( ) ,
89- ] ;
9052
91- private static void DrawTerritoryImage ( TerritoryType option , IDataManager dataManager , ITextureProvider textureProvider ) {
92- using var imageFrame = ImRaii . Child ( $ "image_frame{ option } ", ImGuiHelpers . ScaledVector2 ( Width * ImGuiHelpers . GlobalScale , Height ) , false , ImGuiWindowFlags . NoInputs ) ;
93- if ( ! imageFrame ) return ;
94-
95- if ( dataManager . GetExcelSheet < LoadingImage > ( ) ! . GetRow ( option . LoadingImage ) is { } loadingImageInfo ) {
96- if ( textureProvider . GetFromGame ( $ "ui/loadingimage/{ loadingImageInfo . Unknown0 } _hr1.tex") . GetWrapOrDefault ( ) is { } texture ) {
97- ImGui . Image ( texture . ImGuiHandle , ImGuiHelpers . ScaledVector2 ( Width , Height ) , new Vector2 ( 0.15f , 0.15f ) , new Vector2 ( 0.85f , 0.85f ) ) ;
98- }
99- else {
100- ImGuiHelpers . ScaledDummy ( Width , Height ) ;
101- }
102- }
53+ protected override void DrawSelection ( DrawableOption option ) {
54+ option . Draw ( ) ;
10355 }
56+
57+ protected override IEnumerable < string > GetFilterStrings ( DrawableOption option )
58+ => option . GetFilterStrings ( ) ;
10459}
0 commit comments