[messages] [Technical Support & Bugs] How do I "load" GamePieces in Java?

Magnus.Pihl magnus.pihl at gmail.com
Sun Jan 13 12:54:37 MST 2013


I finally found a (somewhat roundabout) way of doing this. Here it is,
for the benefit of future generations:

First, you need to find the GamePiece Palette you wish to load Pieces
from. In my case, I could do this with the following:
List<PieceWindow> piecePalettes =
GameModule.getGameModule().getAllDescendantComponentsOf(PieceWindow.class);
You can iterate over them, asking them for "getConfigureName()" if you
know what you're looking for, to get the right one.

Once you have the right palette (let's say we saved it in a variable
called palette), follow the same logic to get its PieceSlots:
List<PieceSlot> slots =
palette.getAllDescendantComponentsOf(PieceSlot.class);

Now you can iterate over all your slots, asking each one for its
"getPiece()" and then querying the GamePieces for the correct one.
Once you have the Piece, you can add it to a map with
maps.get(?).addPiece(...).

_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=38024#p38024


More information about the messages mailing list