Create account / Log in

Why is my custom trait being listed as a "Marker" trait?

Topics related to Vassal game modules.

Moderators: Tim M, uckelman

Why is my custom trait being listed as a "Marker" trait?

Postby Joe12 » June 7th, 2016, 3:56 pm

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:
Code: Select all
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: Select all
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;
   }
}
Last edited by Joe12 on June 7th, 2016, 4:02 pm, edited 1 time in total.
Joe12
 
Posts: 13
Joined: May 5th, 2012, 5:45 pm

Re: Why is my custom trait being listed as a "Marker" trait?

Postby Joe12 » June 8th, 2016, 10:53 am

I've tried using the Zap Wars Magnifier trait with the Zap Wars counter factory and this example code has the same problem
Joe12
 
Posts: 13
Joined: May 5th, 2012, 5:45 pm

Re: Why is my custom trait being listed as a "Marker" trait?

Postby Joe12 » June 8th, 2016, 1:39 pm

I can see the Zapwars Magnifier trait works when its used in the Zap Wars module in Vassal 3.2.16 so I will find out why its not working in my module.
Joe12
 
Posts: 13
Joined: May 5th, 2012, 5:45 pm

Re: Why is my custom trait being listed as a "Marker" trait?

Postby Joe12 » June 9th, 2016, 11:14 am

My mistake was simply not replacing <VASSAL.build.module.BasicCommandEncoder/> with <zap.MyCounterFactory/> in my module's build file because its been a long time since I've read the programming tutorial from start to finish and I've been assuming Vassal was searching for and finding my custom counter factory class because the Magnifier trait was importable so I thought the Vassal module editor would therefore update the build file to include my counter factory.
Joe12
 
Posts: 13
Joined: May 5th, 2012, 5:45 pm


Return to Module General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron