About box

AS1/2: Fixed important decompiling bug
This commit is contained in:
Jindra Pet��k
2011-07-30 14:14:27 +02:00
parent c4a5d74377
commit bce40e6880
7 changed files with 264 additions and 5 deletions
+6
View File
@@ -19,6 +19,7 @@
package com.jpexs.asdec; package com.jpexs.asdec;
import com.jpexs.asdec.abc.NotSameException; import com.jpexs.asdec.abc.NotSameException;
import com.jpexs.asdec.gui.AboutDialog;
import com.jpexs.asdec.gui.LoadingDialog; import com.jpexs.asdec.gui.LoadingDialog;
import com.jpexs.asdec.gui.ModeFrame; import com.jpexs.asdec.gui.ModeFrame;
import com.jpexs.asdec.gui.View; import com.jpexs.asdec.gui.View;
@@ -464,4 +465,9 @@ public class Main {
saveReplacements(); saveReplacements();
System.exit(0); System.exit(0);
} }
public static void about()
{
(new AboutDialog()).setVisible(true);
}
} }
@@ -283,6 +283,13 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
menuTools.add(miProxy); menuTools.add(miProxy);
menuBar.add(menuTools); menuBar.add(menuTools);
JMenu menuHelp = new JMenu("Help");
JMenuItem miAbout = new JMenuItem("About...");
miAbout.setActionCommand("ABOUT");
miAbout.addActionListener(this);
menuHelp.add(miAbout);
menuBar.add(menuHelp);
setJMenuBar(menuBar); setJMenuBar(menuBar);
/* Constants */ /* Constants */
@@ -328,6 +335,10 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
} }
if (Main.isWorking()) return; if (Main.isWorking()) return;
if (e.getActionCommand().equals("ABOUT")) {
Main.about();
}
if (e.getActionCommand().equals("SHOWPROXY")) { if (e.getActionCommand().equals("SHOWPROXY")) {
Main.showProxy(); Main.showProxy();
+5 -1
View File
@@ -430,10 +430,14 @@ public class Action {
* @return address * @return address
*/ */
public static long ip2adr(List<Action> actions, int ip, int version) { public static long ip2adr(List<Action> actions, int ip, int version) {
if (ip == actions.size()) { if (ip >= actions.size()) {
if (actions.size() == 0) return 0; if (actions.size() == 0) return 0;
return actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; return actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length;
} }
if(ip==-1)
{
return 0;
}
return actions.get(ip).getAddress(); return actions.get(ip).getAddress();
} }
@@ -177,6 +177,13 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi
menuTools.add(miProxy); menuTools.add(miProxy);
menuBar.add(menuTools); menuBar.add(menuTools);
JMenu menuHelp = new JMenu("Help");
JMenuItem miAbout = new JMenuItem("About...");
miAbout.setActionCommand("ABOUT");
miAbout.addActionListener(this);
menuHelp.add(miAbout);
menuBar.add(menuHelp);
setJMenuBar(menuBar); setJMenuBar(menuBar);
setTitle(Main.applicationName + " - " + Main.getFileTitle()); setTitle(Main.applicationName + " - " + Main.getFileTitle());
@@ -195,8 +202,12 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi
@Override @Override
public void run() { public void run() {
editor.setText(asm.getASMSource(10)); //TODO:Ensure correct version here editor.setText(asm.getASMSource(10)); //TODO:Ensure correct version here
if(Main.DO_DECOMPILE) if(Main.DO_DECOMPILE){
decompiledEditor.setText(Highlighting.stripHilights(com.jpexs.asdec.action.Action.actionsToSource(asm.getActions(10), 10))); //TODO:Ensure correct version here List<com.jpexs.asdec.action.Action> as=asm.getActions(10);//TODO:Ensure correct version here
com.jpexs.asdec.action.Action.setActionsAddresses(as, 0, 10);//TODO:Ensure correct version here
decompiledEditor.setText(Highlighting.stripHilights(com.jpexs.asdec.action.Action.actionsToSource(as, 10))); //TODO:Ensure correct version here
}
Main.stopWork(); Main.stopWork();
} }
}).start(); }).start();
@@ -214,6 +225,9 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi
if (e.getActionCommand().equals("EXIT")) { if (e.getActionCommand().equals("EXIT")) {
System.exit(0); System.exit(0);
} }
if (e.getActionCommand().equals("ABOUT")) {
Main.about();
}
if (e.getActionCommand().equals("SHOWPROXY")) { if (e.getActionCommand().equals("SHOWPROXY")) {
Main.showProxy(); Main.showProxy();
} }
@@ -0,0 +1,110 @@
/*
* Copyright (C) 2011 JPEXS
*
* 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 com.jpexs.asdec.gui;
import com.jpexs.asdec.Main;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
/**
*
* @author JPEXS
*/
public class AboutDialog extends JDialog {
public AboutDialog() {
setDefaultCloseOperation(HIDE_ON_CLOSE);
setSize(new Dimension(300,270));
setTitle("About");
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
JLabel jpLabel=new JLabel("JP");
jpLabel.setForeground(new Color(0,0,160));
jpLabel.setFont(new Font("Tahoma",Font.BOLD,25));
jpLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(jpLabel);
JLabel asLabel=new JLabel("ActionScript");
asLabel.setFont(new Font("Tahoma",Font.BOLD,25));
asLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(asLabel);
JLabel decLabel=new JLabel("Decompiler");
decLabel.setForeground(Color.red);
decLabel.setFont(new Font("Tahoma",Font.BOLD,25));
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(decLabel);
JLabel verLabel=new JLabel("version "+Main.version);
verLabel.setPreferredSize(new Dimension(300, 15));
verLabel.setFont(new Font("Tahoma",Font.BOLD,15));
verLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(verLabel);
JLabel byLabel=new JLabel("by");
byLabel.setPreferredSize(new Dimension(300, 15));
byLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(byLabel);
JLabel jpexsLabel=new JLabel("JPEXS");
jpexsLabel.setForeground(new Color(0,0,160));
jpexsLabel.setFont(new Font("Tahoma",Font.BOLD,20));
jpexsLabel.setPreferredSize(new Dimension(300, 25));
jpexsLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(jpexsLabel);
JLabel dateLabel=new JLabel("2010-2011");
dateLabel.setPreferredSize(new Dimension(300, 10));
dateLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(dateLabel);
LinkLabel wwwLabel=new LinkLabel("http://code.google.com/p/asdec/");
wwwLabel.setForeground(Color.blue);
wwwLabel.setPreferredSize(new Dimension(300, 25));
wwwLabel.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(wwwLabel);
JButton okButton=new JButton("OK");
cp.add(okButton);
okButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
setModal(true);
View.centerScreen(this);
View.setWindowIcon(this);
}
}
@@ -0,0 +1,114 @@
/*
* Copyright (C) 2011 JPEXS
*
* 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 com.jpexs.asdec.gui;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
/**
* An extension of JLabel which looks like a link and responds appropriately
* when clicked. Note that this class will only work with Swing 1.1.1 and later.
* Note that because of the way this class is implemented, getText() will not
* return correct values, user <code>getNormalText</code> instead.
*/
public class LinkLabel extends JLabel{
/**
* The normal text set by the user.
*/
private String text;
/**
* Creates a new LinkLabel with the given text.
*/
public LinkLabel(String text){
super(text);
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
enableEvents(MouseEvent.MOUSE_EVENT_MASK);
}
/**
* Sets the text of the label.
*/
public void setText(String text){
super.setText("<html><font color=\"#0000CF\"><u>"+text+"</u></font></html>");
this.text = text;
}
/**
* Returns the text set by the user.
*/
public String getNormalText(){
return text;
}
/**
* Processes mouse events and responds to clicks.
*/
protected void processMouseEvent(MouseEvent evt){
super.processMouseEvent(evt);
if (evt.getID() == MouseEvent.MOUSE_CLICKED)
clicked();
}
protected void clicked(){
if(java.awt.Desktop.isDesktopSupported() )
{
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
try {
java.net.URI uri = new java.net.URI( getNormalText() );
desktop.browse( uri );
}
catch ( Exception e ) {
System.err.println( e.getMessage() );
}
}
}
}
+2 -2
View File
@@ -61,7 +61,7 @@ public class View {
* *
* @param f Frame to set icon in * @param f Frame to set icon in
*/ */
public static void setWindowIcon(Frame f) { public static void setWindowIcon(Window f) {
java.util.List<Image> images = new ArrayList<Image>(); java.util.List<Image> images = new ArrayList<Image>();
images.add(loadImage("com/jpexs/asdec/gui/graphics/icon16.png")); images.add(loadImage("com/jpexs/asdec/gui/graphics/icon16.png"));
images.add(loadImage("com/jpexs/asdec/gui/graphics/icon32.png")); images.add(loadImage("com/jpexs/asdec/gui/graphics/icon32.png"));
@@ -74,7 +74,7 @@ public class View {
* *
* @param f Frame to center on the screen * @param f Frame to center on the screen
*/ */
public static void centerScreen(Frame f) { public static void centerScreen(Window f) {
Dimension dim = f.getToolkit().getScreenSize(); Dimension dim = f.getToolkit().getScreenSize();
Rectangle abounds = f.getBounds(); Rectangle abounds = f.getBounds();
f.setLocation((dim.width - abounds.width) / 2, f.setLocation((dim.width - abounds.width) / 2,