BoAEdit

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).

Pages

AuthorTopic: BoAEdit
Off With Their Heads
Member # 4045
Profile Homepage #25
This is what I get:

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)


--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Infiltrator
Member # 3441
Profile Homepage #26
Try it now.
Here, if you don't feel like going back to previous page.

--------------------
"As our circle of knowledge expands, so does the circumference of darkness surrounding it." --Albert Einstein
--------------------
BoaEdit
Posts: 536 | Registered: Sunday, September 7 2003 07:00
Off With Their Heads
Member # 4045
Profile Homepage #27
Now it gives me
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)


--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Infiltrator
Member # 5576
Profile Homepage #28
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:
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:

M:Calls 1
S:Basic Script and I/O Calls
I: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 Calls
I:clear_quest(short which_quest);
I:end_scenario(short party_won);
M:Calls 2
S:Basic Dialog Box Calls
I:reset_dialog();
I:add_dialog_choice(short which_option,char choice_text);
S:Terrain Script and Creature Script Calls
I: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:
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.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Guardian
Member # 6670
Profile Homepage #29
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

[ Thursday, June 07, 2007 10:09: Message edited by: Dintiradan ]
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
Infiltrator
Member # 3441
Profile Homepage #30
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.

--------------------
"As our circle of knowledge expands, so does the circumference of darkness surrounding it." --Albert Einstein
--------------------
BoaEdit
Posts: 536 | Registered: Sunday, September 7 2003 07:00
Infiltrator
Member # 3441
Profile Homepage #31
I know this is a double post, but my sig now contains a link to the download page for BoaEdit. I made some minor changes.

--------------------
"As our circle of knowledge expands, so does the circumference of darkness surrounding it." --Albert Einstein
--------------------
BoaEdit
Posts: 536 | Registered: Sunday, September 7 2003 07:00
Off With Their Heads
Member # 4045
Profile Homepage #32
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.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Infiltrator
Member # 5576
Profile Homepage #33
The thing with the menus is an unfortunate effect of using Java. It can be fixed, but it would require a Mac OS specific version.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Apprentice
Member # 4231
Profile #34
No, but it would require an operating system check or best-case getting the local menu lookAndFeel. Which probably wouldn't be too bad on the whole but I couldn't figure it out last time I tried. The option is there, since this is bright shiny Java.

--------------------
Lifetime Spiderweb Gamer
and Fan of Classic Style Graphics
Posts: 42 | Registered: Saturday, April 10 2004 07:00

Pages