diff --git a/.gitignore b/.gitignore
index 2668f00..17d6f3f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
*.war
*.ear
hs_err_pid*
-
+*.db
## GWT
war/
html/war/gwt_bree/
diff --git a/ForgE.eml b/ForgE.eml
new file mode 100644
index 0000000..a5fe51d
--- /dev/null
+++ b/ForgE.eml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
index 062f441..312ccb6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,3 +1,4 @@
+
buildscript {
repositories {
mavenCentral()
@@ -7,14 +8,15 @@ buildscript {
}
allprojects {
- apply plugin: "eclipse"
apply plugin: "idea"
-
- version = '1.0'
+ apply plugin: "eclipse"
+ version = '0.01'
ext {
- appName = 'ForgE'
- gdxVersion = '1.4.1'
- roboVMVersion = '1.0.0-alpha-04'
+ appName = 'ForgE'
+ gdxVersion = '1.4.0'
+ roboVMVersion = '1.0.0-alpha-04'
+ aiVersion = '1.4.0'
+ ashleyVersion = '1.3.1'
}
repositories {
@@ -26,27 +28,27 @@ allprojects {
}
project(":editor") {
- apply plugin: "java"
-
+ apply plugin: "java"
- dependencies {
- compile project(":desktop")
- compile 'net.contentobjects.jnotify:jnotify:0.94+'
- compile 'org.nuiton.thirdparty:l2fprod-common:0.1'
- }
+ dependencies {
+ compile project(":desktop")
+ compile 'net.contentobjects.jnotify:jnotify:0.94+'
+ compile 'org.nuiton.thirdparty:l2fprod-common:0.1'
+ }
}
project(":desktop") {
- apply plugin: "java"
+ apply plugin: "java"
-
- dependencies {
- compile project(":core")
- compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
- compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
- compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
- compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
- }
+ dependencies {
+ compile project(":core")
+ compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
+ compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
+ compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
+ compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
+ compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
+ compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
+ }
}
project(":core") {
@@ -55,10 +57,11 @@ project(":core") {
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
+ compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
+ compile "com.badlogicgames.ashley:ashley:$ashleyVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
- compile "com.badlogicgames.ashley:ashley:1.3.1"
- compile 'com.esotericsoftware.kryo:kryo:2.10'
- //compile "com.badlogicgames.gdx:gdx-ai:1.4"
+ compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
+ compile 'com.esotericsoftware:kryo-shaded:3.0.0'
}
}
diff --git a/core/build.gradle b/core/build.gradle
index 03cd1be..0f56980 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -5,7 +5,3 @@ sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]
-
-eclipse.project {
- name = appName + "-core"
-}
diff --git a/core/core.eml b/core/core.eml
new file mode 100644
index 0000000..7b507cf
--- /dev/null
+++ b/core/core.eml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/src/macbury/forge/ForgE.java b/core/src/macbury/forge/ForgE.java
index 24365b1..3fb05d7 100644
--- a/core/src/macbury/forge/ForgE.java
+++ b/core/src/macbury/forge/ForgE.java
@@ -4,6 +4,7 @@
import com.badlogic.gdx.Gdx;
import macbury.forge.assets.AssetsManager;
import macbury.forge.db.GameDatabase;
+import macbury.forge.storage.StorageManager;
import macbury.forge.graphics.GraphicsUtils;
import macbury.forge.input.InputManager;
import macbury.forge.screens.ScreenManager;
@@ -15,12 +16,12 @@ public class ForgE extends Game {
public static AssetsManager assets;
public static ShadersManager shaders;
public static Config config;
+ public static StorageManager storage;
public static GameDatabase db;
public static InputManager input;
private ForgEBootListener bootListener;
-
public ForgE(Config config) {
super();
this.config = config;
@@ -28,12 +29,15 @@ public ForgE(Config config) {
@Override
public void create () {
- db = new GameDatabase();
+ storage = new StorageManager();
+
+ db = storage.loadOrInitializeDB();
graphics = new GraphicsUtils();
screens = new ScreenManager(this);
assets = new AssetsManager();
shaders = new ShadersManager();
input = new InputManager();
+
Gdx.input.setInputProcessor(input);
if (bootListener != null) {
bootListener.afterEngineCreate(this);
diff --git a/core/src/macbury/forge/db/GameDatabase.java b/core/src/macbury/forge/db/GameDatabase.java
index 1f468b5..fc8aab6 100644
--- a/core/src/macbury/forge/db/GameDatabase.java
+++ b/core/src/macbury/forge/db/GameDatabase.java
@@ -1,9 +1,26 @@
package macbury.forge.db;
-import com.esotericsoftware.kryo.Kryo;
-
/**
* Created by macbury on 07.11.14.
*/
-public class GameDatabase extends Kryo {
+public class GameDatabase {
+ public static final String FILE_NAME = "game.db";
+ public String title;
+ public int currentyUID = 0;
+
+ /**
+ * Create int uuid
+ * @return unique id
+ */
+ public int uid() {
+ return currentyUID += 1;
+ }
+
+ /**
+ * Bootstrap db with default values
+ */
+ public void bootstrap() {
+ title = "ForgE Project";
+ currentyUID = 0;
+ }
}
diff --git a/core/src/macbury/forge/level/LevelState.java b/core/src/macbury/forge/level/LevelState.java
index 13fc867..2b4d9ed 100644
--- a/core/src/macbury/forge/level/LevelState.java
+++ b/core/src/macbury/forge/level/LevelState.java
@@ -1,9 +1,6 @@
package macbury.forge.level;
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.graphics.Pixmap;
-import macbury.forge.voxel.VoxelMaterial;
+import macbury.forge.ForgE;
import macbury.forge.voxel.ChunkMap;
/**
@@ -12,7 +9,6 @@
*/
public class LevelState {
private static final String MAP_NAME_PREFIX = "MAP_";
- private static int uid = 0;
public LevelEnv env;
public ChunkMap terrainMap;
@@ -25,7 +21,7 @@ public class LevelState {
public static LevelState blank(int width, int height, int depth) {
LevelState state = new LevelState();
state.terrainMap = new ChunkMap(ChunkMap.TERRAIN_TILE_SIZE);
- state.id = uid();
+ state.id = ForgE.db.uid();
state.name = MAP_NAME_PREFIX + state.id;
state.env = new LevelEnv();
state.terrainMap.initialize(width,height,depth);
@@ -33,42 +29,4 @@ public static LevelState blank(int width, int height, int depth) {
return state;
}
- public static LevelState heightMapTest() {
- LevelState state = new LevelState();
- state.terrainMap = new ChunkMap(ChunkMap.TERRAIN_TILE_SIZE);
- state.id = uid();
- state.name = MAP_NAME_PREFIX + state.id;
-
- state.terrainMap.initialize(250,50,250);
- state.terrainMap.buildFloor();
-
- Pixmap pixmap = new Pixmap(Gdx.files.internal("heightmap.png"));
- Color color = new Color();
-
- for (int x = 0; x < state.terrainMap.getWidth(); x++) {
- for (int z = 0; z < state.terrainMap.getDepth(); z++) {
- int rawColor = pixmap.getPixel(x, z);
- color.set(rawColor);
- int height = (int)Math.floor(color.r * (state.terrainMap.getHeight() - 5));
-
- for (int y = 1; y < height; y++) {
- VoxelMaterial mat = state.terrainMap.materials.get(Math.max((int)Math.round((state.terrainMap.materials.size-1) * Math.random()), 1));
- state.terrainMap.setMaterialForPosition(mat, x,y,z);
- }
- }
- }
-
- pixmap.dispose();
-
- return state;
- }
-
- /**
- * Create uid for level.
- * @return
- */
- public static int uid() {
- //TODO: After increase save uid to disk
- return uid += 1;
- }
}
diff --git a/core/src/macbury/forge/storage/StorageManager.java b/core/src/macbury/forge/storage/StorageManager.java
new file mode 100644
index 0000000..a3bb7db
--- /dev/null
+++ b/core/src/macbury/forge/storage/StorageManager.java
@@ -0,0 +1,47 @@
+package macbury.forge.storage;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.files.FileHandle;
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+import macbury.forge.db.GameDatabase;
+import macbury.forge.storage.serializers.GameDatabseSerializer;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+
+/**
+ * Created by macbury on 07.11.14.
+ */
+public class StorageManager extends Kryo {
+ public StorageManager() {
+ super();
+ register(GameDatabase.class, new GameDatabseSerializer());
+ }
+
+ public GameDatabase loadOrInitializeDB() {
+ FileHandle dbFile = Gdx.files.internal(GameDatabase.FILE_NAME);
+ GameDatabase db = null;
+ if (dbFile.exists()) {
+ db = readObject(new Input(dbFile.read()), GameDatabase.class);
+ } else {
+ db = new GameDatabase();
+ db.bootstrap();
+ saveDB(db);
+ }
+
+ return db;
+ }
+
+ public void saveDB(GameDatabase db) {
+ FileHandle dbFile = Gdx.files.internal(GameDatabase.FILE_NAME);
+ try {
+ Output output = new Output(new FileOutputStream(dbFile.file(), false));
+ writeObject(output, db);
+ output.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/core/src/macbury/forge/storage/serializers/GameDatabseSerializer.java b/core/src/macbury/forge/storage/serializers/GameDatabseSerializer.java
new file mode 100644
index 0000000..ddbf3fa
--- /dev/null
+++ b/core/src/macbury/forge/storage/serializers/GameDatabseSerializer.java
@@ -0,0 +1,28 @@
+package macbury.forge.storage.serializers;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+import macbury.forge.db.GameDatabase;
+
+/**
+ * Created by macbury on 10.11.14.
+ */
+public class GameDatabseSerializer extends Serializer {
+ @Override
+ public void write(Kryo kryo, Output output, GameDatabase gameDatabase) {
+ output.writeInt(gameDatabase.currentyUID);
+ output.writeString(gameDatabase.title);
+ }
+
+ @Override
+ public GameDatabase read(Kryo kryo, Input input, Class type) {
+ GameDatabase db = new GameDatabase();
+ db.bootstrap();
+ db.currentyUID = input.readInt();
+ db.title = input.readString();
+ return db;
+ }
+
+}
diff --git a/desktop/build.gradle b/desktop/build.gradle
index 48d4d97..d98871a 100644
--- a/desktop/build.gradle
+++ b/desktop/build.gradle
@@ -27,20 +27,3 @@ task dist(type: Jar) {
dist.dependsOn classes
-eclipse {
- project {
- name = appName + "-desktop"
- linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
- }
-}
-
-task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
- doLast {
- def classpath = new XmlParser().parse(file(".classpath"))
- new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
- def writer = new FileWriter(file(".classpath"))
- def printer = new XmlNodePrinter(new PrintWriter(writer))
- printer.setPreserveWhitespace(true)
- printer.print(classpath)
- }
-}
\ No newline at end of file
diff --git a/desktop/desktop.eml b/desktop/desktop.eml
new file mode 100644
index 0000000..2824d5d
--- /dev/null
+++ b/desktop/desktop.eml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/editor/build.gradle b/editor/build.gradle
index ff04802..f1250d3 100644
--- a/editor/build.gradle
+++ b/editor/build.gradle
@@ -26,10 +26,3 @@ task dist(type: Jar) {
}
dist.dependsOn classes
-
-eclipse {
- project {
- name = appName + "-editor"
- linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
- }
-}
diff --git a/editor/editor.eml b/editor/editor.eml
new file mode 100644
index 0000000..8de2e4b
--- /dev/null
+++ b/editor/editor.eml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/editor/src/macbury/forge/editor/Utils.java b/editor/src/macbury/forge/editor/Utils.java
new file mode 100644
index 0000000..c667db6
--- /dev/null
+++ b/editor/src/macbury/forge/editor/Utils.java
@@ -0,0 +1,10 @@
+package macbury.forge.editor;
+import javax.swing.*;
+/**
+ * Created by macbury on 10.11.14.
+ */
+public class Utils {
+ public static ImageIcon getIcon(String name) {
+ return new ImageIcon(Utils.class.getResource("/icons/"+name+".png"));
+ }
+}
diff --git a/editor/src/macbury/forge/editor/controllers/MainToolbarController.java b/editor/src/macbury/forge/editor/controllers/MainToolbarController.java
index 2f08f58..37c7e26 100644
--- a/editor/src/macbury/forge/editor/controllers/MainToolbarController.java
+++ b/editor/src/macbury/forge/editor/controllers/MainToolbarController.java
@@ -1,5 +1,6 @@
package macbury.forge.editor.controllers;
+import macbury.forge.editor.Utils;
import macbury.forge.editor.controllers.listeners.OnMapChangeListener;
import macbury.forge.editor.undo_redo.ChangeManager;
import macbury.forge.editor.undo_redo.ChangeManagerListener;
@@ -43,19 +44,18 @@ public MainToolbarController(JToolBar mainToolbar, MainMenu mainMenu) {
private JToggleButton buildToogleButton(String iconName) {
JToggleButton button = new JToggleButton();
- ImageIcon icon = new ImageIcon(getClass().getResource("/icons/"+iconName+".png"));
button.setFocusable(false);
button.setHorizontalTextPosition(SwingConstants.LEADING);
- button.setIcon(icon);
+ button.setIcon(Utils.getIcon(iconName));
return button;
}
private JButton buildButton(String iconName) {
JButton button = new JButton();
- ImageIcon icon = new ImageIcon(getClass().getResource("/icons/"+iconName+".png"));
+ //ImageIcon icon = new ImageIcon(getClass().getResource("/icons/"+iconName+".png"));
button.setFocusable(false);
button.setHorizontalTextPosition(SwingConstants.LEADING);
- button.setIcon(icon);
+ button.setIcon(Utils.getIcon(iconName));
button.addActionListener(this);
return button;
}
diff --git a/editor/src/macbury/forge/editor/controllers/TerrainToolsController.java b/editor/src/macbury/forge/editor/controllers/TerrainToolsController.java
index 4641841..5ce5b7c 100644
--- a/editor/src/macbury/forge/editor/controllers/TerrainToolsController.java
+++ b/editor/src/macbury/forge/editor/controllers/TerrainToolsController.java
@@ -1,5 +1,6 @@
package macbury.forge.editor.controllers;
+import macbury.forge.editor.Utils;
import macbury.forge.editor.controllers.listeners.OnMapChangeListener;
import macbury.forge.editor.parell.JobManager;
import macbury.forge.editor.screens.EditorScreen;
@@ -80,10 +81,10 @@ private void updateUI() {
private JToggleButton buildToogleButton(String iconName, ButtonGroup buttonGroup) {
JToggleButton button = new JToggleButton();
- ImageIcon icon = new ImageIcon(getClass().getResource("/icons/"+iconName+".png"));
+ //ImageIcon icon = new ImageIcon(getClass().getResource("/icons/"+iconName+".png"));
button.setFocusable(false);
button.setHorizontalTextPosition(SwingConstants.LEADING);
- button.setIcon(icon);
+ button.setIcon(Utils.getIcon(iconName));
toolbar.add(button);
buttonGroup.add(button);
button.addActionListener(this);
diff --git a/editor/src/macbury/forge/editor/systems/SelectionSystem.java b/editor/src/macbury/forge/editor/systems/SelectionSystem.java
index 48b153e..1db7e96 100644
--- a/editor/src/macbury/forge/editor/systems/SelectionSystem.java
+++ b/editor/src/macbury/forge/editor/systems/SelectionSystem.java
@@ -14,7 +14,6 @@
import macbury.forge.components.Position;
import macbury.forge.editor.selection.AbstractSelection;
import macbury.forge.editor.selection.SelectionInterface;
-import macbury.forge.editor.utils.MousePosition;
import macbury.forge.graphics.camera.GameCamera;
import macbury.forge.level.Level;
import macbury.forge.voxel.ChunkMap;
@@ -35,7 +34,6 @@ public class SelectionSystem extends EntitySystem {
private final ShapeRenderer shapeRenderer;
private final RenderContext renderContext;
private Overlay overlay;
- private final MousePosition mousePosition;
public final VoxelCursor voxelCursor = new VoxelCursor();
private AbstractSelection selection;
private Array listeners;
@@ -45,7 +43,6 @@ public SelectionSystem(Level level) {
this.listeners = new Array();
this.voxelPicker = new VoxelPicker(level.terrainMap);
this.camera = level.camera;
- this.mousePosition = new MousePosition(camera);
this.map = level.terrainMap;
this.shapeRenderer = level.batch.shapeRenderer;
this.renderContext = level.renderContext;
diff --git a/editor/src/macbury/forge/editor/utils/MousePosition.java b/editor/src/macbury/forge/editor/utils/MousePosition.java
deleted file mode 100644
index 501db6d..0000000
--- a/editor/src/macbury/forge/editor/utils/MousePosition.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package macbury.forge.editor.utils;
-
-import com.badlogic.gdx.math.Vector2;
-import com.badlogic.gdx.math.Vector3;
-import macbury.forge.graphics.camera.GameCamera;
-
-/**
- * Created by macbury on 26.10.14.
- */
-public class MousePosition extends Vector2 {
- private final GameCamera camera;
- private boolean dirty = false;
- public Vector3 vec3 = new Vector3();
-
- public MousePosition(GameCamera camera) {
- this.camera = camera;
- setZero();
- }
-
- public boolean isDirty() {
- return dirty;
- }
-
- public void setDirty(boolean dirty) {
- this.dirty = dirty;
- }
-
- @Override
- public Vector2 set(float x, float y) {
- setDirty(true);
- y = camera.viewportHeight - y;
- vec3.set(x,y,0);
- return super.set(x, y);
- }
-}
diff --git a/editor/src/macbury/forge/editor/views/MoreToolbarButton.java b/editor/src/macbury/forge/editor/views/MoreToolbarButton.java
index 3f3b081..0e4af8c 100644
--- a/editor/src/macbury/forge/editor/views/MoreToolbarButton.java
+++ b/editor/src/macbury/forge/editor/views/MoreToolbarButton.java
@@ -1,5 +1,7 @@
package macbury.forge.editor.views;
+import macbury.forge.editor.Utils;
+
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
@@ -17,10 +19,9 @@ public class MoreToolbarButton extends JToggleButton implements PopupMenuListene
public MoreToolbarButton(JPopupMenu menu) {
super();
this.menu = menu;
- ImageIcon icon = new ImageIcon(getClass().getResource("/icons/nav_icon.png"));
setFocusable(false);
setHorizontalTextPosition(SwingConstants.LEADING);
- setIcon(icon);
+ setIcon(Utils.getIcon("nav_icon"));
menu.addPopupMenuListener(this);
addItemListener(this);
menu.setMinimumSize(new Dimension(320, 24));
diff --git a/editor/src/macbury/forge/editor/windows/MainWindow.form b/editor/src/macbury/forge/editor/windows/MainWindow.form
index 0b850dd..bf8b0dd 100644
--- a/editor/src/macbury/forge/editor/windows/MainWindow.form
+++ b/editor/src/macbury/forge/editor/windows/MainWindow.form
@@ -1,8 +1,8 @@