Token Context Menu

Progress reports and musings from the developers on the current gaming tools.

Moderators: dorpond, trevor, Azhrei

Post Reply
User avatar
LordAshes
Giant
Posts: 182
Joined: Mon Nov 22, 2010 12:51 pm

Token Context Menu

Post by LordAshes »

RP Tools is really great for Roleplaying applications but it also has great potential for other game table applications such a board games and card games.

However, to use it effectivly for some of these applications, I would like to eliminate some of the Roleplaying specific features...to make is as simple as possible for the players...and provide quick and easy access to application specific features (via macros).

In order to do so, I would like to mod the javascript file(s) so that the token context menu only displays the contents of the macro sub-menu. So the main level of the context menu would not exist at all and, instead, the macro sub-menu would be the main level of the token context menu.

I am guessing this should be fairly easy to do although, I am guessing, it has to be done by modifying the java files (as opposed to being able to do it via macro)...because the macro sub-menu already exists. Thus it should just be a matter of linking the token right click with the macro sub-menu instead of the main level of the context menu. Can someone show me how to do this or at least clue me in as to which javascript file I should be looking at?
"We often compare ourselves to the U.S.,
and often they come out the best...
But they only have the right to bare arms,
while we have the right to bare breasts"
Busting The Breast by Bowser & Blue

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: Token Context Menu

Post by Rumble »

As I recall, a good starting place would be the TokenPopupMenu class. I forget where in the source hierarchy it's located (somewhere under "client"), but that's where I'd look first.

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Token Context Menu

Post by jfrazierjr »

First, you do know that Javascript is NOT JAVA right? Second, based on the your comments, I want to make sure you understand that modifying the source is not enough. You have to build the MapTool jar at the very least using the ANT build script.

In any event, you want src/net/rptools/maptool/client/ui/TokenPopupMenu.java

Roughly on line 96 (I have changed things in there that are not in the SVN source at the moment) is addOwnedItem(createMacroMenu()); You would want to remove all of the other add* methods from the TokenPopupMenu constructor.

Then take most of the code in createMacroMenu and put it directly into the constructor.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
LordAshes
Giant
Posts: 182
Joined: Mon Nov 22, 2010 12:51 pm

Re: Token Context Menu

Post by LordAshes »

jfrazierjr wrote:First, you do know that Javascript is NOT JAVA right?
Yes. It has been a while since I used Java (as opposed to Javascript). If I remember correctly, Javascript is an abbridged version of Java that typically runs inline commands or from uncompiled js files (although I believe it can also run compiled jar files as long as they don't make use of any non-Javascript functions).

Please be patient with me...When it comes to Java/Javascript, I have mostly worked with Javascript and my Java knowledge extends to a couple small apps that I made many years ago...
jfrazierjr wrote:Second, based on the your comments, I want to make sure you understand that modifying the source is not enough. You have to build the MapTool jar at the very least using the ANT build script.
Thanks for the reminder...I had forgotten about that...It is all coming back to me...but slowly :lol:
jfrazierjr wrote:Roughly on line 96 (I have changed things in there that are not in the SVN source at the moment) is addOwnedItem(createMacroMenu()); You would want to remove all of the other add* methods from the TokenPopupMenu constructor.
Okay...I downloaded a JavaDecompiler. I extrated the JAR files into its CLASS files and then I use the JavaDecompiler to get the correspodning JAVA. So far so good (as far as I can tell).

I found the section that you were referring to and I think I should be able to mod it as per your suggestion.

However if it is not too much trouble could you refresh my memory on how I would then re-build the MapTool jar file? You refer to an ANT build script which is something I have completely forgotten. I am a programmer so I can follow programming instructions fairly well (without someone having to write detailed step by step instructions) but in this case I need some help.

I will try Googling it but in case I come up empty if someone has a few moments can you write down a rough outline of the re-build process?

Any help is much appreciated.
"We often compare ourselves to the U.S.,
and often they come out the best...
But they only have the right to bare arms,
while we have the right to bare breasts"
Busting The Breast by Bowser & Blue

User avatar
LordAshes
Giant
Posts: 182
Joined: Mon Nov 22, 2010 12:51 pm

Re: Token Context Menu

Post by LordAshes »

jfrazierjr wrote:You have to build the MapTool jar at the very least using the ANT build script.
Okay...I Googled ANT and found that it seems to be a app for building JAVA files. However it seems that you need to create the ANT file for your project in order to do the actual build.

When can I get the ANT file for MapTools so I don't need to create it from scratch? :?

I have looked the ANT manual which describes in detail how to make project files but there does not seem to me any Quick Reference on hot to use it if you already have a ANT build file (which I don't yet but I assume that one is available).

I should probably learn ANT but at the moment all I am looking for is instructions on how to use an existing MapTools ANT file to rebuild the MapTools file.
"We often compare ourselves to the U.S.,
and often they come out the best...
But they only have the right to bare arms,
while we have the right to bare breasts"
Busting The Breast by Bowser & Blue

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Token Context Menu

Post by Azhrei »

Um, you're probably taking the wrong approach. :|

All of the RPTools applications are open source. That means you can install Eclipse or NetBeans (the two most popular Java development tools, but there are others) and then download the source code instead of decompiling the class files!

There are sticky threads in this forum and the Java Programming Info subdirectory that will describe the process. Start there. :)

Last, Java and JavaScript are entirely different. So different, in fact, that they shouldn't have called the scripting language "JavaScript" as it's not related to Java at all. This is a common misnomer for someone who knows one of them and is interested in the other. :(

User avatar
LordAshes
Giant
Posts: 182
Joined: Mon Nov 22, 2010 12:51 pm

Re: Token Context Menu

Post by LordAshes »

Thanks for the info. I will give that a try and let you know how it works out :wink:
"We often compare ourselves to the U.S.,
and often they come out the best...
But they only have the right to bare arms,
while we have the right to bare breasts"
Busting The Breast by Bowser & Blue

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Token Context Menu

Post by Azhrei »

Np. Speak up if you have a question. :)

Post Reply

Return to “Developer Notes”