66using ColossalFramework . UI ;
77using CSM . API ;
88using CSM . Helpers ;
9+ using CSM . Mods ;
910using UnityEngine ;
1011
1112namespace CSM . Panels
@@ -17,8 +18,10 @@ public class MessagePanel : UIPanel
1718 private string _title ;
1819 private string _message ;
1920
20- private UIButton _closeButton , _githubButton ;
21- private bool _githubShown = false ;
21+ private UIButton _closeButton , _actionButton ;
22+ private bool _actionButtonShown ;
23+ private string _actionButtonLabel = "Open Link" ;
24+ private Action _actionButtonHandler ;
2225
2326 public override void Start ( )
2427 {
@@ -49,13 +52,10 @@ public override void Start()
4952
5053 this . AddScrollbar ( messagePanel ) ;
5154
52- // Github button
53- _githubButton = this . CreateButton ( "Open GitHub" , new Vector2 ( 60 , - 340 ) ) ;
54- _githubButton . eventClicked += ( c , p ) =>
55- {
56- Process . Start ( "https://github.com/CitiesSkylinesMultiplayer/CSM/releases" ) ;
57- } ;
58- _githubButton . isVisible = _githubShown ;
55+ // Generic action button (e.g. open links)
56+ _actionButton = this . CreateButton ( _actionButtonLabel , new Vector2 ( 60 , - 340 ) ) ;
57+ _actionButton . eventClicked += ( c , p ) => _actionButtonHandler ? . Invoke ( ) ;
58+ _actionButton . isVisible = _actionButtonShown ;
5959
6060 // Close button
6161 _closeButton = this . CreateButton ( "Close" , new Vector2 ( 60 , - 410 ) ) ;
@@ -83,8 +83,29 @@ private void SetMessage(string message)
8383 if ( _messageLabel )
8484 _messageLabel . text = message ;
8585
86- if ( _githubButton )
87- _githubButton . Hide ( ) ;
86+ HideActionButton ( ) ;
87+ }
88+
89+ private void HideActionButton ( )
90+ {
91+ _actionButtonShown = false ;
92+ _actionButtonHandler = null ;
93+
94+ if ( _actionButton )
95+ _actionButton . Hide ( ) ;
96+ }
97+
98+ private void ShowActionButton ( string label , Action handler )
99+ {
100+ _actionButtonLabel = label ;
101+ _actionButtonHandler = handler ;
102+ _actionButtonShown = true ;
103+
104+ if ( _actionButton )
105+ {
106+ _actionButton . text = _actionButtonLabel ;
107+ _actionButton . Show ( ) ;
108+ }
88109 }
89110
90111 public void DisplayInvalidApiServer ( )
@@ -203,9 +224,7 @@ public void DisplayUpdateAvailable(Version current, Version latest)
203224 "CSM/releases" ;
204225 SetMessage ( message ) ;
205226
206- _githubShown = true ;
207- if ( _githubButton )
208- _githubButton . Show ( ) ;
227+ ShowActionButton ( "Open GitHub" , ( ) => Process . Start ( "https://github.com/CitiesSkylinesMultiplayer/CSM/releases" ) ) ;
209228
210229 Show ( true ) ;
211230 }
@@ -221,6 +240,25 @@ public void DisplayNoUpdateAvailable()
221240 Show ( true ) ;
222241 }
223242
243+ public void DisplayTmpeSyncRequirement ( )
244+ {
245+ SetTitle ( "TM:PE support requires an addon" ) ;
246+
247+ string message = "Traffic Manager: President Edition is currently\n " +
248+ "marked as unsupported in multiplayer because the\n " +
249+ "required CSM.TmpeSync addon is not enabled.\n \n " +
250+ "If you want to play with supported TM:PE, please\n " +
251+ "subscribe to the \" CSM.TmpeSync\" addon from the\n " +
252+ "Steam Workshop and enable it ingame.\n \n " +
253+ "Use the button below to open the workshop page\n " +
254+ "in the Steam overlay." ;
255+ SetMessage ( message ) ;
256+
257+ ShowActionButton ( "Subscribe" , ( ) => SteamHelpers . OpenOverlayToUrl ( TmpeSupportHelper . TmpeSyncWorkshopLink ) ) ;
258+
259+ Show ( true ) ;
260+ }
261+
224262 public void DisplayTroubleshooting ( bool isHost , int port = 4230 , bool hasVpn = false )
225263 {
226264 SetTitle ( "Troubleshooting" ) ;
0 commit comments