mirror of
				https://github.com/sampletext32/ParkanPlayground.git
				synced 2025-11-03 23:09:44 +03:00 
			
		
		
		
	Allow to view cp .dat in UI
This commit is contained in:
		
							
								
								
									
										40
									
								
								NResUI/Models/CpDatSchemeViewModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								NResUI/Models/CpDatSchemeViewModel.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
using CpDatLib;
 | 
			
		||||
using ScrLib;
 | 
			
		||||
 | 
			
		||||
namespace NResUI.Models;
 | 
			
		||||
 | 
			
		||||
public class CpDatSchemeViewModel
 | 
			
		||||
{
 | 
			
		||||
    public bool HasFile { get; set; }
 | 
			
		||||
    public string? Error { get; set; }
 | 
			
		||||
 | 
			
		||||
    public CpDatScheme? CpDatScheme { get; set; }
 | 
			
		||||
    
 | 
			
		||||
    public List<(int Level, CpDatEntry Entry)> FlatList { get; set; }
 | 
			
		||||
 | 
			
		||||
    public string? Path { get; set; }
 | 
			
		||||
 | 
			
		||||
    public void SetParseResult(CpDatParseResult parseResult, string path)
 | 
			
		||||
    {
 | 
			
		||||
        CpDatScheme = parseResult.Scheme;
 | 
			
		||||
        Error = parseResult.Error;
 | 
			
		||||
        HasFile = true;
 | 
			
		||||
        Path = path;
 | 
			
		||||
 | 
			
		||||
        if (CpDatScheme is not null)
 | 
			
		||||
        {
 | 
			
		||||
            FlatList = [];
 | 
			
		||||
            
 | 
			
		||||
            CollectEntries(CpDatScheme.Root, 0);
 | 
			
		||||
            
 | 
			
		||||
            void CollectEntries(CpDatEntry entry, int level)
 | 
			
		||||
            {
 | 
			
		||||
                FlatList.Add((level, entry));
 | 
			
		||||
                foreach (var child in entry.Children)
 | 
			
		||||
                {
 | 
			
		||||
                    CollectEntries(child, level + 1);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user