|
1 | 1 | # ToolbarControl |
2 | 2 |
|
3 | 3 | An interface to control both the Blizzy Toolbar and the stock Toolbar without having to code for each one. |
| 4 | + |
| 5 | +// If true, activates Blizzy toolbar, if available. Otherwise, use the stock toolbar |
| 6 | +public void UseBlizzy(bool useBlizzy) |
| 7 | + |
| 8 | + |
| 9 | +// The TC_ClickHander is a delegate used to pass in a method reference in the AddToAllToolbars methods below |
| 10 | +public delegate void TC_ClickHandler(); |
| 11 | + |
| 12 | +The method AddToAllToolbars has several definitions. All parameters are the same, the only difference is that |
| 13 | +the shorter ones don't pass in unneeded parameters |
| 14 | + |
| 15 | +(Callback onTrue, Callback onFalse, Callback onHover, Callback onHoverOut, Callback onEnable, Callback onDisable, AppScenes visibleInScenes, Texture texture); |
| 16 | + |
| 17 | + |
| 18 | +Definitions |
| 19 | +=========== |
| 20 | +The onTrue parameter is unique in that it applies both to the stock toolbar and the Blizzy toolbar. |
| 21 | + onTrue Corresponds to the onTrue parameter in the AddModApplication function. This also corresponds to the |
| 22 | + blizzyButton.OnClick setting |
| 23 | + |
| 24 | +The following corresponds to the same parameter in the AddModApplication() method |
| 25 | + onFalse |
| 26 | + onHover |
| 27 | + onHoverOut |
| 28 | + onenable |
| 29 | + onDisable |
| 30 | + |
| 31 | + visibleInScenes The values are the same as stock ApplicationLauncher.AppScenes. The mod will use this to build the appropriate |
| 32 | + values for the Blizzy toolbar |
| 33 | + |
| 34 | +Icons |
| 35 | + largeToolbarIcon used for the stock toolbar |
| 36 | + smallToolbarIcon Used for the Blizzy toolbar |
| 37 | + |
| 38 | +If used, the following will be used to change the icon depending on whether it is active or not |
| 39 | + largeToolbarIconActive large is used for the stock toolbar |
| 40 | + largeToolbarIconInactive |
| 41 | + |
| 42 | + smallToolbarIconActive small is used for Blizzy toolbar |
| 43 | + smallToolbarIconInactive |
| 44 | + |
| 45 | +The following are used by the Blizzy toolbar only |
| 46 | + nameSpace Namespace of the mod |
| 47 | + toolbarId unique id for the toolbar |
| 48 | + tooltip tooltip which is shown when hovering the mouse over the button |
| 49 | + |
| 50 | + |
| 51 | +The following methods are available, more can be added if requested |
| 52 | + |
| 53 | +public void AddToAllToolbars(TC_ClickHandler onTrue, TC_ClickHandler onFalse, |
| 54 | + ApplicationLauncher.AppScenes visibleInScenes, |
| 55 | + string nameSpace, string toolbarId, |
| 56 | + string largeToolbarIcon, string smallToolbarIcon, |
| 57 | + string toolTip = "") |
| 58 | + |
| 59 | +public void AddToAllToolbars(TC_ClickHandler onTrue, TC_ClickHandler onFalse, |
| 60 | + ApplicationLauncher.AppScenes visibleInScenes, |
| 61 | + string nameSpace, string toolbarId, |
| 62 | + string largeToolbarIconActive, |
| 63 | + string largeToolbarIconInactive, |
| 64 | + string smallToolbarIconActive, |
| 65 | + string smallToolbarIconInactive, |
| 66 | + string toolTip = "") |
| 67 | + |
| 68 | +public void AddToAllToolbars(TC_ClickHandler onTrue, TC_ClickHandler onFalse, TC_ClickHandler onHover, TC_ClickHandler onHoverOut, TC_ClickHandler onEnable, TC_ClickHandler onDisable, |
| 69 | + ApplicationLauncher.AppScenes visibleInScenes, |
| 70 | + string nameSpace, string toolbarId, |
| 71 | + string largeToolbarIcon, string smallToolbarIcon, |
| 72 | + string toolTip = "") |
| 73 | + |
| 74 | +public void AddToAllToolbars(TC_ClickHandler onTrue, TC_ClickHandler onFalse, TC_ClickHandler onHover, TC_ClickHandler onHoverOut, TC_ClickHandler onEnable, TC_ClickHandler onDisable, |
| 75 | + ApplicationLauncher.AppScenes visibleInScenes, |
| 76 | + string nameSpace, string toolbarId, |
| 77 | + string largeToolbarIconActive, string largeToolbarIconInactive, string smallToolbarIconActive, string smallToolbarIconInactive, |
| 78 | + string toolTip = "") |
| 79 | + |
| 80 | + |
| 81 | +If you have the toolbar selectable in a settings page, you an ensure that any time the user changes the setting |
| 82 | +the toolbar will change immediately by adding the following (example from FlightPlanner): |
| 83 | + |
| 84 | + private void OnGUI() |
| 85 | + { |
| 86 | + toolbarControl.UseBlizzy(HighLogic.CurrentGame.Parameters.CustomParams<FP>().useBlizzy); |
| 87 | + } |
| 88 | + |
| 89 | +You can also add, if you like, various callbacks to monitor the settings. This is a very lightweight call, if |
| 90 | +there isn't any change, it returns immediately |
0 commit comments