@@ -140,7 +140,6 @@ private static bool FrameIsLevel(Frame frame)
140140 {
141141 return frame . GetType ( ) == typeof ( LevelFrame ) ;
142142 }
143-
144143 private void RenderMenuBar ( )
145144 {
146145 if ( ImGui . BeginMainMenuBar ( ) )
@@ -161,6 +160,11 @@ private void RenderMenuBar()
161160 AddFrame ( lf ) ;
162161 }
163162 }
163+ if ( ImGui . MenuItem ( "Open ps3data folder" ) )
164+ {
165+ var res = CrossFileDialog . OpenFolder ( ) ;
166+ if ( res . Length > 0 ) TryOpenFolder ( res ) ;
167+ }
164168
165169 if ( ImGui . MenuItem ( "Quit" ) )
166170 {
@@ -169,6 +173,40 @@ private void RenderMenuBar()
169173 ImGui . EndMenu ( ) ;
170174 }
171175
176+ // Put levels dropdown if it can find the game id in the path.
177+ // This is probably stupid.
178+ // Could probably be better to open the first engine.ps3 files it finds, and then from there maybe work out
179+ // what game it is, since there is a way to detect gametype in the engine parser?
180+ // Ahhhh.... I don't know.
181+ if ( activeGameId != null && rootFolder != null )
182+ {
183+ var names = LevelLists . GetLevelNames ( activeGameId , levelListsFolder ) ;
184+ if ( names != null && ImGui . BeginMenu ( "Levels" ) )
185+ {
186+ foreach ( var ( id , name ) in names . OrderBy ( x => x . Key ) )
187+ {
188+ string levelPath = Path . Join ( rootFolder , $ "level{ id } ", "engine.ps3" ) ;
189+ bool exists = File . Exists ( levelPath ) ;
190+
191+ if ( ! exists )
192+ ImGui . BeginDisabled ( ) ;
193+
194+ if ( ImGui . MenuItem ( name ) )
195+ {
196+ foreach ( var frame in openFrames . Where ( FrameIsLevel ) )
197+ frame . Dispose ( ) ;
198+
199+ openFrames . RemoveAll ( FrameIsLevel ) ;
200+ openFrames . Add ( new LevelFrame ( this , levelPath ) ) ;
201+ }
202+
203+ if ( ! exists )
204+ ImGui . EndDisabled ( ) ;
205+ }
206+ ImGui . EndMenu ( ) ;
207+ }
208+ }
209+
172210 if ( ImGui . BeginMenu ( "About" ) )
173211 {
174212 if ( ImGui . MenuItem ( "About Replanetizer" ) )
@@ -186,6 +224,19 @@ private void RenderMenuBar()
186224 }
187225 }
188226
227+ private string ? rootFolder = null ;
228+ private string ? activeGameId = null ;
229+ private string levelListsFolder = Path . Join ( AppContext . BaseDirectory , "LevelLists" ) ;
230+ private void TryOpenFolder ( string folder )
231+ {
232+ string ? gameId = LevelLists . DetectGameFile ( folder ) ;
233+ if ( gameId == null )
234+ return ;
235+
236+ rootFolder = folder ;
237+ activeGameId = gameId ;
238+ }
239+
189240 private void RenderUI ( float deltaTime )
190241 {
191242 RenderMenuBar ( ) ;
0 commit comments