Example #1
0
        private void GenerateRawCodes()
        {
            StringBuilder sb       = new StringBuilder();
            Regex         validate = new Regex(radGameGenie.Checked ? "^[a-f0-9]{4}-[a-f0-9]{4}$" : "^[a-f0-9]{8}$", RegexOptions.IgnoreCase);

            foreach (string code in txtCodes.Text.Split(new string[1] {
                Environment.NewLine
            }, StringSplitOptions.None))
            {
                string trimmedCode = code.Trim();
                if (trimmedCode.Length > 0)
                {
                    if (!validate.IsMatch(trimmedCode))
                    {
                        sb.AppendLine("[invalid code]");
                    }
                    else
                    {
                        uint encodedCheat = CheatCode.GetEncodedCheat(trimmedCode, radGameGenie.Checked ? CheatFormat.GameGenie : CheatFormat.ProActionReplay);
                        sb.AppendLine("$" + (encodedCheat >> 8).ToString("X6") + " = $" + (encodedCheat & 0xFF).ToString("X2"));
                    }
                }
                else
                {
                    sb.AppendLine("");
                }
            }
            txtRawCodes.Text = sb.ToString();
        }
Example #2
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
     }
 }
Example #3
0
 private void DeleteSelectedCheats()
 {
     if (lstCheats.SelectedItems.Count > 0)
     {
         foreach (ListViewItem item in lstCheats.SelectedItems)
         {
             CheatCode cheat = item.Tag as CheatCode;
             _cheats.Remove(cheat);
         }
         ApplyCheats();
         UpdateCheatList();
     }
 }
Example #4
0
        public frmCheat(CheatCode cheat)
        {
            InitializeComponent();

            this.Icon = Resources.CheatCode;

            this.Entity = cheat;

            AddBinding(nameof(CheatCode.Description), txtCheatName);
            AddBinding(nameof(CheatCode.Enabled), chkEnabled);
            AddBinding(nameof(CheatCode.Codes), txtCodes);

            radGameGenie.Checked       = cheat.Format == CheatFormat.GameGenie;
            radProActionReplay.Checked = cheat.Format == CheatFormat.ProActionReplay;
        }
Example #5
0
        private void mnuAddCheat_Click(object sender, EventArgs e)
        {
            CheatCode newCheat = new CheatCode()
            {
                Enabled = true
            };

            using (frmCheat frm = new frmCheat(newCheat)) {
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    AddCheats(new List <CheatCode>()
                    {
                        newCheat
                    });
                }
            }
        }
Example #6
0
        private void btnImportFromDb_Click(object sender, EventArgs e)
        {
            using (frmCheatDbList frm = new frmCheatDbList()) {
                if (frm.ShowDialog(btnImportFromDb, this) == DialogResult.OK)
                {
                    List <CheatCode> importedCheats = new List <CheatCode>();
                    Dictionary <string, CheatCode> existingCheats = new Dictionary <string, CheatCode>();
                    foreach (CheatCode cheat in _cheats)
                    {
                        existingCheats[cheat.Description] = cheat;
                    }

                    foreach (CheatDbCheatEntry dbCheat in frm.ImportedCheats)
                    {
                        CheatCode cheat = new CheatCode();
                        cheat.Description = dbCheat.Description;
                        cheat.Enabled     = false;
                        cheat.Format      = CheatFormat.ProActionReplay;
                        foreach (string code in dbCheat.Codes)
                        {
                            cheat.Codes += code + Environment.NewLine;
                            if (code.Contains('-'))
                            {
                                cheat.Format = CheatFormat.GameGenie;
                            }
                        }

                        if (!existingCheats.ContainsKey(cheat.Description) || existingCheats[cheat.Description].Codes != cheat.Codes)
                        {
                            //Only import cheats that don't already exist in the list
                            importedCheats.Add(cheat);
                        }
                    }
                    AddCheats(importedCheats);
                }
            }
        }
Example #7
0
 public override void OnDialogStateEnter(PersistState ownerState, BaseDialogState previousDialog, object data)
 {
     base.OnDialogStateEnter(ownerState, previousDialog, data);
     Close.onClick.AddListener(() => { OnPreviousPress(); });
     DoScript.onClick.AddListener(() =>
     {
         try
         {
             if (string.IsNullOrEmpty(scriptInput.text))
             {
                 result.text = "输入为空";
                 return;
             }
             result.text = "秘籍可查阅指令表";
             if (!CheatCode.UseCheatCode(scriptInput.text))
             {
                 if (U3D.IsMultiplyPlayer())
                 {
                     result.text = "联机时只支持部分指令";
                 }
                 else
                 {
                     ScriptMng.Ins.CallString(scriptInput.text);
                 }
             }
             else
             {
                 result.text = "秘籍成功执行";
             }
         }
         catch (Exception exp)
         {
             result.text = "执行出错:" + exp.Message + "-" + exp.StackTrace;
         }
     });
 }
        public override void OnInspectorGUI()
        {
            CheatCodeSettings settings = (CheatCodeSettings)target;

            CheatCodeSettings.SetInstance(settings);
            cheatCodes = CheatCodeSettings.CheatCodes;

            EditorGUILayout.LabelField("Cheat Codes");

            EditorGUILayout.HelpBox("A list of all cheat codes", MessageType.None);

            CheatCodeSettings.CheatCodeLength = EditorGUILayout.IntField(cheatLenghtLabel, CheatCodeSettings.CheatCodeLength);

            EditorGUILayout.Space();

            for (int i = 0; i < cheatCodes.Count; i++)
            {
                EditorGUILayout.LabelField("Cheat Code " + (i + 1) + " - " + cheatCodes[i].name);
                cheatCodes[i].name      = EditorGUILayout.TextField(userFriendlyLabel, cheatCodes[i].name);
                cheatCodes[i].shortCode = EditorGUILayout.TextField(shortCodeLabel, cheatCodes[i].shortCode);

                EditorGUILayout.LabelField("Cheat Code Sequence");

                for (int o = 0; o < CheatCodeSettings.CheatCodeLength; o++)
                {
                    GUIContent step = new GUIContent("Step " + (o + 1));
                    cheatCodes[i].cheatCodeSequence[o] = (KeyCode)EditorGUILayout.EnumPopup(step, cheatCodes[i].cheatCodeSequence[o]);
                }

                if (GUILayout.Button("Delete this cheat code!"))
                {
                    cheatCodes.Remove(cheatCodes[i]);
                    SaveAsset(settings);
                }

                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Add New Cheat Code"))
            {
                CheatCode newCheatCode = new CheatCode();
                newCheatCode.name              = "New Cheat Code";
                newCheatCode.shortCode         = "newCheatCode";
                newCheatCode.cheatCodeSequence = new List <KeyCode>(CheatCodeSettings.CheatCodeLength);

                //prepopulate with empty strings, otherwise gives error as setting the capacity above does nothing
                for (int i = 0; i < CheatCodeSettings.CheatCodeLength; i++)
                {
                    newCheatCode.cheatCodeSequence.Add(KeyCode.A);
                }
                cheatCodes.Add(newCheatCode);

                SaveAsset(settings);
            }

            if (GUI.changed)
            {
                Debug.Log("gui changed");
                SaveAsset(settings);
            }
        }
        public override void OnInspectorGUI()
        {
            CheatCodeSettings settings = (CheatCodeSettings)target;
            CheatCodeSettings.SetInstance(settings);
            cheatCodes = CheatCodeSettings.CheatCodes;

            EditorGUILayout.LabelField("Cheat Codes");

            EditorGUILayout.HelpBox("A list of all cheat codes", MessageType.None);

            CheatCodeSettings.CheatCodeLength = EditorGUILayout.IntField(cheatLenghtLabel, CheatCodeSettings.CheatCodeLength);

            EditorGUILayout.Space();

            for (int i = 0; i < cheatCodes.Count; i++)
            {
                EditorGUILayout.LabelField("Cheat Code " + (i+1) + " - " + cheatCodes[i].name);
                cheatCodes[i].name = EditorGUILayout.TextField(userFriendlyLabel, cheatCodes[i].name);
                cheatCodes[i].shortCode = EditorGUILayout.TextField(shortCodeLabel, cheatCodes[i].shortCode);

                EditorGUILayout.LabelField("Cheat Code Sequence");

                for (int o = 0; o < CheatCodeSettings.CheatCodeLength; o++)
                {
                    GUIContent step = new GUIContent("Step " + (o + 1));
                    cheatCodes[i].cheatCodeSequence[o] = (KeyCode)EditorGUILayout.EnumPopup(step, cheatCodes[i].cheatCodeSequence[o]);
                }

                if (GUILayout.Button("Delete this cheat code!"))
                {
                    cheatCodes.Remove(cheatCodes[i]);
                    SaveAsset(settings);
                }

                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Add New Cheat Code"))
            {
                CheatCode newCheatCode = new CheatCode();
                newCheatCode.name = "New Cheat Code";
                newCheatCode.shortCode = "newCheatCode";
                newCheatCode.cheatCodeSequence = new List<KeyCode>(CheatCodeSettings.CheatCodeLength);

                //prepopulate with empty strings, otherwise gives error as setting the capacity above does nothing
                for (int i = 0; i < CheatCodeSettings.CheatCodeLength; i++)
                {
                    newCheatCode.cheatCodeSequence.Add(KeyCode.A);
                }
                cheatCodes.Add(newCheatCode);

                SaveAsset(settings);
            }

            if (GUI.changed)
            {
                Debug.Log("gui changed");
                SaveAsset(settings);
            }
        }