protected BuildableModItem(
            string _classID,
            string _friendlyName,
            string _handOverText,
            string _description,
            TechType requiredForUnlock,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            bool _unlockedAtStart,

            string iconFileName,
            TechType iconTechType,
            TechType prefabTemplate,
            string gamerResourceFileName
            )
            : base(_classID, _friendlyName, _description)
        {
            _ClassID          = _classID;
            _FriendlyName     = _friendlyName;
            _Description      = _description;
            _HandOverText     = _handOverText;
            RequiredForUnlock = requiredForUnlock;
            GroupForPDA       = groupForPDA;
            CategoryForPDA    = categoryForPDA;
            _UnlockedAtStart  = _unlockedAtStart;

            IconFilename         = iconFileName;
            IconTechType         = iconTechType;
            PrefabTemplate       = prefabTemplate;
            GameResourceFileName = gamerResourceFileName;
        }
Example #2
0
        internal static void AddToCustomGroup(TechGroup group, TechCategory category, TechType techType, TechType after)
        {
            Dictionary <TechGroup, Dictionary <TechCategory, List <TechType> > > groups = CraftData.groups;
            Dictionary <TechCategory, List <TechType> > techGroup = groups[group];

            if (techGroup == null)
            {
                // Should never happen, but doesn't hurt to add it.
                Logger.Log("Invalid TechGroup!", LogLevel.Error);
                return;
            }

            List <TechType> techCategory = techGroup[category];

            if (techCategory == null)
            {
                Logger.Log($"Invalid TechCategory Combination! TechCategory: {category} TechGroup: {group}", LogLevel.Error);
                return;
            }

            int index = techCategory.IndexOf(after);

            if (index == -1) // Not found
            {
                techCategory.Add(techType);
                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\"", LogLevel.Debug);
            }
            else
            {
                techCategory.Insert(index + 1, techType);

                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\" after \"{after.AsString():G}\"", LogLevel.Debug);
            }
        }
Example #3
0
 protected Craftable(
     string nameID,
     string nameUsingForFiles,
     string friendlyName,
     string description,
     TechType template,
     CraftTree.Type fabricatorType,
     string fabricatorTab,
     TechType requiredAnalysis,
     TechGroup groupForPDA,
     TechCategory categoryForPDA,
     EquipmentType equipmentType,
     QuickSlotType quickSlotType,
     Vector2int itemSize,
     string gamerResourceFileName
     )
     : base(nameID, $"{nameID}Prefab")
 {
     NameID               = nameID;
     NameUsingForFiles    = nameUsingForFiles;
     FriendlyName         = friendlyName;
     Description          = description;
     PrefabTemplate       = template;
     FabricatorType       = fabricatorType;
     FabricatorTab        = fabricatorTab;
     RequiredForUnlock    = requiredAnalysis;
     GroupForPDA          = groupForPDA;
     CategoryForPDA       = categoryForPDA;
     TypeForEquipment     = equipmentType;
     TypeForQuickslot     = quickSlotType;
     ItemSize             = itemSize;
     GameResourceFileName = gamerResourceFileName;
 }
        protected Craftable(
            string nameID,
            string friendlyName,
            string description,
            TechType template,
            CraftTree.Type fabricatorType,
            string fabricatorTab,
            TechType requiredAnalysis,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            Craftable prerequisite = null)
            : base(nameID, $"{nameID}Prefab")
        {
            NameID       = nameID;
            FriendlyName = friendlyName;
            Description  = description;

            PrefabTemplate = template;
            FabricatorType = fabricatorType;
            FabricatorTab  = fabricatorTab;

            RequiredForUnlock = requiredAnalysis;

            GroupForPDA    = groupForPDA;
            CategoryForPDA = categoryForPDA;

            Prerequisite = prerequisite;
        }
        protected ModPrefab_Craftable(
            string techTypeName,
            string friendlyName,
            string description,
            TechType template,
            TechType requiredAnalysis,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            EquipmentType equipmentType,
            QuickSlotType quickSlotType,
            CraftData.BackgroundType backgroundType,
            Vector2int itemSize,
            ModPrefab_Fragment fragment
            )
            : base(techTypeName, $"{techTypeName}.Prefab")
        {
            TechTypeName      = techTypeName;
            FriendlyName      = friendlyName;
            Description       = description;
            PrefabTemplate    = template;
            RequiredForUnlock = requiredAnalysis;
            GroupForPDA       = groupForPDA;
            CategoryForPDA    = categoryForPDA;
            TypeForEquipment  = equipmentType;
            TypeForQuickslot  = quickSlotType;
            BackgroundType    = backgroundType;
            ItemSize          = itemSize;
            _Fragment         = fragment;

            IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent);
        }
Example #6
0
        internal static void AddToCustomGroup(TechGroup group, TechCategory category, TechType techType, TechType after)
        {
            if (!CraftData.groups.TryGetValue(group, out Dictionary <TechCategory, List <TechType> > techGroup))
            {
                // Should never happen, but doesn't hurt to add it.
                Logger.Log("Invalid TechGroup!", LogLevel.Error);
                return;
            }

            if (!techGroup.TryGetValue(category, out List <TechType> techCategory))
            {
                Logger.Log($"{group} does not contain {category} as a registered group. Please ensure to register your TechCategory to the TechGroup using the TechCategoryHandler before using the combination.", LogLevel.Error);
                return;
            }

            if (techCategory.Contains(techType))
            {
                Logger.Log($"\"{techType.AsString():G}\" Already exists at \"{group:G}->{category:G}\", Skipping Duplicate Entry", LogLevel.Debug);
                return;
            }

            int index = techCategory.IndexOf(after);

            if (index == -1) // Not found
            {
                techCategory.Add(techType);
                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\"", LogLevel.Debug);
            }
            else
            {
                techCategory.Insert(index + 1, techType);

                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\" after \"{after.AsString():G}\"", LogLevel.Debug);
            }
        }
Example #7
0
        private static void GenerateOriginalsFile(TechGroup group, TechCategory category, List <TechType> list, string fileName)
        {
            var printyPrints = new List <string>();

            printyPrints.AddRange(EmUtils.CommentTextLinesCentered(new string[]
            {
                "This file was generated with original recipes in the game",
                "You can copy individual entries from this file to use in your personal overrides",
                "--------------------------------------------------------------------------------",
                $"PdaGroup: {group} - PdaCategory:{category}",
                "--------------------------------------------------------------------------------",
            }));

            var originals = new ModifiedRecipeList();

            foreach (TechType craftable in list)
            {
                originals.Add(new ModifiedRecipe(craftable));
            }

            printyPrints.Add(originals.PrettyPrint());

            File.WriteAllLines(FileLocations.OriginalsFolder + fileName, printyPrints.ToArray(), Encoding.UTF8);

            QuickLogger.Debug($"{fileName} file not found. File generated.");
        }
Example #8
0
        /// <summary>
        /// Adds a new <see cref="TechCategory" /> into the game.
        /// </summary>
        /// <param name="techCatagoryName">The name of the TechCategory. Should not contain special characters.</param>
        /// <param name="displayName">The display name of the TechCategory. Can be anything.</param>
        /// <returns>
        /// The new <see cref="TechCategory" /> that is created.
        /// </returns>
        public TechCategory AddTechCategory(string techCatagoryName, string displayName)
        {
            TechCategory techCategory = TechCategoryPatcher.AddTechCategory(techCatagoryName);

            LanguageHandler.SetLanguageLine("TechCategory" + techCatagoryName, displayName);

            return(techCategory);
        }
Example #9
0
 public Tech(string name, Cost cost, TechRequirements techRequirements, int ranking, TechCategory category)
 {
     this.name             = name;
     this.cost             = cost;
     this.techRequirements = techRequirements;
     this.ranking          = ranking;
     this.category         = category;
 }
 public ActionResult Delete(int TechCategoryID)
 {
     myHandler = new BusinessLogicHandler();
     tech = new TechCategory();
     tech.TechCategoryID = TechCategoryID;
     tech = myHandler.GetTechnologyType(TechCategoryID);
     return View(tech);
 }
Example #11
0
        protected void addToGroup(TechGroup group, TechCategory category, TechType after = TechType.None)
        {
            CraftDataHandler.AddToGroup(group, category, TechType, after);

            if (group >= TechGroup.BasePieces && group <= TechGroup.Miscellaneous)             // little hack
            {
                CraftDataHandler.AddBuildable(TechType);
            }
        }
 public ActionResult Create(TechCategory techCategory)
 {
     try
     {
         BusinessLogicHandler myHandler = new BusinessLogicHandler();
         myHandler.AddTechnologyType(techCategory);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Example #13
0
        /// <summary>
        /// Adds a new <see cref="TechCategory" /> into the game.
        /// </summary>
        /// <param name="techCatagoryName">The name of the TechCategory. Should not contain special characters.</param>
        /// <param name="displayName">The display name of the TechCategory. Can be anything.</param>
        /// <returns>
        /// The new <see cref="TechCategory" /> that is created.
        /// </returns>
        public TechCategory AddTechCategory(string techCatagoryName, string displayName)
        {
            TechCategory techCategory = TechCategoryPatcher.AddTechCategory(techCatagoryName);

            Dictionary <TechCategory, string> valueToString = uGUI_BlueprintsTab.techCategoryStrings.valueToString;

            valueToString[techCategory] = "TechCategory" + techCatagoryName;


            LanguageHandler.SetLanguageLine("TechCategory" + techCatagoryName, displayName);

            return(techCategory);
        }
Example #14
0
        public static void AddToCustomGroup(TechGroup group, TechCategory category, TechType techType)
        {
            //if (!customGroups.ContainsKey(group))
            //    customGroups.Add(group, new Dictionary<TechCategory, List<TechType>>());
            //if (!customGroups[group].ContainsKey(category))
            //    customGroups[group][category] = new List<TechType>();
            //customGroups[group][category].Add(techType);

            var groups = GroupsField.GetValue(null) as Dictionary <TechGroup, Dictionary <TechCategory, List <TechType> > >;

            groups[group][category].Add(techType);

            Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\"");
        }
Example #15
0
        /// <summary>
        /// Safely looks for a modded category from another mod in the SMLHelper TechCategoryCache and outputs its <see cref="TechCategory" /> value when found.
        /// </summary>
        /// <param name="techCategoryString">The string used to define the techcategory.</param>
        /// <param name="modTechCategory">The TechCategory enum value of the modded. Defaults to <see cref="TechCategory.Misc" /> when the item was not found.</param>
        /// <returns>
        ///   <c>True</c> if the item was found; Otherwise <c>false</c>.
        /// </returns>
        public bool TryGetModdedTechCategory(string techCategoryString, out TechCategory modTechCategory)
        {
            EnumTypeCache cache = TechCategoryPatcher.cacheManager.RequestCacheForTypeName(techCategoryString, false);

            if (cache != null) // Item Found
            {
                modTechCategory = (TechCategory)cache.Index;
                return(true);
            }
            else // Mod not present or not yet loaded
            {
                modTechCategory = TechCategory.Misc;
                return(false);
            }
        }
Example #16
0
        /// <summary>
        /// Registers the TechCategory to a TechGroup in CraftData.groups.
        /// </summary>
        /// <param name="techGroup">The tech group.</param>
        /// <param name="techCategory">The tech category.</param>
        /// <returns></returns>
        public bool TryRegisterTechCategoryToTechGroup(TechGroup techGroup, TechCategory techCategory)
        {
            if (!CraftData.groups.TryGetValue(techGroup, out var techCategories))
            {
                //Should not even really be possible but just incase.
                return(false);
            }

            if (techCategories.ContainsKey(techCategory))
            {
                return(true);
            }

            techCategories[techCategory] = new List <TechType>();
            return(true);
        }
        public ActionResult Delete(int TechCategoryID, FormCollection collection)
        {
            try
            {
                myHandler = new BusinessLogicHandler();
                tech = new TechCategory();
                tech.TechCategoryID = TechCategoryID;
                myHandler.DeleteTechnologyType(TechCategoryID);

                TempData["Alert Message"] = "Category Successfully Deleted";
                return RedirectToAction("Index", "TechCategory");
            }
            catch
            {
                return View();
            }
        }
        internal static TechCategory AddTechCategory(string name)
        {
            EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache()
            {
                Name  = name,
                Index = cacheManager.GetNextAvailableIndex()
            };

            TechCategory TechCategory = (TechCategory)cache.Index;

            cacheManager.Add(TechCategory, cache.Index, cache.Name);

            Logger.Log($"Successfully added TechCategory: '{name}' to Index: '{cache.Index}'", LogLevel.Debug);


            return(TechCategory);
        }
Example #19
0
        public GlobalTechInfo(int techID, TechCategory category, int plymouthCost, int edenCost, int maxScientists, LabType labType,
                              string techName, string description, string teaser, string improveDescription, IList <int> requiredTechIDs, IList <UnitPropertyInfo> unitProperties)
        {
            TechID             = techID;
            Category           = category;
            PlymouthCost       = plymouthCost;
            EdenCost           = edenCost;
            MaxScientists      = maxScientists;
            LabType            = labType;
            TechName           = techName;
            Description        = description;
            Teaser             = teaser;
            ImproveDescription = improveDescription;

            RequiredTechIDs = new ReadOnlyCollection <int>(requiredTechIDs);
            UnitProperties  = new ReadOnlyCollection <UnitPropertyInfo>(unitProperties);
        }
Example #20
0
        protected ModPrefab_Craftable(
            string nameID,
            string iconFilePath,
            TechType iconTechType,
            string friendlyName,
            string description,
            TechType template,
            TabNode newTabNode,
            CraftTree.Type[] fabricatorTypes,
            string[][] fabricatorTabs,
            TechType requiredAnalysis,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            EquipmentType equipmentType,
            QuickSlotType quickSlotType,
            CraftData.BackgroundType backgroundType,
            Vector2int itemSize,
            string gamerResourceFileName,
            ModPrefab_Fragment fragment
            )
            : base(nameID, $"{nameID}:Prefab")
        {
            NameID               = nameID;
            IconFilePath         = iconFilePath;
            IconTechType         = iconTechType;
            FriendlyName         = friendlyName;
            Description          = description;
            PrefabTemplate       = template;
            NewTabNode           = newTabNode;
            FabricatorTypes      = fabricatorTypes;
            FabricatorTabs       = fabricatorTabs;
            RequiredForUnlock    = requiredAnalysis;
            GroupForPDA          = groupForPDA;
            CategoryForPDA       = categoryForPDA;
            TypeForEquipment     = equipmentType;
            TypeForQuickslot     = quickSlotType;
            BackgroundType       = backgroundType;
            ItemSize             = itemSize;
            GameResourceFileName = gamerResourceFileName;
            _Fragment            = fragment;

            //IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent);
        }
Example #21
0
        internal static void RemoveFromCustomGroup(TechGroup group, TechCategory category, TechType techType)
        {
            if (!CraftData.groups.TryGetValue(group, out Dictionary <TechCategory, List <TechType> > techGroup))
            {
                return;
            }

            if (!techGroup.TryGetValue(category, out List <TechType> techCategory))
            {
                return;
            }

            if (!techCategory.Contains(techType))
            {
                return;
            }

            techCategory.Remove(techType);
            Logger.Log($"Successfully Removed \"{techType.AsString():G}\" from groups under \"{group:G}->{category:G}\"", LogLevel.Debug);
        }
Example #22
0
 protected ModPrefab_Vehicle(
     string techTypeName,
     string friendlyName,
     string description,
     TechType template,
     TechType requiredAnalysis,
     TechGroup groupForPDA,
     TechCategory categoryForPDA,
     ModPrefab_Fragment fragment
     )
     : base(techTypeName, $"{techTypeName}.Prefab")
 {
     TechTypeName      = techTypeName;
     FriendlyName      = friendlyName;
     Description       = description;
     PrefabTemplate    = template;
     RequiredForUnlock = requiredAnalysis;
     GroupForPDA       = groupForPDA;
     CategoryForPDA    = categoryForPDA;
     _Fragment         = fragment;
 }
Example #23
0
        internal static void RemoveFromCustomGroup(TechGroup group, TechCategory category, TechType techType)
        {
            Dictionary <TechGroup, Dictionary <TechCategory, List <TechType> > > groups = CraftData.groups;
            Dictionary <TechCategory, List <TechType> > techGroup = groups[group];

            if (techGroup == null)
            {
                // Should never happen, but doesn't hurt to add it.
                Logger.Log("Invalid TechGroup!", LogLevel.Error);
                return;
            }

            List <TechType> techCategory = techGroup[category];

            if (techCategory == null)
            {
                Logger.Log($"Invalid TechCategory Combination! TechCategory: {category} TechGroup: {group}", LogLevel.Error);
                return;
            }

            techCategory.Remove(techType);

            Logger.Log($"Removed \"{techType.AsString():G}\" from groups under \"{group:G}->{category:G}\"", LogLevel.Debug);
        }
Example #24
0
 /// <summary>
 /// Allows you to remove an existing TechType from the game's internal group system.
 /// </summary>
 /// <param name="group">The TechGroup in which the TechType is located.</param>
 /// <param name="category">The TechCategory in which the TechType is located.</param>
 /// <param name="techType">The TechType which you want to remove.</param>
 public static void RemoveFromGroup(TechGroup group, TechCategory category, TechType techType)
 {
     Main.RemoveFromGroup(group, category, techType);
 }
Example #25
0
 /// <summary>
 /// Allows you to add items to the game's internal grouping system.
 /// Required if you want to make buildable items show up in the Habitat Builder.
 /// </summary>
 /// <param name="group">The TechGroup you want to add your TechType to.</param>
 /// <param name="category">The TechCategory (in the TechGroup) you want to add your TechType to.</param>
 /// <param name="techType">The TechType you want to add.</param>
 /// <param name="after">Added TechType will be added after this TechType, for sorting purposes.</param>
 public static void AddToGroup(TechGroup group, TechCategory category, TechType techType, TechType after)
 {
     Main.AddToGroup(group, category, techType, after);
 }
Example #26
0
 /// <summary>
 /// Allows you to add items to the game's internal grouping system.
 /// Required if you want to make buildable items show up in the Habitat Builder.
 /// </summary>
 /// <param name="group">The TechGroup you want to add your TechType to.</param>
 /// <param name="category">The TechCategory (in the TechGroup) you want to add your TechType to.</param>
 /// <param name="techType">The TechType you want to add.</param>
 public static void AddToGroup(TechGroup group, TechCategory category, TechType techType)
 {
     Main.AddToGroup(group, category, techType, TechType.None);
 }
Example #27
0
        private static GlobalTechInfo ParseTechValues(List <List <string> > techValues)
        {
            // Process tech header
            string techName = techValues[0][1];

            int techId;

            if (!int.TryParse(techValues[0][2], out techId))
            {
                Debug.LogError("Tech '" + techName + "' has an invalid tech Id!");
            }

            TechCategory            category        = TechCategory.Basic;
            string                  description     = "";
            string                  teaser          = "";
            string                  improveDesc     = "";
            int                     edenCost        = 0;
            int                     plymouthCost    = 0;
            int                     maxScientists   = 0;
            LabType                 labType         = LabType.Standard;
            List <int>              requiredTechIDs = new List <int>();
            List <UnitPropertyInfo> unitProperties  = new List <UnitPropertyInfo>();


            // Process tech values
            for (int i = 0; i < techValues.Count; ++i)
            {
                if (techValues[i].Count < 2)
                {
                    Debug.LogError("TechID " + techId + ": Not enough values specified for type: " + techValues[i][0]);
                    continue;
                }

                int value;
                int.TryParse(techValues[i][1], out value);

                switch (techValues[i][0])
                {
                case "CATEGORY":                        category = (TechCategory)value;         break;

                case "DESCRIPTION":                     description = techValues[i][1];         break;

                case "TEASER":                          teaser = techValues[i][1];                      break;

                case "IMPROVE_DESC":            improveDesc = techValues[i][1];         break;

                case "REQUIRES":                        requiredTechIDs.Add(value);                     break;

                case "COST":                            edenCost = plymouthCost = value;        break;

                case "EDEN_COST":                       edenCost = value;                                       break;

                case "PLYMOUTH_COST":           plymouthCost = value;                           break;

                case "MAX_SCIENTISTS":          maxScientists = value;                          break;

                case "LAB":                                     labType = (LabType)value;                       break;

                case "UNIT_PROP":
                    if (techValues[i].Count < 4)
                    {
                        Debug.LogError("TechID " + techId + ": Not enough values specified for type: " + techValues[i][0]);
                        continue;
                    }

                    map_id mapId = SheetReader.GetMapIdFromCodeName(techValues[i][1]);
                    if (mapId == map_id.None)
                    {
                        Debug.LogError("TechID " + techId + ": Bad unit specifier: " + techValues[i][1]);
                        break;
                    }

                    UnitProperty property = GetUnitProperty(techValues[i][2]);
                    if (property == UnitProperty.None)
                    {
                        Debug.LogError("TechID " + techId + ": Bad property specifier: " + techValues[i][2]);
                        break;
                    }

                    int.TryParse(techValues[i][3], out value);

                    unitProperties.Add(new UnitPropertyInfo(mapId, property, value));

                    break;
                }
            }

            return(new GlobalTechInfo(techId, category, plymouthCost, edenCost, maxScientists, labType, techName, description, teaser, improveDesc, requiredTechIDs, unitProperties));
        }
Example #28
0
 public void setCategory(TechCategory category)
 {
     this.category = category;
 }
 public static void registerCustomTechNeed(TechType techType, TechTreeData[] ingredients, TechGroup techGroup, TechCategory techCategory)
 {
     Debug.Log("[UM4SN] Registering " + (int)techType);
     customTechTreeNeeds.Add(techType, ingredients);
     CraftData.groups[techGroup][techCategory].Add(techType);
     CraftData.buildables.Add(techType);
 }
Example #30
0
        public static void RegisterCustomTechNeed(TechType techType, TechTreeData[] ingredients, TechGroup techGroup, TechCategory techCategory)
        {
            Debug.Log("[UM4SN] Registering " + (int)techType);
            customTechTreeNeeds.Add(techType, ingredients);

            if (groups == null)
            {
                groups = (Dictionary <TechGroup, Dictionary <TechCategory, List <TechType> > >) typeof(CraftData).ReflectionGet("groups", false, true);
            }
            if (buildables == null)
            {
                buildables = (List <TechType>) typeof(CraftData).ReflectionGet("buildables", false, true);
            }
            groups[techGroup][techCategory].Add(techType);
            buildables.Add(techType);

            //CraftData.groups[techGroup][techCategory].Add(techType);
            //CraftData.buildables.Add(techType);
        }
Example #31
0
 /// <summary>
 /// Allows you to add items to the game's internal grouping system.
 /// Required if you want to make buildable items show up in the Habitat Builder or show in the Blueprints Tab of the PDA.
 /// </summary>
 /// <param name="group">The TechGroup you want to add your TechType to.</param>
 /// <param name="category">The TechCategory (in the TechGroup) you want to add your TechType to.</param>
 /// <param name="techType">The TechType you want to add.</param>
 /// <param name="after">Added TechType will be added after this TechType, for sorting purposes.</param>
 void ICraftDataHandler.AddToGroup(TechGroup group, TechCategory category, TechType techType, TechType after)
 {
     CraftDataPatcher.AddToCustomGroup(group, category, techType, after);
 }
Example #32
0
 public TechHull(string name, Cost cost, TechRequirements techRequirements, int ranking, TechCategory category) : base(name, cost, techRequirements, ranking, category)
 {
 }
 public ActionResult Edit(int TechCategoryID, FormCollection collection)
 {
     try
     {
         myHandler = new BusinessLogicHandler();
         tech = new TechCategory();
         TryUpdateModel(tech);
         if (ModelState.IsValid)
         {
             myHandler.UpdateTechnologyType(tech);
         }
         return RedirectToAction("Index", "TechCategory");
     }
     catch
     {
         return View();
     }
 }
 public ActionResult ViewTechCategory(TechCategory tech)
 {
     myHandler = new BusinessLogicHandler();
     if (ModelState.IsValid)
     {
         myHandler.AddTechnologyType(tech);
     }
     return Json(new { success = true });
 }
Example #35
0
 /// <summary>
 /// Allows you to remove an existing TechType from the game's internal group system.
 /// </summary>
 /// <param name="group">The TechGroup in which the TechType is located.</param>
 /// <param name="category">The TechCategory in which the TechType is located.</param>
 /// <param name="techType">The TechType which you want to remove.</param>
 void ICraftDataHandler.RemoveFromGroup(TechGroup group, TechCategory category, TechType techType)
 {
     CraftDataPatcher.RemoveFromCustomGroup(group, category, techType);
 }
        public ActionResult Edit(int ProductID)
        {
            AddNewTechViewModel model = new AddNewTechViewModel();

            myHandler = new BusinessLogicHandler();
            gadget = new Technology();
            gadget = myHandler.GetTechnologyDetails(ProductID);

            model.techs = new Technology();
            model.techs = gadget;

            SupplierHandler supHandler = new SupplierHandler();
            /*TEMP LIST*/
            //List<Supplier> nameList = new List<Supplier>();
            IEnumerable<Supplier> nameList = (IEnumerable<Supplier>)supHandler.GetTechSupplierList();
            var disp = from nameAndId in nameList
                       select new { Value = nameAndId.SupplierID, Text = nameAndId.Name };

            ViewBag.SupplierList = new SelectList(disp.ToList());

            TechCategoryHandler typeHandler = new TechCategoryHandler();
            IEnumerable<TechCategory> typeList = (IEnumerable<TechCategory>)typeHandler.GetTechCategoryList();
            var dispTC = from name in typeList
                         select new { Value = name.TechCategoryID, Text = name.CategoryName };
            ViewBag.TechCategoryList = new SelectList(dispTC.ToList());

            ManufacturerHandler manHandler = new ManufacturerHandler();
            IEnumerable<Manufacturer> manList = (IEnumerable<Manufacturer>)manHandler.GetManufacturerList();
            var dispM = from mName in manList
                        select new { Value = mName.ManufacturerID, Text = mName.Name };
            ViewBag.ManufacturerList = new SelectList(dispM.ToList());

            model.techs = myHandler.GetTechnologyDetails(ProductID);
            Supplier sp = new Supplier();
            TechCategory tck = new TechCategory();
            Manufacturer mna = new Manufacturer();

            foreach (var item in manList)
            {
                if (item.ManufacturerID == model.techs.ManufacturerID)
                {
                    mna.ManufacturerID = item.ManufacturerID;
                    mna.Name = item.Name;
                }
            }
            foreach (var item in nameList)
            {
                if (item.SupplierID == model.techs.SupplierID)
                {
                    sp.SupplierID = item.SupplierID;
                    sp.Name = item.Name;
                }
            }
            foreach (var item in typeList)
            {
                if (item.TechCategoryID == model.techs.TechCategoryID)
                {
                    tck.TechCategoryID = item.TechCategoryID;
                    tck.CategoryName = item.CategoryName;
                }
            }

            List<SelectListItem> supplier = new List<SelectListItem>();
            supplier.Add(new SelectListItem { Value = sp.SupplierID.ToString(), Text = sp.Name, Selected = true });
            foreach (var item in nameList)
            {
                if (item.SupplierID != sp.SupplierID)
                    supplier.Add(new SelectListItem { Text = item.Name, Value = item.SupplierID.ToString() });
            }
            model.suppliers = new List<SelectListItem>();
            model.suppliers = supplier;
            ViewData["suppliers"] = supplier;

            List<SelectListItem> techCategory = new List<SelectListItem>();
            techCategory.Add(new SelectListItem { Value = tck.TechCategoryID.ToString(), Text = tck.CategoryName, Selected = true });
            foreach (var item in typeList)
            {
                if (item.TechCategoryID != tck.TechCategoryID)
                    techCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.TechCategoryID.ToString() });
            }
            model.techCategories = new List<SelectListItem>();
            model.techCategories = techCategory;
            ViewData["techCategories"] = techCategory;

            List<SelectListItem> manufacturer = new List<SelectListItem>();
            manufacturer.Add(new SelectListItem { Value = mna.ManufacturerID.ToString(), Text = mna.Name, Selected = true });
            foreach (var item in manList)
            {
                if (item.ManufacturerID != mna.ManufacturerID)
                    manufacturer.Add(new SelectListItem { Text = item.Name, Value = item.ManufacturerID.ToString() });
            }
            model.manufacturers = new List<SelectListItem>();
            model.manufacturers = manufacturer;
            ViewData["manufacturers"] = manufacturer;

            return View(model);
        }