Create account / Log in

Invisible Opacity Level

Talk about module design ideas and techniques.

Moderators: Tim M, uckelman

Invisible Opacity Level

Postby BigAl737 » February 27th, 2011, 11:06 pm

Greetings,

I'd like to adjust the opacity level set by the program when the invisible trait = true for a game piece. I'm wondering if a simple change to the build module file would do this for me. Here's the code that I think applies:

<VASSAL.build.module.PrototypeDefinition name="AirUnitNF">+/null/hideCmd;;Hide;CurrentMap = Main Map;67\,130,68\,650 footprint;;Movement Trail;false;false;5;255,255,255;255,255,0;80;40;20;30;2.0\ translate;Move Forward;38,130;0;60;false;0;0;0;0;Move Forward\\ rotate;6;39,130;37,130;Turn Right;Turn Left;;;Turn\\\ report;37\,130;$location$: $newPieceName$ turns left;;;Turn left\\\\ report;39\,130;$location$: $newPieceName$ turns right;;;Turn right\\\\\ hide;72,130;Hide\/Show;153,153,255;sides:Referee\\\\\\ piece;;;;/ false;;0\ \\ 0\\\ -1\\\\ -1\\\\\ null\\\\\\ null;0;0;</VASSAL.build.module.PrototypeDefinition>

Using the code above as an example, what I want to do is have the Referee see an invisible = true piece appear in its invisible = false appearance.

Can changing a value(s) in the code above or some where make this happen?

Thanks very much.

Allan
BigAl737
 
Posts: 47
Joined: July 10th, 2009, 6:47 am
Location: Eagle River, AK

Re: Invisible Opacity Level

Postby mycenae » February 28th, 2011, 7:12 am

I think you could achieve the same thing by adding a side called Referee, and then adding the referee to the list of sides that could make a piece invisible (in the Invisible trait of each piece). Then the ref would see whatever the player sees.
mycenae
 
Posts: 392
Joined: May 16th, 2008, 6:41 pm

Re: Invisible Opacity Level

Postby BigAl737 » March 5th, 2011, 12:17 am

mycenae wrote:I think you could achieve the same thing by adding a side called Referee, and then adding the referee to the list of sides that could make a piece invisible (in the Invisible trait of each piece). Then the ref would see whatever the player sees.


Unfortunately it's not that simple. The Referee would still see a semi transparent image.

The image below contains 3 counters. Counter 1 is what invisibility looks like to the owning player. Counter 2 is the same except a purple highlight color has been selected. Counter 3 is unhidden. What I'd like to do is make hidden units look like counter 3 (i.e. no transparency) to the owning player.

Thanks for the idea. Does any one have any others?

Thanks very much.

Allan
Attachments
InvisibleTransparency.jpg
InvisibleTransparency.jpg (69.52 KiB) Viewed 3815 times
BigAl737
 
Posts: 47
Joined: July 10th, 2009, 6:47 am
Location: Eagle River, AK

Re: Invisible Opacity Level

Postby mycenae » March 5th, 2011, 12:46 am

It's possible that the same end could be achieved by different means than the invisibility trait.The transparency in a hidden piece is just there as a visual indicator that the piece is hidden to non-owners. Is there some in-game reason why you wouldn't want an owning player to know that his piece is hidden?
mycenae
 
Posts: 392
Joined: May 16th, 2008, 6:41 pm

Re: Invisible Opacity Level

Postby BigAl737 » March 5th, 2011, 1:13 am

It's possible that the same end could be achieved by different means than the invisibility trait.The transparency in a hidden piece is just there as a visual indicator that the piece is hidden to non-owners. Is there some in-game reason why you wouldn't want an owning player to know that his piece is hidden?


The printed game uses two maps...a player map and an umpire (or referee) map. For the VASSAL module, I've combined the two maps into one. Since a piece hidden to the player will never be made visible to the player (i.e. it stays hidden for the entire game, I thought it would be more aesthetic for the umpire to view the hidden piece as if it wasn't hidden.

Does that make sense?
BigAl737
 
Posts: 47
Joined: July 10th, 2009, 6:47 am
Location: Eagle River, AK

Re: Invisible Opacity Level

Postby BigAl737 » March 6th, 2011, 10:15 pm

I've been experimenting with other options to achieve the same affect but to no avail. All options haven't worked or introduce too many other issues. I've tried map level Game Piece Layers, Masks, and transparent piece layers.

I found a similar capability that's what I want in another VASSAL option. When using the LOS thread you have an option to vary the opacity of units on the map. I've appended a line from the build file that seems to apply to this option. In my example I selected an opacity of 37% and that seems to correlate with the hideOpacity="37" listing in the line of code.

Is there a way to generate a similar setting for invisible game pieces? I wish I was a programmer. I think the answer could be a fairly simple edit to the Invisible portion of the VASSAL programming code. I'm hoping an edit could be made to the build file code to achieve this result. Obviously though I'm in the dark about what this would take.

Thanks for any help. I appreciate it.

Allan

<VASSAL.build.module.map.LOS_Thread drawRange="true" global="Never" hideCounters="true" hideOpacity="37" hotkey="82,195" iconName="/images/thread.gif" label="" persistence="Never" persistentIconName="" rangeBg="0,0,0" rangeFg="255,255,255" report="" round="Nearest whole number" scale="0" snapEnd="true" snapStart="true" threadColor="255,255,51" threadName="Range" tooltip="Click/Drag to find range in hexes"/>
BigAl737
 
Posts: 47
Joined: July 10th, 2009, 6:47 am
Location: Eagle River, AK

Re: Invisible Opacity Level

Postby Tim M » March 7th, 2011, 2:08 pm

You can find the relevant Invisible trait code here

http://vassalengine.svn.sourceforge.net ... a?view=log

You wouldnt want to edit it but make a copied version which you would change and import as a custom class so It does not affect other modules. You would probably want this custom class to override/write? how hideable works. You really need Joel or Mike or Brent or Pieter (who's done a lot of this lately) tell you specifics here how to do it.

Going over the code it looks like (I think - could be wrong) that it is using java.awt.AlphasComposite to create the opacity effect for the hidden counter specifically the section:

Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3F));
piece.draw(g, x, y, obs, zoom);
g2d.setComposite(oldComposite);

I'm guessing you are going to want to change the AlphaComposite.SRC_OVER to 1.0F (which would be Clear).

See http://download.oracle.com/javase/1.4.2 ... osite.html
Tim,
Vassal Uber Geek/Guru

Problems? post your OS, Physical Mem, version of Vassal and Java plus the Module in question.
No developer can help with out that info, thx!
User avatar
Tim M
 
Posts: 1777
Joined: December 8th, 2007, 12:22 pm
Location: Earth

Re: Invisible Opacity Level

Postby BigAl737 » March 8th, 2011, 8:46 pm

This is very helpful Tim, thank you.

I've been searching previous posts for a tutorial on how to import a java class. I found one thread but this is such foreign territory for me that I'm still lost...albeit not as lost as when I first posed the question. Thanks again Tim.

What is the name of the class that the AlphaComposite.SRC_OVER resides in?

I assume I use a text editor to change the 0.3F to 1.0F and then save it with the class name.

Then do I place that file in the module zip archive?

Where does the program look for imported classes?

Many components of a module allow you to import a class. Does it matter where in the module you import the class? Since I'm applying this trait to specific game pieces I'm guessing that I should import the class to a prototype that is applied to all affected pieces.

Maybe Joel, Mike, Brent, or Pieter could chime in and make sure I'm on the right track?

I apologize for all the questions. I'm trying to learn. VASSAL is fantastic platform!

Thank you again in advance. I really appreciate your help.

Allan
BigAl737
 
Posts: 47
Joined: July 10th, 2009, 6:47 am
Location: Eagle River, AK

Re: [messages] [Module Design] Re: Invisible Opacity Level

Postby pgeerkens » March 9th, 2011, 6:22 am

I am still buried under arranging incorporation, and getting started on a
new contract. I am now pretty good at importing classes, but may not be able
to look at this for you until Friday. Remind me then.

Pieter

-----Original Message-----
From: messages-bounces@vassalengine.org
[mailto:messages-bounces@vassalengine.org] On Behalf Of BigAl737
Sent: Tuesday, March 08, 2011 3:47 PM
To: messages@vassalengine.org
Subject: [messages] [Module Design] Re: Invisible Opacity Level

This is very helpful Tim, thank you.

I've been searching previous posts for a tutorial on how to import a
java class. I found one thread but this is such foreign territory for me
that I'm still lost...albeit not as lost as when I first posed the
question. Thanks again Tim.

What is the name of the class that the AlphaComposite.SRC_OVER resides
in?

I assume I use a text editor to change the 0.3F to 1.0F and then save it
with the class name.

Then do I place that file in the module zip archive?

Where does the program look for imported classes?

Many components of a module allow you to import a class. Does it matter
where in the module you import the class? Since I'm applying this trait
to specific game pieces I'm guessing that I should import the class to a
prototype that is applied to all affected pieces.

Maybe Joel, Mike, Brent, or Pieter could chime in and make sure I'm on
the right track?

I apologize for all the questions. I'm trying to learn. VASSAL is
fantastic platform!

Thank you again in advance. I really appreciate your help.

Allan

_______________________________________________
Read this topic online here:
viewtopic.php?p=22117#p22117
Pieter
-----------------------------------------
"Even on the attack, I found the spade [to be] the equal of the rifle."
Erwin Rommel, Infantry Attacks
User avatar
pgeerkens
 
Posts: 228
Joined: September 12th, 2010, 4:33 am
Location: Hamilton, Ontario, Canada

Re: Invisible Opacity Level

Postby BigAl737 » March 12th, 2011, 3:25 am

Remind me then.

Pieter


Here's your friendly reminder Pieter, thanks. I won't be able to act on any suggestions for a week so please respond when convenient.

In case you need it, here's a link to the module. The specific pieces I'm trying to modify are all the Targets and the Alert and Hit markers. The Invisible trait assigned to the Targets is part of a prototype named AirUnitTarget.

Thank you.

http://preview.tinyurl.com/NFprv4a
BigAl737
 
Posts: 47
Joined: July 10th, 2009, 6:47 am
Location: Eagle River, AK

Re: Invisible Opacity Level

Postby BigAl737 » April 9th, 2011, 12:57 am

Remind me then.

Pieter



A friendly reminder to see if your schedule has let up Pieter or if anyone else can help me out.

Thanks.

Allan
BigAl737
 
Posts: 47
Joined: July 10th, 2009, 6:47 am
Location: Eagle River, AK


Return to Module Design

Who is online

Users browsing this forum: No registered users and 1 guest

cron