Exemple #1
0
        public string GetPathDefinitionIdentifier(ItemSaveType saveType, string domain)
        {
            domain = IncludeFile.ConvertToValidDirectoryName(domain);
            //HACK ALERT: this is just hardcoded values. ItemSaveType needs to be phased out by DomainWorkspaceDirectories
            //Also note that this only works for the default domain (the one this workspace if for, because
            //that's the context under which we would ever need to know where to save files
            switch (saveType)
            {
            case ItemSaveType.Armor:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Armor].DefinedIndentifier); }

            case ItemSaveType.Door:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Door].DefinedIndentifier); }

            case ItemSaveType.Meal:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Meal].DefinedIndentifier); }

            case ItemSaveType.NPC:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Npc].DefinedIndentifier); }

            case ItemSaveType.Object:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Object].DefinedIndentifier); }

            case ItemSaveType.Room:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Room].DefinedIndentifier); }

            case ItemSaveType.Weapon:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Weapon].DefinedIndentifier); }

            default:
            { return(this.ReferenceDomains[domain].Defines[DomainWorkspaceDirectory.Object].DefinedIndentifier); }
            }
        }
Exemple #2
0
        private void NewDomain(string rootDir)
        {
            //obtain the name of the domain from the final directory
            List <string> sub = new List <string>(rootDir.Split('\\'));

            Name          = sub[sub.Count - 1];
            RootDirectory = rootDir;

            //there is always at least one DomainReference, this domain!
            DomainReference localRef = new DomainReference("domain");

            Include            = new IncludeFile(Name);
            localRef.Doors     = new Dictionary <string, FileReferenceModel>();
            localRef.Inventory = new Dictionary <string, FileReferenceModel>();

            DomainFileReferences = new List <DomainReference>();
            DomainFileReferences.Add(localRef);

            //Directories = new DirectoryStructure(RootDirectory);
            Rooms       = new LinkedList <RoomModel>();
            RoomNameMap = new Dictionary <string, RoomModel>();

            //load all sub directories and files
            DomainInitialized = true;
        }
Exemple #3
0
        /// <summary>
        /// Determines the item type (and thus the directory is should be saved too) based
        /// on it's full path, regardless of it's domain.
        /// </summary>
        /// <param name="fullPath"></param>
        /// <returns></returns>
        public DomainWorkspaceDirectory GetDirectoryType(string fullPath)
        {
            fullPath = IncludeFile.ConvertToValidDirectoryName(fullPath);

            foreach (DomainDirectoryDefines definesList in ReferenceDomains.Values)
            {
                foreach (DefinedDirectory definedDir in definesList.Defines.Values)
                {
                    //METHOD 1
                    //string basePath = DeadSouls.Globals.DeadSoulsGlobals.Domains + "/" + definedDir.DomainConstantTitle;
                    //string remainingPath = definedDir.DirectoryLiteral.Replace(basePath + "/","");

                    //METHOD 2
                    //string[] temp = definedDir.DirectoryLiteral.Split('/');
                    //string remainingPath = temp[temp.Length-1];

                    ////de-pluralize
                    //remainingPath = remainingPath.TrimEnd('s');

                    //if(fullPath.Contains(remainingPath))
                    //    {
                    //    return definedDir.DirectoryType;
                    //    }

                    //METHOD 3
                    if (definedDir.DefinedIndentifier.ToLower().Contains(fullPath.ToLower()))
                    {
                        return(definedDir.DirectoryType);
                    }
                }
            }

            return(DomainWorkspaceDirectory.Unknown);
        }
Exemple #4
0
        public IncludeFile(string domainName)
        {
            DomainName  = IncludeFile.ConvertToValidDirectoryName(domainName);
            DomainRoot  = DeadSouls.Globals.DeadSoulsGlobals.Domains + "/" + domainName;
            LocalDomain = domainName;

            AddDomainReference(domainName, "domain");
        }
Exemple #5
0
 public FileReferenceModel(string itemName, ItemSaveType type, IncludeFile includeFile, string domain)
     : this()
 {
     refIncludeFile = includeFile;
     Type           = type;
     RawName        = itemName;
     FullDSPath     = ConvertNameToFullPath(itemName, domain);
 }
Exemple #6
0
 public FileReferenceModel(string fullDsPath, IncludeFile includeFile)
     : this()
 {
     //we should be able to figure out what it is based on it's save path
     refIncludeFile = includeFile;
     Type           = includeFile.DetermineSaveType(fullDsPath);
     RawName        = ConvertFullPathToName(fullDsPath);
     FullDSPath     = fullDsPath;
 }
Exemple #7
0
        public static string ConvertDomainFileToDomainName(string domainFile)
        {
            string[] temp = domainFile.Split('\\');
            domainFile = temp[temp.Length - 1];
            temp       = domainFile.Split('.');
            domainFile = temp[0];
            domainFile = IncludeFile.ConvertToValidDirectoryName(domainFile);

            return(domainFile);
        }
Exemple #8
0
        public void AddDomainReference(string domainName, string domainTitle)
        {
            domainName = IncludeFile.ConvertToValidDirectoryName(domainName);
            if (ReferenceDomains.ContainsKey(domainName))
            {
                return;
            }

            //to maintain backwards compatibility we refer to the started domain (the one we are building
            //with this tool) with the title 'DOMAIN' rather than simply the domain name
            DomainDirectoryDefines defines = new DomainDirectoryDefines(domainName, DefineAllValuesForDomain(domainName, domainTitle));

            this.ReferenceDomains.Add(domainName, defines);
        }
Exemple #9
0
        /// <summary>
        /// Constructs the identifier and value for a single #define statment for use in a domain's global
        /// header file. The identifier name is an amalgamation of the passed domain name and
        /// the name of the variable of the enumerated type. The string literal for the value
        /// is obtained through reflection from the Stellarmap.DeadSouls.Globals.DomainDirectories
        /// class using reflection by matching the enumed variable name to the aforementioned class's
        /// variable of the same name. (yeh, read that again then go look up the files in question so
        /// you get it straight. I realize that was pretty obtuse ;)
        /// </summary>
        /// <param name="domainName"></param>
        /// <param name="identifier"></param>
        public DefinedDirectory(string domainName, string identifiersTitle, DomainWorkspaceDirectory identifier)
        {
            domainName          = IncludeFile.ConvertToValidDirectoryName(domainName);
            DomainConstantTitle = domainName;
            IdentifiersTitle    = identifiersTitle;

            //HACK ALERT: We are retreiving the name of the enumeration's identifier in DomainWorkspaceDirectory
            //            and then using that name to find the variable of the same name in DeadSouls.GLobals.DomainDirecotries
            //			  so that we can retreive the value from it. Using this method we can generate both the identifer and the value
            //            for a single #define statement.
            Type dirGlobal = typeof(DeadSouls.Globals.DomainDirectories);

            //don't bother with any of this if the define is being generated for 'Unknown'. It's just
            //a paceholder return type.
            if (dirGlobal.Name == "Unknown")
            {
                this.DirectoryType       = DomainWorkspaceDirectory.Unknown;
                this.DirectoryLiteral    = "";
                this.DefinedIndentifier  = "";
                this.DomainConstantTitle = "";
                this.IdentifiersTitle    = "";
                return;
            }
            FieldInfo globalInfo = dirGlobal.GetField(identifier.ToString(), BindingFlags.Static | BindingFlags.Public);

            if (globalInfo != null)
            {
                DefinedIndentifier = IdentifiersTitle.ToUpper() + "_" + identifier.ToString().ToUpper();
                string lastDir = (string)globalInfo.GetValue(null);
                if (lastDir.Length > 0)
                {
                    DirectoryLiteral = DeadSouls.Globals.DeadSoulsGlobals.Domains + "/" + DomainConstantTitle + lastDir;
                }
                else
                {
                    DirectoryLiteral = DeadSouls.Globals.DeadSoulsGlobals.Domains;
                }
            }

            DirectoryType = identifier;

            //if it's the root directory we need to add the domain directory name to the end of it
            //if(dirGlobal.Name == "Root")
            if (globalInfo.Name == "Root")
            {
                DirectoryLiteral += "/" + domainName;
            }
            return;
        }
Exemple #10
0
        private List <string> RemoveIncludedDomainsFromList(List <string> list)
        {
            if (list.Contains(IncludeFile.ConvertToValidDirectoryName(refDomain.DomainName)))
            {
                list.Remove(IncludeFile.ConvertToValidDirectoryName(refDomain.DomainName));
            }

            foreach (string s in refDomain.ReferencedDomains)
            {
                if (list.Contains(s))
                {
                    list.Remove(s);
                }
            }

            return(list);
        }
Exemple #11
0
 public DomainReference(string name)
 {
     Name = IncludeFile.ConvertToValidDirectoryName(name);
     //TODO: add file loading code
 }