diff --git a/.gitignore b/.gitignore index b267804..5196db5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,16 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +/bin/ + +#Eclipse files +.project +.classpath + +#generated maps +/maps + +# IntelliJ project files +.idea +*.iml +out \ No newline at end of file diff --git a/src/com/wurmonline/wurmapi/api/WurmAPI.java b/src/com/wurmonline/wurmapi/api/WurmAPI.java index dde295c..6d70f42 100644 --- a/src/com/wurmonline/wurmapi/api/WurmAPI.java +++ b/src/com/wurmonline/wurmapi/api/WurmAPI.java @@ -1,7 +1,5 @@ package com.wurmonline.wurmapi.api; -import com.wurmonline.wurmapi.api.map.dump.Colorist; - import java.io.File; import java.io.IOException; diff --git a/src/net/buddat/wgenerator/HeightMap.java b/src/net/buddat/wgenerator/HeightMap.java index 6b4281f..7e842bd 100644 --- a/src/net/buddat/wgenerator/HeightMap.java +++ b/src/net/buddat/wgenerator/HeightMap.java @@ -2,6 +2,7 @@ import java.awt.image.BufferedImage; import java.awt.image.DataBufferUShort; +import java.awt.image.Raster; import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; @@ -83,18 +84,17 @@ private void importHeightImage() { } long startTime = System.currentTimeMillis(); - try { - DataBufferUShort buffer = (DataBufferUShort) heightImage.getRaster().getDataBuffer(); + Raster data = heightImage.getData(); - int[][] array = new int[mapSize][mapSize]; + for (int x = 0; x < mapSize; x++) { + for (int y = 0; y < mapSize; y++) { - for (int x = 0; x < mapSize; x++) { - for (int y = 0; y < mapSize; y++) { + double[] dArray = null; - array[x][y] = buffer.getElem(x + y * mapSize); + dArray = data.getPixel(x,y, dArray); - setHeight(x, y, getHeight(x, y) + (array[x][y] / 65536f), false); + setHeight(x, y, getHeight(x, y) + (dArray[0] / 65536f), false); } } diff --git a/src/net/buddat/wgenerator/MainWindow.java b/src/net/buddat/wgenerator/MainWindow.java index b842dd6..bb61eaf 100644 --- a/src/net/buddat/wgenerator/MainWindow.java +++ b/src/net/buddat/wgenerator/MainWindow.java @@ -19,6 +19,7 @@ import javax.swing.GroupLayout.Alignment; import javax.swing.LayoutStyle.ComponentPlacement; import java.awt.*; +import java.awt.Taskbar.State; import javax.imageio.ImageIO; import java.io.*; @@ -43,6 +44,8 @@ public class MainWindow extends JFrame { private Constants.VIEW_TYPE defaultView = Constants.VIEW_TYPE.HEIGHT; private ProgressHandler progress; + private Taskbar taskbar = Taskbar.getTaskbar(); + private JProgressBar progressBar; private JLabel lblMemory; private JPanel contentPane; @@ -219,12 +222,14 @@ public MainWindow() { contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setLocationRelativeTo(null); setContentPane(contentPane); - + + taskbar.setWindowProgressState(this, State.NORMAL); + JTabbedPane optionsPane = new JTabbedPane(JTabbedPane.TOP); progressBar = new JProgressBar(); progressBar.setStringPainted(true); - progressBar.setString(""); + progressBar.setString(Constants.READY); progressBar.setEnabled(true); progressBar.setValue(100); @@ -1368,7 +1373,7 @@ private void init() { setupButtonActions(); setRockTotal(); updateMapCoords(0,0,false); - progress = new ProgressHandler(progressBar,lblMemory); + progress = new ProgressHandler(progressBar,lblMemory, taskbar, this); progress.update(100); System.setErr(new PrintStream(new StreamCapturer(System.err,this))); @@ -1712,7 +1717,8 @@ private void startLoading(String task) { } private void stopLoading() { - progress.update(100,""); + progress.update(100, Constants.READY); + taskbar.setWindowProgressValue(this, 0); } boolean actionReady() { @@ -2014,11 +2020,13 @@ void actionResetBiomes () { for (int i = 0; i < heightMap.getMapSize(); i++) { for (int j = 0; j < heightMap.getMapSize(); j++) { - progress.update((int)((float)(i*heightMap.getMapSize()+j)/(heightMap.getMapSize()*heightMap.getMapSize())*100f)); + int prog = (int)((float)(i*heightMap.getMapSize()+j)/(heightMap.getMapSize()*heightMap.getMapSize())*100f); + taskbar.setWindowProgressValue(this, prog); + progress.update(prog); tileMap.addDirt(i, j, 0); } } - + updateMapView(); genHistory.add("RESETBIOMES:null"); @@ -2472,7 +2480,9 @@ private void updateMapView() { Graphics g = mapPanel.getMapImage().getGraphics(); for (int i = 0; i < heightMap.getMapSize(); i++) { - progress.update((int)((float)i/heightMap.getMapSize()*98f)); + int prog = (int)((float)i/heightMap.getMapSize()*98f); + taskbar.setWindowProgressValue(this, prog); + progress.update(prog); for (int j = 0; j < heightMap.getMapSize(); j++) { g.setColor(new Color((float) heightMap.getHeight(i, j), (float) heightMap.getHeight(i, j), (float) heightMap.getHeight(i, j))); g.fillRect(i, j, 1, 1); @@ -2504,7 +2514,9 @@ private void updateAPIMap() { try { for (int i = 0; i < heightMap.getMapSize(); i++) { - progress.update((int)((float)i/heightMap.getMapSize()*100f/3)); + int prog = (int)((float)i/heightMap.getMapSize()*100f/3); + taskbar.setWindowProgressValue(this, prog); + progress.update(prog); for (int j = 0; j < heightMap.getMapSize(); j++) { map.setSurfaceHeight(i, j, tileMap.getSurfaceHeight(i, j)); map.setRockHeight(i, j, tileMap.getRockHeight(i, j)); @@ -2516,7 +2528,9 @@ private void updateAPIMap() { } } for (int i = 0; i < heightMap.getMapSize(); i++) { - progress.update((int)((float)i/heightMap.getMapSize()*100f/3)+33); + int prog = (int)((float)i/heightMap.getMapSize()*100f/3)+33; + taskbar.setWindowProgressValue(this, prog); + progress.update(prog); for (int j = 0; j < heightMap.getMapSize(); j++) { if(tileMap.getType(i, j) != Tile.TILE_ROCK && !tileMap.getType(i, j).isTree() && !tileMap.getType(i, j).isBush()) { for(int x = i - 1; x <= i + 1; x++) { @@ -2531,7 +2545,9 @@ private void updateAPIMap() { } } for (int i = 0; i < heightMap.getMapSize(); i++) { - progress.update((int)((float)i/heightMap.getMapSize()*100f/3)+66); + int prog = (int)((float)i/heightMap.getMapSize()*100f/3)+66; + taskbar.setWindowProgressValue(this, prog); + progress.update(prog); for (int j = 0; j < heightMap.getMapSize(); j++) { if (tileMap.getType(i, j).isTree()) { map.setTree(i, j, tileMap.getType(i, j).getTreeType((byte) 0), FoliageAge.values()[treeRand.nextInt(FoliageAge.values().length)], GrowthTreeStage.MEDIUM); @@ -2906,4 +2922,4 @@ public void submitError(String err) { public static void log (String s) { System.out.println(s); } -} +} \ No newline at end of file diff --git a/src/net/buddat/wgenerator/util/Constants.java b/src/net/buddat/wgenerator/util/Constants.java index 217e335..b66823e 100644 --- a/src/net/buddat/wgenerator/util/Constants.java +++ b/src/net/buddat/wgenerator/util/Constants.java @@ -5,8 +5,9 @@ */ public class Constants { - public static final String version = "2.9.0"; + public static final String version = "2.9.1"; public static final String WINDOW_TITLE = "Map Generator for Wurm Unlimited"; + public static final String READY = "Ready"; public static final int MAP_SIZE = 2048; public static final int MAP_HEIGHT = 4096; diff --git a/src/net/buddat/wgenerator/util/ProgressHandler.java b/src/net/buddat/wgenerator/util/ProgressHandler.java index 49130a8..ad4a439 100644 --- a/src/net/buddat/wgenerator/util/ProgressHandler.java +++ b/src/net/buddat/wgenerator/util/ProgressHandler.java @@ -1,15 +1,24 @@ package net.buddat.wgenerator.util; +import java.awt.Taskbar; + import javax.swing.*; +import net.buddat.wgenerator.MainWindow; + public class ProgressHandler { - JProgressBar progressBar; - JLabel lblMemory; + private JProgressBar progressBar; + private JLabel lblMemory; + + private Taskbar taskbar; + private MainWindow mainWindow; - public ProgressHandler(JProgressBar progress, JLabel memory) { - progressBar = progress; - lblMemory = memory; + public ProgressHandler(JProgressBar progress, JLabel memory, Taskbar taskbar, MainWindow mainWindow) { + this.progressBar = progress; + this.lblMemory = memory; + this.taskbar = taskbar; + this.mainWindow = mainWindow; } private void setMemoryUsage() { @@ -25,6 +34,13 @@ public void update(int value) { public void update(int value, String text) { progressBar.setValue(value); progressBar.setString(text); + taskbar.setWindowProgressValue(mainWindow, value); + if(value == 100) { + mainWindow.setTitle(Constants.WINDOW_TITLE + " - v " + Constants.version + " - " + "Ready"); + }else { + mainWindow.setTitle(Constants.WINDOW_TITLE + " - v " + Constants.version + " - " + text + ": " + value + "%"); + } + setMemoryUsage(); }