Convert console output to debug output

output messages are now no longer in release builds, as they are only
visible when debugging in an IDE.
This commit is contained in:
Kurt
2017-07-01 19:43:51 -07:00
parent b760509fcb
commit 4e9b6be8e5
18 changed files with 57 additions and 48 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using static PKHeX.Core.LegalityCheckStrings;
@@ -91,7 +92,7 @@ public LegalityAnalysis(PKM pk)
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Debug.WriteLine(e.Message);
Valid = false;
AddLine(Severity.Invalid, V190, CheckIdentifier.Misc);
pkm = pk;

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
namespace PKHeX.Core
@@ -266,7 +267,7 @@ public override int Gender
case 191:
return IV_ATK >= 12 ? 0 : 1;
}
Console.WriteLine("Unknown Gender value: " + gv);
Debug.WriteLine("Unknown Gender value: " + gv);
return 0;
}
set { }

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
@@ -197,7 +198,7 @@ public static PKM ConvertToType(PKM pk, Type PKMType, out string comment)
Type fromType = pk.GetType();
int fromFormat = int.Parse(fromType.Name.Last().ToString());
int toFormat = int.Parse(PKMType.Name.Last().ToString());
Console.WriteLine($"Trying to convert {fromType.Name} to {PKMType.Name}.");
Debug.WriteLine($"Trying to convert {fromType.Name} to {PKMType.Name}.");
PKM pkm = null;

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
namespace PKHeX.Core
@@ -119,13 +120,13 @@ private PersonalTable(byte[] data, GameVersion format)
public int[] GetAbilities(int species, int forme)
{
if (species >= Table.Length)
{ species = 0; Console.WriteLine("Requested out of bounds SpeciesID"); }
{ species = 0; Debug.WriteLine("Requested out of bounds SpeciesID"); }
return this[GetFormeIndex(species, forme)].Abilities;
}
public int GetFormeIndex(int species, int forme)
{
if (species >= Table.Length)
{ species = 0; Console.WriteLine("Requested out of bounds SpeciesID"); }
{ species = 0; Debug.WriteLine("Requested out of bounds SpeciesID"); }
return this[species].FormeIndex(species, forme);
}
public PersonalInfo GetFormeEntry(int species, int forme)

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
@@ -290,7 +291,7 @@ protected override void SetChecksums()
// Check for invalid block lengths
if (Blocks.Length < 3) // arbitrary...
{
Console.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
Debug.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
return;
}
// Apply checksums
@@ -309,7 +310,7 @@ public override bool ChecksumsValid
// Check for invalid block lengths
if (Blocks.Length < 3) // arbitrary...
{
Console.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
Debug.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
return false;
}
@@ -332,7 +333,7 @@ public override string ChecksumInfo
// Check for invalid block lengths
if (Blocks.Length < 3) // arbitrary...
{
Console.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
Debug.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
return "Not a valid save to check.";
}
string r = "";

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
@@ -92,14 +93,14 @@ protected override void SetChecksums()
// Check for invalid block lengths
if (Blocks.Length < 3) // arbitrary...
{
Console.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
Debug.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
return;
}
// Apply checksums
for (int i = 0; i < Blocks.Length; i++)
{
if (Blocks[i].Length + Blocks[i].Offset > Data.Length)
{ Console.WriteLine("Block {0} has invalid offset/length value.", i); return; }
{ Debug.WriteLine("Block {0} has invalid offset/length value.", i); return; }
byte[] array = new byte[Blocks[i].Length];
Array.Copy(Data, Blocks[i].Offset, array, 0, array.Length);
BitConverter.GetBytes(SaveUtil.CRC16_CCITT(array)).CopyTo(Data, BlockInfoOffset + 6 + i * 8);

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
@@ -130,14 +131,14 @@ protected override void SetChecksums()
// Check for invalid block lengths
if (Blocks.Length < 3) // arbitrary...
{
Console.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
Debug.WriteLine("Not enough blocks ({0}), aborting SetChecksums", Blocks.Length);
return;
}
// Apply checksums
for (int i = 0; i < Blocks.Length; i++)
{
if (Blocks[i].Length + Blocks[i].Offset > Data.Length)
{ Console.WriteLine("Block {0} has invalid offset/length value.", i); return; }
{ Debug.WriteLine("Block {0} has invalid offset/length value.", i); return; }
byte[] array = new byte[Blocks[i].Length];
Array.Copy(Data, Blocks[i].Offset, array, 0, array.Length);
BitConverter.GetBytes(SaveUtil.CRC16_7(array, Blocks[i].ID)).CopyTo(Data, BlockInfoOffset + 6 + i * 8);

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
namespace PKHeX.Core
@@ -193,7 +194,7 @@ public PKM[] PartyData
if (value.Any(pk => PKMType != pk.GetType()))
throw new ArgumentException($"Not {PKMType} array.");
if (value[0].Species == 0)
Console.WriteLine($"Empty first slot, received {value.Length}.");
Debug.WriteLine($"Empty first slot, received {value.Length}.");
PKM[] newParty = value.Where(pk => pk.Species != 0).ToArray();

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
@@ -199,7 +200,7 @@ private static void SetLocalization(Type t, IEnumerable<string> lines)
}
catch
{
Console.WriteLine($"Property not present: {prop} || Value written: {value}");
Debug.WriteLine($"Property not present: {prop} || Value written: {value}");
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -120,23 +121,17 @@ public void HandleMovePKM(PictureBox pb, int slot, int box, bool encrypt)
// Browser apps need time to load data since the file isn't moved to a location on the user's local storage.
// Tested 10ms -> too quick, 100ms was fine. 500ms should be safe?
if (!external)
{
if (File.Exists(newfile) && DragInfo.CurrentPath == null)
File.Delete(newfile);
}
else
{
new Task(() =>
{
Thread.Sleep(500);
if (File.Exists(newfile) && DragInfo.CurrentPath == null)
File.Delete(newfile);
}).Start();
}
int delay = external ? 500 : 0;
DeleteAsync(newfile, delay);
if (DragInfo.Source.IsParty || DragInfo.Destination.IsParty)
SE.SetParty();
}
private async void DeleteAsync(string path, int delay)
{
await Task.Delay(delay);
if (File.Exists(path) && DragInfo.CurrentPath == null)
File.Delete(path);
}
private string CreateDragDropPKM(PictureBox pb, int box, bool encrypt, out bool external)
{
byte[] dragdata = SAV.DecryptPKM(DragInfo.Source.OriginalData);
@@ -245,7 +240,7 @@ private bool TryLoadFiles(string[] files, DragEventArgs e, bool noEgg)
if (pk == null)
{
WinFormsUtil.Error(c);
Console.WriteLine(c);
Debug.WriteLine(c);
return false;
}
@@ -258,14 +253,14 @@ private bool TryLoadFiles(string[] files, DragEventArgs e, bool noEgg)
string concat = string.Join(Environment.NewLine, errata);
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, concat, "Continue?"))
{
Console.WriteLine(c);
Console.WriteLine(concat);
Debug.WriteLine(c);
Debug.WriteLine(concat);
return false;
}
}
SetPKM(pk, false, Resources.slotSet);
Console.WriteLine(c);
Debug.WriteLine(c);
return true;
}
private bool TrySetPKMDestination(object sender, DragEventArgs e, bool overwrite, bool clone, bool noEgg)
@@ -355,7 +350,7 @@ public void SetPKM(PKM pk, SlotChange slot, bool src, Image img)
{
if (boxview.CurrentBox == slot.Box)
{
Console.WriteLine($"Setting to {boxview.Parent.Name}'s [{boxview.CurrentBox+1:d2}]|{boxview.CurrentBoxName} at Slot {slot.Slot+1}.");
Debug.WriteLine($"Setting to {boxview.Parent.Name}'s [{boxview.CurrentBox+1:d2}]|{boxview.CurrentBoxName} at Slot {slot.Slot+1}.");
SetSlotSprite(slot, pk, boxview);
}
}

View File

@@ -595,7 +595,7 @@ private bool TryLoadPKM(byte[] input, string path, string ext, SaveFile SAV)
}
PKME_Tabs.PopulateFields(pk);
Console.WriteLine(c);
Debug.WriteLine(c);
return true;
}
private bool TryLoadPCBoxBin(byte[] input)
@@ -619,7 +619,7 @@ private bool TryLoadBattleVideo(byte[] input)
BattleVideo b = BattleVideo.GetVariantBattleVideo(input);
bool result = C_SAV.OpenBattleVideo(b, out string c);
WinFormsUtil.Alert(c);
Console.WriteLine(c);
Debug.WriteLine(c);
return result;
}
private bool TryLoadMysteryGift(byte[] input, string path, string ext)
@@ -643,7 +643,7 @@ private bool TryLoadMysteryGift(byte[] input, string path, string ext)
}
PKME_Tabs.PopulateFields(pk);
Console.WriteLine(c);
Debug.WriteLine(c);
return true;
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
@@ -279,7 +280,7 @@ private bool ProcessPKM(PKM pkm, IEnumerable<StringInstruction> Filters, IEnumer
if (!pkm.Valid || pkm.Locked)
{
len++;
Console.WriteLine("Skipped a pkm due to disallowed input: " + (pkm.Locked ? "Locked." : "Not Valid."));
Debug.WriteLine("Skipped a pkm due to disallowed input: " + (pkm.Locked ? "Locked." : "Not Valid."));
return false;
}
@@ -348,7 +349,7 @@ public void SetRandRange(string pv)
if (Min == Max)
{
PropertyValue = Min.ToString();
Console.WriteLine(PropertyName + " randomization range Min/Max same?");
Debug.WriteLine(PropertyName + " randomization range Min/Max same?");
}
else
Random = true;
@@ -439,7 +440,7 @@ private static ModifyResult TryModifyPKM(PKM PKM, IEnumerable<StringInstruction>
if (IsPKMFiltered(pkm, cmd, info, out result))
return result; // why it was filtered out
}
catch { Console.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); }
catch { Debug.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); }
}
foreach (var cmd in Instructions)
@@ -448,7 +449,7 @@ private static ModifyResult TryModifyPKM(PKM PKM, IEnumerable<StringInstruction>
{
result = SetPKMProperty(PKM, info, cmd);
}
catch { Console.WriteLine($"Unable to set {cmd.PropertyName} to {cmd.PropertyValue}."); }
catch { Debug.WriteLine($"Unable to set {cmd.PropertyName} to {cmd.PropertyValue}."); }
}
return result;
}

View File

@@ -546,7 +546,7 @@ private IEnumerable<PKM> SearchDatabase()
if (!pkm.GetType().HasPropertyAll(cmd.PropertyName))
return false;
try { if (ReflectUtil.IsValueEqual(pkm, cmd.PropertyName, cmd.PropertyValue) == cmd.Evaluator) continue; }
catch { Console.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); }
catch { Debug.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); }
return false;
}
return true;

View File

@@ -291,7 +291,7 @@ private void B_Search_Click(object sender, EventArgs e)
if (!gift.GetType().HasPropertyAll(cmd.PropertyName))
return false;
try { if (ReflectUtil.IsValueEqual(gift, cmd.PropertyName, cmd.PropertyValue) == cmd.Evaluator) continue; }
catch { Console.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); }
catch { Debug.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); }
return false;
}
return true;

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -418,7 +419,7 @@ private void DiffSaves()
catch (Exception e)
{
WinFormsUtil.Error("An unexpected error has occurred.", e);
Console.Write(e);
Debug.WriteLine(e);
}
TB_IsSet.Text = tbIsSet;
TB_UnSet.Text = tbUnSet;
@@ -438,7 +439,7 @@ private void DiffSaves()
catch (Exception e)
{
WinFormsUtil.Error("An unexpected error has occurred.", e);
Console.Write(e);
Debug.WriteLine(e);
}
if (string.IsNullOrEmpty(r))

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.Runtime.InteropServices;
@@ -46,7 +47,7 @@ private static void SetPKXFont()
#endif
}
catch (Exception ex) { Console.WriteLine("Unable to add ingame font: " + ex.Message); }
catch (Exception ex) { Debug.WriteLine("Unable to add ingame font: " + ex.Message); }
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
@@ -18,7 +19,7 @@ public static string GetStringFromURL(string webURL)
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Debug.WriteLine(e.Message);
return null;
}
}
@@ -33,7 +34,7 @@ public static Image GetImageFromURL(string webURL)
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Debug.WriteLine(e.Message);
return null;
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using PKHeX.Core;
@@ -115,7 +116,7 @@ public static bool LoadBoxes(this SaveFile SAV, string path, out string result,
PKM pk = PKMConverter.ConvertToType(temp, SAV.PKMType, out string c);
if (pk == null)
{ Console.WriteLine(c); continue; }
{ Debug.WriteLine(c); continue; }
if (SAV.IsPKMCompatible(pk).Length > 0)
continue;