Rotghroth Rhapsody WiKiSpidweb Posted May 10, 2007 Share Posted May 10, 2007 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... 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. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted May 10, 2007 Share Posted May 10, 2007 Niemand's color-coding, Alinting, and snippeting are all worth attempting to match if possible. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted May 10, 2007 Author Share Posted May 10, 2007 I'll see what I can do, but I'm not exactly the world's greatest programmer. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted May 10, 2007 Share Posted May 10, 2007 Yay! Someone making a windows program for this purpose! I'll be happy to share my ideas, WKS, if there's anything you're curious about that I've done. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted May 10, 2007 Author Share Posted May 10, 2007 Awesome, I still have a bit to do to, especially with File reading and writing, before I can think about adding features, but after that I'd love to figure out how you did some of the things. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 3, 2007 Author Share Posted June 3, 2007 Still working on it. Adding every single call takes a while. 633 lines so far. If you want to see the code so far, it's here. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Khoth Posted June 3, 2007 Share Posted June 3, 2007 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. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 3, 2007 Author Share Posted June 3, 2007 Yeah, I've been trying to think of a way to do that, but so far, I've come up with nothing. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Khoth Posted June 3, 2007 Share Posted June 3, 2007 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 Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 3, 2007 Author Share Posted June 3, 2007 Thanks! I noticed however, in the documentation, that for some calls, Jeff omitted the void or short. An example would be reset_dialog() under Basic Dialogue Calls, curiously enough, your program did pick up reset_dialog_preset_options(short dialog_options) under the same category. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Khoth Posted June 3, 2007 Share Posted June 3, 2007 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. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 5, 2007 Author Share Posted June 5, 2007 With that convenient list, I made a program to save me a lot of time. I now only have five categories left to finish, before I can release the preliminary version. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Dintiradan Posted June 5, 2007 Share Posted June 5, 2007 I know a little Swing, so I can help with testing when the time comes. -------------------- It's official: shoes are the new WMD. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 5, 2007 Author Share Posted June 5, 2007 OK, the preliminary version is available here. Source file is here. You will also need this file. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Aran Posted June 6, 2007 Share Posted June 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk Jewels Posted June 6, 2007 Share Posted June 6, 2007 Well, we're not all as talented as you Aran. 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. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Dintiradan Posted June 6, 2007 Share Posted June 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
Hatchling Cockatrice Lilith Posted June 6, 2007 Share Posted June 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
Hatchling Cockatrice Mea Tulpa Posted June 6, 2007 Share Posted June 6, 2007 What Thuryl said. I mean, if you know how to code, you can theoretically write your own game engine, right? Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted June 6, 2007 Share Posted June 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 6, 2007 Author Share Posted June 6, 2007 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? Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted June 6, 2007 Share Posted June 6, 2007 Quote: Originally written by WiKiSpidweb:You do have Java installed, right? I have no idea. How do I know? Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 6, 2007 Author Share Posted June 6, 2007 Try downloading it here. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted June 6, 2007 Share Posted June 6, 2007 Yeah, I downloaded the appropriate Java update and still can't open the program. It says to check the Console for error messages, but I don't know where that is. I'm running OS 10.3.9, if it matters. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Dintiradan Posted June 6, 2007 Share Posted June 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted June 6, 2007 Share Posted June 6, 2007 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) Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 6, 2007 Author Share Posted June 6, 2007 Try it now. Here, if you don\'t feel like going back to previous page. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted June 7, 2007 Share Posted June 7, 2007 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) Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted June 7, 2007 Share Posted June 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Dintiradan Posted June 7, 2007 Share Posted June 7, 2007 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 Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 8, 2007 Author Share Posted June 8, 2007 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. Quote Link to comment Share on other sites More sharing options...
Rotghroth Rhapsody WiKiSpidweb Posted June 8, 2007 Author Share Posted June 8, 2007 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. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted June 9, 2007 Share Posted June 9, 2007 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. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted June 9, 2007 Share Posted June 9, 2007 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. Quote Link to comment Share on other sites More sharing options...
Articulate Vlish Octavo Posted July 1, 2007 Share Posted July 1, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.