Page 1 of 1

Clear Last Popup - Utility Function

Posted: Thu Oct 01, 2020 9:09 pm
by joshcamas
Since a lot of events (such as interactions and deaths) lead to popups that can't be modified, I made a little function that clears the last created popup. In my case, I'm using it to stop death popups and the "You see a " popup on interaction on a certain enemy. :) It would also be easy to go through the list and remove certain popups, if you wanted to do that.

Code: Select all

public static void ClearLastPopup()
        {
            var flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance;

            var popupField = typeof(DaggerfallHUD).GetField("popupText",flags);
            var dfHUD = typeof(DaggerfallUI).GetField("dfHUD", flags);
            var textRowsField = typeof(PopupText).GetField("textRows", flags);

            var hud = dfHUD.GetValue(DaggerfallUI.Instance);
            var popup = popupField.GetValue(hud);
            var textRows = (LinkedList<TextLabel>)textRowsField.GetValue(popup);

            if(textRows.Count > 0)
                    textRows.RemoveLast();
        }