2014-05-06 20:38:28 +00:00
|
|
|
package org.multimc;/*
|
2017-01-08 03:58:05 +00:00
|
|
|
* Copyright 2012-2017 MultiMC Contributors
|
2014-01-09 00:22:34 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2013-01-11 01:25:40 +00:00
|
|
|
|
|
|
|
import net.minecraft.Launcher;
|
2014-01-09 00:22:34 +00:00
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
2013-01-11 01:25:40 +00:00
|
|
|
import java.applet.Applet;
|
2014-01-09 00:22:34 +00:00
|
|
|
import java.awt.*;
|
2013-01-11 01:25:40 +00:00
|
|
|
import java.awt.event.WindowEvent;
|
|
|
|
import java.awt.event.WindowListener;
|
2014-01-09 00:22:34 +00:00
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2013-01-11 01:25:40 +00:00
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
|
|
|
|
2014-01-09 00:22:34 +00:00
|
|
|
public class LegacyFrame extends Frame implements WindowListener
|
2013-01-11 01:25:40 +00:00
|
|
|
{
|
2013-11-04 01:53:05 +00:00
|
|
|
private Launcher appletWrap = null;
|
2014-01-09 00:22:34 +00:00
|
|
|
public LegacyFrame(String title)
|
2013-11-04 01:53:05 +00:00
|
|
|
{
|
|
|
|
super ( title );
|
2014-01-09 00:22:34 +00:00
|
|
|
BufferedImage image;
|
2013-11-04 01:53:05 +00:00
|
|
|
try {
|
|
|
|
image = ImageIO.read ( new File ( "icon.png" ) );
|
|
|
|
setIconImage ( image );
|
|
|
|
} catch ( IOException e ) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
this.addWindowListener ( this );
|
|
|
|
}
|
|
|
|
|
2017-10-29 11:24:49 +00:00
|
|
|
public void start ( Applet mcApplet, String user, String session, int winSizeW, int winSizeH, boolean maximize )
|
2013-11-04 01:53:05 +00:00
|
|
|
{
|
|
|
|
try {
|
2014-01-09 00:22:34 +00:00
|
|
|
appletWrap = new Launcher( mcApplet, new URL ( "http://www.minecraft.net/game" ) );
|
2013-11-04 01:53:05 +00:00
|
|
|
} catch ( MalformedURLException ignored ) {}
|
|
|
|
appletWrap.setParameter ( "username", user );
|
|
|
|
appletWrap.setParameter ( "sessionid", session );
|
|
|
|
appletWrap.setParameter ( "stand-alone", "true" ); // Show the quit button.
|
2017-09-20 21:57:20 +00:00
|
|
|
appletWrap.setParameter ( "haspaid", "true" ); // Some old versions need this for world saves to work.
|
2014-01-09 00:22:34 +00:00
|
|
|
appletWrap.setParameter ( "demo", "false" );
|
|
|
|
appletWrap.setParameter("fullscreen", "false");
|
|
|
|
mcApplet.setStub(appletWrap);
|
2013-11-04 01:53:05 +00:00
|
|
|
this.add ( appletWrap );
|
2017-10-29 11:24:49 +00:00
|
|
|
appletWrap.setPreferredSize ( new Dimension (winSizeW, winSizeH) );
|
2013-11-04 01:53:05 +00:00
|
|
|
this.pack();
|
|
|
|
this.setLocationRelativeTo ( null );
|
|
|
|
this.setResizable ( true );
|
|
|
|
if ( maximize ) {
|
|
|
|
this.setExtendedState ( MAXIMIZED_BOTH );
|
|
|
|
}
|
|
|
|
validate();
|
|
|
|
appletWrap.init();
|
|
|
|
appletWrap.start();
|
|
|
|
setVisible ( true );
|
|
|
|
}
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
@Override
|
|
|
|
public void windowActivated ( WindowEvent e ) {}
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
@Override
|
|
|
|
public void windowClosed ( WindowEvent e ) {}
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
@Override
|
|
|
|
public void windowClosing ( WindowEvent e )
|
|
|
|
{
|
|
|
|
new Thread() {
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
Thread.sleep ( 30000L );
|
|
|
|
} catch ( InterruptedException localInterruptedException ) {
|
|
|
|
localInterruptedException.printStackTrace();
|
|
|
|
}
|
|
|
|
System.out.println ( "FORCING EXIT!" );
|
|
|
|
System.exit ( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.start();
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
if ( appletWrap != null ) {
|
|
|
|
appletWrap.stop();
|
|
|
|
appletWrap.destroy();
|
|
|
|
}
|
|
|
|
// old minecraft versions can hang without this >_<
|
|
|
|
System.exit ( 0 );
|
|
|
|
}
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
@Override
|
|
|
|
public void windowDeactivated ( WindowEvent e ) {}
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
@Override
|
|
|
|
public void windowDeiconified ( WindowEvent e ) {}
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
@Override
|
|
|
|
public void windowIconified ( WindowEvent e ) {}
|
2013-01-11 01:25:40 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
@Override
|
|
|
|
public void windowOpened ( WindowEvent e ) {}
|
|
|
|
}
|