Ejemplo n.º 1
0
        private void DrawModCategory(Rect entryRect, ModCategory m)
        {
            try
            {
                GUI.BeginGroup(entryRect);

                float curY    = 0f;
                Rect  modRect = new Rect(0f, 0f, entryRect.width, EntryHeight);
                DrawModRow(modRect, m);
                curY += EntryHeight;
                if (m.Expanded)
                {
                    foreach (var cat in m.HelpCategories)
                    {
                        Rect catRect = new Rect(0f, curY, entryRect.width, cat.DrawHeight);
                        DrawHelpCategory(catRect, cat);
                        curY += cat.DrawHeight;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error("Exception drawing mod category: " + m.ModName + "\n" + e.ToString());
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Ejemplo n.º 2
0
        private void DrawModRow(Rect modRect, ModCategory mod)
        {
            try
            {
                GUI.BeginGroup(modRect);

                if (modRect.Contains(Event.current.mousePosition))
                {
                    Widgets.DrawHighlight(modRect);
                }

                Rect      imageRect = new Rect(Margin, modRect.height / 2f - ArrowImageSize.y / 2f, ArrowImageSize.x, ArrowImageSize.y);
                Texture2D texture   = mod.Expanded ? ArrowUpTex : ArrowDownTex;
                GUI.DrawTexture(imageRect, texture);

                Rect labelRect = new Rect(imageRect.xMax + Margin, 0f, modRect.width - ArrowImageSize.x - Margin * 2, EntryHeight);
                Text.Anchor = TextAnchor.MiddleLeft;
                GUI.color   = Color.yellow;
                Text.Font   = GameFont.Medium;
                Widgets.Label(labelRect, mod.ModName);
                Text.Font   = GameFont.Small;
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;

                if (Widgets.InvisibleButton(modRect))
                {
                    mod.Expanded = !mod.Expanded;
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Ejemplo n.º 3
0
        public static bool IsExclusiveMod(this ModCategory category)
        {
            var cat    = typeof(ModCategory).GetMember(category.ToString());
            var valmem = cat.FirstOrDefault(x => x.DeclaringType == typeof(ModCategory));

            return(valmem.GetCustomAttributes(typeof(ExclusiveModAttribute), false).Any());
        }
Ejemplo n.º 4
0
        internal void LoadModActions(IQueryAdapter dbClient)
        {
            ModCategories = new Dictionary <uint, ModCategory>();

            dbClient.setQuery("SELECT * FROM moderation_categories");
            foreach (DataRow dRow in dbClient.getTable().Rows)
            {
                uint   id          = Convert.ToUInt32(dRow["id"]);
                uint   parentId    = Convert.ToUInt32(dRow["parent_id"]);
                string topicName   = (string)dRow["topicName"];
                uint   topicId     = Convert.ToUInt32(dRow["topicId"]);
                string topicAction = (string)dRow["topicAction"];

                if (parentId == 0) // main case:
                {
                    ModCategory modCategory = new ModCategory(id, topicName);
                    ModCategories.Add(id, modCategory);
                }
                else
                {
                    if (ModCategories.ContainsKey(parentId))
                    {
                        ModCategories[parentId].AddSubCategory(topicId, topicName, topicAction);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        void DrawModRow(Rect modRect, ModCategory mod)
        {
            GUI.BeginGroup(modRect);

            if (modRect.Contains(Event.current.mousePosition))
            {
                Widgets.DrawHighlight(modRect);
            }

            var imageRect = new Rect(
                Margin, modRect.height / 2f - ArrowImageSize.y / 2f,
                ArrowImageSize.x, ArrowImageSize.y);

            Texture2D texture = mod.Expanded ? Icon.HelpMenuArrowUp : Icon.HelpMenuArrowDown;

            GUI.DrawTexture(imageRect, texture);

            var labelRect = new Rect(
                imageRect.xMax + Margin, 0f,
                modRect.width - ArrowImageSize.x - Margin * 2, EntryHeight);

            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = Color.yellow;
            Widgets.Label(labelRect, mod.ModName);
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;

            if (Widgets.InvisibleButton(modRect))
            {
                mod.Expanded = !mod.Expanded;
            }
            GUI.EndGroup();
        }
Ejemplo n.º 6
0
 public ModInfo(string name, string author, string version, string description, ModCategory category)
 {
     this.Name        = name;
     this.Author      = author;
     this.Version     = version;
     this.Description = description;
     this.Category    = category;
 }
 /// <summary>
 /// Update the category in the TreeListView.
 /// </summary>
 /// <param name="p_mctCategory">The category to update.</param>
 /// <param name="strOldValue">The previous category name.</param>
 public void UpdateData(ModCategory p_mctCategory, string strOldValue)
 {
     if (this.Items.Count > 0)
     {
         SetupContextMenu();
         //RefreshObject(p_mctCategory);
     }
 }
Ejemplo n.º 8
0
        public void DrawModEntry(ref Vector2 cur, int nestLevel, Rect view, ModCategory mc)
        {
            State curState = mc.Expanded ? State.Expanded : State.Closed;

            if (DrawEntry(ref cur, nestLevel, view, mc.ModName, curState))
            {
                mc.Expanded = !mc.Expanded;
            }
        }
Ejemplo n.º 9
0
 public ModListing(ModCategory category)
 {
     InitializeComponent();
     ModRepository.Instance.InstalledModsUpdated += () => App.RunInMainThread(Update);
     _category                = category;
     CategoryTitle.Text       = category.Name;
     CategoryDescription.Text = category.Description;
     Update();
 }
Ejemplo n.º 10
0
        public void JumpTo(HelpDef helpDef)
        {
            Find.MainTabsRoot.SetCurrentTab(this.def);
            ResetFilter();
            _jump           = true;
            SelectedHelpDef = helpDef;
            HelpCategoryDef cat = DefDatabase <HelpCategoryDef> .AllDefsListForReading.First(hc => hc.HelpDefs.Contains(helpDef));

            cat.Expanded = true;
            ModCategory mod = CachedHelpCategories.First(mc => mc.HelpCategories.Contains(cat));

            mod.Expanded = true;
        }
        /// <summary>
        /// Adds a new category to the TreeListView.
        /// </summary>
        /// <param name="p_imcCategory">The category to add to the roots list.</param>
        /// <param name="booIsNew">Whether the category is new or was just hidden.</param>
        public void AddData(IModCategory p_imcCategory, bool booIsNew)
        {
            ModCategory Category = new ModCategory(p_imcCategory);

            if (CategoryModeEnabled)
            {
                this.AddObject(Category);
                ApplyFilters(Category);
                if (this.Items.Count > 0)
                {
                    this.EnsureVisible(this.Items.Count - 1);
                }
            }
        }
Ejemplo n.º 12
0
 public void Reinit()
 {
     _cachedHelpCategories = new List<ModCategory>();
     foreach (var cat in DefDatabase<HelpCategoryDef>.AllDefs)
     {
         if (!_cachedHelpCategories.Any((t) => t.ModName == cat.ModName))
         {
             ModCategory mCat = new ModCategory(cat.ModName);
             mCat.AddCategory(cat);
             _cachedHelpCategories.Add(mCat);
         }
         else
         {
             ModCategory mCat = _cachedHelpCategories.Find((t) => t.ModName == cat.ModName);
             mCat.AddCategory(cat);
         }
     }
 }
Ejemplo n.º 13
0
 public void Reinit()
 {
     _cachedHelpCategories = new List <ModCategory>();
     foreach (var cat in DefDatabase <HelpCategoryDef> .AllDefs)
     {
         if (!_cachedHelpCategories.Any((t) => t.ModName == cat.ModName))
         {
             ModCategory mCat = new ModCategory(cat.ModName);
             mCat.AddCategory(cat);
             _cachedHelpCategories.Add(mCat);
         }
         else
         {
             ModCategory mCat = _cachedHelpCategories.Find((t) => t.ModName == cat.ModName);
             mCat.AddCategory(cat);
         }
     }
 }
        /// <summary>
        /// Refresh the category in the TreeListView.
        /// </summary>
        /// <param name="p_mctCategory">The category to refresh.</param>
        public bool RefreshData(ModCategory p_mctCategory)
        {
            if (CategoryModeEnabled)
            {
                if (this.Items.Count > 0)
                {
                    foreach (object Item in Roots)
                    {
                        if (((ModCategory)Item).Equals(p_mctCategory))
                        {
                            //RefreshObject(p_mctCategory);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// Applies the default list filters
        /// </summary>
        private void ApplyFilters(ModCategory p_mctModCategory)
        {
            this.ModelFilter = new ModelFilter(delegate(object x)
            {
                if ((x.GetType() == typeof(ModCategory)) && !ShowHiddenCategories)
                {
                    if ((p_mctModCategory != null) && ((ModCategory)x == p_mctModCategory))
                    {
                        return(true);
                    }
                    else if ((Categories.Count > 1) && (GetCategoryModCount((ModCategory)x) <= 0))
                    {
                        return(false);
                    }
                }

                return(true);
            });
        }
Ejemplo n.º 16
0
        void DrawModCategory(Rect entryRect, ModCategory m)
        {
            GUI.BeginGroup(entryRect);

            float curY    = 0f;
            var   modRect = new Rect(0f, 0f, entryRect.width, EntryHeight);

            DrawModRow(modRect, m);
            curY += EntryHeight;
            if (m.Expanded)
            {
                foreach (var cat in m.HelpCategories)
                {
                    var catRect = new Rect(0f, curY, entryRect.width, cat.DrawHeight);
                    DrawHelpCategory(catRect, cat);
                    curY += cat.DrawHeight;
                }
            }
            GUI.EndGroup();
        }
Ejemplo n.º 17
0
 public static void Recache()
 {
     CachedHelpCategories = new List <ModCategory>();
     foreach (var helpCategory in DefDatabase <HelpCategoryDef> .AllDefs)
     {
         // parent modcategory does not exist, create it.
         if (CachedHelpCategories.All(t => t.ModName != helpCategory.ModName))
         {
             var mCat = new ModCategory(helpCategory.ModName);
             mCat.AddCategory(helpCategory);
             CachedHelpCategories.Add(mCat);
         }
         // add to existing modcategory
         else
         {
             var mCat = CachedHelpCategories.Find(t => t.ModName == helpCategory.ModName);
             mCat.AddCategory(helpCategory);
         }
     }
 }
Ejemplo n.º 18
0
        public static IEnumerable <ModListBoxItem> GetModItems(string path, ModCategory category)
        {
            foreach (string subDir in Directory.GetDirectories(path))
            {
                ModListBoxItem modItem = new ModListBoxItem();

                modItem.ModPath  = subDir;
                modItem.Category = category;
                modItem.ModName  = GetModName(subDir);
                //modItem.IsCleanMode = false;
                if (System.IO.Path.GetFileName(subDir) == "Core")
                {
                    modItem.GenerateOption = GenerateMode.Core;
                }
                else
                {
                    modItem.GenerateOption = GenerateMode.Standard;
                }

                yield return(modItem);
            }
        }
Ejemplo n.º 19
0
        private void Reinit()
        {
            //Set whether the window forces a pause
            if (TabDef != null)
            {
                this.forcePause = TabDef.pauseGame;
            }

            _cachedHelpCategories = new List <ModCategory>();
            foreach (var cat in DefDatabase <HelpCategoryDef> .AllDefs)
            {
                if (_cachedHelpCategories.All(t => t.ModName != cat.ModName))
                {
                    var mCat = new ModCategory(cat.ModName);
                    mCat.AddCategory(cat);
                    _cachedHelpCategories.Add(mCat);
                }
                else
                {
                    var mCat = _cachedHelpCategories.Find(t => t.ModName == cat.ModName);
                    mCat.AddCategory(cat);
                }
            }
        }
Ejemplo n.º 20
0
		/// <summary>
		/// Adds a new category to the TreeListView.
		/// </summary>
		/// <param name="p_imcCategory">The category to add to the roots list.</param>
		/// <param name="booIsNew">Whether the category is new or was just hidden.</param>
		public void AddData(IModCategory p_imcCategory, bool booIsNew)
		{
			ModCategory Category = new ModCategory(p_imcCategory);
			if (CategoryModeEnabled)
			{
				this.AddObject(Category);
				ApplyFilters(Category);
				if (this.Items.Count > 0)
					this.EnsureVisible(this.Items.Count - 1);
			}
		}
        void DrawModCategory(Rect entryRect, ModCategory m)
        {
            GUI.BeginGroup(entryRect);

            float curY = 0f;
            var modRect = new Rect(0f, 0f, entryRect.width, EntryHeight);
            DrawModRow(modRect, m);
            curY += EntryHeight;
            if (m.Expanded)
            {
                foreach (var cat in m.HelpCategories)
                {
                    var catRect = new Rect(0f, curY, entryRect.width, cat.DrawHeight);
                    DrawHelpCategory(catRect, cat);
                    curY += cat.DrawHeight;
                }
            }
            GUI.EndGroup();
        }
Ejemplo n.º 22
0
		/// <summary>
		/// Applies the default list filters
		/// </summary>
		private void ApplyFilters(ModCategory p_mctModCategory)
		{
			this.ModelFilter = new ModelFilter(delegate(object x)
			{
				if ((x.GetType() == typeof(ModCategory)) && !ShowHiddenCategories)
					if ((p_mctModCategory != null) && ((ModCategory)x == p_mctModCategory))
						return true;
					else if ((Categories.Count > 1) && (GetCategoryModCount((ModCategory)x) <= 0))
						return false;

				return true;
			});
		}
        void DrawModRow(Rect modRect, ModCategory mod)
        {
            GUI.BeginGroup(modRect);

            if (modRect.Contains(Event.current.mousePosition))
            {
                Widgets.DrawHighlight(modRect);
            }

            var imageRect = new Rect(
                Margin, modRect.height / 2f - ArrowImageSize.y / 2f,
                ArrowImageSize.x, ArrowImageSize.y);

            Texture2D texture = mod.Expanded ? Icon.HelpMenuArrowUp : Icon.HelpMenuArrowDown;
            GUI.DrawTexture(imageRect, texture);

            var labelRect = new Rect(
                imageRect.xMax + Margin, 0f,
                modRect.width - ArrowImageSize.x - Margin * 2, EntryHeight);

            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color = Color.yellow;
            Widgets.Label(labelRect, mod.ModName);
            GUI.color = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;

            if (Widgets.InvisibleButton(modRect))
            {
                mod.Expanded = !mod.Expanded;
            }
            GUI.EndGroup();
        }
 public void DrawModEntry( ref Vector2 cur, int nestLevel, Rect view, ModCategory mc )
 {
     State curState = mc.Expanded ? State.Expanded : State.Closed;
     if( DrawEntry( ref cur, nestLevel, view, mc.ModName, curState ) )
     {
         mc.Expanded = !mc.Expanded;
     }
 }
Ejemplo n.º 25
0
		/// <summary>
		/// Refresh the category in the TreeListView.
		/// </summary>
		/// <param name="p_mctCategory">The category to refresh.</param>
		public bool RefreshData(ModCategory p_mctCategory)
		{
			if (CategoryModeEnabled)
				if (this.Items.Count > 0)
					foreach (object Item in Roots)
						if (((ModCategory)Item).Equals(p_mctCategory))
						{
							//RefreshObject(p_mctCategory);
							return true;
						}

			return false;
		}
Ejemplo n.º 26
0
		/// <summary>
		/// Update the category in the TreeListView.
		/// </summary>
		/// <param name="p_mctCategory">The category to update.</param>
		/// <param name="strOldValue">The previous category name.</param>
		public void UpdateData(ModCategory p_mctCategory, string strOldValue)
		{
			if (this.Items.Count > 0)
			{
				SetupContextMenu();
				//RefreshObject(p_mctCategory);
			}
		}
Ejemplo n.º 27
0
 /// <summary>
 /// Returns <paramref name="category"/> as an int
 /// </summary>
 public static int Get(ModCategory category)
 {
     return((int)category);
 }
Ejemplo n.º 28
0
        private void DrawModCategory(Rect entryRect, ModCategory m)
        {
            try
            {
                GUI.BeginGroup(entryRect);

                float curY = 0f;
                Rect modRect = new Rect(0f, 0f, entryRect.width, EntryHeight);
                DrawModRow(modRect, m);
                curY += EntryHeight;
                if (m.Expanded)
                {
                    foreach (var cat in m.HelpCategories)
                    {
                        Rect catRect = new Rect(0f, curY, entryRect.width, cat.DrawHeight);
                        DrawHelpCategory(catRect, cat);
                        curY += cat.DrawHeight;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error("Exception drawing mod category: " + m.ModName + "\n" + e.ToString());
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Ejemplo n.º 29
0
        private void DrawModRow(Rect modRect, ModCategory mod)
        {
            try
            {
                GUI.BeginGroup(modRect);

                if (modRect.Contains(Event.current.mousePosition))
                    Widgets.DrawHighlight(modRect);

                Rect imageRect = new Rect(Margin, modRect.height / 2f - ArrowImageSize.y / 2f, ArrowImageSize.x, ArrowImageSize.y);
                Texture2D texture = mod.Expanded ? ArrowUpTex : ArrowDownTex;
                GUI.DrawTexture(imageRect, texture);

                Rect labelRect = new Rect(imageRect.xMax + Margin, 0f, modRect.width - ArrowImageSize.x - Margin * 2, EntryHeight);
                Text.Anchor = TextAnchor.MiddleLeft;
                GUI.color = Color.yellow;
                Text.Font = GameFont.Medium;
                Widgets.Label(labelRect, mod.ModName);
                Text.Font = GameFont.Small;
                GUI.color = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;

                if (Widgets.InvisibleButton(modRect))
                {
                    mod.Expanded = !mod.Expanded;
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
        private void Reinit()
        {
            //Set whether the window forces a pause
            if (TabDef != null)
            {
                this.forcePause = TabDef.pauseGame;
            }

            _cachedHelpCategories = new List<ModCategory>();
            foreach (var cat in DefDatabase<HelpCategoryDef>.AllDefs)
            {
                if (_cachedHelpCategories.All(t => t.ModName != cat.ModName))
                {
                    var mCat = new ModCategory(cat.ModName);
                    mCat.AddCategory(cat);
                    _cachedHelpCategories.Add(mCat);
                }
                else
                {
                    var mCat = _cachedHelpCategories.Find(t => t.ModName == cat.ModName);
                    mCat.AddCategory(cat);
                }
            }
        }
Ejemplo n.º 31
0
        public void PopulateProperties()
        {
            Props.Clear();

            // Populate property list automatically from namespace
            Assembly asm = assembly;

            string nameSpace = GetType().Namespace;

            foreach (Type type in asm.GetTypes())
            {
                if (!string.IsNullOrEmpty(type.Namespace) && type.Namespace.Contains(nameSpace))
                {
                    foreach (FieldInfo field in type.GetFields())
                    {
                        if (field.FieldType.IsSubclassOf(typeof(ModPropertyBase)))
                        {
                            Props.Add((ModPropertyBase)field.GetValue(null));

                            Props[Props.Count - 1].ResetToDefault();

                            if (Props[Props.Count - 1].Category == null)
                            {
                                ModCategory chunkAttr = (ModCategory)field.GetCustomAttribute(typeof(ModCategory), false);
                                if (chunkAttr != null)
                                {
                                    Props[Props.Count - 1].Category = chunkAttr.ID;
                                }
                                else
                                {
                                    ModCategory typeAttr = (ModCategory)field.DeclaringType.GetCustomAttribute(typeof(ModCategory), false);
                                    if (typeAttr != null)
                                    {
                                        Props[Props.Count - 1].Category = typeAttr.ID;
                                    }
                                    else
                                    {
                                        Props[Props.Count - 1].Category = 0;
                                    }
                                }
                            }

                            if (string.IsNullOrWhiteSpace(Props[Props.Count - 1].Name))
                            {
                                Props[Props.Count - 1].Name = field.Name;
                            }
                            if (Game.TextClass != null)
                            {
                                foreach (MethodInfo text in Game.TextClass.GetRuntimeMethods())
                                {
                                    if (text.Name == "get_" + field.Name)
                                    {
                                        Props[Props.Count - 1].Name = (string)text.Invoke(null, null);
                                    }
                                    else if (text.Name == "get_" + field.Name + "Desc")
                                    {
                                        Props[Props.Count - 1].Description = (string)text.Invoke(null, null);
                                    }
                                }
                            }
                            Props[Props.Count - 1].CodeName = field.Name;
                        }
                    }
                }
            }
        }
 public static void Recache()
 {
     CachedHelpCategories = new List<ModCategory>();
     foreach( var helpCategory in DefDatabase<HelpCategoryDef>.AllDefs )
     {
         // parent modcategory does not exist, create it.
         if( CachedHelpCategories.All( t => t.ModName != helpCategory.ModName ) )
         {
             var mCat = new ModCategory( helpCategory.ModName );
             mCat.AddCategory( helpCategory );
             CachedHelpCategories.Add( mCat );
         }
         // add to existing modcategory
         else
         {
             var mCat = CachedHelpCategories.Find( t => t.ModName == helpCategory.ModName );
             mCat.AddCategory( helpCategory );
         }
     }
 }
 public static void Recache()
 {
     _cachedHelpCategories = new List<ModCategory>();
     foreach (var cat in DefDatabase<HelpCategoryDef>.AllDefs)
     {
         if (_cachedHelpCategories.All(t => t.ModName != cat.ModName))
         {
             var mCat = new ModCategory(cat.ModName);
             mCat.AddCategory(cat);
             _cachedHelpCategories.Add(mCat);
         }
         else
         {
             var mCat = _cachedHelpCategories.Find(t => t.ModName == cat.ModName);
             mCat.AddCategory(cat);
         }
     }
 }