mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Use an ingame developer console
This commit is contained in:
1 parent
5be1da2fec
commit
8370eb0967
9 files changed
+237
-25
No files matched your search
@@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Screencap", "Plugins\Screen
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceRedirector", "Plugins\ResourceRedirector\ResourceRedirector.csproj", "{3EA76CA3-45B6-4A1A-B04F-7A1A8C978AF6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeveloperConsole", "Plugins\DeveloperConsole\DeveloperConsole.csproj", "{434F00D0-BD2A-4C81-A2FE-8DBFBBD9D9AB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
BepInEx.Common\BepInEx.Common.projitems*{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}*SharedItemsImports = 4
|
||||
@@ -72,6 +74,10 @@ Global
|
||||
{3EA76CA3-45B6-4A1A-B04F-7A1A8C978AF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3EA76CA3-45B6-4A1A-B04F-7A1A8C978AF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3EA76CA3-45B6-4A1A-B04F-7A1A8C978AF6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{434F00D0-BD2A-4C81-A2FE-8DBFBBD9D9AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{434F00D0-BD2A-4C81-A2FE-8DBFBBD9D9AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{434F00D0-BD2A-4C81-A2FE-8DBFBBD9D9AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{434F00D0-BD2A-4C81-A2FE-8DBFBBD9D9AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -84,6 +90,7 @@ Global
|
||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{6A9D08C0-4482-4D1A-9368-9F41B7126F9E} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{3EA76CA3-45B6-4A1A-B04F-7A1A8C978AF6} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{434F00D0-BD2A-4C81-A2FE-8DBFBBD9D9AB} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {55AC11EF-F568-4C79-A356-7ED9510145B1}
|
||||
|
||||
+32
-19
@@ -17,37 +17,50 @@ namespace BepInEx
|
||||
public static List<BaseUnityPlugin> Plugins { get; protected set; } = new List<BaseUnityPlugin>();
|
||||
public static GameObject ManagerObject { get; protected set; } = new GameObject("BepInEx_Manager");
|
||||
|
||||
|
||||
|
||||
public delegate void EntryLoggedEventHandler(string entry, bool show = false);
|
||||
|
||||
public static event EntryLoggedEventHandler EntryLogged;
|
||||
|
||||
|
||||
public static void Log(string entry, bool show = false)
|
||||
{
|
||||
EntryLogged?.Invoke(entry, show);
|
||||
}
|
||||
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (loaded)
|
||||
return;
|
||||
|
||||
UnityInjector.ConsoleUtil.ConsoleWindow.Attach();
|
||||
Console.WriteLine("Chainloader started");
|
||||
|
||||
UnityEngine.Object.DontDestroyOnLoad(ManagerObject);
|
||||
|
||||
|
||||
if (Directory.Exists(Utility.PluginsDirectory))
|
||||
try
|
||||
{
|
||||
var pluginTypes = LoadTypes<BaseUnityPlugin>(Utility.PluginsDirectory);
|
||||
UnityEngine.Object.DontDestroyOnLoad(ManagerObject);
|
||||
|
||||
//UnityInjector.ConsoleUtil.ConsoleEncoding.ConsoleCodePage = 932;
|
||||
Console.WriteLine($"{pluginTypes.Count()} plugins found");
|
||||
|
||||
|
||||
foreach (Type t in pluginTypes)
|
||||
if (Directory.Exists(Utility.PluginsDirectory))
|
||||
{
|
||||
var plugin = (BaseUnityPlugin)ManagerObject.AddComponent(t);
|
||||
Plugins.Add(plugin);
|
||||
Console.WriteLine($"Loaded [{plugin.Name}]");
|
||||
var pluginTypes = LoadTypes<BaseUnityPlugin>(Utility.PluginsDirectory);
|
||||
|
||||
//Log($"{pluginTypes.Count()} plugins found");
|
||||
|
||||
foreach (Type t in pluginTypes)
|
||||
{
|
||||
var plugin = (BaseUnityPlugin)ManagerObject.AddComponent(t);
|
||||
Plugins.Add(plugin);
|
||||
//Log($"Loaded [{plugin.Name}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Plugins directory not found, skipping");
|
||||
}
|
||||
UnityInjector.ConsoleUtil.ConsoleWindow.Attach();
|
||||
//UnityInjector.ConsoleUtil.ConsoleEncoding.ConsoleCodePage = 932;
|
||||
|
||||
Console.WriteLine("Error occurred starting the game");
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ColorCorrector
|
||||
void OnGUI()
|
||||
{
|
||||
if (showingUI)
|
||||
UI = GUI.Window(0, UI, WindowFunction, "Filter settings");
|
||||
UI = GUI.Window(Name.GetHashCode() + 0, UI, WindowFunction, "Filter settings");
|
||||
}
|
||||
|
||||
void WindowFunction(int windowID)
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
using BepInEx;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DeveloperConsole
|
||||
{
|
||||
public class DeveloperConsole : BaseUnityPlugin
|
||||
{
|
||||
public override string Name => "Developer Console";
|
||||
|
||||
private Rect UI = new Rect(20, 20, 400, 200);
|
||||
bool showingUI = false;
|
||||
string TotalLog = "";
|
||||
|
||||
int showCounter = 0;
|
||||
string TotalShowingLog = "";
|
||||
|
||||
public DeveloperConsole()
|
||||
{
|
||||
Chainloader.EntryLogged += (log, show) =>
|
||||
{
|
||||
string current = $"{TotalLog}\r\n{log}";
|
||||
if (current.Length > 400)
|
||||
{
|
||||
current = current.Remove(0, 200);
|
||||
}
|
||||
TotalLog = current;
|
||||
|
||||
if (show)
|
||||
{
|
||||
if (showCounter == 0)
|
||||
TotalShowingLog = "";
|
||||
|
||||
showCounter = 400;
|
||||
TotalShowingLog = $"{TotalShowingLog}\r\n{log}";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F12))
|
||||
{
|
||||
showingUI = !showingUI;
|
||||
}
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
ShowLog();
|
||||
|
||||
if (showingUI)
|
||||
UI = GUI.Window(Name.GetHashCode() + 0, UI, WindowFunction, "Developer Console");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShowLog()
|
||||
{
|
||||
if (showCounter != 0)
|
||||
{
|
||||
showCounter--;
|
||||
|
||||
GUI.Label(new Rect(40, 0, 600, 160), TotalShowingLog, new GUIStyle
|
||||
{
|
||||
alignment = TextAnchor.UpperLeft,
|
||||
fontSize = 26,
|
||||
normal = new GUIStyleState
|
||||
{
|
||||
textColor = Color.white
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void WindowFunction(int windowID)
|
||||
{
|
||||
GUI.Label(new Rect(10, 40, 380, 160), TotalLog, new GUIStyle
|
||||
{
|
||||
alignment = TextAnchor.LowerLeft,
|
||||
wordWrap = true,
|
||||
normal = new GUIStyleState
|
||||
{
|
||||
textColor = Color.white
|
||||
}
|
||||
});
|
||||
|
||||
GUI.DragWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{434F00D0-BD2A-4C81-A2FE-8DBFBBD9D9AB}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DeveloperConsole</RootNamespace>
|
||||
<AssemblyName>DeveloperConsole</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>K:\BepInEx\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>K:\BepInEx\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\lib\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\..\lib\UnityEngine.UI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DeveloperConsole.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
|
||||
<Project>{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}</Project>
|
||||
<Name>BepInEx</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DeveloperConsole")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DeveloperConsole")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("434f00d0-bd2a-4c81-a2fe-8dbfbbd9d9ab")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -63,7 +63,7 @@ namespace DynamicTranslationLoader
|
||||
if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F10))
|
||||
{
|
||||
Dump();
|
||||
Console.WriteLine($"Text dumped to \"{Path.GetFullPath("dumped-tl.txt")}\"");
|
||||
Chainloader.Log($"Text dumped to \"{Path.GetFullPath("dumped-tl.txt")}\"", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace ResourceRedirector
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
|
||||
Console.WriteLine($"Loading {path}");
|
||||
|
||||
Chainloader.Log($"Loading {path}");
|
||||
|
||||
path = $"file://{path.Replace('\\', '/')}";
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Screencap
|
||||
{
|
||||
UnityEngine.Application.CaptureScreenshot(filename);
|
||||
Illusion.Game.Utils.Sound.Play(SystemSE.photo);
|
||||
Console.WriteLine($"Screenshot saved to {filename}");
|
||||
Chainloader.Log($"Screenshot saved to {filename}", true);
|
||||
}
|
||||
|
||||
void TakeCharScreenshot(string filename)
|
||||
@@ -54,7 +54,7 @@ namespace Screencap
|
||||
File.WriteAllBytes(filename, tex.EncodeToPNG());
|
||||
Destroy(tex);
|
||||
Illusion.Game.Utils.Sound.Play(SystemSE.photo);
|
||||
Console.WriteLine($"Character screenshot saved to {filename}");
|
||||
Chainloader.Log($"Character screenshot saved to {filename}", true);
|
||||
}
|
||||
|
||||
Texture2D RenderCamera(Camera cam)
|
||||
|
||||
Reference in new issue
Block a user