Jump to content

BoAEdit


Recommended Posts

I am working on a simple utility for script writing at the moment. I though I would give people a heads up to let you know, solicit advice, etc...

screenshot.JPG

Basically, what I have in mind is a text editor, where you can go up to the menu bar and select a call, instead of having to write it in yourself. I know Niemand is making some sort of script editor, but it is Mac only. Since I am making this in Java, it should be cross-platform.

Link to comment
Share on other sites

  • 4 weeks later...

I think that rather than manually adding two lines of code for each option, you'd be better off having your code read in the menu options from some kind of configuration file (or have some way to make it only one line of code per option).

 

I needed to get a list of calls for alint, and I was able to do a lot of it by doing crazy find/replace tricks on the editor documentation.

Link to comment
Share on other sites

For extracting the calls from the docs, you can do find-and-replace tricks (probably with regular expressions). A call starts with "short" or "void" at the start of a line, and ends with the first ")" after that. Once you've sucked them out, you can do any other replacements you need to do to get them in the form you want.

 

Edit: I'm feeling helpful, and I wanted perl practice, so here you go: http://khoth.ath.cx/~khoth/calls.txt

 

This was done by putting the docs appendix into a text file, and running:

Code:
perl -pi -e 's/(^(short|void|string).*?\)).*/\1/' calls.txtperl -ni -e 'print if /(^(short|void|string).*)|(.*Calls)/' calls.txt
Link to comment
Share on other sites

Hmm, yeah, you'll need to skim through and manually add the missing ones.

 

The reason reset_dialog_preset_options(short dialog_options) is on the list is that actually I lied about the commands I did - I forgot to include the beginning-of-line anchors, and manually fixed up the non-call stuff that got left in by that. Without them, the "short" in the parameter for that call matches and makes it stay in.

Link to comment
Share on other sites

It's a rather neat tool, but I question the concept a bit.

 

One of the major improvements about BoA scripts (to me) is that I can write out the call I want in a text editor rather than having to navigate and click through about three different menus or dialog windows as in BoE.

 

In fact, one of my wishes for an improved scenario editor is to somehow do away with the Item and Creature selection menus as well. Going through five lists to find that blasted Goblin or Vahnatai is hell.

 

These days, I design towns with both corescendata files open in the editor, and if I need something, I use a text search so I know exactly where to look in the menus.

Link to comment
Share on other sites

Well, we're not all as talented as you Aran. :p

 

Those of us with less knowledge and shorter memories find point and click irreplacable.

 

I haven't attempted to write a BoA scenario yet because of my lack of scripting knowledge and I'm eagerly awaiting the Windows versions of the afore mentioned utilities.

Link to comment
Share on other sites

Huh. For some strange reason, I don't have java.util.Scanner in rt.jar, even though I downloaded the latest Windows SDK yesterday. Must have hit an old link.

 

I just tried it for a second on my Linux box at work. You don't terminate the application when you close the window (you don't notice this unless you're running from the command line). You need something like:

Code:
frame.addWindowListener(new WindowAdapter() {	public void windowClosing(WindowEvent event) {		System.exit(0);	}});
I'll get to more extensive testing later once I get the right SDK at home.

 

--------------------

I was in the first submarine. Instead of a periscope, they had a kaleidoscope. "We're surrounded."

- Steven Wright

Link to comment
Share on other sites

Quote:
Originally written by Dr. Johann Georg Faust:
It's a rather neat tool, but I question the concept a bit.

One of the major improvements about BoA scripts (to me) is that I can write out the call I want in a text editor rather than having to navigate and click through about three different menus or dialog windows as in BoE.

In fact, one of my wishes for an improved scenario editor is to somehow do away with the Item and Creature selection menus as well. Going through five lists to find that blasted Goblin or Vahnatai is hell.
Maybe for you, but those of us who don't write code for a living tend to prefer the way BoE's scenario editor works. Having to write out a whole lot of little scripts in a text editor is pretty much the #1 complaint about BoA scenario design.
Link to comment
Share on other sites

I have always said that the menu interface for the scenario editor sucks badly, and the obvious replacement is a palette system (as we have for floors and terrains, but for creatures and items, too). This is what the BoA Editor Remake was supposed to accomplish, but it never managed to do so.

 

I have said before that a drag-and-drop interface would be by far the best for a script editor. That said, I'll have to try this out to see how it is.

 

Um, this is supposed to be cross-platform, right? How do I get it to run on a Mac? I tried to download it and open it, and it just crashed and said it couldn't be opened.

Link to comment
Share on other sites

I'm definitely aware that you don't always want to have to point and click, but since most of us don't have all of the calls memorized, I think the menu's make it a lot easier to insert a call. Note that it works as a bare bones text editor as well. There are many flaws in the current design, and with time, I intend to iron them out and expand to include more features. I'm learning as I go, however, so don't expect miracles.

 

EDIT: You posted while I was writing, Kel. I'm not sure why it doesn't run properly on a Mac, not having one myself. You do have Java installed, right?

Link to comment
Share on other sites

Open up a command-line window/terminal/whatever it is for Macs, go to the directory you have the .jar file, and then run it.

 

For example, if you put the .jar into '/Kel/Folder', type "cd /Kel/Folder" to get to the directory, and then type "java -jar BoaEdit.jar" to run the .jar. If there are any errors when you run it, they should be printed out onto the screen.

 

--------------------

I was sad because I had no shoes, until I met a man who had no feet. So I said, "Got any shoes you're not using?"

- Steven Wright

Link to comment
Share on other sites

This is what I get:

 

Code:
 Exception in thread "main" java.lang.Error: Do not use javax.swing.JFrame.setLayout() use javax.swing.JFrame.getContentPane().setLayout() instead        at javax.swing.JFrame.createRootPaneException(JFrame.java:465)        at javax.swing.JFrame.setLayout(JFrame.java:531)        at boaEdit.BoaEdit.<init>(BoaEdit.java:1152)        at boaEdit.BoaEdit.main(BoaEdit.java:1282)  
Link to comment
Share on other sites

Now it gives me

Code:
 Exception in thread "main" java.lang.Error: Do not use javax.swing.JFrame.add() use javax.swing.JFrame.getContentPane().add() instead

at javax.swing.JFrame.createRootPaneException(JFrame.java:465)

at javax.swing.JFrame.addImpl(JFrame.java:491)

at java.awt.Container.add(Container.java:307)

at boaEdit.BoaEdit.<init>(BoaEdit.java:1156)

at boaEdit.BoaEdit.main(BoaEdit.java:1284)

Link to comment
Share on other sites

WKS, you can simplify the program a lot if instead of hard coding all of the calls into the menus, you have the program read them in from a file. I put together a quick test like this:

Code:
	private void populateCallMenus() throws Exception, FileNotFoundException, IOException{		File file = new File("calls.txt");		BufferedReader in;		in=new BufferedReader(new FileReader(file));		String line;		int lineOn = 0;		int state = 0; //1=valid menu, 2=submenu, 3=item		JMenu curMenu = null;		JMenu curSubMenu = null;		JMenuItem curItem = null;		try{			while((line=in.readLine())!= null){				lineOn++;				line=line.trim();				if(line.indexOf("//")>0){					line=line.substring(0,line.indexOf("//"));				}				if(line.startsWith("M")){					line=line.substring(2);					if(state<1)						state=1;					curMenu = new JMenu(line);					menuBar.add(curMenu);				}				if(line.startsWith("S")){					if(state<1)						throw new Exception("Error: can't create a submenu without a valid menu to put it in.");					line=line.substring(2);					if(state<2)						state=2;					curSubMenu = new JMenu(line);					curMenu.add(curSubMenu);				}				if(line.startsWith("I")){					if(state<2)						throw new Exception("Error: can't create an item without a valid sub-menu to put it in.");					line=line.substring(2);					if(state<3)						state=3;					curItem = new JMenuItem(line);					curItem.addActionListener(this);					curSubMenu.add(curItem);				}							}		}catch(Exception e){			throw new Exception("There was an error while processing line " + lineOn + " of " + file.getName() + ": " + e.getMessage());		}		in.close();	}
Which reads a file formatted like this:

 

Code:
M:Calls 1S:Basic Script and I/O CallsI:print_big_str(string str,short num_to_print,string str2);I:print_big_str_color(string str,short num,string str2,short color);S:Campaign and Scenario CallsI:clear_quest(short which_quest);I:end_scenario(short party_won);M:Calls 2S:Basic Dialog Box CallsI:reset_dialog();I:add_dialog_choice(short which_option,char choice_text);S:Terrain Script and Creature Script CallsI:can_see_loc(short loc_x, short loc_y)I:damage_nearby(short damage_amount,short radius,short damage_type,short good_evil_or_all);
(M lines specify a new menu, S lines specify a new submenu, and I lines specify menu items.)

 

Then, to create the menus, you can replace all the existing code with:

Code:
		try{			populateCallMenus();		}catch (Exception e){			JOptionPane.showMessageDialog(null, e.getMessage(), "Error while populating menus", JOptionPane.ERROR_MESSAGE);		}
right between when you add the Edit and Analyse menus to the menubar.

 

Because I have little experience with jar files, I've just written it so that the calls.txt file has to be in the directory with the jar file, no doubt there's an elegant way to put it inside. Anyway, I just thought you might find this useful.

Link to comment
Share on other sites

What Niemand said. Not only will it simplify the code, it will also make it very easy to add, remove, and rearrange commands. And with a bit of tweaking, end-users would be able to make their own custom commands. Remember, Laziness is the first of the Three Great Virtues of a Programmer.

 

I didn't play around with it that much (I was watching the Sens choke last night), but I've put a couple changes on here . All my changed are surrounded by "// START DINTIRADAN" and "// END DINTIRADAN" comments (gaze in awe at my version control). Nothing major: I removed the small text field (what was it there for?) and made the program terminate when the window gets closed. I fixed Kel's first problem, but the second still needs to be addressed (shouldn't be hard; just replace 'window.add(' with 'window.getContentPane().add(' ).

 

I also tried to make the text field change size based on the window's size (it's the ComponentAdapter). It doesn't work too well, and I'm sure there's a better way to do it. The scroll pane only resizes after you're done resizing the window.

 

Finally, I noticed that a saved file has Unix line endings. If you save a file, then try to open it with a really simple text editor that can't convert line endings, everything appears on one line. I was surprised by this, I though Java automatically converted line endings.

 

Other than those few things, it's looking great. A great feature to add would be a menu for stubs of different types of scripts (an option to load basicnpc; an option for generating the outline of START_STATE, INIT_STATE, and EXIT_STATE; etc.).

 

--------------------

I went to court for a parking ticket. I pleaded insanity. I said, "Your honor, why would anyone in their right mind park in the passing lane?"

- Steven Wright

Link to comment
Share on other sites

Thanks for the feedback. I'm intrigued by your idea, Niemand, and will have to play around with it a bit.

Your fixes look good, Dintiradan.

The text field was something I was using early in the design for debugging. It can go. With that gone I only have one component to go in the JFrame, so I don't need the to setLayout() or whatever the call is. Without the FlowLayout, it looks like the JScrollBar resizes dynamically with the JFrame. I don't know if this is true for all computers, or just some.

Link to comment
Share on other sites

It works! I can get it up and running. It looks kinda funny, though. Here's a screenshot ; note the upper left corner, where there's the real menu on top and then the BoaEdit menus attached to the BoaEdit window.

 

It's not a pressing issue, by any means, because it works, but I just thought I'd let you know.

Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...