Skip to content

Commit

Permalink
Customizing property inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
macbury committed Apr 9, 2015
1 parent 139581a commit d37a7ef
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 30 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ project(":editor") {
}
dependencies {
compile project(":desktop")
compile files("${rootDir}/libs/ColorPicker.jar")
compile 'net.contentobjects.jnotify:jnotify:0.94+'
compile 'org.apache.commons:commons-io:1.3+'
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
compile 'org.nuiton.thirdparty:l2fprod-common:0.1'
compile 'org.nuiton.thirdparty:l2fprod-common:0.1'
compile files("${rootDir}/libs/task-dialog-1.3.5.jar")
compile files("${rootDir}/libs/swing-bits-0.5.0.jar")
compile files("${rootDir}/libs/miglayout-3.7.2.jar")

}
}

Expand All @@ -67,6 +69,7 @@ project(":desktop") {
compile files("${rootDir}/libs/task-dialog-1.3.5.jar")
compile files("${rootDir}/libs/swing-bits-0.5.0.jar")
compile files("${rootDir}/libs/miglayout-3.7.2.jar")

}
}

Expand Down
1 change: 0 additions & 1 deletion core/assets/shaders/terrain.frag.glsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
uniform vec4 u_eyePosition;
uniform vec4 u_skyColor;
uniform sampler2D u_diffuseTexture;

varying vec4 v_lightDiffuse;
varying vec3 v_normal;
varying vec4 v_position;
Expand Down
4 changes: 2 additions & 2 deletions core/assets/shaders/terrain.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void main() {
v_uvStart = a_textureFullCoords.xy;
v_uvMul = a_textureFullCoords.zw - v_uvStart;

vec3 lightDiffuse = u_ambientLight.rgb + directionalLightDiffuse(u_mainLight, v_normal) - vec3(ao, ao, ao);
v_lightDiffuse = vec4(lightDiffuse, 1f);
vec3 lightDiffuse = directionalLightDiffuse(u_mainLight, v_normal);
v_lightDiffuse = u_ambientLight * vec4(lightDiffuse, 1f);
v_textCoord = a_texCoord0;
v_position = u_worldTransform * a_position;
v_position = applyWind(u_time, u_windDirection, waviness, v_position, u_mapSize, u_windDisplacementTexture);
Expand Down
10 changes: 5 additions & 5 deletions core/src/macbury/forge/ForgE.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class ForgE extends Game {
public static GameDatabase db;
public static BlocksProvider blocks;
public static InputManager input;
public static EntityManager entities;
public static EntityManager entities;
private Array<ForgEBootListener> bootListeners;
public static LevelManager levels;
public static LevelManager levels;


public ForgE(Config config) {
super();
this.config = config;
this.bootListeners = new Array<ForgEBootListener>();
this.config = config;
this.bootListeners = new Array<ForgEBootListener>();
}

@Override
Expand All @@ -48,7 +48,7 @@ public void create () {
input = new InputManager();
blocks = new BlocksProvider();
levels = new LevelManager(storage);
entities = new EntityManager();
entities = new EntityManager();
Gdx.input.setInputProcessor(input);
for (ForgEBootListener listener : bootListeners) {
listener.afterEngineCreate(this);
Expand Down
7 changes: 3 additions & 4 deletions core/src/macbury/forge/graphics/builders/TerrainBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ private void createQuads(Block.Side face, int a, Vector3i origin) {
if(done) { break; }
}

Gdx.app.log(TAG, "New quad: " + mask[n].blockId + " size=" + w+"x"+h + " at " + "X: " + i + " Y: " + j);
//Gdx.app.log(TAG, "New quad: " + mask[n].blockId + " size=" + w+"x"+h + " at " + "X: " + i + " Y: " + j);

TerrainPart currentPart = terrainPartPool.obtain();
currentPart.face = face;
currentPart.face = face;
currentPart.block = mask[n].getBlock();
currentPart.voxel = mask[n];

Expand All @@ -198,8 +198,7 @@ private void createQuads(Block.Side face, int a, Vector3i origin) {

terrainParts.add(currentPart);

Gdx.app.log(TAG, "Quad: " + currentPart.toString() + " with origin " + origin.toString());

//Gdx.app.log(TAG, "Quad: " + currentPart.toString() + " with origin " + origin.toString());

for(int l = 0; l < h; ++l) {
for(int k = 0; k < w; ++k) { mask[n + k + l * ChunkMap.CHUNK_SIZE] = null; }
Expand Down
4 changes: 2 additions & 2 deletions core/src/macbury/forge/level/LevelEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public class LevelEnv {
public LevelEnv() {
skyColor = Color.valueOf("3498db");
mainLight = new DirectionalLight();
mainLight.set(0.8f, 0.8f, 0.8f,-1, -1, 0.5f);
mainLight.set(1f, 1f, 1f,-1, -1, 0.5f);

ambientLight = Color.valueOf("cccccc");
ambientLight = Color.WHITE;
}

}
7 changes: 7 additions & 0 deletions core/src/macbury/forge/psychics/VoxelWorldPsychics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package macbury.forge.psychics;

/**
* Created by macbury on 08.04.15.
*/
public class VoxelWorldPsychics {
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ public LevelEntityEngine(Level level) {
public void dispose() {
debug.dispose();
removeAllEntities();

}
}
3 changes: 3 additions & 0 deletions editor/editor.eml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<lib name="miglayout-3.7.2.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/libs/miglayout-3.7.2.jar!/"/>
</lib>
<lib name="ColorPicker.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/libs/ColorPicker.jar!/"/>
</lib>
<levels>
<level name="Gradle: net.contentobjects.jnotify:jnotify:0.94" value="project"/>
<level name="Gradle: org.nuiton.thirdparty:l2fprod-common:0.1" value="project"/>
Expand Down
Binary file added editor/src/icons/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/src/icons/reset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package macbury.forge.editor.controllers.inspector;
package macbury.forge.editor.controllers.tools.inspector;

import com.badlogic.gdx.Gdx;
import macbury.forge.editor.controllers.ProjectController;
import macbury.forge.editor.controllers.inspector.properties.DefaultBeanBinder;
import macbury.forge.editor.controllers.inspector.properties.EditorScreenBeanInfo;
import macbury.forge.editor.controllers.tools.ToolsController;
import macbury.forge.editor.controllers.tools.inspector.properties.DefaultBeanBinder;
import macbury.forge.editor.controllers.tools.inspector.properties.EditorScreenBeanInfo;
import macbury.forge.editor.controllers.listeners.OnMapChangeListener;
import macbury.forge.editor.screens.EditorScreen;
import macbury.forge.editor.systems.SelectionSystem;
import macbury.forge.editor.undo_redo.ChangeManager;
import macbury.forge.editor.undo_redo.ChangeManagerListener;
import macbury.forge.editor.undo_redo.actions.PropertyChangeable;
import macbury.forge.editor.views.MapPropertySheet;

import javax.swing.*;
import java.awt.*;
import java.beans.PropertyChangeEvent;

/**
* Created by macbury on 15.03.15.
*/
public class InspectorController implements OnMapChangeListener, DefaultBeanBinder.PropertyChangeListener, ChangeManagerListener {
public class InspectorController implements OnMapChangeListener, DefaultBeanBinder.PropertyChangeListener, ChangeManagerListener, ToolsController.ToolControllerListener {
private static final String TAG = "InspectorController";
private final MapPropertySheet inspectorSheetPanel;
private EditorScreen screen;
Expand Down Expand Up @@ -48,6 +51,7 @@ public void onNewMap(ProjectController controller, EditorScreen screen) {

this.binder = new DefaultBeanBinder(new EditorScreenBeanInfo.EditorScreenBean(screen), inspectorSheetPanel, new EditorScreenBeanInfo());
this.binder.setListener(this);

}

@Override
Expand Down Expand Up @@ -75,4 +79,16 @@ public void onPropertyChange(DefaultBeanBinder binder, PropertyChangeEvent event
public void onChangeManagerChange(ChangeManager changeManager) {
inspectorSheetPanel.updateUI();
}

@Override
public void onToolPaneUnSelected(SelectionSystem system) {

}

@Override
public void onToolPaneSelected(ToolsController.ToolControllerListener selectedToolController, SelectionSystem system) {
if (selectedToolController == this)
inspectorSheetPanel.updateUI();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package macbury.forge.editor.controllers.tools.inspector.editors;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;

import com.badlogic.gdx.graphics.Color;
import com.l2fprod.common.beans.editor.AbstractPropertyEditor;
import com.l2fprod.common.swing.renderer.ColorCellRenderer;


/**
* Color editor.
*
* @author Bartosz Firyn (SarXos)
*/
public class ColorEditor extends AbstractPropertyEditor {

protected class ColorEditorComponent extends JPanel {

private static final long serialVersionUID = 411604969565728959L;

private ColorCellRenderer label = null;
private JButton button = null;

public ColorEditorComponent() {

setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

label = new ColorCellRenderer();
label.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
label.setAlignmentX(JTextField.LEFT_ALIGNMENT);
label.setBackground(UIManager.getColor("Table.selectionBackground"));
label.setForeground(UIManager.getColor("Table.selectionForeground"));

Dimension size = new Dimension(24, 15);

Image pencil = null;
try {
pencil = ImageIO.read(getClass().getClassLoader().getResourceAsStream("icons/edit.png"));
} catch (IOException e) {
throw new RuntimeException("Cannot load resource", e);
}

button = new JButton();
button.setPreferredSize(size);
button.setSize(size);
button.setMaximumSize(size);
button.setMinimumSize(size);
button.setAction(new AbstractAction("", new ImageIcon(pencil)) {

private static final long serialVersionUID = 1L;

@Override
public void actionPerformed(ActionEvent e) {
selectColor();
}
});

label.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
selectColor();
}

@Override
public void mousePressed(MouseEvent e) {

}

@Override
public void mouseReleased(MouseEvent e) {

}

@Override
public void mouseEntered(MouseEvent e) {

}

@Override
public void mouseExited(MouseEvent e) {

}
});


JPanel left = new JPanel();
left.setLayout(new BorderLayout(0, 0));
left.add(label);
left.setAlignmentX(JPanel.LEFT_ALIGNMENT);

JPanel right = new JPanel();
right.setLayout(new BoxLayout(right, BoxLayout.X_AXIS));
right.add(button);
right.setPreferredSize(new Dimension(size.width, 25));
right.setAlignmentX(JPanel.RIGHT_ALIGNMENT);

add(left, BorderLayout.WEST);
add(right, BorderLayout.CENTER);
}

public void setColor(Color color) {
label.setValue(new java.awt.Color(color.toIntBits()));
ColorEditor.this.color = color;
}
}

private ColorEditorComponent colorEditor = null;
private Color color;

public ColorEditor() {
editor = colorEditor = new ColorEditorComponent();
}

@Override
public Object getValue() {
return color;
}

@Override
public void setValue(Object value) {
colorEditor.setColor((Color) value);
}

protected void selectColor() {
java.awt.Color oldColor = new java.awt.Color(color.toIntBits());
String title = "Select color";
java.awt.Color selectedColor = JColorChooser.showDialog(editor, title, oldColor);

if (selectedColor != null) {

selectedColor.toString();
Color newColor = new Color(selectedColor.getRed());

//colorEditor.setColor(newColor);

//firePropertyChange(oldColor, newColor);
}
}

protected void selectNull() {
//Color oldColor = color;
//colorEditor.setColor(null);
//firePropertyChange(oldColor, null);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package macbury.forge.editor.controllers.inspector.properties;
package macbury.forge.editor.controllers.tools.inspector.properties;

import java.beans.BeanInfo;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;

import javax.swing.UIManager;

import com.l2fprod.common.model.DefaultBeanInfoResolver;
import com.l2fprod.common.propertysheet.Property;
Expand Down
Loading

0 comments on commit d37a7ef

Please sign in to comment.