Beispiel #1
0
		public Cheat(Cheat cheat)
		{
			if (cheat.IsSeparator)
			{
				_enabled = false;
				_watch = SeparatorWatch.Instance;
				_compare = null;
			}
			else
			{
				_enabled = cheat.Enabled;
				_watch = Watch.GenerateWatch(
					cheat.Domain,
					cheat.Address ?? 0,
					cheat.Size,
					cheat.Type,					
					cheat.BigEndian ?? false,
					cheat.Name
                    );
				_compare = cheat.Compare;
				_val = cheat.Value ?? 0;

				Pulse();
			}
		}
Beispiel #2
0
		public Cheat(Watch watch, int value, int? compare = null, bool enabled = true)
		{
			_enabled = enabled;
			_watch = watch;
			_compare = compare;
			_val = value;

			Pulse();
		}
Beispiel #3
0
		public Cheat(Watch watch, int value, int? compare = null, bool enabled = true, COMPARISONTYPE comparisonType = COMPARISONTYPE.NONE)
		{
			_enabled = enabled;
			_watch = watch;
			_compare = compare;
			_val = value;
			_comparisonType = comparisonType;

			Pulse();
		}
Beispiel #4
0
		public static string ToString(Watch watch, MemoryDomain domain)
		{
			var numDigits = (domain.Size - 1).NumHexDigits();

			var sb = new StringBuilder();

			sb
				.Append((watch.Address ?? 0).ToHexString(numDigits)).Append('\t')
				.Append(watch.SizeAsChar).Append('\t')
				.Append(watch.TypeAsChar).Append('\t')
				.Append(watch.BigEndian ? '1' : '0').Append('\t')
				.Append(watch.DomainName).Append('\t')
				.Append(watch.Notes.Trim(new[] { '\r', '\n' }));

			return sb.ToString();
		}
Beispiel #5
0
 public void SetType(Watch.DisplayType type)
 {
     if (Watch.AvailableTypes(_watch.Size).Contains(type))
     {
         _watch.Type = type;
         Changes();
     }
 }
Beispiel #6
0
		public void SetPreviousType(Watch.PreviousType type)
		{
			if (type == Watch.PreviousType.LastChange)
			{
				throw new InvalidOperationException();
			}

			if (_settings.Mode == Settings.SearchMode.Fast)
			{
				if (type == Watch.PreviousType.LastFrame)
				{
					throw new InvalidOperationException();
				}
			}

			_settings.PreviousType = type;
		}
Beispiel #7
0
		public void SetType(Watch.DisplayType type)
		{
			if (Watch.AvailableTypes(_settings.Size).Contains(type))
			{
				_settings.Type = type;
			}
		}
Beispiel #8
0
			public void Update(Watch.PreviousType type, MemoryDomain domain, bool bigendian)
			{
				var value = domain.PeekDWord(Address % domain.Size, bigendian);
				if (value != Previous)
				{
					_changecount++;
				}

				switch (type)
				{
					case Watch.PreviousType.Original:
					case Watch.PreviousType.LastSearch:
						break;
					case Watch.PreviousType.LastFrame:
						_previous = _prevFrame;
						break;
				}

				_prevFrame = value;
			}
Beispiel #9
0
        public bool Load(string path, bool append)
        {
            var file = new FileInfo(path);

            if (file.Exists == false)
            {
                return(false);
            }

            if (!append)
            {
                _currentFileName = path;
            }

            using (var sr = file.OpenText())
            {
                if (!append)
                {
                    Clear();
                }

                string s;
                while ((s = sr.ReadLine()) != null)
                {
                    try
                    {
                        if (s == "----")
                        {
                            _cheatList.Add(Cheat.Separator);
                        }
                        else
                        {
                            int?compare;
                            var size      = WatchSize.Byte;
                            var type      = DisplayType.Hex;
                            var bigendian = false;
                            Cheat.CompareType comparisonType = Cheat.CompareType.None;

                            if (s.Length < 6)
                            {
                                continue;
                            }

                            var vals    = s.Split('\t');
                            var address = int.Parse(vals[0], NumberStyles.HexNumber);
                            var value   = int.Parse(vals[1], NumberStyles.HexNumber);

                            if (vals[2] == "N")
                            {
                                compare = null;
                            }
                            else
                            {
                                compare = int.Parse(vals[2], NumberStyles.HexNumber);
                            }

                            var domain  = Global.Emulator.AsMemoryDomains()[vals[3]];
                            var enabled = vals[4] == "1";
                            var name    = vals[5];

                            // For backwards compatibility, don't assume these values exist
                            if (vals.Length > 6)
                            {
                                size      = Watch.SizeFromChar(vals[6][0]);
                                type      = Watch.DisplayTypeFromChar(vals[7][0]);
                                bigendian = vals[8] == "1";
                            }

                            // For backwards compatibility, don't assume these values exist
                            if (vals.Length > 9)
                            {
                                if (!Enum.TryParse <Cheat.CompareType>(vals[9], out comparisonType))
                                {
                                    continue;                                     // Not sure if this is the best answer, could just resort to ==
                                }
                            }

                            var watch = Watch.GenerateWatch(
                                domain,
                                address,
                                size,
                                type,
                                bigendian,
                                name);

                            Add(new Cheat(watch, value, compare, !Global.Config.DisableCheatsOnLoad && enabled, comparisonType));
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            Changes = false;
            return(true);
        }