Beispiel #1
0
    void AddSelected()
    {
        m_PrefabManager.Clear();
        m_PrefabManager.Destroy();

        AddCommand(m_SelectCommands.transform, "", true, CallbackClear);

        string description = "";

        if (m_Category != null)
        {
            AddCommand(m_SelectCommands.transform, m_Category, false, CallbackCategory);
            if (m_Command != null)
            {
                AddCommand(m_SelectCommands.transform, m_Command, false, CallbackCommand);

                CheatInfo cheat_info = CheatInfoManager.Instance.GetInfo(m_Category, m_Command);
                if (cheat_info != null)
                {
                    description = cheat_info.Description;
                }

                if (m_Param != null)
                {
                    AddCommand(m_SelectCommands.transform, m_Param, false, null);
                }
            }
        }

        m_Description.text = description;
    }
Beispiel #2
0
        public static List <CheatInfo> Load(string filename, string gameName, string gameCrc)
        {
            List <CheatInfo> cheats = new List <CheatInfo>();

            foreach (string cheatLine in File.ReadAllLines(filename))
            {
                try {
                    if (!string.IsNullOrWhiteSpace(cheatLine))
                    {
                        List <string> data = new List <string>(cheatLine.Split(':'));

                        if (data.Count >= 3)
                        {
                            bool enabled = false;
                            if (data[0].Length <= 2)
                            {
                                enabled = true;
                                data[1] = data[0] + data[1];
                                data.RemoveAt(0);
                            }

                            string address     = data[0].Substring(data[0].Length - 4);
                            string value       = data[1];
                            string compare     = null;
                            string description = null;
                            if (data[0].StartsWith("SC") && data[0].Length >= 6 || (data[0].StartsWith("C") && data[0].Length >= 5))
                            {
                                compare     = data[2];
                                description = GetValue(data, 3);
                            }
                            else
                            {
                                description = GetValue(data, 2);
                            }

                            var cheat = new CheatInfo()
                            {
                                GameCrc           = gameCrc,
                                GameName          = gameName,
                                CheatName         = description,
                                Enabled           = enabled,
                                CheatType         = CheatType.Custom,
                                IsRelativeAddress = true,
                                Address           = HexToInt(address),
                                Value             = (byte)HexToInt(value)
                            };

                            if (compare != null)
                            {
                                cheat.CompareValue    = (byte)HexToInt(compare);
                                cheat.UseCompareValue = true;
                            }

                            cheats.Add(cheat);
                        }
                    }
                } catch { }
            }
            return(cheats);
        }
Beispiel #3
0
        public frmCheat(CheatInfo cheat)
        {
            InitializeComponent();

            Entity = cheat;

            _gameCrc = cheat.GameCrc;

            radGameGenie.Tag       = CheatType.GameGenie;
            radProActionRocky.Tag  = CheatType.ProActionRocky;
            radCustom.Tag          = CheatType.Custom;
            radRelativeAddress.Tag = true;
            radAbsoluteAddress.Tag = false;

            AddBinding("Enabled", chkEnabled);
            AddBinding("CheatName", txtCheatName);
            AddBinding("GameName", txtGameName);
            AddBinding("CheatType", radGameGenie.Parent);
            AddBinding("GameGenieCode", txtGameGenie);
            AddBinding("ProActionRockyCode", txtProActionRocky);
            AddBinding("Address", txtAddress);
            AddBinding("Value", txtValue);
            AddBinding("UseCompareValue", chkCompareValue);
            AddBinding("CompareValue", txtCompare);
            AddBinding("IsRelativeAddress", radRelativeAddress.Parent);
        }
Beispiel #4
0
 private void lstCheats_ItemChecked(object sender, ItemCheckedEventArgs e)
 {
     if (e.Item.Tag is CheatInfo)
     {
         ((CheatInfo)e.Item.Tag).Enabled = e.Item.Checked;
         CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
     }
 }
Beispiel #5
0
 private void btnDeleteGameCheats_Click(object sender, EventArgs e)
 {
     foreach (var item in lstCheats.Items)
     {
         CheatInfo cheat = ((ListViewItem)item).Tag as CheatInfo;
         _cheats.Remove(cheat);
     }
     UpdateGameList();
 }
Beispiel #6
0
 private void DeleteSelectedCheats()
 {
     foreach (ListViewItem item in lstCheats.SelectedItems)
     {
         CheatInfo cheat = item.Tag as CheatInfo;
         _cheats.Remove(cheat);
     }
     UpdateGameList();
 }
Beispiel #7
0
 private void btnDeleteGameCheats_Click(object sender, EventArgs e)
 {
     foreach (var item in lstCheats.Items)
     {
         CheatInfo cheat = ((ListViewItem)item).Tag as CheatInfo;
         _cheats.Remove(cheat);
     }
     CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
     UpdateGameList();
 }
Beispiel #8
0
 private void lstCheats_DoubleClick(object sender, EventArgs e)
 {
     if (lstCheats.SelectedItems.Count == 1)
     {
         frmCheat frm = new frmCheat((CheatInfo)lstCheats.SelectedItems[0].Tag);
         if (frm.ShowDialog() == DialogResult.OK)
         {
             UpdateGameList();
             CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
         }
     }
 }
Beispiel #9
0
 private void btnImportFromFile_Click(object sender, EventArgs e)
 {
     using (var frm = new frmCheatImport()) {
         frm.FormClosing += (o, evt) => {
             if (frm.DialogResult == DialogResult.OK && frm.ImportedCheats != null)
             {
                 AddCheats(frm.ImportedCheats);
                 CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
             }
         };
         frm.ShowDialog(sender, this);
     }
 }
Beispiel #10
0
 private void DeleteSelectedCheats()
 {
     if (lstCheats.SelectedItems.Count > 0)
     {
         foreach (ListViewItem item in lstCheats.SelectedItems)
         {
             CheatInfo cheat = item.Tag as CheatInfo;
             _cheats.Remove(cheat);
         }
         CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
         UpdateGameList();
     }
 }
Beispiel #11
0
    void AddParams()
    {
        AddSelected();

        CheatInfo cheat_info = CheatInfoManager.Instance.GetInfo(m_Category, m_Command);

        bool isFirst = true;

        foreach (string command in cheat_info.Params)
        {
            AddCommand(m_Commands.transform, command, isFirst, CallbackExecute);
            isFirst = false;
        }
    }
Beispiel #12
0
 private void mnuCheats_Click(object sender, EventArgs e)
 {
     if (_cheatListWindow == null)
     {
         _cheatListWindow = new frmCheatList();
         _cheatListWindow.Show(sender, this);
         _cheatListWindow.FormClosed += (s, evt) => {
             CheatInfo.ApplyCheats();
             _cheatListWindow = null;
         };
     }
     else
     {
         _cheatListWindow.Focus();
     }
 }
Beispiel #13
0
        private void mnuAddCheat_Click(object sender, EventArgs e)
        {
            CheatInfo newCheat = new CheatInfo {
                GameCrc  = _selectedItem?.Crc,
                GameName = _selectedItem?.Text
            };

            using (frmCheat frm = new frmCheat(newCheat)) {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    AddCheats(new List <CheatInfo>()
                    {
                        newCheat
                    });
                }
            }
        }
Beispiel #14
0
        private void btnCreateCheat_Click(object sender, EventArgs e)
        {
            RomInfo   romInfo  = InteropEmu.GetRomInfo();
            CheatInfo newCheat = new CheatInfo {
                GameCrc   = romInfo.GetPrgCrcString(),
                GameName  = romInfo.GetRomName(),
                Address   = (uint)lstAddresses.CurrentAddress,
                CheatType = CheatType.Custom
            };

            frmCheat frm = new frmCheat(newCheat);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                OnAddCheat?.Invoke(newCheat, new EventArgs());
            }
        }
Beispiel #15
0
 private void lstCheats_DoubleClick(object sender, EventArgs e)
 {
     if (lstCheats.SelectedItems.Count == 1)
     {
         Configuration configBackup = ConfigManager.Config.Clone();
         using (frmCheat frm = new frmCheat((CheatInfo)lstCheats.SelectedItems[0].Tag)) {
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 UpdateGameList();
                 CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
             }
             else
             {
                 ConfigManager.RevertDirtyToBackup(configBackup);
             }
         }
     }
 }
Beispiel #16
0
        private void ConvertCode()
        {
            //Automatically update the other fields to match the active code (when possible)
            UpdateObject();

            CheatInfo cheat = (CheatInfo)this.Entity;

            if (cheat.CheatType == CheatType.GameGenie)
            {
                CheatData convertedData = ConvertGameGenieCode(cheat.GameGenieCode.ToUpper());
                txtProActionRocky.Text  = ToProActionReplayCode(convertedData.Address, convertedData.Value, convertedData.CompareValue);
                txtAddress.Text         = convertedData.Address.ToString("X4");
                txtValue.Text           = convertedData.Value.ToString("X2");
                txtCompare.Text         = convertedData.CompareValue >= 0 ? convertedData.CompareValue.ToString("X2") : "";
                chkCompareValue.Checked = convertedData.CompareValue >= 0;
            }
            else if (cheat.CheatType == CheatType.ProActionRocky)
            {
                CheatData convertedData = ConvertProActionReplayCode(cheat.ProActionRockyCode);
                txtGameGenie.Text          = ToGameGenieCode(convertedData.Address, convertedData.Value, convertedData.CompareValue);
                txtAddress.Text            = convertedData.Address.ToString("X4");
                txtValue.Text              = convertedData.Value.ToString("X2");
                txtCompare.Text            = convertedData.CompareValue.ToString("X2");
                radRelativeAddress.Checked = true;
                chkCompareValue.Checked    = true;
            }
            else
            {
                if (cheat.IsRelativeAddress && cheat.Address >= 0x8000)
                {
                    txtGameGenie.Text      = ToGameGenieCode((int)cheat.Address, cheat.Value, cheat.UseCompareValue ? cheat.CompareValue : -1);
                    txtProActionRocky.Text = ToProActionReplayCode((int)cheat.Address, cheat.Value, cheat.UseCompareValue ? cheat.CompareValue : -1);
                }
                else
                {
                    txtProActionRocky.Text = "";
                    txtGameGenie.Text      = "";
                }
            }
        }
Beispiel #17
0
    void OnExecute()
    {
        if (m_Category == null || m_Command == null)
        {
            Tooltip.Instance.ShowMessage("Please select command.");
            return;
        }

        CheatInfo cheat_info = CheatInfoManager.Instance.GetInfo(m_Category, m_Command);

        if (m_Param == null)
        {
            if (cheat_info.Params.Count > 0)
            {
                Tooltip.Instance.ShowMessage("Please select param.");
                return;
            }
            m_Param = "";
        }

        if (BattleBase.Instance != null && m_Category != "Show")
        {
            Tooltip.Instance.ShowMessage("In the battle it can not be used.");
            return;
        }

        if (cheat_info.IsClient)
        {
            OnExecuteClient();
        }
        else
        {
            C2G.Cheat packet = new C2G.Cheat();
            packet.category = m_Category;
            packet.command  = m_Command;
            packet.param    = m_Param;
            Network.GameServer.JsonAsync <C2G.Cheat, C2G.CheatAck>(packet, OnExecuteAck);
        }
    }
Beispiel #18
0
        private void AddCheats(List <CheatInfo> cheats)
        {
            if (cheats.Count > 0)
            {
                HashSet <string> existingCheats = new HashSet <string>();
                foreach (CheatInfo cheat in _cheats)
                {
                    existingCheats.Add(cheat.GameCrc + cheat.ToString());
                }

                foreach (CheatInfo cheat in cheats)
                {
                    if (!existingCheats.Contains(cheat.GameCrc + cheat.ToString()))
                    {
                        _cheats.Add(cheat);
                    }
                }

                UpdateGameList(cheats[0].GameCrc);
                CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
            }
        }
        private static List <CheatInfo> Load(XmlDocument xml, string gameName, string gameCrc, string filepath)
        {
            try {
                List <CheatInfo> cheats = new List <CheatInfo>();

                bool validFile         = false;
                bool hasMatchingCheats = false;
                foreach (XmlNode node in xml.SelectNodes("/cheats/cheat"))
                {
                    try {
                        if (node.Attributes["game"] != null)
                        {
                            validFile = true;
                            var nodeGameName = node.Attributes["gameName"]?.Value;
                            if (nodeGameName != null && string.IsNullOrWhiteSpace(gameCrc) || node.Attributes["game"].Value.Contains(gameCrc))
                            {
                                hasMatchingCheats = true;
                                var  crc         = node.Attributes["game"].Value.Replace("0x", "").ToUpper();
                                var  genie       = node.SelectSingleNode("genie");
                                var  rocky       = node.SelectSingleNode("rocky");
                                var  description = node.SelectSingleNode("description");
                                var  address     = node.SelectSingleNode("address");
                                var  value       = node.SelectSingleNode("value");
                                var  compare     = node.SelectSingleNode("compare");
                                bool isPrgOffset = node.SelectSingleNode("isPrgOffset")?.InnerText == "true";

                                var cheat = new CheatInfo();
                                cheat.GameCrc   = crc;
                                cheat.GameName  = nodeGameName ?? gameName;
                                cheat.CheatName = description?.InnerXml;
                                cheat.Enabled   = node.Attributes["enabled"] != null && node.Attributes["enabled"].Value == "1" ? true : false;
                                if (genie != null)
                                {
                                    cheat.CheatType     = CheatType.GameGenie;
                                    cheat.GameGenieCode = genie.InnerText.ToUpper();
                                }
                                else if (rocky != null)
                                {
                                    cheat.CheatType          = CheatType.ProActionRocky;
                                    cheat.ProActionRockyCode = HexToInt(rocky.InnerText);
                                }
                                else
                                {
                                    cheat.CheatType         = CheatType.Custom;
                                    cheat.IsRelativeAddress = !isPrgOffset;
                                    cheat.Address           = HexToInt(address?.InnerText);
                                    cheat.Value             = (byte)HexToInt(value?.InnerText);
                                    if (compare != null)
                                    {
                                        cheat.CompareValue    = (byte)HexToInt(compare.InnerText);
                                        cheat.UseCompareValue = true;
                                    }
                                }

                                cheats.Add(cheat);
                            }
                        }
                    } catch { }
                }

                if (!validFile)
                {
                    //Valid xml file, but invalid content
                    MesenMsgBox.Show("InvalidCheatFile", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, Path.GetFileName(filepath));
                    return(null);
                }
                else if (!hasMatchingCheats)
                {
                    //Valid cheat file, but no cheats match selected game
                    MesenMsgBox.Show("NoMatchingCheats", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, Path.GetFileName(filepath));
                    return(null);
                }
                else
                {
                    return(cheats);
                }
            } catch {
                //Invalid xml file
                MesenMsgBox.Show("InvalidXmlFile", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, Path.GetFileName(filepath));
                return(null);
            }
        }
Beispiel #20
0
 private void chkDisableCheats_CheckedChanged(object sender, EventArgs e)
 {
     CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
 }