mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Added option to activate/deactivate JSON game log. Added logic to write the logs to subdirectory. Some changes to SEND_PLAYER_ACTION type logging.
This commit is contained in:
parent
dc5220df4f
commit
b60522f9e4
7 changed files with 138 additions and 70 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,6 +4,7 @@ syntax: glob
|
|||
Mage.Client/*.dck
|
||||
Mage.Client/db
|
||||
Mage.Client/gamelogs
|
||||
Mage.Client/gamelogsJson
|
||||
Mage.Client/*.log
|
||||
Mage.Client/plugins/images
|
||||
Mage.Client/plugins/plugin.data
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package mage.client;
|
||||
|
||||
import java.util.*;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.chat.LocalCommands;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.game.match.MatchOptions;
|
||||
|
@ -14,8 +16,6 @@ import mage.remote.Session;
|
|||
import mage.remote.SessionImpl;
|
||||
import mage.view.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by IGOUDT on 15-9-2016.
|
||||
*/
|
||||
|
@ -26,6 +26,7 @@ public final class SessionHandler {
|
|||
public static void startSession(MageFrame mageFrame) {
|
||||
|
||||
session = new SessionImpl(mageFrame);
|
||||
session.setJsonLogActive("true".equals(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_LOG_AUTO_SAVE, "true")));
|
||||
}
|
||||
|
||||
public static void ping() {
|
||||
|
@ -322,7 +323,7 @@ public final class SessionHandler {
|
|||
}
|
||||
|
||||
public static void updateDeck(UUID tableId, DeckCardLists deckCardLists) {
|
||||
session.updateDeck(tableId, deckCardLists);
|
||||
session.updateDeck(tableId, deckCardLists);
|
||||
}
|
||||
|
||||
public static boolean emailAuthToken(Connection connection) {
|
||||
|
@ -330,10 +331,10 @@ public final class SessionHandler {
|
|||
}
|
||||
|
||||
public static boolean resetPassword(Connection connection) {
|
||||
return session.resetPassword(connection);
|
||||
return session.resetPassword(connection);
|
||||
}
|
||||
|
||||
public static boolean register(Connection connection) {
|
||||
return session.register(connection);
|
||||
return session.register(connection);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,17 +25,18 @@
|
|||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="saveButton" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="exitButton" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="saveButton" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="exitButton" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tabsPanel" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
|
@ -94,10 +95,10 @@
|
|||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="main_game" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="main_gamelog" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="main_gamelog" min="-2" pref="107" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="main_battlefield" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="154" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="121" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -121,9 +122,10 @@
|
|||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="cbDraftLogAutoSave" max="32767" attributes="0"/>
|
||||
<Component id="cbGameLogAutoSave" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="cbDraftLogAutoSave" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cbGameJsonLogAutoSave" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cbGameLogAutoSave" alignment="0" min="-2" pref="505" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -134,7 +136,10 @@
|
|||
<Group type="102" attributes="0">
|
||||
<Component id="cbGameLogAutoSave" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cbDraftLogAutoSave" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cbDraftLogAutoSave" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cbGameJsonLogAutoSave" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -143,7 +148,7 @@
|
|||
<Component class="javax.swing.JCheckBox" name="cbGameLogAutoSave">
|
||||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Auto save game logs (to "../Mage.Client/gamelogs/" directory)"/>
|
||||
<Property name="text" type="java.lang.String" value="Save game logs (to "../Mage.Client/gamelogs/" directory)"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="The logs of all your games will be saved to the mentioned folder if this option is switched on."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
|
@ -153,13 +158,23 @@
|
|||
<Component class="javax.swing.JCheckBox" name="cbDraftLogAutoSave">
|
||||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Auto save draft logs (to "../Mage.Client/gamelogs/" directory)"/>
|
||||
<Property name="text" type="java.lang.String" value="Save draft logs (to "../Mage.Client/gamelogs/" directory)"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="The logs of all your games will be saved to the mentioned folder if this option is switched on."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbDraftLogAutoSaveActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="cbGameJsonLogAutoSave">
|
||||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Save JSON game logs (to "../Mage.Client/gamelogsJson/" directory)"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="The JSON logs of all your games will be saved to the mentioned folder if this option is switched on."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbGameJsonLogAutoSaveActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="main_card">
|
||||
|
@ -221,7 +236,7 @@
|
|||
<Property name="toolTipText" type="java.lang.String" value="Write the card's name on the card to make the card name more recognizable."/>
|
||||
<Property name="actionCommand" type="java.lang.String" value=""/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
<Color id="Standardcursor"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
|
@ -252,7 +267,7 @@
|
|||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Show the path Xmage is expecting for this card's image (only displays if missing)"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
<Color id="Standardcursor"/>
|
||||
</Property>
|
||||
<Property name="label" type="java.lang.String" value="Display image path for missing images"/>
|
||||
</Properties>
|
||||
|
@ -289,7 +304,7 @@
|
|||
<Component id="cbAskMoveToGraveOrder" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="showAbilityPickerForced" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="255" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="177" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -4318,7 +4333,7 @@
|
|||
</Group>
|
||||
<Component id="cbUseDefaultImageFolder" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="270" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="308" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
|
@ -5743,7 +5758,7 @@
|
|||
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="198" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="201" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -6008,7 +6023,7 @@
|
|||
<Component id="keyToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="controlsDescriptionLabel" pref="441" max="32767" attributes="0"/>
|
||||
<Component id="controlsDescriptionLabel" pref="478" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
|
|
|
@ -65,12 +65,11 @@ import javax.swing.filechooser.FileFilter;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.components.KeyBindButton;
|
||||
import static mage.client.constants.Constants.BATTLEFIELD_FEEDBACK_COLORIZING_MODE_ENABLE_BY_MULTICOLOR;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
|
||||
import static mage.client.constants.Constants.BATTLEFIELD_FEEDBACK_COLORIZING_MODE_ENABLE_BY_MULTICOLOR;
|
||||
import static mage.constants.Constants.DEFAULT_AVATAR_ID;
|
||||
import static mage.constants.Constants.MAX_AVATAR_ID;
|
||||
import static mage.constants.Constants.MIN_AVATAR_ID;
|
||||
|
@ -79,6 +78,7 @@ import mage.players.net.UserGroup;
|
|||
import mage.players.net.UserSkipPrioritySteps;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.Connection.ProxyType;
|
||||
import mage.remote.Session;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -122,6 +122,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave";
|
||||
public static final String KEY_DRAFT_LOG_AUTO_SAVE = "draftLogAutoSave";
|
||||
public static final String KEY_JSON_GAME_LOG_AUTO_SAVE = "gameLogJsonAutoSave";
|
||||
|
||||
public static final String KEY_CARD_IMAGES_USE_DEFAULT = "cardImagesUseDefault";
|
||||
public static final String KEY_CARD_IMAGES_PATH = "cardImagesPath";
|
||||
|
@ -406,6 +407,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
main_gamelog = new javax.swing.JPanel();
|
||||
cbGameLogAutoSave = new javax.swing.JCheckBox();
|
||||
cbDraftLogAutoSave = new javax.swing.JCheckBox();
|
||||
cbGameJsonLogAutoSave = new javax.swing.JCheckBox();
|
||||
main_card = new javax.swing.JPanel();
|
||||
showCardName = new javax.swing.JCheckBox();
|
||||
tooltipDelayLabel = new javax.swing.JLabel();
|
||||
|
@ -600,7 +602,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
main_gamelog.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Game log"));
|
||||
|
||||
cbGameLogAutoSave.setSelected(true);
|
||||
cbGameLogAutoSave.setText("Auto save game logs (to \"../Mage.Client/gamelogs/\" directory)");
|
||||
cbGameLogAutoSave.setText("Save game logs (to \"../Mage.Client/gamelogs/\" directory)");
|
||||
cbGameLogAutoSave.setToolTipText("The logs of all your games will be saved to the mentioned folder if this option is switched on.");
|
||||
cbGameLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
@ -609,7 +611,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
});
|
||||
|
||||
cbDraftLogAutoSave.setSelected(true);
|
||||
cbDraftLogAutoSave.setText("Auto save draft logs (to \"../Mage.Client/gamelogs/\" directory)");
|
||||
cbDraftLogAutoSave.setText("Save draft logs (to \"../Mage.Client/gamelogs/\" directory)");
|
||||
cbDraftLogAutoSave.setToolTipText("The logs of all your games will be saved to the mentioned folder if this option is switched on.");
|
||||
cbDraftLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
@ -617,15 +619,25 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
});
|
||||
|
||||
cbGameJsonLogAutoSave.setSelected(true);
|
||||
cbGameJsonLogAutoSave.setText("Save JSON game logs (to \"../Mage.Client/gamelogsJson/\" directory)");
|
||||
cbGameJsonLogAutoSave.setToolTipText("The JSON logs of all your games will be saved to the mentioned folder if this option is switched on.");
|
||||
cbGameJsonLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cbGameJsonLogAutoSaveActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
org.jdesktop.layout.GroupLayout main_gamelogLayout = new org.jdesktop.layout.GroupLayout(main_gamelog);
|
||||
main_gamelog.setLayout(main_gamelogLayout);
|
||||
main_gamelogLayout.setHorizontalGroup(
|
||||
main_gamelogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(main_gamelogLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.add(main_gamelogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
|
||||
.add(cbDraftLogAutoSave, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(cbGameLogAutoSave, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.add(main_gamelogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(cbDraftLogAutoSave)
|
||||
.add(cbGameJsonLogAutoSave)
|
||||
.add(cbGameLogAutoSave, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 505, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
main_gamelogLayout.setVerticalGroup(
|
||||
|
@ -633,7 +645,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.add(main_gamelogLayout.createSequentialGroup()
|
||||
.add(cbGameLogAutoSave)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(cbDraftLogAutoSave))
|
||||
.add(cbDraftLogAutoSave)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(cbGameJsonLogAutoSave)
|
||||
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
main_card.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card"));
|
||||
|
@ -785,7 +800,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.add(cbShowStormCounter, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(cbAskMoveToGraveOrder, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(showAbilityPickerForced, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(255, Short.MAX_VALUE))
|
||||
.addContainerGap(177, Short.MAX_VALUE))
|
||||
);
|
||||
main_gameLayout.setVerticalGroup(
|
||||
main_gameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
|
@ -860,10 +875,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(main_game, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(main_gamelog, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(main_gamelog, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(main_battlefield, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(154, Short.MAX_VALUE))
|
||||
.addContainerGap(121, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
main_card.getAccessibleContext().setAccessibleName("Game panel");
|
||||
|
@ -1582,7 +1597,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(cbNumberOfDownloadThreads, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
|
||||
.add(cbUseDefaultImageFolder))
|
||||
.add(0, 270, Short.MAX_VALUE)))
|
||||
.add(0, 308, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
panelCardImagesLayout.setVerticalGroup(
|
||||
|
@ -2387,7 +2402,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.add(connection_serversLayout.createSequentialGroup()
|
||||
.add(141, 141, 141)
|
||||
.add(jLabel17)))
|
||||
.addContainerGap(198, Short.MAX_VALUE))
|
||||
.addContainerGap(201, Short.MAX_VALUE))
|
||||
);
|
||||
connection_serversLayout.setVerticalGroup(
|
||||
connection_serversLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
|
@ -2626,7 +2641,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.add(keyEndStep, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(keyToggleRecordMacro, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE)))
|
||||
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
tabControlsLayout.setVerticalGroup(
|
||||
|
@ -2708,16 +2723,16 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(saveButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(exitButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(6, 6, 6))
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.add(tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
|
||||
.add(org.jdesktop.layout.GroupLayout.LEADING, tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(layout.createSequentialGroup()
|
||||
.add(0, 0, Short.MAX_VALUE)
|
||||
.add(saveButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(exitButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
|
||||
.add(6, 6, 6))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
|
@ -2749,6 +2764,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
save(prefs, dialog.cbAskMoveToGraveOrder, KEY_GAME_ASK_MOVE_TO_GRAVE_ORDER, "true", "false", UPDATE_CACHE_POLICY);
|
||||
save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
|
||||
save(prefs, dialog.cbDraftLogAutoSave, KEY_DRAFT_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
|
||||
save(prefs, dialog.cbGameJsonLogAutoSave, KEY_JSON_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
|
||||
|
||||
String paramName = KEY_BATTLEFIELD_FEEDBACK_COLORIZING_MODE;
|
||||
int paramValue = dialog.cbBattlefieldFeedbackColorizingMode.getSelectedIndex();
|
||||
|
@ -3197,6 +3213,13 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
}//GEN-LAST:event_cbBattlefieldFeedbackColorizingModeActionPerformed
|
||||
|
||||
private void cbGameJsonLogAutoSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameJsonLogAutoSaveActionPerformed
|
||||
Session session = SessionHandler.getSession();
|
||||
if (session != null) {
|
||||
session.setJsonLogActive(cbGameJsonLogAutoSave.isSelected());
|
||||
}
|
||||
}//GEN-LAST:event_cbGameJsonLogAutoSaveActionPerformed
|
||||
|
||||
private void showProxySettings() {
|
||||
Connection.ProxyType proxyType = (Connection.ProxyType) cbProxyType.getSelectedItem();
|
||||
switch (proxyType) {
|
||||
|
@ -3311,6 +3334,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true");
|
||||
load(prefs, dialog.cbDraftLogAutoSave, KEY_DRAFT_LOG_AUTO_SAVE, "true");
|
||||
load(prefs, dialog.cbGameJsonLogAutoSave, KEY_JSON_GAME_LOG_AUTO_SAVE, "true", "false");
|
||||
|
||||
String feedbackParam = "";
|
||||
try {
|
||||
|
@ -3865,6 +3889,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
private javax.swing.JCheckBox cbEnableGameSounds;
|
||||
private javax.swing.JCheckBox cbEnableOtherSounds;
|
||||
private javax.swing.JCheckBox cbEnableSkipButtonsSounds;
|
||||
private javax.swing.JCheckBox cbGameJsonLogAutoSave;
|
||||
private javax.swing.JCheckBox cbGameLogAutoSave;
|
||||
private javax.swing.JComboBox cbNumberOfDownloadThreads;
|
||||
private javax.swing.JCheckBox cbPassPriorityActivation;
|
||||
|
|
|
@ -190,16 +190,15 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
break;
|
||||
}
|
||||
case GAME_OVER: {
|
||||
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
||||
ActionData actionData = appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
||||
String logFileName = "game-" + actionData.gameId + ".json";
|
||||
|
||||
S3Uploader.upload(logFileName, actionData.gameId.toString());
|
||||
|
||||
Session session = SessionHandler.getSession();
|
||||
if (session.isJsonLogActive()) {
|
||||
appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
||||
ActionData actionData = appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
||||
String logFileName = "game-" + actionData.gameId + ".json";
|
||||
S3Uploader.upload(logFileName, actionData.gameId.toString());
|
||||
}
|
||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
||||
}
|
||||
break;
|
||||
|
@ -408,10 +407,13 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
private ActionData appendJsonEvent(String name, UUID gameId, Object value) {
|
||||
Session session = SessionHandler.getSession();
|
||||
ActionData actionData = new ActionData(name, gameId);
|
||||
actionData.value = value;
|
||||
session.appendJsonLog(actionData);
|
||||
return actionData;
|
||||
if (session.isJsonLogActive()) {
|
||||
ActionData actionData = new ActionData(name, gameId);
|
||||
actionData.value = value;
|
||||
session.appendJsonLog(actionData);
|
||||
return actionData;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createChatStartMessage(ChatPanelBasic chatPanel) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.remote;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
@ -89,6 +90,7 @@ public class SessionImpl implements Session {
|
|||
private static boolean debugMode = false;
|
||||
|
||||
private boolean canceled = false;
|
||||
private boolean jsonLogActive = false;
|
||||
|
||||
static {
|
||||
debugMode = System.getProperty("debug.mage") != null;
|
||||
|
@ -892,12 +894,20 @@ public class SessionImpl implements Session {
|
|||
|
||||
@Override
|
||||
public void appendJsonLog(ActionData actionData) {
|
||||
actionData.sessionId = getSessionId();
|
||||
String logFileName = "game-" + actionData.gameId + ".json";
|
||||
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(logFileName, true)))) {
|
||||
out.println(actionData.toJson());
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
if (isJsonLogActive()) {
|
||||
String dir = "gamelogsJson";
|
||||
File saveDir = new File(dir);
|
||||
//Existence check
|
||||
if (!saveDir.exists()) {
|
||||
saveDir.mkdirs();
|
||||
}
|
||||
actionData.sessionId = getSessionId();
|
||||
String logFileName = dir + File.separator + "game-" + actionData.gameId + ".json";
|
||||
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(logFileName, true)))) {
|
||||
out.println(actionData.toJson());
|
||||
} catch (IOException e) {
|
||||
logger.error("Cant write JSON game log file - " + logFileName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1308,7 +1318,7 @@ public class SessionImpl implements Session {
|
|||
if (isConnected()) {
|
||||
ActionData actionData = new ActionData("SEND_PLAYER_ACTION", gameId, getSessionId());
|
||||
|
||||
actionData.value = data;
|
||||
actionData.value = passPriorityAction + (data != null ? " " + data.toString() : "");
|
||||
appendJsonLog(actionData);
|
||||
|
||||
server.sendPlayerAction(passPriorityAction, gameId, sessionId, data);
|
||||
|
@ -1634,6 +1644,16 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJsonLogActive() {
|
||||
return jsonLogActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJsonLogActive(boolean jsonLogActive) {
|
||||
this.jsonLogActive = jsonLogActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MageAuthenticator extends Authenticator {
|
||||
|
|
|
@ -37,4 +37,8 @@ public interface ClientData {
|
|||
String getUserName();
|
||||
|
||||
boolean updatePreferencesForServer(UserData userData);
|
||||
|
||||
void setJsonLogActive(boolean active);
|
||||
|
||||
boolean isJsonLogActive();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue