-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
403 additions
and
68 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
craft3data/src/com/hiveworkshop/wc3/gui/modeledit/BitmapListCellRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.hiveworkshop.wc3.gui.modeledit; | ||
|
||
import java.awt.Component; | ||
import java.awt.Font; | ||
import java.awt.Image; | ||
import java.awt.image.BufferedImage; | ||
import java.util.HashMap; | ||
|
||
import javax.swing.DefaultListCellRenderer; | ||
import javax.swing.ImageIcon; | ||
import javax.swing.JList; | ||
|
||
import com.hiveworkshop.wc3.mdl.Bitmap; | ||
import com.hiveworkshop.wc3.mdl.EditableModel; | ||
|
||
public class BitmapListCellRenderer extends DefaultListCellRenderer { | ||
private static final Bitmap NO_VALUE_BITMAP = new Bitmap("Textures\\White.blp"); | ||
EditableModel model; | ||
HashMap<Bitmap, ImageIcon> map = new HashMap<Bitmap, ImageIcon>(); | ||
Font theFont = new Font("Arial", Font.BOLD, 32); | ||
|
||
public BitmapListCellRenderer(final EditableModel model) { | ||
this.model = model; | ||
} | ||
|
||
@Override | ||
public Component getListCellRendererComponent(final JList list, Object value, final int index, final boolean iss, | ||
final boolean chf) { | ||
String name; | ||
if (value == null) { | ||
name = "(No value)"; | ||
// the no value helps with the map cache | ||
value = NO_VALUE_BITMAP; | ||
} | ||
else { | ||
name = ((Bitmap) value).getName(); | ||
} | ||
ImageIcon myIcon = map.get(value); | ||
if (myIcon == null) { | ||
final BufferedImage bufferedImage = ((Bitmap) value).getBufferedImage(model.getWrappedDataSource()); | ||
if (bufferedImage != null) { | ||
myIcon = new ImageIcon(bufferedImage.getScaledInstance(64, 64, Image.SCALE_SMOOTH)); | ||
map.put((Bitmap) value, myIcon); | ||
} | ||
} | ||
super.getListCellRendererComponent(list, name, index, iss, chf); | ||
setIcon(myIcon); | ||
setFont(theFont); | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
craft3data/src/com/hiveworkshop/wc3/gui/modeledit/TextureAnimListCellRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.hiveworkshop.wc3.gui.modeledit; | ||
|
||
import java.awt.Component; | ||
import java.awt.Font; | ||
|
||
import javax.swing.DefaultListCellRenderer; | ||
import javax.swing.JList; | ||
|
||
import com.hiveworkshop.wc3.mdl.EditableModel; | ||
import com.hiveworkshop.wc3.mdl.TextureAnim; | ||
|
||
public class TextureAnimListCellRenderer extends DefaultListCellRenderer { | ||
Font theFont = new Font("Arial", Font.BOLD, 32); | ||
private final EditableModel model; | ||
|
||
public TextureAnimListCellRenderer(final EditableModel model) { | ||
this.model = model; | ||
} | ||
|
||
@Override | ||
public Component getListCellRendererComponent(final JList list, final Object value, final int index, | ||
final boolean iss, final boolean chf) { | ||
String name; | ||
if (value == null) { | ||
name = "(No value)"; | ||
} | ||
else { | ||
name = "TextureAnim " + model.getTextureAnimId((TextureAnim) value); | ||
} | ||
super.getListCellRendererComponent(list, name, index, iss, chf); | ||
setFont(theFont); | ||
return this; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...m/hiveworkshop/wc3/gui/modeledit/actions/componenttree/material/SetLayerBitmapAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.hiveworkshop.wc3.gui.modeledit.actions.componenttree.material; | ||
|
||
import com.hiveworkshop.wc3.gui.modeledit.UndoAction; | ||
import com.hiveworkshop.wc3.gui.modeledit.actions.newsys.ModelStructureChangeListener; | ||
import com.hiveworkshop.wc3.mdl.Bitmap; | ||
import com.hiveworkshop.wc3.mdl.Layer; | ||
import com.hiveworkshop.wc3.mdl.ShaderTextureTypeHD; | ||
|
||
public class SetLayerBitmapAction implements UndoAction { | ||
|
||
private final Layer layer; | ||
private final ShaderTextureTypeHD shaderTextureTypeHD; | ||
private final Bitmap prevBitmap; | ||
private final Bitmap newBitmap; | ||
private final ModelStructureChangeListener modelStructureChangeListener; | ||
|
||
public SetLayerBitmapAction(final Layer layer, final ShaderTextureTypeHD shaderTextureTypeHD, | ||
final Bitmap prevBitmap, final Bitmap newBitmap, | ||
final ModelStructureChangeListener modelStructureChangeListener) { | ||
this.layer = layer; | ||
this.shaderTextureTypeHD = shaderTextureTypeHD; | ||
this.prevBitmap = prevBitmap; | ||
this.newBitmap = newBitmap; | ||
this.modelStructureChangeListener = modelStructureChangeListener; | ||
} | ||
|
||
@Override | ||
public void undo() { | ||
if (prevBitmap == null) { | ||
layer.getShaderTextures().remove(shaderTextureTypeHD); | ||
} | ||
else { | ||
layer.getShaderTextures().put(shaderTextureTypeHD, prevBitmap); | ||
} | ||
modelStructureChangeListener.texturesChanged(); | ||
} | ||
|
||
@Override | ||
public void redo() { | ||
if (newBitmap == null) { | ||
layer.getShaderTextures().remove(shaderTextureTypeHD); | ||
} | ||
else { | ||
layer.getShaderTextures().put(shaderTextureTypeHD, newBitmap); | ||
} | ||
modelStructureChangeListener.texturesChanged(); | ||
} | ||
|
||
@Override | ||
public String actionName() { | ||
return "set Layer Bitmap"; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
.../hiveworkshop/wc3/gui/modeledit/actions/componenttree/material/SetLayerCoordIdAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.hiveworkshop.wc3.gui.modeledit.actions.componenttree.material; | ||
|
||
import com.hiveworkshop.wc3.gui.modeledit.UndoAction; | ||
import com.hiveworkshop.wc3.gui.modeledit.actions.newsys.ModelStructureChangeListener; | ||
import com.hiveworkshop.wc3.mdl.Layer; | ||
|
||
public class SetLayerCoordIdAction implements UndoAction { | ||
private final Layer layer; | ||
private final int prevCoordId; | ||
private final int newCoordId; | ||
private final ModelStructureChangeListener modelStructureChangeListener; | ||
|
||
public SetLayerCoordIdAction(final Layer layer, final int prevCoordId, final int newCoordId, | ||
final ModelStructureChangeListener modelStructureChangeListener) { | ||
this.layer = layer; | ||
this.prevCoordId = prevCoordId; | ||
this.newCoordId = newCoordId; | ||
this.modelStructureChangeListener = modelStructureChangeListener; | ||
} | ||
|
||
@Override | ||
public void undo() { | ||
layer.setCoordId(prevCoordId); | ||
modelStructureChangeListener.texturesChanged(); | ||
} | ||
|
||
@Override | ||
public void redo() { | ||
layer.setCoordId(newCoordId); | ||
modelStructureChangeListener.texturesChanged(); | ||
} | ||
|
||
@Override | ||
public String actionName() { | ||
return "set Layer CoordId"; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...eworkshop/wc3/gui/modeledit/actions/componenttree/material/SetLayerTextureAnimAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.hiveworkshop.wc3.gui.modeledit.actions.componenttree.material; | ||
|
||
import com.hiveworkshop.wc3.gui.modeledit.UndoAction; | ||
import com.hiveworkshop.wc3.gui.modeledit.actions.newsys.ModelStructureChangeListener; | ||
import com.hiveworkshop.wc3.mdl.Layer; | ||
import com.hiveworkshop.wc3.mdl.TextureAnim; | ||
|
||
public class SetLayerTextureAnimAction implements UndoAction { | ||
private final Layer layer; | ||
private final TextureAnim prevTexAnim; | ||
private final TextureAnim newTexAnim; | ||
private final ModelStructureChangeListener modelStructureChangeListener; | ||
|
||
public SetLayerTextureAnimAction(final Layer layer, final TextureAnim prevTexAnim, final TextureAnim newTexAnim, | ||
final ModelStructureChangeListener modelStructureChangeListener) { | ||
this.layer = layer; | ||
this.prevTexAnim = prevTexAnim; | ||
this.newTexAnim = newTexAnim; | ||
this.modelStructureChangeListener = modelStructureChangeListener; | ||
} | ||
|
||
@Override | ||
public void undo() { | ||
layer.setTextureAnim(prevTexAnim); | ||
modelStructureChangeListener.texturesChanged(); | ||
} | ||
|
||
@Override | ||
public void redo() { | ||
layer.setTextureAnim(newTexAnim); | ||
modelStructureChangeListener.texturesChanged(); | ||
} | ||
|
||
@Override | ||
public String actionName() { | ||
return "set Layer TVertexAnim"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.