feat: add alpha config and handle invalid data
This commit is contained in:
parent
ee404dea95
commit
5af40e83d4
@ -19,6 +19,7 @@ public class Configuration : IPluginConfiguration {
|
|||||||
public bool ClickThroughViewer;
|
public bool ClickThroughViewer;
|
||||||
public bool HideTitlebar;
|
public bool HideTitlebar;
|
||||||
public bool ShowEmotes = true;
|
public bool ShowEmotes = true;
|
||||||
|
public float EmoteAlpha = 25.0f;
|
||||||
public float ViewerOpacity = 100.0f;
|
public float ViewerOpacity = 100.0f;
|
||||||
public int DefaultGlyph = 3;
|
public int DefaultGlyph = 3;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ internal class Settings : ITab {
|
|||||||
anyChanged |= vfx |= ImGui.Checkbox("Disable in cutscenes", ref this.Plugin.Config.DisableInCutscene);
|
anyChanged |= vfx |= ImGui.Checkbox("Disable in cutscenes", ref this.Plugin.Config.DisableInCutscene);
|
||||||
anyChanged |= vfx |= ImGui.Checkbox("Disable in /gpose", ref this.Plugin.Config.DisableInGpose);
|
anyChanged |= vfx |= ImGui.Checkbox("Disable in /gpose", ref this.Plugin.Config.DisableInGpose);
|
||||||
anyChanged |= vfx |= ImGui.Checkbox("Remove glow effect from signs", ref this.Plugin.Config.RemoveGlow);
|
anyChanged |= vfx |= ImGui.Checkbox("Remove glow effect from signs", ref this.Plugin.Config.RemoveGlow);
|
||||||
anyChanged |= ImGui.Checkbox("Show player emotes", ref this.Plugin.Config.ShowEmotes);
|
|
||||||
|
|
||||||
var tt = this.Plugin.DataManager.GetExcelSheet<TerritoryType>();
|
var tt = this.Plugin.DataManager.GetExcelSheet<TerritoryType>();
|
||||||
if (tt == null) {
|
if (tt == null) {
|
||||||
@ -221,6 +220,9 @@ internal class Settings : ITab {
|
|||||||
|
|
||||||
anyChanged |= ImGui.Checkbox("Lock viewer in place", ref this.Plugin.Config.LockViewer);
|
anyChanged |= ImGui.Checkbox("Lock viewer in place", ref this.Plugin.Config.LockViewer);
|
||||||
anyChanged |= ImGui.Checkbox("Click through viewer", ref this.Plugin.Config.ClickThroughViewer);
|
anyChanged |= ImGui.Checkbox("Click through viewer", ref this.Plugin.Config.ClickThroughViewer);
|
||||||
|
|
||||||
|
anyChanged |= ImGui.Checkbox("Show player emotes", ref this.Plugin.Config.ShowEmotes);
|
||||||
|
anyChanged |= ImGui.SliderFloat("Player emote opacity", ref this.Plugin.Config.EmoteAlpha, 0f, 100f, "%.2f%%");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawUnlocks(ref bool anyChanged, ref bool vfx) {
|
private void DrawUnlocks(ref bool anyChanged, ref bool vfx) {
|
||||||
|
@ -171,6 +171,7 @@ internal class Write : ITab {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.SetNextWindowSizeConstraints(new Vector2(100 * ImGuiHelpers.GlobalScale, 0), new Vector2(float.MaxValue));
|
||||||
var preview = x == (-1, -1) ? "" : template.Words[x.Item2];
|
var preview = x == (-1, -1) ? "" : template.Words[x.Item2];
|
||||||
if (!ImGui.BeginCombo(id, preview)) {
|
if (!ImGui.BeginCombo(id, preview)) {
|
||||||
return;
|
return;
|
||||||
@ -207,6 +208,7 @@ internal class Write : ITab {
|
|||||||
|
|
||||||
for (var listIdx = 0; listIdx < words.Count; listIdx++) {
|
for (var listIdx = 0; listIdx < words.Count; listIdx++) {
|
||||||
var list = words[listIdx];
|
var list = words[listIdx];
|
||||||
|
ImGui.SetNextWindowSizeConstraints(new Vector2(100 * ImGuiHelpers.GlobalScale, 0), new Vector2(float.MaxValue));
|
||||||
if (!ImGui.BeginMenu(list.Name)) {
|
if (!ImGui.BeginMenu(list.Name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,13 @@ internal class ActorManager : IDisposable {
|
|||||||
internal ActorManager(Plugin plugin) {
|
internal ActorManager(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
this.Plugin.Framework.Update += this.OnFramework;
|
this.Plugin.Framework.Update += this.OnFramework;
|
||||||
|
this.Plugin.ClientState.TerritoryChanged += this.OnTerritoryChange;
|
||||||
this.Plugin.Ui.Viewer.View += this.OnView;
|
this.Plugin.Ui.Viewer.View += this.OnView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.Plugin.Ui.Viewer.View -= this.OnView;
|
this.Plugin.Ui.Viewer.View -= this.OnView;
|
||||||
|
this.Plugin.ClientState.TerritoryChanged -= this.OnTerritoryChange;
|
||||||
this.Plugin.Framework.Update -= this.OnFramework;
|
this.Plugin.Framework.Update -= this.OnFramework;
|
||||||
|
|
||||||
if (this._idx != null) {
|
if (this._idx != null) {
|
||||||
@ -54,6 +56,10 @@ internal class ActorManager : IDisposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnTerritoryChange(ushort obj) {
|
||||||
|
this._idx = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnView(Message? message) {
|
private void OnView(Message? message) {
|
||||||
var msg = message == null ? "null" : "not null";
|
var msg = message == null ? "null" : "not null";
|
||||||
Plugin.Log.Debug($"OnView message is {msg}");
|
Plugin.Log.Debug($"OnView message is {msg}");
|
||||||
@ -145,6 +151,12 @@ internal class ActorManager : IDisposable {
|
|||||||
rawCustomise[i] = emote.Customise[i];
|
rawCustomise[i] = emote.Customise[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if data is valid to prevent crashes
|
||||||
|
if (!(&drawData->CustomizeData)->NormalizeCustomizeData(&drawData->CustomizeData)) {
|
||||||
|
drawData->CustomizeData = new CustomizeData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// weapon and equipment values don't cause crashes, just transparent body parts
|
||||||
for (var i = 0; i < Math.Min(drawData->EquipmentModelIds.Length, emote.Equipment.Length); i++) {
|
for (var i = 0; i < Math.Min(drawData->EquipmentModelIds.Length, emote.Equipment.Length); i++) {
|
||||||
var equip = emote.Equipment[i];
|
var equip = emote.Equipment[i];
|
||||||
drawData->Equipment((DrawDataContainer.EquipmentSlot) i) = new EquipmentModelId {
|
drawData->Equipment((DrawDataContainer.EquipmentSlot) i) = new EquipmentModelId {
|
||||||
@ -177,7 +189,7 @@ internal class ActorManager : IDisposable {
|
|||||||
|
|
||||||
drawData->SetGlasses(0, (ushort) emote.Glasses);
|
drawData->SetGlasses(0, (ushort) emote.Glasses);
|
||||||
|
|
||||||
chara->Alpha = 0.25f;
|
chara->Alpha = Math.Clamp(manager.Plugin.Config.EmoteAlpha / 100, 0, 1);
|
||||||
chara->SetMode(CharacterModes.AnimLock, 0);
|
chara->SetMode(CharacterModes.AnimLock, 0);
|
||||||
if (emoteRow != null) {
|
if (emoteRow != null) {
|
||||||
chara->Timeline.BaseOverride = (ushort) emoteRow.ActionTimeline[0].Row;
|
chara->Timeline.BaseOverride = (ushort) emoteRow.ActionTimeline[0].Row;
|
||||||
@ -235,7 +247,6 @@ internal class ActorManager : IDisposable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
objMan->DeleteObjectByIndex((ushort) idx, 0);
|
|
||||||
manager._idx = null;
|
manager._idx = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user