// Path: baggle-client/src/inouire/baggle/client/Main.java
// public class Main {
// 
//     //global variables
//     public static String LOCALE=System.getProperty("user.language");
//     
//     public final static String VERSION = "3.7";
//     public final static int BUILD=3700;
//     
//     public static final String OFFICIAL_WEBSITE="http://baggle.org";
//     public static String MASTER_SERVER_HOST="masterserver.baggle.org";
//     public static int MASTER_SERVER_PORT=80;
//     
//     public static String STATIC_SERVER_IP="localhost";
//     public static int STATIC_SERVER_PORT=42705;
// 
//     public static boolean STORE_CONFIG_LOCALLY=false;
//     public static String CONNECT_ONLY_TO=null;
//     public static File CONFIG_FOLDER;
// 
//     public static MainFrame mainFrame;
// 
//     public static ServerConnection connection;
//     public static BotServerConnection bot;
//     
//     public static CachedServersList cachedServers;
//     public static CachedServersList cachedLANServers;
//     
//     public static AvatarFactory avatarFactory;
//     public static UserConfiguration configuration;
//         
//     public static void printUsage(){
//         System.out.println("B@ggle client version "+Main.VERSION);
//         System.out.println("Usage:      \n\t-M [master server host]"+
//                                        "\n\t-P [master server port]"+
//                                        "\n\t-l (store config file in current directory)");
//         System.out.println("All parameters are optionnal.");
//     }
//     
//     /**
//      * Main function for baggle-client.
//      * Schedules all the others
//      * @param Args the command line Arguments
//      */
//     public static void main(String[] args) throws InterruptedException {
// 
//         Utils.setBestLookAndFeelAvailable();
// 
//         printUsage();
//         
//         SimpleLog.initConsoleConfig();
//         SimpleLog.logger.setLevel(Level.INFO);
//         
//         MASTER_SERVER_HOST   = Args.getStringOption("-M",args,MASTER_SERVER_HOST);
//         MASTER_SERVER_PORT   = Args.getIntegerOption("-P", args, MASTER_SERVER_PORT);
//         STORE_CONFIG_LOCALLY = Args.getOption("-l",args);
//         CONNECT_ONLY_TO      = Args.getStringOption("--only",args,CONNECT_ONLY_TO);
//         
//         //set path of config folder
//         if(Main.STORE_CONFIG_LOCALLY){
//             CONFIG_FOLDER=new File(".baggle"+File.separator);
//         }else{
//             CONFIG_FOLDER=new File(System.getProperty("user.home")+File.separator+".baggle"+File.separator);
//         }
//         
//         //init graphical elements
//         avatarFactory=new AvatarFactory();
//         
//         //init main frame with connect panel only (for faster startup)
//         mainFrame = new MainFrame();
//         mainFrame.initConnectionPanel();
//         mainFrame.setVisible(true);
//         
//         //load configuration
//         configuration = new UserConfiguration();
//         configuration.loadFromFile();
//         
//         //load cached servers list
//         cachedServers = new CachedServersList(Main.MASTER_SERVER_HOST);
//         cachedServers.loadList(7);
//         
//         //set auto refresh for server detection
//         Timer T = new Timer();
//         T.schedule(new AutoRefresh(), 0, 120000);//every 2 minutes
//         
//         //now init the game part of the main frame
//         mainFrame.initGamePanel();
//              
//         //check for new version in the background
//         mainFrame.connectionPane.sideConnectionPane.newVersionPane.checkForNewVersion();
//     }
// }


import java.util.TimerTask;
import inouire.baggle.client.Main;
import inouire.basics.SimpleLog;
package inouire.baggle.client.threads;


/**
 *
 * @author edouard
 */
public class AutoRefresh extends TimerTask{

    @Override
    public void run() {
        
        if(!Main.mainFrame.inRoom()){
            SimpleLog.logger.debug("Auto refresh servers list & scores");
        
            //get information from master server
            new MasterServerHTTPConnection(Main.mainFrame.connectionPane.officialServersPane).start();
            
            //then get scores
// Path: baggle-client/src/inouire/baggle/client/Main.java
// public class Main {
// 
//     //global variables
//     public static String LOCALE=System.getProperty("user.language");
//     
//     public final static String VERSION = "3.7";
//     public final static int BUILD=3700;
//     
//     public static final String OFFICIAL_WEBSITE="http://baggle.org";
//     public static String MASTER_SERVER_HOST="masterserver.baggle.org";
//     public static int MASTER_SERVER_PORT=80;
//     
//     public static String STATIC_SERVER_IP="localhost";
//     public static int STATIC_SERVER_PORT=42705;
// 
//     public static boolean STORE_CONFIG_LOCALLY=false;
//     public static String CONNECT_ONLY_TO=null;
//     public static File CONFIG_FOLDER;
// 
//     public static MainFrame mainFrame;
// 
//     public static ServerConnection connection;
//     public static BotServerConnection bot;
//     
//     public static CachedServersList cachedServers;
//     public static CachedServersList cachedLANServers;
//     
//     public static AvatarFactory avatarFactory;
//     public static UserConfiguration configuration;
//         
//     public static void printUsage(){
//         System.out.println("B@ggle client version "+Main.VERSION);
//         System.out.println("Usage:      \n\t-M [master server host]"+
//                                        "\n\t-P [master server port]"+
//                                        "\n\t-l (store config file in current directory)");
//         System.out.println("All parameters are optionnal.");
//     }
//     
//     /**
//      * Main function for baggle-client.
//      * Schedules all the others
//      * @param Args the command line Arguments
//      */
//     public static void main(String[] args) throws InterruptedException {
// 
//         Utils.setBestLookAndFeelAvailable();
// 
//         printUsage();
//         
//         SimpleLog.initConsoleConfig();
//         SimpleLog.logger.setLevel(Level.INFO);
//         
//         MASTER_SERVER_HOST   = Args.getStringOption("-M",args,MASTER_SERVER_HOST);
//         MASTER_SERVER_PORT   = Args.getIntegerOption("-P", args, MASTER_SERVER_PORT);
//         STORE_CONFIG_LOCALLY = Args.getOption("-l",args);
//         CONNECT_ONLY_TO      = Args.getStringOption("--only",args,CONNECT_ONLY_TO);
//         
//         //set path of config folder
//         if(Main.STORE_CONFIG_LOCALLY){
//             CONFIG_FOLDER=new File(".baggle"+File.separator);
//         }else{
//             CONFIG_FOLDER=new File(System.getProperty("user.home")+File.separator+".baggle"+File.separator);
//         }
//         
//         //init graphical elements
//         avatarFactory=new AvatarFactory();
//         
//         //init main frame with connect panel only (for faster startup)
//         mainFrame = new MainFrame();
//         mainFrame.initConnectionPanel();
//         mainFrame.setVisible(true);
//         
//         //load configuration
//         configuration = new UserConfiguration();
//         configuration.loadFromFile();
//         
//         //load cached servers list
//         cachedServers = new CachedServersList(Main.MASTER_SERVER_HOST);
//         cachedServers.loadList(7);
//         
//         //set auto refresh for server detection
//         Timer T = new Timer();
//         T.schedule(new AutoRefresh(), 0, 120000);//every 2 minutes
//         
//         //now init the game part of the main frame
//         mainFrame.initGamePanel();
//              
//         //check for new version in the background
//         mainFrame.connectionPane.sideConnectionPane.newVersionPane.checkForNewVersion();
//     }
// }


// Path: baggle-client/src/inouire/baggle/client/threads/AutoRefresh.java
import java.util.TimerTask;
import inouire.baggle.client.Main;
import inouire.basics.SimpleLog;

package inouire.baggle.client.threads;


/**
 *
 * @author edouard
 */
public class AutoRefresh extends TimerTask{

    @Override
    public void run() {
        
        if(!Main.mainFrame.inRoom()){
            SimpleLog.logger.debug("Auto refresh servers list & scores");
        
            //get information from master server
            new MasterServerHTTPConnection(Main.mainFrame.connectionPane.officialServersPane).start();
            
            //then get scores
            Main.mainFrame.connectionPane.sideConnectionPane.scoresPane.updateScores();