Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • Shady Aftermath: Skyfire317, The Only Server With Warding,Divination,Archaeology, AFK Auto Upgrade [link]
      July 09, 2020, 12:09:03 AM
    • Shady Aftermath: Skyfire317, The Only Server With Warding,Divination,Archaeology, AFK Auto Upgrade [link]
      July 09, 2020, 12:08:59 AM
    • Shady Aftermath: Skyfire317, The Only Server With Warding,Divination,Archaeology, AFK Auto Upgrade [link]
      July 09, 2020, 12:08:51 AM
    • demon dylan: anyone know moparscape call back link?
      July 08, 2020, 07:02:51 PM
    • ragnoroker: Brand new server! Less than 1 week old! Nightmare/Raids 1/2/Hydra/Pk Modes/Exp modes/ Unique  Join today - [link]
      July 04, 2020, 06:42:38 PM
    • ragnoroker: Brand new server! Less than 1 week old! Nightmare/Raids 1/2/Hydra/Pk Modes/Exp modes/ Unique  Join today - [link]
      July 04, 2020, 06:42:32 PM
    • iddsyou: PkOwnage 2 worlds, modern OSRS & 2014 server! [link]  Join us on Discord! [link]
      July 04, 2020, 11:07:29 AM
    • slayerpure: kingdom full blown custom server with over 50 custom bosses released last week. play now here     [link]
      July 02, 2020, 08:44:32 PM
    • jgoet: dodian !!
      July 02, 2020, 07:15:44 PM
    • jgoet: join [link]  its back online !!!!
      July 02, 2020, 07:15:37 PM
    • Protojae: RIP moparscape
      July 02, 2020, 03:01:32 PM
    • Protojae: obviously thiswebsite is dead as fudge
      July 02, 2020, 03:01:14 PM
    • ragnoroker: RuneGuild has just been released! 1 Hour old, Come join the fun - [link]
      June 26, 2020, 02:14:21 PM
    • ragnoroker: RuneGuild has just been released! 1 Hour old, Come join the fun - [link]
      June 26, 2020, 02:14:08 PM
    • ragnoroker: RuneGuild has just been released! 1 Hour old, Come join the fun - [link]
      June 26, 2020, 02:14:00 PM
    • Fox2007: rune-nexus.com - FREE advertising, SEO optimized - no registration required
      June 26, 2020, 06:21:47 AM
    • Decimate Returns: trailer video posted for Project Decimate, Official Launch is in a few weeks! watch here: [youtube]LBorsdI-k1Y[/youtube]
      June 24, 2020, 07:18:03 PM
    • slayerpure: 1 week old rsps we need players and potential staff, customs and goku/vegeta sets play here!    [link] join our discord [link]
      June 24, 2020, 05:23:46 PM
    • Decimate Returns: Project Decimate is still in BETA: join our discord to keep up with the new content added: [link]
      June 24, 2020, 01:09:23 PM
    • Decimate Returns: Project Decimate is still in BETA: join our discord to keep up with the new content added: [link]
      June 24, 2020, 01:09:03 PM

    Author Topic: [ANY][667+ Preferred] Adding a Splash Screen to your client  (Read 1348 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