mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #796 from Soreepeong/test1
This commit is contained in:
commit
ae2765dabb
3 changed files with 117 additions and 19 deletions
|
|
@ -189,6 +189,50 @@ namespace Dalamud.Injector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Process GetProcessFromExecuting(string gamePath)
|
||||||
|
{
|
||||||
|
var gameVersion = File.ReadAllText(Path.Combine(Directory.GetParent(gamePath).FullName, "ffxivgame.ver"));
|
||||||
|
var sqpackPath = Path.Combine(Directory.GetParent(gamePath).FullName, "sqpack");
|
||||||
|
var maxEntitledExpansionId = 0;
|
||||||
|
while (File.Exists(Path.Combine(sqpackPath, $"ex{maxEntitledExpansionId + 1}", $"ex{maxEntitledExpansionId + 1}.ver")))
|
||||||
|
maxEntitledExpansionId++;
|
||||||
|
|
||||||
|
var process = Process.Start(gamePath, new string[]
|
||||||
|
{
|
||||||
|
"DEV.TestSID=0",
|
||||||
|
"DEV.UseSqPack=1",
|
||||||
|
"DEV.DataPathType=1",
|
||||||
|
"DEV.LobbyHost01=127.0.0.1",
|
||||||
|
"DEV.LobbyPort01=54994",
|
||||||
|
"DEV.LobbyHost02=127.0.0.2",
|
||||||
|
"DEV.LobbyPort02=54994",
|
||||||
|
"DEV.LobbyHost03=127.0.0.3",
|
||||||
|
"DEV.LobbyPort03=54994",
|
||||||
|
"DEV.LobbyHost04=127.0.0.4",
|
||||||
|
"DEV.LobbyPort04=54994",
|
||||||
|
"DEV.LobbyHost05=127.0.0.5",
|
||||||
|
"DEV.LobbyPort05=54994",
|
||||||
|
"DEV.LobbyHost06=127.0.0.6",
|
||||||
|
"DEV.LobbyPort06=54994",
|
||||||
|
"DEV.LobbyHost07=127.0.0.7",
|
||||||
|
"DEV.LobbyPort07=54994",
|
||||||
|
"DEV.LobbyHost08=127.0.0.8",
|
||||||
|
"DEV.LobbyPort08=54994",
|
||||||
|
"DEV.LobbyHost09=127.0.0.9",
|
||||||
|
"DEV.LobbyPort09=54994",
|
||||||
|
"SYS.Region=0",
|
||||||
|
"language=1",
|
||||||
|
$"ver={gameVersion}",
|
||||||
|
$"DEV.MaxEntitledExpansionID={maxEntitledExpansionId}",
|
||||||
|
"DEV.GMServerHost=127.0.0.100",
|
||||||
|
"DEV.GameQuitMessageBox=0",
|
||||||
|
});
|
||||||
|
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
|
||||||
private static Process? GetProcess(string? arg)
|
private static Process? GetProcess(string? arg)
|
||||||
{
|
{
|
||||||
Process process = null;
|
Process process = null;
|
||||||
|
|
@ -196,7 +240,15 @@ namespace Dalamud.Injector
|
||||||
var pid = -1;
|
var pid = -1;
|
||||||
if (arg != default)
|
if (arg != default)
|
||||||
{
|
{
|
||||||
pid = int.Parse(arg);
|
try
|
||||||
|
{
|
||||||
|
pid = int.Parse(arg);
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
if (File.Exists(arg))
|
||||||
|
return GetProcessFromExecuting(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pid)
|
switch (pid)
|
||||||
|
|
@ -223,22 +275,8 @@ namespace Dalamud.Injector
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -2:
|
case -2:
|
||||||
var exePath = "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\ffxiv_dx11.exe";
|
return GetProcessFromExecuting("C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\ffxiv_dx11.exe");
|
||||||
var exeArgs = new StringBuilder()
|
|
||||||
.Append("DEV.TestSID=0 DEV.UseSqPack=1 DEV.DataPathType=1 ")
|
|
||||||
.Append("DEV.LobbyHost01=127.0.0.1 DEV.LobbyPort01=54994 ")
|
|
||||||
.Append("DEV.LobbyHost02=127.0.0.1 DEV.LobbyPort02=54994 ")
|
|
||||||
.Append("DEV.LobbyHost03=127.0.0.1 DEV.LobbyPort03=54994 ")
|
|
||||||
.Append("DEV.LobbyHost04=127.0.0.1 DEV.LobbyPort04=54994 ")
|
|
||||||
.Append("DEV.LobbyHost05=127.0.0.1 DEV.LobbyPort05=54994 ")
|
|
||||||
.Append("DEV.LobbyHost06=127.0.0.1 DEV.LobbyPort06=54994 ")
|
|
||||||
.Append("DEV.LobbyHost07=127.0.0.1 DEV.LobbyPort07=54994 ")
|
|
||||||
.Append("DEV.LobbyHost08=127.0.0.1 DEV.LobbyPort08=54994 ")
|
|
||||||
.Append("SYS.Region=0 language=1 version=1.0.0.0 ")
|
|
||||||
.Append("DEV.MaxEntitledExpansionID=2 DEV.GMServerHost=127.0.0.1 DEV.GameQuitMessageBox=0").ToString();
|
|
||||||
process = Process.Start(exePath, exeArgs);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,8 @@ namespace Dalamud.Interface.GameFonts
|
||||||
font->FontSize /= fontScale;
|
font->FontSize /= fontScale;
|
||||||
font->Ascent /= fontScale;
|
font->Ascent /= fontScale;
|
||||||
font->Descent /= fontScale;
|
font->Descent /= fontScale;
|
||||||
|
for (int i = 0, i_ = font->ConfigDataCount; i < i_; i++)
|
||||||
|
font->ConfigData[i].SizePixels /= fontScale;
|
||||||
var glyphs = (ImFontGlyphReal*)font->Glyphs.Data;
|
var glyphs = (ImFontGlyphReal*)font->Glyphs.Data;
|
||||||
for (int i = 0, i_ = font->Glyphs.Size; i < i_; i++)
|
for (int i = 0, i_ = font->Glyphs.Size; i < i_; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -596,6 +596,29 @@ namespace Dalamud.Interface.Internal
|
||||||
|
|
||||||
private unsafe class TargetFontModification : IDisposable
|
private unsafe class TargetFontModification : IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="TargetFontModification"/> class.
|
||||||
|
/// Constructs new target font modification information, assuming that AXIS fonts will not be applied.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of the font to write to ImGui font information.</param>
|
||||||
|
/// <param name="sizePx">Target font size in pixels, which will not be considered for further scaling.</param>
|
||||||
|
internal TargetFontModification(string name, float sizePx)
|
||||||
|
{
|
||||||
|
this.Name = name;
|
||||||
|
this.Axis = AxisMode.Suppress;
|
||||||
|
this.TargetSizePx = sizePx;
|
||||||
|
this.Scale = 1;
|
||||||
|
this.SourceAxis = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="TargetFontModification"/> class.
|
||||||
|
/// Constructs new target font modification information.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of the font to write to ImGui font information.</param>
|
||||||
|
/// <param name="axis">Whether and how to use AXIS fonts.</param>
|
||||||
|
/// <param name="sizePx">Target font size in pixels, which will not be considered for further scaling.</param>
|
||||||
|
/// <param name="scale">Font scale to be referred for loading AXIS font of appropriate size.</param>
|
||||||
internal TargetFontModification(string name, AxisMode axis, float sizePx, float scale)
|
internal TargetFontModification(string name, AxisMode axis, float sizePx, float scale)
|
||||||
{
|
{
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
|
|
@ -630,6 +653,10 @@ namespace Dalamud.Interface.Internal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads font for use in ImGui text functions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scaler">If non-zero, then glyphs will be loaded in smaller resolution to make all glyphs fit into given constraints.</param>
|
||||||
private unsafe void SetupFonts(int scaler = 0)
|
private unsafe void SetupFonts(int scaler = 0)
|
||||||
{
|
{
|
||||||
var gameFontManager = Service<GameFontManager>.Get();
|
var gameFontManager = Service<GameFontManager>.Get();
|
||||||
|
|
@ -817,8 +844,39 @@ namespace Dalamud.Interface.Internal
|
||||||
config.OversampleV = 1;
|
config.OversampleV = 1;
|
||||||
|
|
||||||
var name = Encoding.UTF8.GetString((byte*)config.Name.Data, config.Name.Count).TrimEnd('\0');
|
var name = Encoding.UTF8.GetString((byte*)config.Name.Data, config.Name.Count).TrimEnd('\0');
|
||||||
this.loadedFontInfo[config.DstFont.NativePtr] = new($"PluginRequest({name})", TargetFontModification.AxisMode.Suppress, config.SizePixels, 1);
|
|
||||||
config.SizePixels = (disableBigFonts ? DefaultFontSizePx : config.SizePixels) * fontLoadScale;
|
// ImFont information is reflected only if corresponding ImFontConfig has MergeMode not set.
|
||||||
|
if (config.MergeMode)
|
||||||
|
{
|
||||||
|
if (!this.loadedFontInfo.ContainsKey(config.DstFont.NativePtr))
|
||||||
|
{
|
||||||
|
Log.Warning("MergeMode specified for {0} but not found in loadedFontInfo. Skipping.", name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.loadedFontInfo.ContainsKey(config.DstFont.NativePtr))
|
||||||
|
{
|
||||||
|
Log.Warning("MergeMode not specified for {0} but found in loadedFontInfo. Skipping.", name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// While the font will be loaded in the scaled size after FontScale is applied, the font will be treated as having the requested size when used from plugins.
|
||||||
|
this.loadedFontInfo[config.DstFont.NativePtr] = new($"PlReq({name})", config.SizePixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disableBigFonts)
|
||||||
|
{
|
||||||
|
// If a plugin has requested a font size that is bigger than current restrictions, load it scaled down.
|
||||||
|
// After loading glyphs onto font atlas, font information will be modified to make it look like the font of original size has been loaded.
|
||||||
|
if (config.SizePixels > DefaultFontSizePx * fontLoadScale)
|
||||||
|
config.SizePixels = DefaultFontSizePx * fontLoadScale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.SizePixels = config.SizePixels * fontLoadScale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ioFonts.Build();
|
ioFonts.Build();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue