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 @@ namespace PKHeX.Core
}
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 @@ namespace PKHeX.Core
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 @@ namespace PKHeX.Core
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 @@ namespace PKHeX.Core
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 @@ namespace PKHeX.Core
// 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 @@ namespace PKHeX.Core
// 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 @@ namespace PKHeX.Core
// 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 @@ namespace PKHeX.Core
// 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 @@ namespace PKHeX.Core
// 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 @@ namespace PKHeX.Core
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 @@ namespace PKHeX.Core
}
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 @@ namespace PKHeX.WinForms.Controls
// 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 @@ namespace PKHeX.WinForms.Controls
if (pk == null)
{
WinFormsUtil.Error(c);
Console.WriteLine(c);
Debug.WriteLine(c);
return false;
}
@ -258,14 +253,14 @@ namespace PKHeX.WinForms.Controls
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 @@ namespace PKHeX.WinForms.Controls
{
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 @@ namespace PKHeX.WinForms
}
PKME_Tabs.PopulateFields(pk);
Console.WriteLine(c);
Debug.WriteLine(c);
return true;
}
private bool TryLoadPCBoxBin(byte[] input)
@ -619,7 +619,7 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
}
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 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
{
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 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
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 @@ namespace PKHeX.WinForms
#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 @@ namespace PKHeX.WinForms
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Debug.WriteLine(e.Message);
return null;
}
}
@ -33,7 +34,7 @@ namespace PKHeX.WinForms
}
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 @@ namespace PKHeX.WinForms
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;