Esempio n. 1
0
        private bool loadAtrs(Dictionary <string, string> profiles)
        {
            //ColorChangeAtr=BodyM*,BodyD*,GrayG*,Brown*,Main*
            var namesPrefixAtrChange = profiles["ColorChangeAtr"].Split(',');

            foreach (var namePrefix in namesPrefixAtrChange)
            {
                var    namePrefixLowered = namePrefix.ToLower();
                var    index             = namePrefixLowered.LastIndexOf('*');
                string prefix            = namePrefixLowered;
                if (index != -1)
                {
                    prefix = namePrefixLowered.Substring(0, index);
                }
                this.namesPrefixAtrToUsePalette.Add(prefix);
            }

            // load genie.atr
            var context = TotekanParse.parseAtr(this.nameFileGenie);
            var visitor = new DoGAAtrVisitor(this.pathAtr);

            visitor.Visit(context as IParseTree);
            this.atrsGenie = getMapAtrs(visitor.atrs);

            // load atr.ini
            var setNamesFileAtr = new HashSet <string>();
            var namesFileIni    = Directory.GetFiles(this.pathAtr, "*.ini", SearchOption.TopDirectoryOnly);

            foreach (var nameFileIni in namesFileIni)
            {
                var result = this.loadIniPalette(nameFileIni, ref setNamesFileAtr);
                if (!result)
                {
                    return(false);
                }
            }
            // load atrs

            var mapNameFileToAtr = loadFilesAtr(this.pathAtr, setNamesFileAtr);

            // associate palettes and atr
            this.associatePaletteFileAtrToAtr(mapNameFileToAtr);
            this.associatePaletteFileImageToAtr();
            this.associatePaletteMaterialToAtr();
            this.associatePaletteRefToAtr();

            return(true);
        }
Esempio n. 2
0
        public static Dictionary <string, Dictionary <string, DoGAAtr> > loadFilesAtr(Dictionary <string, string> mapNamesFileAtrFullPath)
        {
            var mapNameFileToAtr = new Dictionary <string, Dictionary <string, DoGAAtr> >();

            // load atr files described in atr.ini
            foreach (var pairNameFileFullPath in mapNamesFileAtrFullPath)
            {
                var nameFile         = pairNameFileFullPath.Key;
                var nameFileFullPath = pairNameFileFullPath.Value;
                if (mapNameFileToAtr.ContainsKey(nameFileFullPath))
                {
                    continue;
                }
                if (!File.Exists(nameFileFullPath))
                {
                    continue;
                }
                var contextAtr = TotekanParse.parseAtr(nameFileFullPath);
                var visitorAtr = new DoGAAtrVisitor(Path.GetDirectoryName(nameFileFullPath));
                visitorAtr.Visit(contextAtr as IParseTree);
                mapNameFileToAtr.Add(nameFile, getMapAtrs(visitorAtr.atrs));
            }
            return(mapNameFileToAtr);
        }