Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java 2 / Swing Counter-Strike Config Generator (WIP)

  • 31-10-2001 2:44am
    #1
    Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭


    java.jpg

    here is a work in progress of my adventures in swing gui creation.

    (btw does anyone know is it possible to put the JTabbedPanel format into an applet, without making an applet window?)


Comments

  • Posts: 0 [Deleted User]


    put all the CS options in, gwan, gwan , gwan. Put in sumink so as u can load and save yr settings seperate. Ooooh, Oooooh, ooooooh, and don't call it Toast.exe ;P


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    saving is super easy... you just fiddle with one massive string

    output = output + "net_graph "
    if (net_graph.getState() == true)
    output = output + "3";
    else
    output = output + "0";
    output = output + " // Show hide the netgraph"


    loading on the other hard is a super massive string parser and string buffer loader and mega stuff that i dont know how to do yet :)

    but then again the reason i am writing the program is to learn


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Perhaps you should think about storing the config as XML, of course you'd have to write a .cfg to XML converter but once that's done it would be pretty sweet.

    Games should be using XML for this kind of thing anyway. Suppose we'll see it in the next few years.


  • Registered Users, Registered Users 2 Posts: 3,316 ✭✭✭ButcherOfNog


    Originally posted by Enygma

    Games should be using XML for this kind of thing anyway. Suppose we'll see it in the next few years.

    congrats, you've just invented 'XGML'.

    Editor looks good dbc, saving the config as XML Enygma ... just to convert it to the correct .cfg format later ... plz explain the logic? Do you want to slow the saving & loading of the config for a particular reason or just for the hell of it. XML is cool technology when used correctly, sticking it in everything just for the sake of it is pointless, unless of course, DBC wants to learn some XML :)


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by DeadBankClerk
    saving is super easy... you just fiddle with one massive string

    <snip>

    loading on the other hard is a super massive string parser and string buffer loader and mega stuff that i dont know how to do yet :)

    As a thought, I would do the following :

    1) Allow it to "save" configurations, which are not saved as CS config files. The easiest way to do this is to have a serialisable object which contains your settings, serialise it and write to file. Later, you load from file and de-serialise. Wonderful.

    2) Allow it to "set" configurations, which takes the loaded configuration and generates the CS files for you in the correct location

    3) [Additional functionality for coolness and all that] write a CS-file-parser. You basically need to read in a CS file line-at-a-time and pattern-match it against known stuff.

    This way, if you hve steps one and two, I can use it to set up a specific configuration from scratch, and get it to set that config to my CS system when I want.

    Implementing option 3 simply allows me to read an existing CS config....which is most likely to be used by a user the first time they run the app, and never after!

    Also, if you implement the "config-reader", you should also get it to report to the user any items which it cannot parse. These can then be reported to you as bugs, or the user can at least verify that they have magic gunk in there for some reason.

    Looks good....best of luck with it.

    jc


  • Advertisement
  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    saving the config as XML Enygma ... just to convert it to the correct .cfg format later ... plz explain the logic? Do you want to slow the saving & loading of the config for a particular reason or just for the hell of it.

    Just a suggestion really, wasn't thinking about speed or performance or anything just thought it would be nice to have that type of thing stored as XML. Validation and editing would be easier, and the code would definetely be a lot cleaner and easier to maintain.
    Writing to a .cfg would be simple with an XSL. Besides it'd be a good thing to learn.

    But you're right, sticking XML into places it doesn't belong is pointless.

    Very cool app BTW!


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    i have been coding for the evening :)

    i have the graphics and player tabs now full of boxes and sliders :)
    adding sliders and buttons etc is easy
    writing the actionlistener code and the string changer is easy.

    but it takes so long to add *all* the buttons and strings....

    atm i have the output going directly to a JTextArea with load / save buttons ghosted out.

    so once my code is done for all the tick boxes/sliders i will implement save.

    then i will add a button binding section
    my idea is for a gui like any other game:

    Jump [______]

    and when the person clicks the textfield box beside jump it waits for a keyPressed event and puts the key name in the text field.

    as for XML i think i will give it a miss.


    out of interest, how many ppl have the java 2 plugin installed?


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    most people I'd imagine, if not 1.3. (I've got 1.3.1)
    Are you going to try signing it so you can do file IO, or are you just doing it as an application?


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    i'm going to run it as an application at first, becasue it is easier for me, then when it is made, i will convert it to an applet. does it cost money to get it signed or anything?


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    No it doesn't cost anything afaik- although I've never tried it myself so if you do it let us know how you get on - all the tools you need are in the JDK bin directory (v1.2+). As far as I can see it's just kind of niggly and takes a bit of setting up on both sides. This page has a good straightforward explanation on how to do it.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    java2.jpg

    mmm.. since the last pic i have made all the code nice and added actionlisteners for everything. tomorrow i will add the net settings, and maybe a few more graphics. then i will set up the file saving.

    once it saves i will attempt to get it bind keys (easy but i want a nice interface) and load files (big string parser with a few hundred if/then/else's), then i will try and turn my application into a signed applet.

    has anyone any idea how to make an interface similar to the quake3/half-life controls section?

    basically i want a button that when u click it it grabs the mouse and waits for a key input, then gives you back the mouse and writes the keyname on the button. other programs that are simialr to mine have a drop down list for every button in cs, others have a picture of a keyboards, with a big imagemap over it.

    tangent: if signing an aplet costs nothing, can anyone make a mega virus applet?


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Originally posted by DeadBankClerk
    tangent: if signing an aplet costs nothing, can anyone make a mega virus applet?
    Well you need to have a policy file set up on the client which specifies which applets can do what, and keys to recognise the signature need to be stored on the client too. So basically no, unless you get a really stupid person who will download any policy file and go to the bother of setting it up properly, without knowing where the applet came from or what it does. And that person almost deserves to get infected. :p
    basically i want a button that when u click it it grabs the mouse and waits for a key input
    I don't think that Java will let you control the postition of the mouse, but you could set the cursor to be invisible with
    Toolkit toolkit=Toolkit.getDefaultToolkit();
    byte blankBytes[]={};
    Image blankImage=toolkit.createImage(blankBytes);
    setCursor(toolkit.createCustomCursor(blankImage, new Point(0,0), ""));
    
    and then use a combination of a KeyListener and MouseListener to get which keys/mouse buttons have been pressed. The cursor will only be invisible while inside the applet though.


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    endLine.jpg


    does anyone know why the "\n" character is appearing as the black boxes? (like a q3 cfg)

    (my proggy now writes to disc :)
    only things left is to create a key-binding interface and maybe a mega string parser to load a cfg.


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    try \n\r or \r\n or something like that


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    String newLine = System.getProperty("line.separator");
    will get you the systems line separator.


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    ooh oooh oooh thats a very nice tip enygma it will come in very handy in the future I'm sure, super tip, and I'm not being sarcy even though it sounds uncannily similar.

    Baz_


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    The black box is cos java uses unicode, notepad uses ascii. I think. V. nice app, when it's finished can I download it? please? (+1 karma for cool java app)

    Question for everybody. Can you use Button arrays in java like you can in vb?


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by Evil Phil
    The black box is cos java uses unicode, notepad uses ascii. I think.

    Not the problem. If it was unicode problems, then every second character would be misinterpreted.

    The problem is that "\n" will put a unif LF (or does unix use CR) in place, instead of a CR/LF pair, and most pc editors are too stupid to auto-convert.

    Enygma's code is a neat solution to that :)
    V. nice app, when it's finished can I download it? please? (+1 karma for cool java app)

    Does karma still exist? How can people see their karma (I dont think I have any, but I used to, and I thought it had been dropped from the system).
    Question for everybody. Can you use Button arrays in java like you can in vb?
    What do you mean by "button" - command button?

    In java you can hook the same "event listener" to multiple controls, and identify the control which fired the event through the event object passed in. Which means that its actually more powerful than VB cause you dont need to specifically set up control arrays (which destory naming conventions IMHO), nor are you bound to only having an event handler for controls of the same type.

    jc


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    Originally posted by bonkey
    What do you mean by "button" - command button?

    i assume he means
    javax.swing.JButton[]


Advertisement