mirror of
				https://github.com/Strongleong/ScrapModLoader.git
				synced 2024-08-15 00:03:19 +00:00 
			
		
		
		
	Addeed ability to load mods
This commit is contained in:
		
							parent
							
								
									4d34f4eaa6
								
							
						
					
					
						commit
						cb4c8ac90d
					
				
					 4 changed files with 32 additions and 4 deletions
				
			
		|  | @ -55,9 +55,9 @@ | |||
|                     </TabControl> | ||||
|                 </Grid> | ||||
|             </TabItem> | ||||
|             <TabItem Header="Settings" Height="22" Margin="-2,0,-2,0" VerticalAlignment="Bottom"> | ||||
|             <!--<TabItem Header="Settings" Height="22" Margin="-2,0,-2,0" VerticalAlignment="Bottom"> | ||||
|                 <Grid Background="#FEFEFE"/> | ||||
|             </TabItem> | ||||
|             </TabItem>--> | ||||
|         </TabControl> | ||||
|         <Grid Grid.Row="1" Margin="10,10,10,10"> | ||||
|             <Grid.ColumnDefinitions> | ||||
|  |  | |||
|  | @ -157,14 +157,17 @@ namespace ScrapModLoader | |||
| 
 | ||||
|         private void ButtonRunScrapland_Click(Object sender, RoutedEventArgs e) | ||||
|         { | ||||
|             String executablePath = ScraplandVersion.SelectedIndex == 0  | ||||
| 
 | ||||
|             String gamePath = ScraplandVersion.SelectedIndex == 0  | ||||
|                 ? modsLauncher.ScraplandPath : modsLauncher.ScraplandRemasteredPath; | ||||
| 
 | ||||
|             modsLauncher.LoadMods(gamePath); | ||||
| 
 | ||||
|             String args = "-fullscreen:1"; | ||||
|             if (Windowed.IsChecked ?? false) | ||||
|                 args = "-fullscreen:0"; | ||||
| 
 | ||||
|             Process.Start(executablePath + @"\bin\Scrap.exe", args); | ||||
|             Process.Start(gamePath + @"\bin\Scrap.exe", args); | ||||
| 
 | ||||
|             if (CloseLauncher.IsChecked ?? false) | ||||
|                 Close(); | ||||
|  |  | |||
|  | @ -2,6 +2,8 @@ | |||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| 
 | ||||
| using Ionic.Zip; | ||||
| 
 | ||||
| using Microsoft.Win32; | ||||
| 
 | ||||
| namespace ScrapModLoader | ||||
|  | @ -75,5 +77,11 @@ namespace ScrapModLoader | |||
| 
 | ||||
|             return isFound; | ||||
|         } | ||||
| 
 | ||||
|         internal void LoadMods(String gamePath) | ||||
|         { | ||||
|             foreach (ScrapMod mod in Mods.FindAll(mod => mod.Checked)) | ||||
|                 mod.LoadModToGame(gamePath); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -38,6 +38,23 @@ namespace ScrapModLoader | |||
|             LoadFromFile(path); | ||||
|         } | ||||
| 
 | ||||
|         public void LoadModToGame(String gamePath) | ||||
|         { | ||||
|             gamePath += @"Mods\" + Name; | ||||
|             Directory.CreateDirectory(gamePath); | ||||
| 
 | ||||
|             using (ZipFile zipFile = ZipFile.Read(ModPath)) | ||||
|             { | ||||
|                 foreach (ZipEntry zipEntry in zipFile) | ||||
|                 { | ||||
|                     if (Path.GetExtension(zipEntry.FileName) == ".packed") | ||||
|                     { | ||||
|                         zipEntry.Extract(gamePath); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         private void LoadFromFile(String path) | ||||
|         { | ||||
|             using (ZipFile zipFile = ZipFile.Read(path)) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue