Skip to content

Commit

Permalink
Merge pull request tgstation#10312 from CorruptComputer/morethan1
Browse files Browse the repository at this point in the history
Selecting Multiple files with new map merger
  • Loading branch information
Cheridan committed Jul 3, 2015
2 parents dc4f192 + 473eaf8 commit 1e28365
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 30 deletions.
Binary file modified tools/mapmerge/MapMerge.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/mapmerge/Run Map Merge.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off

java -jar ../../tools/mapmerge/MapMerge.jar
java -jar MapMerge.jar ../../_maps/

pause
2 changes: 1 addition & 1 deletion tools/mapmerge/Source/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="E:/-tg-station/tools/mapmerge/MapPatcher.jar"/>
<classpathentry kind="lib" path="src/MapPatcher.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file modified tools/mapmerge/Source/bin/MapMergerMain.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tools/mapmerge/Source/bin/MapPatcher.jar
Binary file not shown.
95 changes: 67 additions & 28 deletions tools/mapmerge/Source/src/MapMergerMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,88 @@ public class MapMergerMain {

private static Scanner input = new Scanner(System.in);

public static void main(String[] args) throws IOException{

System.out.print("Path to _maps folder: ");
String pathTo_maps = input.nextLine();
Path fileDir = Paths.get(pathTo_maps);
FileFinder finder = new FileFinder("*.dmm");
Files.walkFileTree(fileDir, finder);
ArrayList<Path> foundFiles = finder.foundPaths;
public static void main(String[] mapPath) throws IOException{
Path pathToMaps = Paths.get(mapPath[0]);
FileFinder dmmFinder = new FileFinder("*.dmm");
Files.walkFileTree(pathToMaps, dmmFinder);
ArrayList<Path> foundFiles = dmmFinder.foundPaths;
if (foundFiles.size() > 0) {
for(int num = 0;num < foundFiles.size();num++){
System.out.println(num + ": " + foundFiles.get(num));
}
try{
merge(foundFiles);
}catch(Exception e){
System.out.println("Something went wrong.");
e.printStackTrace();
}
}else{
System.out.println("No files were found!");
System.out.println("No files were found in provided directory!");
System.out.print("Path to maps folder: ");
pathToMaps = Paths.get(input.nextLine());
dmmFinder = new FileFinder("*.dmm");
Files.walkFileTree(pathToMaps, dmmFinder);
foundFiles = dmmFinder.foundPaths;
try{
merge(foundFiles);
}catch(Exception e){
System.out.println("Something went wrong.");
e.printStackTrace();
}
}
System.out.print("File to use: ");
int selection;
}


public static void merge(ArrayList<Path> foundFiles){

System.out.println("How many files do you want to merge?");
int selection1;
inputCheck:while(true){
while(!input.hasNextInt()){
String temp = input.next();
System.out.println(temp + " is not a valid int.");
}
selection = input.nextInt();
if(selection < 0 || selection >= foundFiles.size()){
if(selection < 0){
selection1 = input.nextInt();
if(selection1 < 0){
System.out.println("Use a number greater than 0!");
}else{
System.out.println("Use a number less than " + foundFiles.size() +"!");
}
continue inputCheck;
}else{
break inputCheck;
}
}

String newMap = foundFiles.get(selection) + "";
String oldMap = foundFiles.get(selection) + ".backup";
String[] passInto = new String[4];
passInto[0] = "-clean";
passInto[1] = oldMap;
passInto[2] = newMap;
passInto[3] = newMap;
MapPatcher.main(passInto);
for(int numOfFiles = selection1; numOfFiles != 0; numOfFiles--){

for(int num = 0;num < foundFiles.size();num++){
System.out.println(num + ": " + foundFiles.get(num));
}

System.out.print("File to use: ");
int selection2;
inputCheck:while(true){
while(!input.hasNextInt()){
String temp = input.next();
System.out.println(temp + " is not a valid int.");
}
selection2 = input.nextInt();
if(selection2 < 0 || selection2 >= foundFiles.size()){
if(selection2 < 0){
System.out.println("Use a number greater than 0!");
}else{
System.out.println("Use a number less than " + foundFiles.size() +"!");
}
continue inputCheck;
}else{
break inputCheck;
}
}

String newMap = foundFiles.get(selection2) + "";
String oldMap = foundFiles.get(selection2) + ".backup";
String[] passInto = new String[4];
passInto[0] = "-clean";
passInto[1] = oldMap;
passInto[2] = newMap;
passInto[3] = newMap;
MapPatcher.main(passInto);
}
}

}
Binary file added tools/mapmerge/Source/src/MapPatcher.jar
Binary file not shown.

0 comments on commit 1e28365

Please sign in to comment.