Commit dc8e8113 authored by Blacksmith's avatar Blacksmith

Merge branch 'master' of git.cardforge.org:core-developers/forge

parents 351d1570 50a2ee70
......@@ -283,6 +283,7 @@
<fileset dir="${basedir}/../forge-gui/release-files/" includes="ISSUES.txt" />
<fileset dir="${basedir}/../forge-gui/release-files/" includes="CHANGES.txt" />
<fileset dir="${basedir}/../forge-gui/" includes="MANUAL.txt" />
<fileset dir="${basedir}/../forge-gui-mobile-dev/" includes="sentry.properties" />
<fileset dir="${basedir}/../forge-gui/">
<include name="res/**" />
<exclude name="res/cardsfolder/**" />
......
......@@ -25,13 +25,15 @@
-dontwarn java.awt.**
-dontwarn java.util.**
-dontwarn java.lang.**
-dontwarn org.slf4j.**
-dontwarn javax.**
-keep class forge.** { *; }
-keep class com.thoughtworks.xstream.** { *; }
-keep class org.apache.commons.lang3.** { *; }
-keep class com.google.guava.** { *; }
-keep class com.google.common.** { *; }
-keep class io.sentry.event.Event { *; }
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
......@@ -81,3 +83,8 @@
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepattributes LineNumberTable,SourceFile
# https://stackoverflow.com/a/32615580
-optimizations !class/unboxing/enum
\ No newline at end of file
......@@ -319,6 +319,7 @@
<fileset dir="${project.build.directory}" includes="forge.sh" />
<fileset dir="${project.build.directory}" includes="forge.command" />
<fileset dir="${basedir}/../forge-gui/" includes="forge.profile.properties.example" />
<fileset dir="${basedir}/" includes="sentry.properties" />
<fileset dir="${basedir}/../forge-gui/" includes="LICENSE.txt" />
<fileset dir="${basedir}/../forge-gui/" includes="README.txt" />
<fileset dir="${basedir}/../forge-gui/" includes="MANUAL.txt" />
......@@ -464,6 +465,7 @@
<fileset dir="${project.build.directory}" includes="forge.sh" />
<fileset dir="${project.build.directory}" includes="forge.command" />
<fileset dir="${basedir}/../forge-gui/" includes="forge.profile.properties.example" />
<fileset dir="${basedir}/" includes="sentry.properties" />
<fileset dir="${basedir}/../forge-gui/" includes="LICENSE.txt" />
<fileset dir="${basedir}/../forge-gui/" includes="MANUAL.txt" />
<fileset dir="${basedir}/../forge-gui/release-files/" includes="CONTRIBUTORS.txt" />
......@@ -578,6 +580,7 @@
<fileset dir="${basedir}/../forge-gui/release-files/" includes="ISSUES.txt" />
<fileset dir="${basedir}/../forge-gui/release-files/" includes="INSTALLATION.txt" />
<fileset dir="${basedir}/../forge-gui/" includes="MANUAL.txt" />
<fileset dir="${basedir}/" includes="sentry.properties" />
</copy>
<taskdef name="bundleapp" classpath="${basedir}/../forge-gui/${configSourceDirectory}/appbundler-1.0-custom.jar" classname="com.oracle.appbundler.AppBundlerTask" />
<bundleapp outputdirectory="${project.build.directory}/${project.build.finalName}-osx" name="${project.name}" displayname="${project.name}" shortversion="${project.version}" identifier="forge.view.Main" icon="${basedir}/${configSourceDirectory}/Forge.icns" applicationCategory="public.app-category.games" mainclassname="forge.view.Main">
......@@ -688,6 +691,7 @@
<fileset dir="${basedir}/../forge-gui/" includes="LICENSE.txt" />
<fileset dir="${basedir}/../forge-gui/" includes="README.txt" />
<fileset dir="${basedir}/../forge-gui/" includes="MANUAL.txt" />
<fileset dir="${basedir}/" includes="sentry.properties" />
</copy>
<taskdef name="bundleapp" classpath="${basedir}/../forge-gui/${configSourceDirectory}/appbundler-1.0-custom.jar" classname="com.oracle.appbundler.AppBundlerTask" />
<bundleapp outputdirectory="${project.build.directory}/${project.build.finalName}-osx" name="${project.name}" displayname="${project.name}" shortversion="${project.version}" identifier="forge.view.Main" icon="${basedir}/${configSourceDirectory}/Forge.icns" applicationCategory="public.app-category.games" mainclassname="forge.view.Main">
......
# ideally this should be using HTTPS, but this is fine for now
dsn=http://87bc8d329e49441895502737c069067b@sentry.cardforge.org:9000/3
stacktrace.app.packages=forge
# where to store events if offline or can't reach the above server
buffer.dir=sentry-events
buffer.size=100
# allow ample time for graceful shutdown
buffer.shutdowntimeout=5000
async.shutdowntimeout=5000
# allow longer messages
maxmessagelength=1500
\ No newline at end of file
......@@ -28,17 +28,19 @@ import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import forge.model.FModel;
import forge.properties.ForgePreferences;
import net.miginfocom.swing.MigLayout;
import forge.gui.WrapLayout;
import forge.toolbox.FHyperlink;
import forge.toolbox.FLabel;
/**
* The class BugReportDialog. Enables showing and saving error messages that
......@@ -59,22 +61,19 @@ public class BugReportDialog {
area.setWrapStyleWord(true);
JPanel helpPanel = new JPanel(new WrapLayout(FlowLayout.LEFT, 4, 2));
for (String word : BugReporter.HELP_URL_LABEL.split(" ")) {
helpPanel.add(new FLabel.Builder().text("<html>" + word + "</html>").useSkinColors(false).build());
}
helpPanel.add(new FHyperlink.Builder().url(BugReporter.HELP_URL).text("<html>this post</html>").useSkinColors(false).build());
JPanel p = new JPanel(new MigLayout("wrap"));
p.add(new FLabel.Builder().text(BugReporter.HELP_TEXT).useSkinColors(false).build(), "gap 5");
p.add(helpPanel, "w 600");
p.add(new JScrollPane(area), "w 100%, h 100%, gaptop 5");
// Button is not modified, String gets the automatic listener to hide
// the dialog
List<Object> options = new ArrayList<Object>();
options.add(new JButton(new _CopyAndGo(area)));
options.add(new JButton(new _Report()));
// option to enable automatic Sentry submission
options.add(new JCheckBox(new _ActivateSentry()));
options.add(new JLabel(BugReporter.SENTRY));
options.add(new JButton(new _SaveAction(area)));
options.add(BugReporter.CONTINUE);
options.add(BugReporter.DISCARD);
if (showExitAppBtn) {
options.add(new JButton(new _ExitAction()));
}
......@@ -91,18 +90,29 @@ public class BugReportDialog {
}
@SuppressWarnings("serial")
private static class _CopyAndGo extends AbstractAction {
private final JTextArea text;
private static class _ActivateSentry extends AbstractAction {
@Override
public void actionPerformed(final ActionEvent actionEvent) {
JCheckBox checkBox = (JCheckBox)actionEvent.getSource();
// enable Sentry use in the future through preference setting
FModel.getPreferences().setPref(ForgePreferences.FPref.USE_SENTRY, checkBox.isSelected());
FModel.getPreferences().save();
}
}
@SuppressWarnings("serial")
private static class _Report extends AbstractAction {
public _CopyAndGo(JTextArea text) {
public _Report() {
super(BugReporter.REPORT);
this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
this.text = text;
}
@Override
public void actionPerformed(final ActionEvent e) {
BugReporter.copyAndGoToForums(text.getText());
BugReporter.sendSentry();
JOptionPane.getRootFrame().dispose();
}
}
......
......@@ -116,6 +116,7 @@ public enum CSubmenuPreferences implements ICDoc {
lstControls.add(Pair.of(view.getCbUiForTouchScreen(), FPref.UI_FOR_TOUCHSCREN));
lstControls.add(Pair.of(view.getCbTimedTargOverlay(), FPref.UI_TIMED_TARGETING_OVERLAY_UPDATES));
lstControls.add(Pair.of(view.getCbCompactMainMenu(), FPref.UI_COMPACT_MAIN_MENU));
lstControls.add(Pair.of(view.getCbUseSentry(), FPref.USE_SENTRY));
lstControls.add(Pair.of(view.getCbPromptFreeBlocks(), FPref.MATCHPREF_PROMPT_FREE_BLOCKS));
lstControls.add(Pair.of(view.getCbPauseWhileMinimized(), FPref.UI_PAUSE_WHILE_MINIMIZED));
lstControls.add(Pair.of(view.getCbWorkshopSyntax(), FPref.DEV_WORKSHOP_SYNTAX));
......
......@@ -98,6 +98,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbFilterLandsByColorId = new OptionsCheckBox("Filter Lands by Color in Activated Abilities");
private final JCheckBox cbShowStormCount = new OptionsCheckBox("Show Storm Count in Prompt Pane");
private final JCheckBox cbRemindOnPriority = new OptionsCheckBox("Visually Alert on Receipt of Priority");
private final JCheckBox cbUseSentry = new OptionsCheckBox("Automatically submit bug reports.");
private final Map<FPref, KeyboardShortcutField> shortcutFields = new HashMap<>();
......@@ -147,6 +148,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbCompactMainMenu, titleConstraints);
pnlPrefs.add(new NoteLabel("Enable for a space efficient sidebar that displays only one menu group at a time (RESTART REQUIRED)."), descriptionConstraints);
pnlPrefs.add(cbUseSentry, titleConstraints);
pnlPrefs.add(new NoteLabel("When enabled, automatically submits bug reports to developers."), descriptionConstraints);
pnlPrefs.add(btnResetJavaFutureCompatibilityWarnings, "w 300px!, h 30px!, gap 27px 0 0 20px, span 2 1");
// Gameplay Options
......@@ -503,6 +507,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbCompactMainMenu;
}
/** @return {@link javax.swing.JCheckBox} */
public final JCheckBox getCbUseSentry() {
return cbUseSentry;
}
/** @return {@link javax.swing.JCheckBox} */
public final JCheckBox getCbRemoveSmall() {
return cbRemoveSmall;
......
......@@ -22,6 +22,9 @@ import forge.GuiDesktop;
import forge.Singletons;
import forge.card.CardReaderExperiments;
import forge.error.ExceptionHandler;
import forge.util.BuildInfo;
import io.sentry.Sentry;
import io.sentry.SentryClient;
/**
* Main class for Forge's swing application view.
......@@ -31,6 +34,12 @@ public final class Main {
* Main entry point for Forge
*/
public static void main(final String[] args) {
Sentry.init();
SentryClient sentryClient = Sentry.getStoredClient();
sentryClient.setRelease(BuildInfo.getVersionString());
sentryClient.setEnvironment(System.getProperty("os.name"));
sentryClient.addTag("Java Version", System.getProperty("java.version"));
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
......
# ideally this should be using HTTPS, but this is fine for now
dsn=http://a0b8dbad9b8a49cfa51bf65d462e8dae@sentry.cardforge.org:9000/2
stacktrace.app.packages=forge
# where to store events if offline or can't reach the above server
buffer.dir=sentry-events
buffer.size=100
# allow ample time for graceful shutdown
buffer.shutdowntimeout=5000
async.shutdowntimeout=5000
# allow longer messages
maxmessagelength=1500
\ No newline at end of file
......@@ -29,11 +29,11 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
Forge.openScreen(new BugReportDialog(title, text, showExitAppBtn));
}
private final FTextArea lblHeader = add(new FTextArea(false, BugReporter.HELP_TEXT));
private final FTextArea lblHeader = add(new FTextArea(false, "Report Bug"));
private final TemplateView tvDetails;
private final FButton btnReport = add(new FButton(BugReporter.REPORT));
private final FButton btnSave = add(new FButton(BugReporter.SAVE));
private final FButton btnContinue = add(new FButton(BugReporter.CONTINUE));
private final FButton btnDiscard = add(new FButton(BugReporter.DISCARD));
private final FButton btnExit = add(new FButton(BugReporter.EXIT));
private BugReportDialog(String title, String text0, boolean showExitAppBtn) {
......@@ -43,7 +43,8 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
btnReport.setCommand(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
BugReporter.copyAndGoToForums(tvDetails.text);
BugReporter.sendSentry();
Forge.back();
}
});
btnSave.setCommand(new FEventHandler() {
......@@ -52,7 +53,7 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
BugReporter.saveToFile(tvDetails.text);
}
});
btnContinue.setCommand(new FEventHandler() {
btnDiscard.setCommand(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
Forge.back();
......@@ -115,11 +116,11 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
y += buttonHeight + PADDING;
}
if (btnExit.isVisible()) {
btnContinue.setBounds(x, y, buttonWidth, buttonHeight);
btnDiscard.setBounds(x, y, buttonWidth, buttonHeight);
btnExit.setBounds(x + buttonWidth + PADDING, y, buttonWidth, buttonHeight);
}
else {
btnContinue.setBounds(x, y, 2 * buttonWidth + PADDING, buttonHeight);
btnDiscard.setBounds(x, y, 2 * buttonWidth + PADDING, buttonHeight);
}
}
......
......@@ -78,6 +78,10 @@ public class SettingsPage extends TabPage<SettingsScreen> {
"Minimize on Screen Lock",
"Minimize Forge when screen is locked (enable if you experience graphic glitches after locking your screen)."),
0);
lstSettings.addItem(new BooleanSetting(FPref.USE_SENTRY,
"Automatic Bug Reports",
"Automatically send bug reports to the developers, without prompting."),
0);
//Gameplay Options
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CURRENT_AI_PROFILE,
......
......@@ -67,5 +67,15 @@
<artifactId>cling-support</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-log4j</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.22</version>
</dependency>
</dependencies>
</project>
......@@ -26,8 +26,12 @@ import java.io.StringWriter;
import forge.FThreads;
import forge.GuiBase;
import forge.util.BuildInfo;
import forge.model.FModel;
import forge.properties.ForgePreferences;
import forge.util.gui.SOptionPane;
import io.sentry.Sentry;
import io.sentry.event.Breadcrumb;
import io.sentry.event.BreadcrumbBuilder;
/**
* The class ErrorViewer. Enables showing and saving error messages that
......@@ -41,27 +45,13 @@ public class BugReporter {
public static final String REPORT = "Report";
public static final String SAVE = "Save";
public static final String CONTINUE = "Continue";
public static final String DISCARD = "Discard";
public static final String EXIT = "Exit";
public static final String SENTRY = "Submit bug reports automatically";
private static Throwable exception;
private static String message;
public static final String HELP_TEXT = String.format(
"A template for a post in the bug reports forum topic is shown below. Just select '%s' "
+ "and the template will be copied to your system clipboard and the forum page will open in your browser. "
+ "Then all you have to do is paste the text into a forum post and edit the description line.", REPORT);
public static final String HELP_URL_LABEL =
"Reporting bugs in Forge is very important. We sincerely thank you for your time."
+ " For help writing a solid bug report, please see:";
public static final String HELP_URL =
"http://www.slightlymagic.net/forum/viewtopic.php?f=26&p=109925#p109925";
private static final String FORUM_URL;
static {
if (BuildInfo.isDevelopmentVersion()) {
FORUM_URL = "http://www.slightlymagic.net/forum/viewtopic.php?f=52&t=6333&start=54564487645#bottom";
} else {
FORUM_URL = "http://www.slightlymagic.net/forum/viewforum.php?f=26";
}
}
/**
* Shows exception information in a format ready to post to the forum as a
......@@ -72,6 +62,7 @@ public class BugReporter {
if (ex == null) {
return;
}
exception = ex;
if (message != null) {
System.err.printf("%s > %s%n", FThreads.debugGetCurrThreadId(), message);
}
......@@ -79,10 +70,10 @@ public class BugReporter {
ex.printStackTrace();
final StringBuilder sb = new StringBuilder();
sb.append("Description: [describe what you were doing when the crash occurred]\n\n");
buildSpoilerHeader(sb, ex.getClass().getSimpleName());
sb.append("\n\n");
if (null != message && !message.isEmpty()) {
Sentry.getContext().recordBreadcrumb(
new BreadcrumbBuilder().setMessage(message).build()
);
sb.append(FThreads.debugGetCurrThreadId()).append(" > ").append(message).append("\n");
}
......@@ -100,12 +91,16 @@ public class BugReporter {
else {
sb.append(swStr);
}
buildSpoilerFooter(sb);
GuiBase.getInterface().showBugReportDialog("Report a crash", sb.toString(), true);
if (isSentryEnabled()) {
sendSentry();
} else {
GuiBase.getInterface().showBugReportDialog("Report a crash", sb.toString(), true);
}
}
private static boolean isSentryEnabled() {
return FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.USE_SENTRY);
}
/**
* Alias for reportException(ex, null).
*/
......@@ -125,41 +120,16 @@ public class BugReporter {
*/
public static void reportBug(final String details) {
final StringBuilder sb = new StringBuilder();
sb.append("Description: [describe the problem]\n\n");
buildSpoilerHeader(sb, "General bug report");
if (null != details && !details.isEmpty()) {
sb.append("\n\n");
sb.append(details);
}
buildSpoilerFooter(sb);
GuiBase.getInterface().showBugReportDialog("Report a bug", sb.toString(), false);
}
private static StringBuilder buildSpoilerHeader(final StringBuilder sb, final String reportTitle) {
sb.append("[spoiler=").append(reportTitle).append("][code]");
sb.append("\nForge Version: ").append(GuiBase.getInterface().getCurrentVersion());
sb.append("\nOperating System: ").append(System.getProperty("os.name"))
.append(" ").append(System.getProperty("os.version"))
.append(" ").append(System.getProperty("os.arch"));
sb.append("\nJava Version: ").append(System.getProperty("java.version"))
.append(" ").append(System.getProperty("java.vendor"));
return sb;
}
private static StringBuilder buildSpoilerFooter(final StringBuilder sb) {
sb.append("[/code][/spoiler]");
return sb;
}
message = sb.toString();
public static void copyAndGoToForums(final String text) {
try {
// copy text to clipboard
GuiBase.getInterface().copyToClipboard(text);
GuiBase.getInterface().browseToUrl(FORUM_URL);
} catch (final Exception ex) {
SOptionPane.showMessageDialog("Sorry, a problem occurred while opening the forum in your default browser.",
"A problem occurred", SOptionPane.ERROR_ICON);
if (isSentryEnabled()) {
sendSentry();
} else {
GuiBase.getInterface().showBugReportDialog("Report a bug", message, false);
}
}
......@@ -187,6 +157,14 @@ public class BugReporter {
}
}
public static void sendSentry() {
if (exception != null) {
Sentry.capture(exception);
} else if (message !=null) {
Sentry.capture(message);
}
}
/**
* Private constructor to prevent instantiation.
*/
......
......@@ -136,6 +136,8 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
//TODO This should be removed after the update that requires Java 8.
DISABLE_DISPLAY_JAVA_8_UPDATE_WARNING("false"),
USE_SENTRY("false"), // this controls whether automated bug reporting is done or not
MATCH_HOT_SEAT_MODE("false"), //this only applies to mobile game
MATCHPREF_PROMPT_FREE_BLOCKS("false"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment