Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • SantaHoHo: you wont regret when u join really nice server
      December 10, 2019, 06:35:18 PM
    • SantaHoHo: need staff :)
      December 10, 2019, 06:35:08 PM
    • SantaHoHo: divinescape.eu5.org
      December 10, 2019, 06:35:00 PM
    • SantaHoHo:[link]
      December 10, 2019, 06:34:39 PM
    • Moneyking800: Yanille is back! We’re in beta looking for new players. We are small around 5-10 players on at anytime atm looking for active testers to build off of! Yanille-os.com
      December 10, 2019, 06:14:45 PM
    • drubrkletern: be honest with me boss
      December 06, 2019, 01:31:52 AM
    • drubrkletern: now is it really that unique
      December 06, 2019, 01:31:47 AM
    • SuperNativeZ: COME PLAY THE MOST UNIQUE CUSTOM RSPS #1 [link][link][link]
      December 05, 2019, 09:22:55 PM
    • SuperNativeZ: FASTEST GROWING #1 UNIQUE CUSTOM RSPS [link][link][link]
      December 05, 2019, 09:22:42 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 60+ online : [link]
      December 05, 2019, 02:48:39 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      December 05, 2019, 02:48:31 PM
    • Cole1497: you click any of these links? those boner pills theyre selling are wicked
      December 04, 2019, 05:58:03 PM
    • Cole1497: oh shit vain whats crackin
      December 04, 2019, 05:57:49 PM
    • ArtexAdv: FASTEST GROWING #1 UNIQUE CUSTOM RSPS [link]
      December 04, 2019, 06:30:27 AM
    • Vain_: where the boys at
      December 01, 2019, 03:20:36 PM
    • black evil111: They should close this down, mostly the downloads section. The mods dont know how to do their jobs worth shit and its no excuse like "we have real life stuff going on" everyones replacable. Speaking of replacable, fix download links! Before I go to rune-server.
      December 01, 2019, 01:50:26 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      November 28, 2019, 12:41:24 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      November 28, 2019, 12:40:42 PM
    • 1strangler77: how do i post pictures on a post
      November 24, 2019, 05:16:18 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      November 23, 2019, 08:23:51 PM

    Author Topic: [ANY][667+ Preferred] Adding a Splash Screen to your client  (Read 1279 times)

    0 Members and 1 Guest are viewing this topic.

    Offlinearham 4

    • Member
    • ****
    • *
    • Posts: 6,721
    • Thanks: +0/-0
      • View Profile


    Yes, this has been released before. I am basing this off a previous release.

    This can be used for ANY client, but in the example I am using the clients Matrix uses.

    ---

    Hello! Today we are going to be adding a splash screen to our client. It's a pretty simple process.

    What we are doing exactly... BTC (Behind the Code)
    So, what we are going to do is make a new java file, SplashScreen.java, load when our client starts. In this SplashScreen class, we will have some variables that control the look of out splash screen when it appears and then our little showSplash() method, which shows our splash screen (Duh!).

    Adding the code
    Make a new java file and name it "SplashScreen". Add the following into it:
    Code: [Select]
    import java.awt.*;
    import javax.swing.*;
    import java.net.URL;

    import javax.imageio.ImageIO;

    /**
     * SplashScreen - Shows splash screen and starts client.
     *
     * @author Arham 4
     * @author Klepto
     */
    public class SplashScreen extends JWindow {

    /**
    * Splash screen duration (milliseconds).
    */
    private static int splashDuration = 5000;

    /**
    * Splash screen image.
    */
    private static String fileUrl = "http://i.imgur.com/kOLYMBd.png";

    /**
    * The dimensions of the splash screen.
    */
    private static int[] dimensions = {619, 349};

    /**
    * Shows splash screen in the center of desktop.
    */
    public static void showSplash() {
    Image image = null;
            try {
                URL url = new URL(fileUrl);
               image = ImageIO.read(url);
           } catch (Exception e) {
            e.printStackTrace();
            }
     
            JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
            frame.setSize(dimensions[0], dimensions[1]);
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
            JLabel label = new JLabel(new ImageIcon(image));
            frame.add(label);
            frame.setVisible(true);

    try { Thread.sleep(splashDuration); } catch (Exception e) {}
    frame.setVisible(false);
    }
    }
    splashDuration: int - This variables controls how long our splash screen stays on the screen (in milliseconds). You can choose to be cruel and make it 60000 (1 minute) or you can be nice and make it 2500 (2.5 seconds). Your choice.
    fileUrl: String - Here's something that didn't come in the Splash screen released a while back. And... this is also the reason why I made a new tutorial. This system is based on URL, whereas the previous was based on file, which would be bad because in our 667+ clients, we use Update Server, not auto-cache download, so we can't really transfer our file to another person's computer. Thus, let's just use an online URL?
    dimensions: int[] - These are the dimensions of the image. You want to make it exact.
    showSplash(): void - This is what initializes our splash screen.

    Now, you want to go to Loader.java and find:
    Code: [Select]
    public static void main(String[] args) {
    This method is the first method run by Java to run our client.

    Add the following directly below it:
    Code: [Select]
    SplashScreen splash = new SplashScreen();
    splash.showSplash();
    This makes the splash screen load as soon as the client starts.

    A more deeper look into the code.
    I need to make this qualify as a tutorial, so lets look at the showSplash() method.

    Code: [Select]
    /**
    * Shows splash screen in the center of desktop.
    */
    public static void showSplash() {
    Image image = null;
            try {
                URL url = new URL(fileUrl);
               image = ImageIO.read(url);
           } catch (Exception e) {
            e.printStackTrace();
            }
     
            JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
            frame.setSize(dimensions[0], dimensions[1]);
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
            JLabel label = new JLabel(new ImageIcon(image));
            frame.add(label);
            frame.setVisible(true);

    try { Thread.sleep(splashDuration); } catch (Exception e) {}
    frame.setVisible(false);
    }
    So first, we load the image from the URL we specified.
    Code: [Select]
    Image image = null;
            try {
                URL url = new URL(fileUrl);
               image = ImageIO.read(url);
           } catch (Exception e) {
            e.printStackTrace();
            }
    Then, we make our JFrame.
    Code: [Select]
            JFrame frame = new JFrame();
    And then we remove the window pane.
    Code: [Select]
    frame.setUndecorated(true);
    frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
    Next, we set the dimensions.
    Code: [Select]
            frame.setSize(dimensions[0], dimensions[1]);
    After that, we make the splash screen appear at the center of the screen.
    Code: [Select]
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
    After doing that, we load our image onto the JFrame.
    Code: [Select]
            JLabel label = new JLabel(new ImageIcon(image));
            frame.add(label);
    Then we set our JFrame as visible.
    Code: [Select]
            frame.setVisible(true);
    Next, we make the thread of the client "sleep", so it makes the pause that we said in the splashDuration.
    Code: [Select]
    try { Thread.sleep(splashDuration); } catch (Exception e) {}
    After the little nap our Thread had, we make the frame not visible, so the client can load.
    Code: [Select]
    frame.setVisible(false);

    ---

    And we are done. :)

    Tip: Don't use puush for uploading the image, the ImageIO for some reason throws an exception for puush.

    Thanks for reading,
    Arham

    P.S: My first time I EVER worked with the client. Clients really scare the hell out of me.
    « Last Edit: June 06, 2014, 04:29:13 PM by arham 4 »
    lolol remember when mopar was a thing
    Runescape Gambling

    OfflineAmbokile

    • Member
    • ****
    • Posts: 3,009
    • Thanks: +0/-0
      • View Profile
    Re: [ANY][667+ Preferred] Adding a Splash Screen to your client
    « Reply #1 on: June 06, 2014, 04:36:12 PM »
    Tip: Don't use puush for uploading the image, the ImageIO for some reason throws an exception for puush.

    Why would you use an online host instead of storing it with the client?

    Other than that, not a bad tutorial but it'd be better suited in the Client Hacking section

    Offlinearham 4

    • Member
    • ****
    • *
    • Posts: 6,721
    • Thanks: +0/-0
      • View Profile
    Re: [ANY][667+ Preferred] Adding a Splash Screen to your client
    « Reply #2 on: June 06, 2014, 04:41:17 PM »
    Tip: Don't use puush for uploading the image, the ImageIO for some reason throws an exception for puush.

    Why would you use an online host instead of storing it with the client?

    Other than that, not a bad tutorial but it'd be better suited in the Client Hacking section

    Totally forgot about that section to be honest haha.

    Also, my reasoning is:
    fileUrl: String - Here's something that didn't come in the Splash screen released a while back. And... this is also the reason why I made a new tutorial. This system is based on URL, whereas the previous was based on file, which would be bad because in our 667+ clients, we use Update Server, not auto-cache download, so we can't really transfer our file to another person's computer. Thus, let's just use an online URL?
    lolol remember when mopar was a thing

    OfflineAmbokile

    • Member
    • ****
    • Posts: 3,009
    • Thanks: +0/-0
      • View Profile
    Re: [ANY][667+ Preferred] Adding a Splash Screen to your client
    « Reply #3 on: June 06, 2014, 04:54:14 PM »
    Totally forgot about that section to be honest haha.

    Also, my reasoning is:
    fileUrl: String - Here's something that didn't come in the Splash screen released a while back. And... this is also the reason why I made a new tutorial. This system is based on URL, whereas the previous was based on file, which would be bad because in our 667+ clients, we use Update Server, not auto-cache download, so we can't really transfer our file to another person's computer. Thus, let's just use an online URL?

    Can you not send the splash screen image with the update server?

    Offlineenzo42

    • Member
    • ****
    • Posts: 784
    • Thanks: +0/-0
      • View Profile
    Re: [ANY][667+ Preferred] Adding a Splash Screen to your client
    « Reply #4 on: June 06, 2014, 05:54:54 PM »
       /**
        * The dimensions of the splash screen.
        */
       private static int[] dimensions = {619, 349};

    Why not just
    Code: [Select]
    private final static Dimension DIMENSION = new Dimension(619, 349);
    and why not make them final

    Nice one though

    Offlinearham 4

    • Member
    • ****
    • *
    • Posts: 6,721
    • Thanks: +0/-0
      • View Profile
    Re: [ANY][667+ Preferred] Adding a Splash Screen to your client
    « Reply #5 on: June 06, 2014, 06:30:30 PM »
       /**
        * The dimensions of the splash screen.
        */
       private static int[] dimensions = {619, 349};

    Why not just
    Code: [Select]
    private final static Dimension DIMENSION = new Dimension(619, 349);
    and why not make them final

    Nice one though
    I don't use the dimensions array in my client. I only did the array for the sake of the tutorial so people could edit it faster, thus I didn't really think whilst doing it.

    Thanks for the change, I think I'll change it in the tutorial.
    lolol remember when mopar was a thing

    OfflineInt Bauk

    • Member
    • ****
    • Posts: 958
    • Thanks: +0/-0
      • View Profile
    Re: [ANY][667+ Preferred] Adding a Splash Screen to your client
    « Reply #6 on: June 30, 2014, 11:28:49 AM »
    wouldn't need an array, two constants x and y would be fine


    but gj

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal