map image dumper: add main method
Co-authored-by: Explv <explv@osbot.org>
This commit is contained in:
@@ -27,12 +27,15 @@ package net.runelite.cache;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.imageio.ImageIO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -59,6 +62,13 @@ import net.runelite.cache.region.Region;
|
||||
import net.runelite.cache.region.RegionLoader;
|
||||
import net.runelite.cache.util.BigBufferedImage;
|
||||
import net.runelite.cache.util.KeyProvider;
|
||||
import net.runelite.cache.util.XteaKeyManager;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
|
||||
@Slf4j
|
||||
@Accessors(chain = true)
|
||||
@@ -129,6 +139,59 @@ public class MapImageDumper
|
||||
this.objectManager = new ObjectManager(store);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
Options options = new Options();
|
||||
options.addOption(Option.builder().longOpt("cachedir").hasArg().required().build());
|
||||
options.addOption(Option.builder().longOpt("xteapath").hasArg().required().build());
|
||||
options.addOption(Option.builder().longOpt("outputdir").hasArg().required().build());
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine cmd;
|
||||
try
|
||||
{
|
||||
cmd = parser.parse(options, args);
|
||||
}
|
||||
catch (ParseException ex)
|
||||
{
|
||||
System.err.println("Error parsing command line options: " + ex.getMessage());
|
||||
System.exit(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
final String cacheDirectory = cmd.getOptionValue("cachedir");
|
||||
final String xteaJSONPath = cmd.getOptionValue("xteapath");
|
||||
final String outputDirectory = cmd.getOptionValue("outputdir");
|
||||
|
||||
XteaKeyManager xteaKeyManager = new XteaKeyManager();
|
||||
try (FileInputStream fin = new FileInputStream(xteaJSONPath))
|
||||
{
|
||||
xteaKeyManager.loadKeys(fin);
|
||||
}
|
||||
|
||||
File base = new File(cacheDirectory);
|
||||
File outDir = new File(outputDirectory);
|
||||
outDir.mkdirs();
|
||||
|
||||
try (Store store = new Store(base))
|
||||
{
|
||||
store.load();
|
||||
|
||||
MapImageDumper dumper = new MapImageDumper(store, xteaKeyManager);
|
||||
dumper.load();
|
||||
|
||||
for (int i = 0; i < Region.Z; ++i)
|
||||
{
|
||||
BufferedImage image = dumper.drawMap(i);
|
||||
|
||||
File imageFile = new File(outDir, "img-" + i + ".png");
|
||||
|
||||
ImageIO.write(image, "png", imageFile);
|
||||
log.info("Wrote image {}", imageFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected double random()
|
||||
{
|
||||
// the client would use a random value here, but we prefer determinism
|
||||
|
||||
Reference in New Issue
Block a user