@@ -128,6 +128,12 @@ private void AddOptionsSection(TooltipPanel tooltipPanel)
128128 mainMenuList . Add ( spacer ) ;
129129 }
130130
131+ private int playerIndex = - 1 ;
132+ private int worldIndex = - 1 ;
133+
134+ public void UpdatePlayerIndex ( int index ) => playerIndex = index ;
135+ public void UpdateWorldIndex ( int index ) => worldIndex = index ;
136+
131137 private void AddSingleplayerSection ( TooltipPanel tooltipPanel )
132138 {
133139 // Load players and worlds for tooltips
@@ -144,22 +150,39 @@ private void AddSingleplayerSection(TooltipPanel tooltipPanel)
144150
145151 var singleplayerHeader = new HeaderMainMenuElement ( Loc . Get ( "MainMenu.SingleplayerHeader" ) , ( ) => Loc . Get ( "MainMenu.SingleplayerTooltip" ) , tooltipPanel ) ;
146152 var joinSingleplayer = new ActionMainMenuElement (
147- ( ) =>
148- {
149- ClientDataJsonHelper . ClientMode = ClientMode . SinglePlayer ;
150- ClientDataJsonHelper . PlayerPath = null ;
151- ClientDataJsonHelper . WorldPath = null ;
152- AutoloadPlayerInWorldSystem . EnterSingleplayerWorld ( ) ;
153- } ,
154- Loc . Get ( "MainMenu.JoinSingleplayerText" ) ,
155- ( ) =>
156- {
157- if ( string . IsNullOrEmpty ( playerName ) || string . IsNullOrEmpty ( worldName ) )
158- return Loc . Get ( "MainMenu.JoinSingleplayerTooltipNoData" ) ;
159- return Loc . Get ( "MainMenu.JoinSingleplayerTooltip" , $ "[c/FFFF00:{ playerName } ]", $ "[c/FFFF00:{ worldName } ]") ;
160- } ,
161- tooltipPanel
162- ) ;
153+ ( ) =>
154+ {
155+ ClientDataJsonHelper . ClientMode = ClientMode . SinglePlayer ;
156+ ClientDataJsonHelper . PlayerPath = null ;
157+ ClientDataJsonHelper . WorldPath = null ;
158+ AutoloadPlayerInWorldSystem . EnterSingleplayerWorld ( ) ;
159+ } ,
160+ Loc . Get ( "MainMenu.JoinSingleplayerText" ) ,
161+ ( ) =>
162+ {
163+ Main . LoadPlayers ( ) ;
164+ Main . LoadWorlds ( ) ;
165+
166+ int playerIdx = Utilities . FindPlayerId ( Conf . C . Player ) ;
167+ int worldIdx = Utilities . FindWorldId ( Conf . C . World ) ;
168+
169+ string pName = ( playerIdx >= 0 && playerIdx < Main . PlayerList . Count )
170+ ? Main . PlayerList [ playerIdx ] . Name
171+ : "" ;
172+ string wName = ( worldIdx >= 0 && worldIdx < Main . WorldList . Count )
173+ ? Main . WorldList [ worldIdx ] . Name
174+ : "" ;
175+
176+ if ( string . IsNullOrEmpty ( pName ) || string . IsNullOrEmpty ( wName ) )
177+ return Loc . Get ( "MainMenu.JoinSingleplayerTooltipNoData" ) ;
178+
179+ return Loc . Get ( "MainMenu.JoinSingleplayerTooltip" ,
180+ $ "[c/FFFF00:{ pName } ]",
181+ $ "[c/FFFF00:{ wName } ]") ;
182+ } ,
183+ tooltipPanel
184+ ) ;
185+
163186 var spacer = new SpacerMainMenuElement ( ) ;
164187 mainMenuList . Add ( singleplayerHeader ) ;
165188 mainMenuList . Add ( joinSingleplayer ) ;
@@ -214,13 +237,6 @@ public override void Draw(SpriteBatch spriteBatch)
214237 //DrawActionRowsDebug(spriteBatch);
215238 }
216239
217- private void PositionTooltip ( )
218- {
219- // tooltipPanel.Left.Set(15 + 3, 0f);
220- // tooltipPanel.Top.Set(470f, 0f); // 6 px under the list
221- // tooltipPanel.Recalculate();
222- }
223-
224240 public override void Update ( GameTime gameTime )
225241 {
226242 base . Update ( gameTime ) ;
0 commit comments