Thread: component system v3

Results 1 to 7 of 7
  1. #1 component system v3 
    Community Veteran

    Songoty's Avatar
    Join Date
    Dec 2007
    Posts
    2,740
    Thanks given
    211
    Thanks received
    1,034
    Rep Power
    2455
    Hello. I'll be maintaining this thread with updates to this system. I am on holidays from work for a week and will be finishing this up.

    It's that time of year again where I write a different component system for the user interface system in my client.

    This time around it is using a 'widget' system for the different pieces of each component.

    Here's a quick example of a login screen using the default runescape login box and what not. obviously it is not a finished login screen but it gets the point of what i'm trying to accomplish with this system across.

    Code:
    package com.ardetus.client.ui.component.impl;
    
    import com.ardetus.client.Ardetus;
    import com.ardetus.client.GlobalConstants;
    import com.ardetus.client.rs.drawing.ImageProducingBuffer;
    import com.ardetus.client.rs.media.Sprite;
    import com.ardetus.client.ui.component.UserInterfaceComponent;
    import com.ardetus.client.ui.widget.impl.ButtonWidget;
    import com.ardetus.client.ui.widget.impl.TextBoxGroupWidget;
    import com.ardetus.client.ui.widget.impl.TextBoxWidget;
    
    /**
     *
     * @author Benjamin Purcell <[email protected]>
     */
    public class LoginScreenComponent extends UserInterfaceComponent {
    
        @Override
        public void draw(ImageProducingBuffer imageProducer) {
            imageProducer.initDrawingArea();
            int centerX = Ardetus.getWidth() / 2;
            int centerY = Ardetus.getHeight() / 2;
            background.drawSprite(centerX - (background.myWidth / 2), centerY - (background.myHeight / 2));
            titleBox.drawSprite(centerX - 176, centerY - 100);
            group.draw(centerX - 90, centerY - 20);
            imageProducer.drawGraphics(0, Ardetus.getClient().graphics, 0);
        }
        
        @Override
        public void clicked(int x, int y, int type) {
            if(type == GlobalConstants.CLICK_TYPE_FIRST) {
                
            }
        }
    
        @Override
        public void mouseOver(int x, int y) {
        }
    
        @Override
        public void input(char c) {
            group.input(c);
        }
        
        @Override
        public void load() {
            group = new TextBoxGroupWidget(this);
            group.setCapacity(2);
            group.setSpacing(30);
            
            TextBoxWidget username = new TextBoxWidget(this);
            username.setType(TextBoxWidget.Type.SINGLE);
            username.setSelected(true);
            username.setAcceptSpecialCharacters(false);
            username.setCharacterLimit(12);
            username.setInputColour(0xFFFFFF);
            username.setLabelColour(0xFFFFFF);
            username.setLabel("Username");
            username.setText(Ardetus.getClient().myUsername);
            username.setTextDrawingArea(Ardetus.getClient().chatTextDrawingArea);
            group.add(username);
            
            TextBoxWidget password = new TextBoxWidget(this);
            password.setType(TextBoxWidget.Type.SINGLE);
            password.setAcceptSpecialCharacters(false);
            password.setCharacterLimit(18);
            password.setInputColour(0xFFFFFF);
            password.setLabelColour(0xFFFFFF);
            password.setLabel("Password");
            password.setMasked(true);
            password.setTextDrawingArea(Ardetus.getClient().chatTextDrawingArea);
            group.add(password);
            
            loginButton = new ButtonWidget(this) {
                
                @Override
                public void clicked(int x, int y) {
                    Ardetus.getClient().login(group.getTextBox(0).getText(), group.getTextBox(1).getText(), false);
                }
            };
            
            loginButton.setLabel("Login");
            loginButton.setNormalSprite(new Sprite(Ardetus.getFileStore().getArchive("sprites"), "titlebutton"));
            
            titleBox = new Sprite(Ardetus.getFileStore().getArchive("sprites"), "titlebox");
            background = new Sprite(Ardetus.getFileStore().getArchive("sprites"), "login_background");
        }
        
        private TextBoxGroupWidget group;
        
        private ButtonWidget loginButton;
        
        private Sprite titleBox;
            
        private Sprite background;
        
    }
    Result: (Direct Link)



    Here's the loading screen. No need for a picture as it looks just like the default loading bar screen without a background. Will be making the progress bar accept different dimensions but it's not needed right now.

    Code:
    package com.ardetus.client.ui.component.impl;
    
    import com.ardetus.client.Ardetus;
    import com.ardetus.client.rs.drawing.ImageProducingBuffer;
    import com.ardetus.client.ui.component.UserInterfaceComponent;
    import com.ardetus.client.ui.widget.impl.ProgressBarWidget;
    
    /**
     *
     * @author Benjamin Purcell <[email protected]>
     */
    public class LoadingScreenComponent extends UserInterfaceComponent {
    
        @Override
        public void draw(ImageProducingBuffer imageProducer) {
            imageProducer.initDrawingArea();
            progressBar.draw(Ardetus.getWidth() / 2, Ardetus.getHeight() / 2);
            imageProducer.drawGraphics(0, Ardetus.getClient().graphics, 0);
    
        }
        
        @Override
        public void clicked(int x, int y, int type) {
        }
    
        @Override
        public void mouseOver(int x, int y) {
        }
    
        @Override
        public void input(char c) {
        }
        
        @Override
        public void load() {
            progressBar = new ProgressBarWidget(this);
            progressBar.setLabel("Starting up");
            progressBar.setPercent(0);
            progressBar.setFillColour(0x8c1111);
            progressBar.setBorderColour(0x8c1111);
            progressBar.setEmptyColour(0x000000);
            progressBar.setTextColour(0xFFFFFF);
        }
    
        public ProgressBarWidget getProgressBar() {
            return progressBar;
        }
        
        private ProgressBarWidget progressBar;
    }
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Stanaveli's Avatar
    Join Date
    Aug 2014
    Posts
    1,490
    Thanks given
    184
    Thanks received
    653
    Rep Power
    1338
    Very nice lad.
    Keep your head up.



    Reply With Quote  
     

  4. #3  
    High Quality Designs

    JxkeDesigns's Avatar
    Join Date
    Nov 2015
    Posts
    194
    Thanks given
    117
    Thanks received
    34
    Rep Power
    89
    Good stuff
    Reply With Quote  
     

  5. #4  
    Rune-Server Affiliate

    Join Date
    Apr 2014
    Posts
    1,761
    Thanks given
    75
    Thanks received
    714
    Rep Power
    1073
    Damn, this is awesome!
    What are things do you plan on implementing with this system?
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Community Veteran

    Songoty's Avatar
    Join Date
    Dec 2007
    Posts
    2,740
    Thanks given
    211
    Thanks received
    1,034
    Rep Power
    2455
    Thought I'd give some insight to the client as I usually do in these kinds of threads.

    The client originally used is Mopar's srcAllDummiesRemoved. There have been extensive modifications and code overhauls preformed on this client.

    • Different build numbering
      • If you notice from the screenshot, the build is 15. It's easier for me and my partner to keep records of what builds introduced so and so changes by starting at '1' and going up with each notable change
    • Different file storage system
      • Runescape's file store (cache) system has been removed completely. In place is a system I've been working on for the past year or so on/off. Here's a picture of the layout.
      • With the new file store system, as well as the changes made to how models, maps, and so on are loaded, the client is ready for login after 2 or so seconds after starting up
      • Updates are handled by the client loader and the patch server. The patch server contains the raw files separated into their archives by folder. On startup, it builds the archive files and is prepared to send modified files to the loader as the loader requests them.
    • A phrase system has been implemented (language archive) for easier translation of the client into different languages. I've only written one phrase implementation (generic english) and have yet to fully covert all strings to it but you get the gist of it
    • Refactoring and repackaging. The refactoring would probably be shunned by some members of this community as I have a gross misunderstanding of a lot of things in the client, but since this client is not meant for general use outside of Ardetus it does not affect you. I'm constantly refactoring things as I understand the various parts better.
    • Changed the 'RSFrame' to 'FrameWrapper' and it is now using the JFrame class. As well as 'RSApplet' is using JApplet. Small change.


    That's just some of it and all I can think of off the top of my head. If you have any questions or comments please feel free to post them. I may end up posting a project thread in the Rs2 Server section to detail the World Server but that will be a bit later on.

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

    @Zion

    Lol I think you asked me nearly the same question in my last thread about this a year ago!

    I'd like everything relating to the UI being doing through a component. Chat area, tab area, minimap, etc.

    As well as interfaces. For the interfaces however I'm still thinking about the best way to do that. I started writing a new interface system as you can see from the screenshot (GameInterface) but maybe I would be able to convert the 317 interface system to mine. I'm not really too sure though.

    The real point of this system is if at any point I find myself a co-developer that he/she would be able to understand how to make new UI components in a fraction of the time rather than having to dig through the Client class, add this to process input, add that to drawGameArea, add that to mousemovement, etc.

    And if anyone is thinking 'jeez, why does this songoty guy keep posting threads like this, this is the third time he has done this system', there's something wrong with me where I'm never satisfied with what I have written and then rewrite it. The last two times were great in and of themselves, but they left me wanting more. I also for a while last year had to stop programming all together as I was working very long days with very few days off. And then promptly deleted the client from my version control and computer.
    Reply With Quote  
     

  8. #6  
    Retired. Stop PMing me.


    Galkon's Avatar
    Join Date
    Nov 2007
    Age
    17
    Posts
    7,526
    Thanks given
    1,805
    Thanks received
    2,830
    Rep Power
    5000
    Once again looks pretty similar to component systems I've written as well. It makes updating things so much easier, or writing new login screens and such, adding new gameframes etc.

    Just pls don't forget to watch the following:

    -Memory usage due to instantiated sprites and other variables not needed (etc when you login, it should dispose of title screen resources. When you logout, it should dispose of game scene resources.
    -Drawing/redrawing of components (don't draw every component every cycle, make it only draw() when an update to the component/widget is required. Big mistake in a lot of 317s as we've reworked game frames and resizable and all that.
    Attached image
    Reply With Quote  
     

  9. #7  
    Community Veteran

    Songoty's Avatar
    Join Date
    Dec 2007
    Posts
    2,740
    Thanks given
    211
    Thanks received
    1,034
    Rep Power
    2455
    Quote Originally Posted by Galkon View Post
    Once again looks pretty similar to component systems I've written as well. It makes updating things so much easier, or writing new login screens and such, adding new gameframes etc.

    Just pls don't forget to watch the following:

    -Memory usage due to instantiated sprites and other variables not needed (etc when you login, it should dispose of title screen resources. When you logout, it should dispose of game scene resources.
    -Drawing/redrawing of components (don't draw every component every cycle, make it only draw() when an update to the component/widget is required. Big mistake in a lot of 317s as we've reworked game frames and resizable and all that.
    I'm not overly concerned about a few megabytes of memory used for the login screen component, but you are correct about the drawing. Drawing them constantly is not needed. This client still has normal image producers and an unmodified game frame. it supports fullscreen somewhat but it just doesn't draw anything other than the game right now
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. What components should a minigame system have?
    By Ambient in forum RS2 Server
    Replies: 6
    Last Post: 04-15-2012, 11:39 PM
  2. Replies: 12
    Last Post: 04-22-2008, 03:18 AM
  3. "Magicka" system! Replacement for runes!
    By Oh Noes! PIERATS! in forum Tutorials
    Replies: 9
    Last Post: 06-10-2007, 12:58 PM
  4. Replies: 15
    Last Post: 05-31-2007, 09:57 AM
  5. Interchat System
    By sarah101 in forum Tutorials
    Replies: 6
    Last Post: 05-16-2007, 03:06 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •