Hi,
After I’ve imported my trait into my piece its correctly listed as a “Research Action Button” trait in the piece’s list of current traits but then when I save my module, close & then reopen the module editor this trait is listed as a “Marker” trait in the piece’s list of traits. And when I modify the simplest code I could give this trait (to test this problem) to actually make it do something in game it fails to work.
I’ve tried used the example Magnifier trait from the programming tutorial’s ZapWars zip and it has the same problem.
My trait:
public class ResearchActionButton extends Decorator implements EditablePiece
{
public final static String ID = "RESEARCHED_ACTION_BUTTON";
public ResearchActionButton(String type, GamePiece inner)
{
mySetType(type);
setInner(inner);
}
public ResearchActionButton()
{
this(ID, null);
}
public String myGetType()
{
return ID;
}
public String getDescription()
{
return "Research Action Button";
}
public void draw(Graphics g, int x, int y, Component obs, double zoom)
{
piece.draw(g, x, y, obs, zoom);
}
public Rectangle boundingBox()
{
return piece.boundingBox();
}
public Shape getShape()
{
return piece.getShape();
}
public String getName()
{
return piece.getName();
}
@Override
public void mySetState(String newState)
{
}
@Override
public String myGetState()
{
return "";
}
@Override
protected KeyCommand[] myGetKeyCommands()
{
return new KeyCommand[0];
}
@Override
public Command myKeyEvent(KeyStroke stroke)
{
return null;
}
public void mySetType(String type)
{
}
public HelpFile getHelpFile()
{
return null;
}
public PieceEditor getEditor()
{
return new SimplePieceEditor(this);
}
}
My counter factory:
[code]public class MyCounterFactory extends BasicCommandEncoder
{
public Decorator createDecorator(String type, GamePiece inner)
{
Decorator piece = null;
if (type.startsWith(ResearchActionButton.ID))
{
piece = new ResearchActionButton(type, inner);
}
else
{
piece = super.createDecorator(type, inner);
}
return piece;
}
}[/code]