    001package net.minecraft.client;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.awt.BorderLayout;
    006import java.awt.Color;
    007import java.awt.Font;
    008import java.awt.Panel;
    009import java.awt.TextArea;
    010import java.io.File;
    011import java.io.PrintWriter;
    012import java.io.StringWriter;
    013import java.text.SimpleDateFormat;
    014import java.util.Date;
    015import net.minecraft.crash.CrashReport;
    016import org.lwjgl.opengl.GL11;
    017
    018@SideOnly(Side.CLIENT)
    019public class PanelCrashReport extends Panel
    020{
    021    public PanelCrashReport(CrashReport par1CrashReport)
    022    {
    023        this.setBackground(new Color(3028036));
    024        this.setLayout(new BorderLayout());
    025        StringWriter stringwriter = new StringWriter();
    026        par1CrashReport.getCrashCause().printStackTrace(new PrintWriter(stringwriter));
    027        String s = stringwriter.toString();
    028        String s1 = "";
    029        String s2 = "";
    030
    031        try
    032        {
    033            s2 = s2 + "Generated " + (new SimpleDateFormat()).format(new Date()) + "\n";
    034            s2 = s2 + "\n";
    035            s2 = s2 + par1CrashReport.func_90021_c();
    036            s1 = GL11.glGetString(GL11.GL_VENDOR);
    037        }
    038        catch (Throwable throwable)
    039        {
    040            s2 = s2 + "[failed to get system properties (" + throwable + ")]\n";
    041        }
    042
    043        s2 = s2 + "\n\n";
    044        s2 = s2 + s;
    045        String s3 = "";
    046        s3 = s3 + "\n";
    047        s3 = s3 + "\n";
    048
    049        if (s.contains("Pixel format not accelerated"))
    050        {
    051            s3 = s3 + "      Bad video card drivers!      \n";
    052            s3 = s3 + "      -----------------------      \n";
    053            s3 = s3 + "\n";
    054            s3 = s3 + "Minecraft was unable to start because it failed to find an accelerated OpenGL mode.\n";
    055            s3 = s3 + "This can usually be fixed by updating the video card drivers.\n";
    056
    057            if (s1.toLowerCase().contains("nvidia"))
    058            {
    059                s3 = s3 + "\n";
    060                s3 = s3 + "You might be able to find drivers for your video card here:\n";
    061                s3 = s3 + "  http://www.nvidia.com/\n";
    062            }
    063            else if (s1.toLowerCase().contains("ati"))
    064            {
    065                s3 = s3 + "\n";
    066                s3 = s3 + "You might be able to find drivers for your video card here:\n";
    067                s3 = s3 + "  http://www.amd.com/\n";
    068            }
    069        }
    070        else
    071        {
    072            s3 = s3 + "      Minecraft has crashed!      \n";
    073            s3 = s3 + "      ----------------------      \n";
    074            s3 = s3 + "\n";
    075            s3 = s3 + "Minecraft has stopped running because it encountered a problem; " + par1CrashReport.getDescription() + "\n\n";
    076            File file1 = par1CrashReport.getFile();
    077
    078            if (file1 == null)
    079            {
    080                par1CrashReport.saveToFile(new File(new File(Minecraft.getMinecraftDir(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt"), Minecraft.getMinecraft().getLogAgent());
    081                file1 = par1CrashReport.getFile();
    082            }
    083
    084            if (file1 != null)
    085            {
    086                String s4 = file1.getAbsolutePath();
    087                s3 = s3 + "A full error report has been saved to " + s4 + " - Please include a copy of that file (Not this screen!) if you report this crash to anyone; without it, they will not be able to help fix the crash :(";
    088                s2 = "Full report at:\n" + s4 + "\nPlease show that file to Mojang, NOT just this screen!\n\n" + s2;
    089            }
    090            else
    091            {
    092                s3 = s3 + "We were unable to save this report to a file.";
    093            }
    094
    095            s3 = s3 + "\n";
    096        }
    097
    098        s3 = s3 + "\n";
    099        s3 = s3 + "\n";
    100        s3 = s3 + "\n";
    101        s3 = s3 + "--- BEGIN ERROR REPORT " + Integer.toHexString(s3.hashCode()) + " --------\n";
    102        s3 = s3 + s2;
    103        s3 = s3 + "--- END ERROR REPORT " + Integer.toHexString(s3.hashCode()) + " ----------\n";
    104        s3 = s3 + "\n";
    105        s3 = s3 + "\n";
    106        TextArea textarea = new TextArea(s3, 0, 0, 1);
    107        textarea.setFont(new Font("Monospaced", 0, 12));
    108        this.add(new CanvasMojangLogo(), "North");
    109        this.add(new CanvasCrashReport(80), "East");
    110        this.add(new CanvasCrashReport(80), "West");
    111        this.add(new CanvasCrashReport(100), "South");
    112        this.add(textarea, "Center");
    113    }
    114}