diff options
-rw-r--r-- | build.xml | 3 | ||||
-rwxr-xr-x | src/jake2/CompatibilityApplet.java | 157 | ||||
-rw-r--r-- | src/jake2/Globals.java | 12 | ||||
-rwxr-xr-x | src/jake2/Jake2Applet.java | 130 | ||||
-rwxr-xr-x | src/jake2/SizeChangeListener.java | 15 | ||||
-rw-r--r-- | src/jake2/qcommon/Q2DataDialog.java | 14 | ||||
-rw-r--r-- | src/jake2/render/opengl/Jsr231Driver.java | 219 | ||||
-rw-r--r-- | src/jake2/sys/JOGLKBD.java | 60 | ||||
-rw-r--r-- | src/jake2/sys/Sys.java | 12 |
9 files changed, 514 insertions, 108 deletions
@@ -26,6 +26,7 @@ <pathelement location="lib/joal/joal.jar"/> <pathelement location="lib/lwjgl/lwjgl.jar"/> <pathelement location="lib/lwjgl/lwjgl_util.jar"/> + <pathelement location="${java.home}/lib/plugin.jar"/> </path> <!-- usage --> @@ -152,6 +153,7 @@ <include name="mirrors"/> </jar> <property name="classes" value="${java.home}/lib/rt.jar"/> + <property name="plugin" value="${java.home}/lib/plugin.jar"/> <condition property="classes" value="${java.home}/../Classes/classes.jar"> <os name="Mac OS X"/> </condition> @@ -163,6 +165,7 @@ <libraryjar name="lib/joal/joal.jar"/> <libraryjar name="lib/joal/gluegen-rt.jar"/> <libraryjar name="${classes}"/> + <libraryjar name="${plugin}"/> <keep access="public" name="jake2.Jake2"> <method name="main(java.lang.String[])"/> </keep> diff --git a/src/jake2/CompatibilityApplet.java b/src/jake2/CompatibilityApplet.java new file mode 100755 index 0000000..216b560 --- /dev/null +++ b/src/jake2/CompatibilityApplet.java @@ -0,0 +1,157 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Sun Microsystems nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package jake2; + +import java.applet.*; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.event.*; +import java.awt.font.*; +import java.awt.geom.*; +import java.net.*; +import java.text.*; +import java.util.*; + +/** + * An applet to smooth the adoption of newer applet content which runs + * only with the new Java Plug-In: in particular, applets launched via + * JNLP. It displays some informative text; clicking on the text will + * open a new browser window pointing to the download page for the new + * Java Plug-In. This applet runs even on very early versions of the + * JRE and can be referenced from the applet tag's code / archive + * attributes while the jnlp_href can point to the new-style applet's + * code. + * <P> + * In 6u10 build 13, it is necessary to copy this applet's source code + * and rename it to be exactly the same class name as is in the + * main-class attribute in the JNLP file, preferably referenced via + * the archive attribute in a jar named something like + * "BackwardCompatibility.jar". In 6u10 build 14, the applet tag may + * refer to this class via its code attribute, and the JNLP file may + * point to an entirely different class name, allowing one copy of the + * compatibility applet to be used for many different JNLP-launched + * applets. + * <P> + * Parameters supported: + * <P> + * <CODE>compat_fontsize</CODE> - the font size used to draw the text.<BR> + * <CODE>compat_fgcolor</CODE> - the color used to draw the text.<BR> + * <CODE>compat_bgcolor</CODE> - the color used to draw the text. + * + * @author Kenneth Russell + */ + +public class CompatibilityApplet extends java.applet.Applet { + private Font font; + private static final String inputText = "Click here to get the new Java Plug-In"; + private static final String url = "https://jdk6.dev.java.net/6uNea.html"; + + public void init() { + int fontSize = 36; + try { + fontSize = Integer.parseInt(getParameter("compat_fontsize")); + } catch (Exception e) { + } + Color fgColor = Color.black; + Color bgColor = Color.white; + try { + fgColor = Color.decode(getParameter("compat_fgcolor")); + } catch (Exception e) { + } + try { + bgColor = Color.decode(getParameter("compat_bgcolor")); + } catch (Exception e) { + } + font = new Font("SansSerif", Font.PLAIN, fontSize); + setForeground(fgColor); + setBackground(bgColor); + addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + try { + getAppletContext().showDocument(new URL(url), "_blank"); + } catch (Exception ex) { + } + } + }); + } + + static class LineInfo { + String text; + float width; + float height; + + LineInfo(String text, float width, float height) { + this.text = text; + this.width = width; + this.height = height; + } + } + + public void paint(Graphics graphics) { + Graphics2D g = (Graphics2D) graphics; + List/*<LineInfo>*/ lines = new ArrayList(); + FontMetrics fm = g.getFontMetrics(); + FontRenderContext frc = g.getFontRenderContext(); + Map attrs = new HashMap(); + attrs.put(TextAttribute.FONT, font); + float totalHeight = 0; + int curPos = 0; + AttributedString str = new AttributedString(inputText, attrs); + LineBreakMeasurer measurer = new LineBreakMeasurer(str.getIterator(), frc); + while (measurer.getPosition() < inputText.length()) { + // Give us a few pixels inset from the edges + int nextPos = measurer.nextOffset(getWidth() - 10); + String line = inputText.substring(curPos, nextPos); + GlyphVector gv = font.createGlyphVector(frc, line); + Rectangle2D bounds = gv.getVisualBounds(); + float height = (float) bounds.getHeight() + 5; + lines.add(new LineInfo(line, (float) bounds.getWidth(), height)); + totalHeight += height; + curPos = nextPos; + measurer.setPosition(curPos); + } + // Draw the strings centered vertically and horizontally in this component + g.setFont(font); + float curY = (getHeight() - totalHeight) / 2; + for (Iterator iter = lines.iterator(); iter.hasNext(); ) { + LineInfo line = (LineInfo) iter.next(); + curY += line.height; + float x = (getWidth() - line.width) / 2; + g.drawString(line.text, (int) x, (int) curY); + } + } +} diff --git a/src/jake2/Globals.java b/src/jake2/Globals.java index a34b5f0..1be09a9 100644 --- a/src/jake2/Globals.java +++ b/src/jake2/Globals.java @@ -2,7 +2,7 @@ * Globals.java * Copyright (C) 2003 * - * $Id: Globals.java,v 1.5 2005-02-07 17:49:26 cawe Exp $ + * $Id: Globals.java,v 1.6 2008-03-02 20:21:12 kbrussel Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -385,4 +385,14 @@ public class Globals extends Defines { public static int vidref_val = VIDREF_GL; public static Random rnd = new Random(); + + //============================================================================= + + // Information used when we're running as an applet + // Whether we're running as an applet + public static boolean appletMode; + // The applet, represented as an Object to avoid an AWT dependency here + public static Object applet; + // A listener to receive video mode changes + public static SizeChangeListener sizeChangeListener; } diff --git a/src/jake2/Jake2Applet.java b/src/jake2/Jake2Applet.java new file mode 100755 index 0000000..16bf627 --- /dev/null +++ b/src/jake2/Jake2Applet.java @@ -0,0 +1,130 @@ +/* + * Jake2Applet.java + * Copyright (C) 2008 + * + * $Id: Jake2Applet.java,v 1.1 2008-03-02 20:21:12 kbrussel Exp $ + */ +/* + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ +package jake2; + +import jake2.game.Cmd; +import jake2.qcommon.*; +import jake2.sys.Timer; + +import java.awt.BorderLayout; +import java.util.Locale; +import javax.swing.JApplet; + +import netscape.javascript.*; + +/** + * Jake2 is the main class of Quake2 for Java. + */ +public class Jake2Applet extends JApplet { + + private JSObject self; + private volatile boolean shouldShutDown; + private boolean shutDown; + private Object shutDownLock = new Object(); + + public void start() { + setLayout(new BorderLayout()); + new GameThread().start(); + } + + public void stop() { + synchronized(shutDownLock) { + shouldShutDown = true; + while (!shutDown) { + try { + shutDownLock.wait(); + } catch (InterruptedException e) { + } + } + } + Cmd.ExecuteString("quit"); + } + + class GameThread extends Thread { + public GameThread() { + super("Jake2 Game Thread"); + } + + public void run() { + // TODO: check if dedicated is set in config file + + Globals.dedicated= Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET); + + // Set things up for applet execution + Qcommon.appletMode = true; + Qcommon.applet = Jake2Applet.this; + Qcommon.sizeChangeListener = new SizeChangeListener() { + public void sizeChanged(int width, int height) { + try { + if (self == null) { + JSObject win = JSObject.getWindow(Jake2Applet.this); + self = (JSObject) win.eval("document.getElementById(\"" + + getParameter("id") + "\")"); + } + + self.setMember("width", new Integer(width)); + self.setMember("height", new Integer(height)); + } catch (Exception e) { + e.printStackTrace(); + } + } + }; + + // open the q2dialog, if we are not in dedicated mode. + if (Globals.dedicated.value != 1.0f) { + Jake2.Q2Dialog = new Q2DataDialog(); + Locale.setDefault(Locale.US); + Jake2.Q2Dialog.setVisible(true); + } + + Qcommon.Init(new String[] { "Jake2" }); + + Globals.nostdout = Cvar.Get("nostdout", "0", 0); + + try { + while (!shouldShutDown) { + int oldtime = Timer.Milliseconds(); + int newtime; + int time; + while (true) { + // find time spending rendering last frame + newtime = Timer.Milliseconds(); + time = newtime - oldtime; + + if (time > 0) + Qcommon.Frame(time); + oldtime = newtime; + } + } + } finally { + synchronized(shutDownLock) { + shutDown = true; + shutDownLock.notifyAll(); + } + } + } + } +} diff --git a/src/jake2/SizeChangeListener.java b/src/jake2/SizeChangeListener.java new file mode 100755 index 0000000..fcf1cfc --- /dev/null +++ b/src/jake2/SizeChangeListener.java @@ -0,0 +1,15 @@ +/* + * SizeChangeListener.java + * Copyright (C) 2008 + * + * $Id: SizeChangeListener.java,v 1.1 2008-03-02 20:21:13 kbrussel Exp $ + */ + +package jake2; + +/** Provides a callback when the user changes the video mode of the + game. */ + +public interface SizeChangeListener { + public void sizeChanged(int width, int height); +} diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java index 7195710..ffb5842 100644 --- a/src/jake2/qcommon/Q2DataDialog.java +++ b/src/jake2/qcommon/Q2DataDialog.java @@ -178,7 +178,9 @@ public class Q2DataDialog extends javax.swing.JDialog { } private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) { - System.exit(1); + if (!Globals.appletMode) { + System.exit(1); + } dispose(); } @@ -212,7 +214,9 @@ public class Q2DataDialog extends javax.swing.JDialog { }//GEN-LAST:event_changeButtonActionPerformed private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing - System.exit(1); + if (!Globals.appletMode) { + System.exit(1); + } dispose(); }//GEN-LAST:event_formWindowClosing @@ -401,7 +405,9 @@ public class Q2DataDialog extends javax.swing.JDialog { exit = new JButton("Exit"); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + if (!Globals.appletMode) { System.exit(0); + } }}); add(exit, constraints); @@ -572,7 +578,9 @@ public class Q2DataDialog extends javax.swing.JDialog { } private void exit() { - System.exit(0); + if (!Globals.appletMode) { + System.exit(0); + } } private void choose() { diff --git a/src/jake2/render/opengl/Jsr231Driver.java b/src/jake2/render/opengl/Jsr231Driver.java index 39c3384..b6fa6eb 100644 --- a/src/jake2/render/opengl/Jsr231Driver.java +++ b/src/jake2/render/opengl/Jsr231Driver.java @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render.opengl; import jake2.Defines; +import jake2.Globals; +import jake2.SizeChangeListener; import jake2.client.VID; import jake2.qcommon.Cbuf; import jake2.qcommon.xcommand_t; @@ -54,6 +56,10 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { private volatile Display display; private volatile Frame window; + // This is either the above Window reference or the global + // applet if we're running in applet mode + private volatile Container container; + // window position on the screen int window_xpos, window_ypos; @@ -135,6 +141,10 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); + if (Globals.appletMode && container == null) { + container = (Container) Globals.applet; + } + /* * full screen handling */ @@ -143,53 +153,68 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { device = env.getDefaultScreenDevice(); } - if (oldDisplayMode == null) { - oldDisplayMode = device.getDisplayMode(); - } - - if (!VID.GetModeInfo(newDim, mode)) { - VID.Printf(Defines.PRINT_ALL, " invalid mode\n"); - return Base.rserr_invalid_mode; - } - - VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); - - // destroy the existing window - if (window != null) shutdown(); - - window = new Frame("Jake2 (jsr231)"); - ImageIcon icon = new ImageIcon(getClass().getResource("/icon-small.png")); - window.setIconImage(icon.getImage()); - window.setLayout(new GridBagLayout()); + if (oldDisplayMode == null) { + oldDisplayMode = device.getDisplayMode(); + } + + if (!VID.GetModeInfo(newDim, mode)) { + VID.Printf(Defines.PRINT_ALL, " invalid mode\n"); + return Base.rserr_invalid_mode; + } + + VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); + + if (!Globals.appletMode) { + // destroy the existing window + if (window != null) shutdown(); + + window = new Frame("Jake2 (jsr231)"); + container = window; + ImageIcon icon = new ImageIcon(getClass().getResource("/icon-small.png")); + window.setIconImage(icon.getImage()); + window.setLayout(new GridBagLayout()); + // register event listener + window.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); + } + }); + } - Display canvas = new Display(new GLCapabilities()); - // we want keypressed events for TAB key - canvas.setFocusTraversalKeysEnabled(false); - - // the OpenGL canvas grows and shrinks with the window - GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.BOTH; - gbc.weightx = gbc.weighty = 1; - window.add(canvas, gbc); + if (Globals.appletMode) { + // Destroy the previous display if there is one + shutdown(); + + // We don't support full-screen mode + fullscreen = false; + + // We need to feed the container to the JOGL + // keyboard class manually because we'll never get + // a component shown event for it + JOGLKBD.Init(container); + } + + Display canvas = new Display(new GLCapabilities()); + // we want keypressed events for TAB key + canvas.setFocusTraversalKeysEnabled(false); + canvas.setSize(newDim.width, newDim.height); + + // the OpenGL canvas grows and shrinks with the window + final GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.BOTH; + gbc.weightx = gbc.weighty = 1; - canvas.setSize(newDim.width, newDim.height); - - // register event listener - window.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); - } - }); - - // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G - window.addComponentListener(JOGLKBD.listener); - canvas.addKeyListener(JOGLKBD.listener); - canvas.addMouseListener(JOGLKBD.listener); - canvas.addMouseMotionListener(JOGLKBD.listener); - canvas.addMouseWheelListener(JOGLKBD.listener); + // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G + container.addComponentListener(JOGLKBD.listener); + canvas.addKeyListener(JOGLKBD.listener); + canvas.addMouseListener(JOGLKBD.listener); + canvas.addMouseMotionListener(JOGLKBD.listener); + canvas.addMouseWheelListener(JOGLKBD.listener); if (fullscreen) { + container.add(canvas, gbc); + DisplayMode displayMode = findDisplayMode(newDim); newDim.width = displayMode.getWidth(); @@ -209,26 +234,48 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); } else { - final Frame f2 = window; - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - //f2.setLocation(window_xpos, window_ypos); - f2.pack(); - f2.setResizable(true); - f2.setVisible(true); - } - }); - } catch (Exception e) { - e.printStackTrace(); - } + if (!Globals.appletMode) { + container.add(canvas, gbc); + final Frame f2 = window; + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + //f2.setLocation(window_xpos, window_ypos); + f2.pack(); + f2.setResizable(false); + f2.setVisible(true); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + final Display fd = canvas; + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + container.add(fd, BorderLayout.CENTER); + // Notify the size listener about the change + SizeChangeListener listener = Globals.sizeChangeListener; + if (listener != null) { + listener.sizeChanged(newDim.width, newDim.height); + } + fd.setSize(newDim.width, newDim.height); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } } - while (!canvas.isDisplayable() || !window.isDisplayable()) { + if (!Globals.appletMode) { + while (!canvas.isDisplayable() || !window.isDisplayable()) { try { - Thread.sleep(100); + Thread.sleep(100); } catch (InterruptedException e) {} - } + } + } canvas.requestFocus(); this.display = canvas; @@ -240,39 +287,47 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { } public void shutdown() { - try { + if (!Globals.appletMode) { + try { EventQueue.invokeAndWait(new Runnable() { public void run() { - if (oldDisplayMode != null - && device.getFullScreenWindow() != null) { - try { - if (device.isFullScreenSupported()) { - if (!device.getDisplayMode().equals( - oldDisplayMode)) - device.setDisplayMode(oldDisplayMode); - - } - device.setFullScreenWindow(null); - } catch (Exception e) { - e.printStackTrace(); - } - } + if (oldDisplayMode != null + && device.getFullScreenWindow() != null) { + try { + if (device.isFullScreenSupported()) { + if (!device.getDisplayMode().equals(oldDisplayMode)) + device.setDisplayMode(oldDisplayMode); + + } + device.setFullScreenWindow(null); + } catch (Exception e) { + e.printStackTrace(); + } + } } - }); - } catch (Exception e) { + }); + } catch (Exception e) { e.printStackTrace(); - } - if (window != null) { + } + + if (window != null) { if (display != null) display.destroy(); window.dispose(); while (window.isDisplayable()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - } + try { + Thread.sleep(100); + } catch (InterruptedException e) { + } } - } + } + } else { + if (display != null) { + display.destroy(); + // Remove the old display if there is one + container.remove(display); + } + } display = null; } diff --git a/src/jake2/sys/JOGLKBD.java b/src/jake2/sys/JOGLKBD.java index 8fda765..dbf54fb 100644 --- a/src/jake2/sys/JOGLKBD.java +++ b/src/jake2/sys/JOGLKBD.java @@ -1,5 +1,6 @@ package jake2.sys; +import jake2.Globals; import jake2.client.Key; import java.awt.*; @@ -21,13 +22,21 @@ final public class JOGLKBD extends KBD try { robot = new Robot(); } catch (AWTException e) { + if (!Globals.appletMode) { System.exit(1); + } } } public void Init() { } + // Used only for the applet case + public static void Init(Component component) { + c = component; + handleCreateAndConfigureNotify(component); + } + public void Update() { // get events HandleEvents(); @@ -85,24 +94,7 @@ final public class JOGLKBD extends KBD case Jake2InputEvent.CreateNotify : case Jake2InputEvent.ConfigureNotify : - Component c = ((ComponentEvent)event.ev).getComponent(); - win_x = 0; - win_y = 0; - win_w2 = c.getWidth() / 2; - win_h2 = c.getHeight() / 2; - int left = 0; int top = 0; - while (c != null) { - if (c instanceof Container) { - Insets insets = ((Container)c).getInsets(); - left += insets.left; - top += insets.top; - } - win_x += c.getX(); - win_y += c.getY(); - c = c.getParent(); - } - win_x += left; win_y += top; - win_w2 -= left / 2; win_h2 -= top / 2; + handleCreateAndConfigureNotify(((ComponentEvent)event.ev).getComponent()); break; } } @@ -113,6 +105,38 @@ final public class JOGLKBD extends KBD } } + private static void handleCreateAndConfigureNotify(Component component) { + // Probably could unify this code better, but for now just + // leave the two code paths separate + if (!Globals.appletMode) { + win_x = 0; + win_y = 0; + win_w2 = component.getWidth() / 2; + win_h2 = component.getHeight() / 2; + int left = 0; int top = 0; + while (component != null) { + if (component instanceof Container) { + Insets insets = ((Container)component).getInsets(); + left += insets.left; + top += insets.top; + } + win_x += component.getX(); + win_y += component.getY(); + component = component.getParent(); + } + win_x += left; win_y += top; + win_w2 -= left / 2; win_h2 -= top / 2; + } else { + win_x = 0; + win_y = 0; + win_w2 = component.getWidth() / 2; + win_h2 = component.getHeight() / 2; + Point p = component.getLocationOnScreen(); + win_x = p.x; + win_y = p.y; + } + } + // strange button numbering in java.awt.MouseEvent // BUTTON1(left) BUTTON2(center) BUTTON3(right) // K_MOUSE1 K_MOUSE3 K_MOUSE2 diff --git a/src/jake2/sys/Sys.java b/src/jake2/sys/Sys.java index 498750a..8ac8fb1 100644 --- a/src/jake2/sys/Sys.java +++ b/src/jake2/sys/Sys.java @@ -2,7 +2,7 @@ * Sys.java * Copyright (C) 2003 * - * $Id: Sys.java,v 1.11 2005-07-01 14:20:54 hzi Exp $ + * $Id: Sys.java,v 1.12 2008-03-02 20:21:15 kbrussel Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -45,13 +45,17 @@ public final class Sys extends Defines { CL.Shutdown(); //StackTrace(); new Exception(error).printStackTrace(); - System.exit(1); + if (!Globals.appletMode) { + System.exit(1); + } } public static void Quit() { CL.Shutdown(); - System.exit(0); + if (!Globals.appletMode) { + System.exit(0); + } } //ok! @@ -240,4 +244,4 @@ public final class Sys extends Defines { System.out.print(msg); } -}
\ No newline at end of file +} |