public static void InitializeCheats() { CheatToolsWindow.OnShown = window => { _studioInstance = Studio.Studio.IsInstance() ? Studio.Studio.Instance : null; _soundInstance = Manager.Sound.instance; _sceneInstance = Scene.instance; _gameMgr = Game.IsInstance() ? Game.Instance : null; _baseMap = BaseMap.instance; _hScene = HSceneFlagCtrl.IsInstance() ? HSceneFlagCtrl.Instance : null; _openInInspectorButtons = new[] { new KeyValuePair <object, string>(_gameMgr != null && _gameMgr.heroineList.Count > 0 ? (Func <object>)(() => _gameMgr.heroineList.Select(x => new ReadonlyCacheEntry(GetHeroineName(x), x))) : null, "Heroine list"), new KeyValuePair <object, string>(ADVManager.IsInstance() ? ADVManager.Instance : null, "Manager.ADVManager.Instance"), new KeyValuePair <object, string>(_baseMap, "Manager.BaseMap.instance"), new KeyValuePair <object, string>(Character.IsInstance() ? Character.Instance : null, "Manager.Character.Instance"), new KeyValuePair <object, string>(typeof(Manager.Config), "Manager.Config"), new KeyValuePair <object, string>(_gameMgr, "Manager.Game.Instance"), new KeyValuePair <object, string>(GameSystem.IsInstance() ? GameSystem.Instance : null, "Manager.GameSystem.Instance"), new KeyValuePair <object, string>(_sceneInstance, "Manager.Scene.instance"), new KeyValuePair <object, string>(_soundInstance, "Manager.Sound.instance"), new KeyValuePair <object, string>(_studioInstance, "Studio.Instance"), new KeyValuePair <object, string>((Func <object>)EditorUtilities.GetRootGoScanner, "Root Objects") }; }; CheatToolsWindow.Cheats.Add(new CheatEntry(w => _hScene != null, DrawHSceneCheats, null)); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _baseMap != null && (_hScene != null || Singleton <LobbySceneManager> .IsInstance()), DrawGirlCheatMenu, "Unable to edit character stats on this screen. Start an H scene or enter the lobby.")); CheatToolsWindow.Cheats.Add(CheatEntry.CreateOpenInInspectorButtons(() => _openInInspectorButtons)); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _studioInstance == null && _gameMgr != null && _gameMgr.saveData != null, DrawGlobalUnlocks, null)); HarmonyLib.Harmony.CreateAndPatchAll(typeof(Hooks)); }
public static void InitializeCheats() { CheatToolsWindow.OnShown = window => { _hFlag = Object.FindObjectOfType <HFlag>(); _talkScene = Object.FindObjectOfType <TalkScene>(); _hSprite = Object.FindObjectOfType <HSprite>(); _studioInstance = Studio.Studio.Instance; _soundInstance = Manager.Sound.Instance; _communicationInstance = Communication.Instance; _sceneInstance = Scene.Instance; _gameMgr = Game.Instance; _openInInspectorButtons = new[] { new KeyValuePair <object, string>(_gameMgr != null && _gameMgr.HeroineList.Count > 0 ? (Func <object>)(() => _gameMgr.HeroineList.Select(x => new ReadonlyCacheEntry(x.ChaName, x))) : null, "Heroine list"), new KeyValuePair <object, string>(_gameMgr, "Manager.Game.Instance"), new KeyValuePair <object, string>(_sceneInstance, "Manager.Scene.Instance"), new KeyValuePair <object, string>(_communicationInstance, "Manager.Communication.Instance"), new KeyValuePair <object, string>(_soundInstance, "Manager.Sound.Instance"), new KeyValuePair <object, string>(_hFlag, "HFlag"), new KeyValuePair <object, string>(_talkScene, "TalkScene"), new KeyValuePair <object, string>(_studioInstance, "Studio.Instance"), new KeyValuePair <object, string>((Func <object>)EditorUtilities.GetRootGoScanner, "Root Objects") }; }; CheatToolsWindow.Cheats.Add(new CheatEntry(w => _studioInstance == null && _gameMgr != null && !_gameMgr.saveData.isOpening, DrawPlayerCheats, "Start the game to see player cheats")); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _hFlag != null, DrawHSceneCheats, null)); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _gameMgr != null, DrawGirlCheatMenu, null)); CheatToolsWindow.Cheats.Add(CheatEntry.CreateOpenInInspectorButtons(() => _openInInspectorButtons)); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _gameMgr != null, DrawGlobalUnlocks, null)); }
// Without any error checking public static void PutBitsU(Buffer buf, uint bits, uint value) { CheatEntry ce = CheatTable[bits * 8 + buf.bitpos]; uint dpos = buf.bytepos; byte[] data = buf.buf; if (buf.bitpos != 0) { data[dpos] = (byte)(data[dpos] | ((value << ce.s0) & ce.mfirst)); } else { data[dpos] = (byte)((value << ce.s0) & ce.mfirst); } buf.bitpos = ce.bitpos; buf.bytepos = dpos + ce.byteofs; if (ce.count == 2) { data[dpos + 1] = (byte)((value >> ce.s1) & ce.mlast); } else if (ce.count == 3) { data[dpos + 1] = (byte)(value >> ce.s1); data[dpos + 2] = (byte)((value >> ce.s2) & ce.mlast); } else if (ce.count == 4) { data[dpos + 1] = (byte)(value >> ce.s1); data[dpos + 2] = (byte)(value >> ce.s2); data[dpos + 3] = (byte)((value >> ce.s3) & ce.mlast); } else if (ce.count == 5) { data[dpos + 1] = (byte)(value >> ce.s1); data[dpos + 2] = (byte)(value >> ce.s2); data[dpos + 3] = (byte)(value >> ce.s3); data[dpos + 4] = (byte)((value >> ce.s4) & ce.mlast); } }
public static UInt32 ReadBits(Buffer buf, uint bits) { if (buf.BitsLeft() < bits) { buf.error = 1; return(0); } CheatEntry ce = CheatTable[bits * 8 + buf.bitpos]; uint dpos = buf.bytepos; byte[] data = buf.buf; buf.bitpos = ce.bitpos; buf.bytepos = dpos + ce.byteofs; uint value = ((uint)data[dpos] & ce.mfirst) >> ce.s0; if (ce.count == 2) { return(value | ((uint)(data[dpos + 1] & ce.mlast) << ce.s1)); } else if (ce.count == 3) { return(value | ((uint)(data[dpos + 1]) << ce.s1) | ((uint)(data[dpos + 2] & ce.mlast) << ce.s2)); } else if (ce.count == 4) { return(value | ((uint)(data[dpos + 1]) << ce.s1) | ((uint)(data[dpos + 2]) << ce.s2) | ((uint)(data[dpos + 3] & ce.mlast) << ce.s3)); } else if (ce.count == 5) { return(value | ((uint)(data[dpos + 1]) << ce.s1) | ((uint)(data[dpos + 2]) << ce.s2) | ((uint)(data[dpos + 3]) << ce.s3) | ((uint)(data[dpos + 4] & ce.mlast) << ce.s4)); } return(value); }
public static void Initialize() { CheatToolsWindow.OnShown = window => { _studioInstance = Studio.Studio.IsInstance() ? Studio.Studio.Instance : null; _soundInstance = Manager.Sound.Instance; _sceneInstance = Scene.Instance; _gameMgr = Game.IsInstance() ? Game.Instance : null; _resources = Resources.Instance; _map = Map.IsInstance() ? Map.Instance : null; _hScene = HSceneFlagCtrl.IsInstance() ? HSceneFlagCtrl.Instance : null; _gameTimeText = null; _openInInspectorButtons = new[] { new KeyValuePair <object, string>(_map != null && _map.AgentTable.Count > 0 ? (Func <object>)(() => _map.AgentTable.Values.Select(x => new ReadonlyCacheEntry(x.CharaName, x))) : null, "Heroine list"), new KeyValuePair <object, string>(Manager.ADV.IsInstance() ? Manager.ADV.Instance : null, "Manager.ADV.Instance"), new KeyValuePair <object, string>(AnimalManager.IsInstance() ? AnimalManager.Instance : null, "Manager.AnimalManager.Instance"), new KeyValuePair <object, string>(_map, "Manager.Map.Instance"), new KeyValuePair <object, string>(Character.IsInstance() ? Character.Instance : null, "Manager.Character.Instance"), new KeyValuePair <object, string>(Config.IsInstance() ? Config.Instance : null, "Manager.Config.Instance"), new KeyValuePair <object, string>(_gameMgr, "Manager.Game.Instance"), new KeyValuePair <object, string>(Manager.Housing.IsInstance() ? Manager.Housing.Instance : null, "Manager.Housing.Instance"), new KeyValuePair <object, string>(_sceneInstance, "Manager.Scene.Instance"), new KeyValuePair <object, string>(_soundInstance, "Manager.Sound.Instance"), new KeyValuePair <object, string>(_studioInstance, "Studio.Instance"), new KeyValuePair <object, string>((Func <object>)EditorUtilities.GetRootGoScanner, "Root Objects") }; }; CheatToolsWindow.Cheats.Add(new CheatEntry(w => _map != null && _map.Player != null && _map.Player.PlayerData != null, DrawPlayerCheats, "Start the game to see player cheats")); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _map != null && _map.Simulator != null, DrawEnviroControls, null)); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _hScene != null, DrawHSceneCheats, null)); CheatToolsWindow.Cheats.Add(new CheatEntry(w => _map != null, DrawGirlCheatMenu, null)); CheatToolsWindow.Cheats.Add(CheatEntry.CreateOpenInInspectorButtons(() => _openInInspectorButtons)); }
private void ParseCheatEntry(XmlNode root) { CheatEntry Entry = new CheatEntry(); // Disable by default Entry.LastState.Activated = false; foreach (XmlNode xnode in root.ChildNodes) { switch (xnode.NodeType) { case XmlNodeType.Element: { switch (xnode.Name) { case "ID": Entry.ID = GetNumber(xnode.InnerText); break; case "Description": Entry.Description = xnode.InnerText.Trim(new char[] { '\"' }); break; case "ShowAsHex": Entry.ShowAsHex = GetBoolean(xnode.InnerText); break; case "Options": // stub // attributes: moHideChildren (bool) break; case "LastState": foreach (XmlAttribute attr in xnode.Attributes) { switch (attr.Name) { case "Value": Entry.LastState.Value = attr.Value; break; case "Activated": Entry.LastState.Activated = (GetNumber(attr.Value) != 0); break; case "RealAddress": Entry.LastState.RealAddress = GetHexNumber(attr.Value); break; } } break; case "Color": { uint color = GetHexNumber(xnode.InnerText); Entry.Color = (color & 0xFFFFFF); break; } case "GroupHeader": // stub break; case "VariableType": switch (xnode.InnerText) { case "Byte": Entry.VariableType = Variable.Byte; break; case "2 Bytes": Entry.VariableType = Variable.Bytes2; break; case "4 Bytes": Entry.VariableType = Variable.Bytes4; break; case "Float": Entry.VariableType = Variable.Float; break; case "Auto Assembler Script": Entry.VariableType = Variable.Unsupported; break; default: Entry.VariableType = Variable.Unsupported; break; } break; case "AssemblerScript": // stub, unsupported break; case "Address": Entry.Address = xnode.InnerText; break; case "Hotkeys": // stub, unsupported // Hotkey children, Action, Keys->Key children, Value, ID break; } break; } } } CTRef.CheatEntries.Add(Entry); }