Пример #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        DsgVarComponent c = (DsgVarComponent)target;

        if (c.editableEntries != null)
        {
            Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 400f);
            InitDsgVarsTreeIfNeeded(rect, c);
            if (treeviewDsgVars.target != c)
            {
                treeviewDsgVars.target = c;
                treeviewDsgVars.treeModel.SetData(GetData());
                treeviewDsgVars.Reload();
            }
            treeviewDsgVars.OnGUI(rect);
        }
        //GUILayout.BeginVertical();

        /*GUILayout.BeginHorizontal();
         *
         * GUILayout.Label("Type/name");
         * GUILayout.Label("Current value");
         * GUILayout.Label("Initial value");
         *
         * GUILayout.EndHorizontal();
         *
         * foreach (DsgVarComponent.DsgVarEditableEntry entry in c.editableEntries) {
         *
         *  GUILayout.BeginHorizontal();
         *
         *  DrawDsgVarEntry(entry);
         *
         *  GUILayout.EndHorizontal();
         * }*/


        /*if (GUILayout.Button("Print initial dsgvar assignments")) {
         *
         *  string printResult = "";
         *
         *  foreach (DsgVarComponent.DsgVarEditableEntry dsgVarEntry in c.editableEntries) {
         *
         *      printResult += DsgVarUtil.DsgVarEntryToCSharpAssignment(dsgVarEntry.entry) + Environment.NewLine;
         *  }
         *
         *  MapLoader.Loader.print(printResult);
         * }*/

        if (GUILayout.Button("Print dsgvar value offsets"))
        {
            string printResult = "";

            DsgMem dsgMem = c.dsgMem;
            foreach (DsgVarComponent.DsgVarEditableEntry dsgVarEntry in c.editableEntries)
            {
                Pointer offsetOfValue = (dsgMem.memBuffer + dsgVarEntry.entry.offsetInBuffer);
                printResult += dsgVarEntry.entry.NiceVariableName + " " + offsetOfValue + Environment.NewLine;
            }

            MapLoader.Loader.print(printResult);
        }

        //GUILayout.EndVertical();
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        DsgVarComponent c = (DsgVarComponent)target;

        if (c.editableEntries != null)
        {
            Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 400f);
            InitDsgVarsTreeIfNeeded(rect, c);
            if (treeviewDsgVars.target != c)
            {
                treeviewDsgVars.target = c;
                treeviewDsgVars.treeModel.SetData(GetData());
                treeviewDsgVars.Reload();
            }
            treeviewDsgVars.OnGUI(rect);
        }
        //GUILayout.BeginVertical();

        /*GUILayout.BeginHorizontal();
         *
         * GUILayout.Label("Type/name");
         * GUILayout.Label("Current value");
         * GUILayout.Label("Initial value");
         *
         * GUILayout.EndHorizontal();
         *
         * foreach (DsgVarComponent.DsgVarEditableEntry entry in c.editableEntries) {
         *
         *  GUILayout.BeginHorizontal();
         *
         *  DrawDsgVarEntry(entry);
         *
         *  GUILayout.EndHorizontal();
         * }*/


        /*if (GUILayout.Button("Print initial dsgvar assignments")) {
         *
         *  string printResult = "";
         *
         *  foreach (DsgVarComponent.DsgVarEditableEntry dsgVarEntry in c.editableEntries) {
         *
         *      printResult += DsgVarUtil.DsgVarEntryToCSharpAssignment(dsgVarEntry.entry) + Environment.NewLine;
         *  }
         *
         *  MapLoader.Loader.print(printResult);
         * }*/

        if (GUILayout.Button("Print dsgvar value offsets"))
        {
            string printResult = "";

            DsgMem dsgMem = c.dsgMem;
            foreach (DsgVarComponent.DsgVarEditableEntry dsgVarEntry in c.editableEntries)
            {
                Pointer offsetOfValue = (dsgMem.memBuffer + dsgVarEntry.entry.offsetInBuffer);
                printResult += dsgVarEntry.entry.NiceVariableName + " " + offsetOfValue + Environment.NewLine;
            }

            MapLoader.Loader.print(printResult);
        }

        if (GUILayout.Button("Copy DsgVars as CheatEngine table"))
        {
            string printResult = "";

            DsgMem dsgMem = c.dsgMem;
            foreach (DsgVarComponent.DsgVarEditableEntry dsgVarEntry in c.editableEntries)
            {
                Pointer offsetOfValue = (dsgMem.memBuffer + dsgVarEntry.entry.offsetInBuffer);

                string variableType;
                switch (dsgVarEntry.Type)
                {
                case DsgVarType.Float: variableType = "Float"; break;

                case DsgVarType.Byte: variableType = "Byte"; break;

                case DsgVarType.UByte: variableType = "Byte"; break;

                case DsgVarType.Short: variableType = "2 Bytes"; break;

                case DsgVarType.UShort: variableType = "2 Bytes"; break;

                case DsgVarType.Vector: variableType = "Float"; break;

                case DsgVarType.Boolean: variableType = "Byte"; break;

                default: variableType = "4 Bytes"; break;
                }

                for (int i = 0; i <= ((dsgVarEntry.Type == DsgVarType.Vector) ? 8 : 0); i += 4)
                {
                    printResult += "<CheatEntry>" +
                                   $"<ID>0</ID>" +
                                   $"<Description>\"{dsgVarEntry.entry.NiceVariableName}\"</Description>" +
                                   $"<LastState Value=\"\" RealAddress=\"{(offsetOfValue+i).offset.ToString("X8")}\"/>" +
                                   $"<VariableType>{variableType}</VariableType>" +
                                   $"<Address>{(offsetOfValue + i).offset.ToString("X8")}</Address>" +
                                   "</CheatEntry>";
                }
            }

            printResult      = $"<?xml version=\"1.0\" encoding=\"utf-8\"?><CheatTable><CheatEntries>{printResult}</CheatEntries></CheatTable>";
            cheatTableString = printResult;

            EditorGUIUtility.systemCopyBuffer = cheatTableString;
        }

        //GUILayout.EndVertical();
    }