Ejemplo n.º 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); }
            }
        }
Ejemplo n.º 2
0
        public ExportItemForm(ItemSaveType defaultType, ExportItemEvent saveEvent)
        {
            InitializeComponent();

            //radio defaults to 'Obj'
            if (defaultType == ItemSaveType.Armor)
            {
                this.radioArmor.Checked = true;
            }
            if (defaultType == ItemSaveType.Weapon)
            {
                this.radioWeap.Checked = true;
            }
            if (defaultType == ItemSaveType.Door)
            {
                this.radioDoor.Checked = true;
            }
            if (defaultType == ItemSaveType.NPC)
            {
                this.radioNpc.Checked = true;
            }
            if (defaultType == ItemSaveType.Meal)
            {
                this.radioMeal.Checked = true;
            }
            Export = saveEvent;
        }
Ejemplo n.º 3
0
        public string GetPathDefinitionValue(ItemSaveType saveType)
        {
            //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 is 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[this.DomainName].Defines[DomainWorkspaceDirectory.Armor].DirectoryLiteral); }

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

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

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

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

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

            default:
            { return(this.ReferenceDomains[this.DomainName].Defines[DomainWorkspaceDirectory.Object].DirectoryLiteral); }
            }
        }
Ejemplo n.º 4
0
 public FileReferenceModel(string itemName, ItemSaveType type, IncludeFile includeFile, string domain)
     : this()
 {
     refIncludeFile = includeFile;
     Type           = type;
     RawName        = itemName;
     FullDSPath     = ConvertNameToFullPath(itemName, domain);
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
        //inventory
        public void AddDoor(string door, ItemSaveType type)
        {
            if (door == null || door.Length < 1)
            {
                return;
            }

            if (!DomainFileReferences[THIS_DOMAIN].Doors.ContainsKey(door))
            {
                FileReferenceModel mod = new FileReferenceModel(door, type, Include, this.Name);
                DomainFileReferences[THIS_DOMAIN].Doors.Add(door, mod);
            }
        }
Ejemplo n.º 7
0
        private bool Save(ItemSaveType path, string fileName)
        {
            if (fileName == null || fileName.Length < 1)
            {
                MessageBox.Show("Please provide a name for the file to be saved.");
                return(false);
            }

            Saved = Manager.GenerateFile(path, fileName);
            if (Saved && refDomain != null)
            {
                //StringBuilder name = new StringBuilder("$" + refDomain.IncludeFile.Door + " \"/" + FileSaveName + Globals.Model.RoomExtension + "\"");
                refDomain.AddInventory(fileName, path);
                refDomain.TriggerCurrentViewControlsUpdate();
            }
            return(true);
        }
Ejemplo n.º 8
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string fileName = this.textFileName.Text;

            if (fileName == null || fileName.Length < 1)
            {
                MessageBox.Show("Please provide a name for the file to be saved.");
            }
            else
            {
                ItemSaveType path = ItemSaveType.Object;
                if (this.radioObj.Checked)
                {
                    path = ItemSaveType.Object;
                }
                if (this.radioWeap.Checked)
                {
                    path = ItemSaveType.Weapon;
                }
                if (this.radioArmor.Checked)
                {
                    path = ItemSaveType.Armor;
                }
                if (this.radioDoor.Checked)
                {
                    path = ItemSaveType.Door;
                }
                if (this.radioNpc.Checked)
                {
                    path = ItemSaveType.NPC;
                }
                if (this.radioMeal.Checked)
                {
                    path = ItemSaveType.Meal;
                }
                if (Export != null)
                {
                    Export(path, fileName);
                }
                this.Close();
                return;
            }
        }
Ejemplo n.º 9
0
        private bool Save(ItemSaveType path, string fileName)
        {
            if (fileName == null || fileName.Length < 1)
            {
                MessageBox.Show("Please provide a name for the file to be saved.");
                return(false);
            }

            Manager.DeleteFunctionsInCode();
            Manager.AddLine("\n::create();\n");
            Saved = Manager.GenerateFile(path, fileName);
            if (Saved && refDomain != null)
            {
                //StringBuilder name = new StringBuilder("$" + ChoosePath(path) + " \"/" + fileName + Globals.Model.RoomExtension + "\"");
                //refDomain.AddDoor(name.ToString(),path);
                //refDomain.TriggerCurrentViewControlsUpdate();
                refDomain.AddDoor(fileName, path);
                refDomain.TriggerCurrentViewControlsUpdate();
            }
            return(true);
        }
Ejemplo n.º 10
0
        public bool AddInventory(string inventory, ItemSaveType type)
        {
            if (inventory == null || inventory.Length < 1)
            {
                return(false);
            }

            //hack alert - gotta infer the item type from the directory.
            //This was added to make the 'import item' functionality work
            if (type == ItemSaveType.Unknown)
            {
                string[] path = inventory.Split('\\');
                type = Include.DetermineSaveType(path[path.Length - 2]);
                if (type == ItemSaveType.Unknown)
                {
                    return(false);
                }

                string inventoryName = path[path.Length - 1].Split('.')[0];
                if (!DomainFileReferences[THIS_DOMAIN].Inventory.ContainsKey(inventoryName))
                {
                    FileReferenceModel mod = new FileReferenceModel(inventoryName, type, Include, this.Name);
                    DomainFileReferences[THIS_DOMAIN].Inventory.Add(inventoryName, mod);
                }
            }
            else
            {
                if (!DomainFileReferences[THIS_DOMAIN].Inventory.ContainsKey(inventory))
                {
                    FileReferenceModel mod = new FileReferenceModel(inventory, type, Include, this.Name);
                    DomainFileReferences[THIS_DOMAIN].Inventory.Add(inventory, mod);
                }
            }

            return(true);
        }
Ejemplo n.º 11
0
        public bool GenerateFile(ItemSaveType itemPath, string fileSaveName)
        {
            bool result = false;

            using (ProgressModal progress = new ProgressModal(5))
            {
                progress.Show();
                if (fileSaveName == null || fileSaveName.Length < 1)
                {
                    return(false);
                }

                progress.UpdateProgressBar();
                List <IFunctionControl> controls = this.CompileFunctionControlsList(this.refParentForm);
                progress.UpdateProgressBar();
                FunctionCallsCollection inherits = this.CompileIheritList(controls);
                progress.UpdateProgressBar();
                FunctionCallsCollection functions = this.CompileFunctioCallsList(controls);
                progress.UpdateProgressBar();
                result = this.Item.SaveModelToDisk(functions, inherits, itemPath, fileSaveName);
                progress.UpdateProgressBar();
            }
            return(result);
        }
Ejemplo n.º 12
0
        public bool SaveModelToDisk(FunctionCallsCollection functions, FunctionCallsCollection inherits, ItemSaveType saveType, string fileName)
        {
            //ensure item directories exists
            Stellarmap.DeadSouls.Globals.DomainDirectories.ValidateDirectoriesExist(this.refMVCDomain.DomainRootDir);


            //determine the path the item will be saved to
            StringBuilder itemPath = new StringBuilder(this.refMVCDomain.DomainRootDir + "\\");

            switch (saveType)
            {
            case ItemSaveType.Weapon:
            {
                itemPath.Append(this.refMVCDomain.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Weapon));
                break;
            }

            case ItemSaveType.Armor:
            {
                itemPath.Append(this.refMVCDomain.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Armor));
                break;
            }

            case ItemSaveType.Door:
            {
                itemPath.Append(this.refMVCDomain.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Door));
                break;
            }

            case ItemSaveType.Meal:
            {
                itemPath.Append(this.refMVCDomain.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Meal));
                break;
            }

            case ItemSaveType.NPC:
            {
                itemPath.Append(this.refMVCDomain.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Npc));
                break;
            }

            case ItemSaveType.Room:
            {
                itemPath.Append(this.refMVCDomain.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Room));
                break;
            }

            default:
            {
                //default to Objects directory
                itemPath.Append(this.refMVCDomain.IncludeFile.StripDeadSoulsPath(DeadSouls.Globals.DomainDirectories.Object));
                break;
            }
            }

            itemPath.Append("\\" + fileName);

            if (!itemPath.ToString().EndsWith(Globals.Model.RoomExtension))
            {
                itemPath.Append(Globals.Model.RoomExtension);
            }

            //TODO: choose save path based on type
            return(this.Serialize(itemPath.ToString(), functions, inherits));
        }
Ejemplo n.º 13
0
 public bool AddInventory(string inventory, ItemSaveType type)
 {
     return(Model.AddInventory(inventory, type));
 }
Ejemplo n.º 14
0
 public void AddDoor(string door, ItemSaveType type)
 {
     Model.AddDoor(door, type);
 }