Archomeda / csl-ambient-sounds-tuner

Tune your ambient sounds volumes individually
http://steamcommunity.com/sharedfiles/filedetails/?id=455958878
MIT License
9 stars 4 forks source link

Exception when enabling or disabling other mods while AST is enabled #35

Closed Archomeda closed 9 years ago

Archomeda commented 9 years ago

The following exception is thrown when enabling or disabling other mods while Ambient Sounds Tuner is enabled:

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component:get_gameObject ()
  at ColossalFramework.UI.UIComponent.GetUIView () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.Invalidate () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIPanel.ChildInvalidatedLayout () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIPanel.ChildIsVisibleChanged (ColossalFramework.UI.UIComponent child, Boolean value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.OnVisibilityChanged () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.set_isVisible (Boolean value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.Show () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIScrollbar.AutoHide () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIScrollbar.set_value (Single value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIScrollbar.set_maxValue (Single value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIScrollablePanel.UpdateScrollbars () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIScrollablePanel.ChildInvalidatedLayout () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIScrollablePanel.ChildInvalidated (ColossalFramework.UI.UIComponent child, Vector2 value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.OnSizeChanged () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.set_size (Vector2 value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.FitChildrenVertically (Single margin) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIPanel.AutoArrange () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIPanel.ChildInvalidatedLayout () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIPanel.ChildInvalidated (ColossalFramework.UI.UIComponent child, Vector2 value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.OnSizeChanged () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.set_size (Vector2 value) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIComponent.FitChildrenVertically (Single margin) [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIPanel.AutoArrange () [0x00000] in <filename unknown>:0 
  at ColossalFramework.UI.UIPanel.Update () [0x00000] in <filename unknown>:0 
Archomeda commented 9 years ago

It would seem that populating the options panel is indirectly causing the above mentioned exception. Every time a mod is disabled or enabled (doesn't matter which mod), every mod has to repopulate its options panel. It's doing fine the first time, and maybe the second time too, but after that, somehow certain values are completely different and this exception is thrown.

In UI.ModOptionsPanel under PopulateUI, the following lines cause this exception:

tabstrip.tabPages.size = new Vector2(
    groupParent.width - 20,
    this.RootPanelInnerArea.y - (groupParent.absolutePosition.y - this.RootPanel.absolutePosition.y) - (groupParent.height - tabstrip.tabPages.height)
);
versionLabel.relativePosition = new Vector3(this.RootPanel.width - versionLabel.size.x - 10, 0);

Somehow changing the size or relative position of a UI component is the cause of this issue.

My best guess is that this is an issue from the game engine itself, and not from AST, as I don't see what's going wrong here. Unless someone has a better idea of what's wrong, I can't fix it in a nice way. The only other way is to hard code the size and position, instead of adjusting it dynamically.

Archomeda commented 9 years ago

I've posted an similar issue on the Paradox forums in the hopes of getting the developers' attention, as I don't see this is caused by AST.