mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 22:37:43 +01:00
feat(DalamudSystemMenu): localize, switch around options (closes #336)
This commit is contained in:
parent
0448c9e36a
commit
a5aa9cd849
2 changed files with 20 additions and 9 deletions
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CheapLoc;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
||||||
|
|
@ -113,16 +113,19 @@ namespace Dalamud.Game.Addon
|
||||||
var secondStringEntry = &atkValueArgs[6 + 15];
|
var secondStringEntry = &atkValueArgs[6 + 15];
|
||||||
atkValueChangeType(secondStringEntry, ValueType.String);
|
atkValueChangeType(secondStringEntry, ValueType.String);
|
||||||
|
|
||||||
|
var strPlugins = Encoding.UTF8.GetBytes(Loc.Localize("SystemMenuPlugins", "Dalamud Plugins"));
|
||||||
|
var strSettings = Encoding.UTF8.GetBytes(Loc.Localize("SystemMenuSettings", "Dalamud Settings"));
|
||||||
|
|
||||||
// do this the most terrible way possible since im lazy
|
// do this the most terrible way possible since im lazy
|
||||||
var bytes = stackalloc byte[17];
|
var bytes = stackalloc byte[strPlugins.Length + 1];
|
||||||
Marshal.Copy(System.Text.Encoding.ASCII.GetBytes("Dalamud Settings"), 0, new IntPtr(bytes), 16);
|
Marshal.Copy(strPlugins, 0, new IntPtr(bytes), strPlugins.Length);
|
||||||
bytes[16] = 0x0;
|
bytes[strPlugins.Length] = 0x0;
|
||||||
|
|
||||||
atkValueSetString(firstStringEntry, bytes); // this allocs the string properly using the game's allocators and copies it, so we dont have to worry about memory fuckups
|
atkValueSetString(firstStringEntry, bytes); // this allocs the string properly using the game's allocators and copies it, so we dont have to worry about memory fuckups
|
||||||
|
|
||||||
var bytes2 = stackalloc byte[16];
|
var bytes2 = stackalloc byte[strSettings.Length + 1];
|
||||||
Marshal.Copy(System.Text.Encoding.ASCII.GetBytes("Dalamud Plugins"), 0, new IntPtr(bytes2), 15);
|
Marshal.Copy(strSettings, 0, new IntPtr(bytes2), strSettings.Length);
|
||||||
bytes2[15] = 0x0;
|
bytes2[strSettings.Length] = 0x0;
|
||||||
|
|
||||||
atkValueSetString(secondStringEntry, bytes2);
|
atkValueSetString(secondStringEntry, bytes2);
|
||||||
|
|
||||||
|
|
@ -137,11 +140,11 @@ namespace Dalamud.Game.Addon
|
||||||
{
|
{
|
||||||
if (commandId == 69420)
|
if (commandId == 69420)
|
||||||
{
|
{
|
||||||
this.dalamud.DalamudUi.OpenSettings();
|
this.dalamud.DalamudUi.OpenPluginInstaller();
|
||||||
}
|
}
|
||||||
else if (commandId == 69421)
|
else if (commandId == 69421)
|
||||||
{
|
{
|
||||||
this.dalamud.DalamudUi.OpenPluginInstaller();
|
this.dalamud.DalamudUi.OpenSettings();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.Internal.Libc {
|
namespace Dalamud.Game.Internal.Libc {
|
||||||
|
|
@ -39,6 +40,13 @@ namespace Dalamud.Game.Internal.Libc {
|
||||||
return new OwnedStdString(pReallocString, DeallocateStdString);
|
return new OwnedStdString(pReallocString, DeallocateStdString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OwnedStdString NewString(string content, Encoding encoding = null)
|
||||||
|
{
|
||||||
|
encoding ??= Encoding.UTF8;
|
||||||
|
|
||||||
|
return this.NewString(encoding.GetBytes(content));
|
||||||
|
}
|
||||||
|
|
||||||
private void DeallocateStdString(IntPtr address) {
|
private void DeallocateStdString(IntPtr address) {
|
||||||
this.stdStringDeallocate(address);
|
this.stdStringDeallocate(address);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue