Skip to content

Commit

Permalink
update and ui fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codelastnight committed Jan 21, 2024
1 parent b480ba1 commit 5525dca
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 76 deletions.
Binary file modified Data/credits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions OofPlugin/DalamudPackager.targets

This file was deleted.

36 changes: 32 additions & 4 deletions OofPlugin/OofPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Party;
using Dalamud.Game.Command;
using Dalamud.Interface.Utility.Table;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Ipc.Exceptions;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using NAudio.Wave;
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Threading;
using static Lumina.Data.Parsing.Layer.LayerCommon;
using Task = System.Threading.Tasks.Task;

//shoutout anna clemens
Expand Down Expand Up @@ -43,7 +47,6 @@ public sealed class OofPlugin : IDalamudPlugin
// i love global variables!!!! the more global the more globaly it gets
// sound
public bool isSoundPlaying { get; set; } = false;
// private WaveStream? reader;
private DirectSoundOut? soundOut;
private string? soundFile { get; set; }

Expand Down Expand Up @@ -305,10 +308,11 @@ private async Task OofAudioPolling(CancellationToken token)
{
if (player.DidPlayOof) continue;
float volume = 1f;
if (Configuration.DistanceBasedOof && player.Distance != Vector3.Zero && player.Distance != ClientState!.LocalPlayer!.Position)
if (Configuration.DistanceBasedOof && player.Distance != ClientState!.LocalPlayer!.Position)
{
var dist = Vector3.Distance(ClientState!.LocalPlayer!.Position, player.Distance);
volume = Math.Max(Configuration.DistanceMinVolume, 1f / (dist * Configuration.DistanceFalloff));
var dist = 0f;
if (player.Distance != Vector3.Zero) dist = Vector3.Distance(ClientState!.LocalPlayer!.Position, player.Distance);
volume = CalcVolumeFromDist(dist);
}
PlaySound(token, volume);
player.DidPlayOof = true;
Expand All @@ -317,6 +321,30 @@ private async Task OofAudioPolling(CancellationToken token)
}
}
}
public float CalcVolumeFromDist(float dist,float distMax = 30)
{
if (dist > distMax) dist = distMax;
var falloff = Configuration.DistanceFalloff > 0 ? 3f - Configuration.DistanceFalloff*3f : 3f - 0.001f;
var vol = 1f - ((dist / distMax) * ( 1 / falloff));
return Math.Max(Configuration.DistanceMinVolume, vol);
}

public async Task TestDistanceAudio(CancellationToken token)
{
async Task CheckthenPlay(float volume)
{
if (token.IsCancellationRequested) return;

PlaySound(token, volume);
await Task.Delay(500, token);
}
await CheckthenPlay(CalcVolumeFromDist(0));
await CheckthenPlay(CalcVolumeFromDist(10));
await CheckthenPlay(CalcVolumeFromDist(20));
await CheckthenPlay(CalcVolumeFromDist(30));

}


/// <summary>
/// dispose
Expand Down
11 changes: 9 additions & 2 deletions OofPlugin/OofPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<Authors>Frogworks Interactive</Authors>
<Company>Frogworks Interactive</Company>
<Version>1.2.3.0</Version>
<AssemblyVersion>1.2.3.0</AssemblyVersion>
<Version>1.3.0.0</Version>
<AssemblyVersion>1.3.0.0</AssemblyVersion>

<Description>OOF!</Description>
<Copyright></Copyright>
Expand Down Expand Up @@ -85,4 +85,11 @@
</Reference>
</ItemGroup>


<ItemGroup>
<None Update="OofPlugin.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
15 changes: 6 additions & 9 deletions OofPlugin/OofPlugin.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
name: OOF!
author: Frogworks Interactive
punchline: Play the OOF! sound on fall and/or death. The Only Plugin You Need!
punchline: Play OOF! on fall and/or death. The Only Plugin You Need!
description: |-
i love roblox!!!
craaazzzy features
- oof on party & alliance deaths!
- use custom mp3 sounds!
- DBO© (Distance Based Oof)!
- instant access to the hour long documentary on oof by hbomberguy!
- fully featured settings window!
whimsical and magical features...
- when other ppl die
- custom mp3
- instant access to the hour long documentary on oof by hbomberguy
repo_url: https://github.com/Frogworks-Interactive/OOF
internal_name: OofPlugin
dalamud_api_level: 9
tags:
- Oof
- Fall Damage
Expand All @@ -22,4 +19,4 @@ tags:
- Alarm
- Roblox
- Obby
- Sound
- Sound
118 changes: 89 additions & 29 deletions OofPlugin/PluginUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Dalamud.Plugin;
using Dalamud.Utility;
using ImGuiNET;
using ImPlotNET;
using ImGuiScene;
using System;
using System.IO;
Expand Down Expand Up @@ -51,11 +52,15 @@ public void DrawSettingsWindow()
{
if (!SettingsVisible) return;
// i miss html/css
ImGui.SetNextWindowSize(new Vector2(355, 560), ImGuiCond.Appearing);
ImGui.SetNextWindowSize(new Vector2(355, 700), ImGuiCond.Appearing);
if (ImGui.Begin("oof options", ref settingsVisible,
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse))
{
// volume with icons


AddLoadAudioUI();

/// volume cntrol -----
var oofVolume = configuration.Volume;
var headingColor = ImGuiColors.DalamudGrey;
ImGuiHelpers.SafeTextColoredWrapped(headingColor, "Volume");
Expand All @@ -72,12 +77,11 @@ public void DrawSettingsWindow()
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
IconTextColor(FontAwesomeIcon.VolumeUp.ToIconString(), headingColor);
/// end volume control -----
ImGui.Spacing();
ImGui.Spacing();

LoadAudioUI();
ImGui.Spacing();

ImGui.Separator();
ImGui.Spacing();

//ImGuiComponents.HelpMarker(
Expand Down Expand Up @@ -109,32 +113,38 @@ public void DrawSettingsWindow()
if (!oofOnFall) ImGui.EndDisabled();

SectionEnd(ref fallOptionsHeight, oofOnFall ? ImGuiCol.PopupBg : ImGuiCol.TitleBg);

ImGui.Spacing();
// when people die options
SectionStart(deathOptionsHeight);
var oofOnDeath = configuration.OofOnDeath;

SectionHeader("Death", ref oofOnDeath, () => { configuration.OofOnDeath = oofOnDeath; });
if (!oofOnDeath) ImGui.BeginDisabled();




ImGui.Columns(2);
var oofOnDeathSelf = configuration.OofOnDeathSelf;

if (ImGui.Checkbox("Self dies###death:self", ref oofOnDeathSelf))
var oofInBattle = configuration.OofOnDeathBattle;

if (ImGui.Checkbox("During combat###death:combat", ref oofInBattle))
{
configuration.OofOnDeathSelf = oofOnDeathSelf;
configuration.OofOnDeathBattle = oofInBattle;
configuration.Save();
}
ImGui.NextColumn();

var oofInBattle = configuration.OofOnDeathBattle;
var oofOnDeathSelf = configuration.OofOnDeathSelf;

if (ImGui.Checkbox("During combat###death:combat", ref oofInBattle))
if (ImGui.Checkbox("Self dies###death:self", ref oofOnDeathSelf))
{
configuration.OofOnDeathBattle = oofInBattle;
configuration.OofOnDeathSelf = oofOnDeathSelf;
configuration.Save();
}

ImGui.NextColumn();


var oofOthersInParty = configuration.OofOnDeathParty;

if (ImGui.Checkbox("Party member dies###death:party", ref oofOthersInParty))
Expand All @@ -150,9 +160,11 @@ public void DrawSettingsWindow()
configuration.Save();
}
ImGui.Columns(1);

ImGui.Spacing();

ImGui.Spacing();

ImGui.Separator();
// distance based oof
ImGui.Spacing();

Expand All @@ -162,15 +174,62 @@ public void DrawSettingsWindow()
configuration.DistanceBasedOof = distanceBasedOof;
configuration.Save();
}
ImGui.SameLine();
ImGuiComponents.HelpMarker(
"change volume based on how far away \nthe player dies from you");
if (!distanceBasedOof) ImGui.BeginDisabled();

ImGui.Columns(2);

ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.GetFontSize() * 2.4f);
ImGui.PushFont(UiBuilder.IconFont);

if (CornerButton(FontAwesomeIcon.Play.ToIconString(), "dbo:play", ImDrawFlags.RoundCornersLeft)) plugin.TestDistanceAudio(plugin.CancelToken.Token);
ImGui.PopFont();
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Test distance");

ImGui.SameLine(0, 0);
ImGui.PushFont(UiBuilder.IconFont);

if (CornerButton(FontAwesomeIcon.Stop.ToIconString(), "dbo:stop", ImDrawFlags.RoundCornersRight)) plugin.StopSound();
ImGui.PopFont();

if (!distanceBasedOof) ImGui.BeginDisabled();


ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, "Lower volume based on how far someone dies from you, from 0 to 30 yalms");



/// graph
var steps = 800;
var distancePoints = new float[steps];
var volumemPoints = new float[steps];
var step = 30f / steps;
for (int i = 0; i < steps; i++)
{
distancePoints[i] = step * i;
volumemPoints[i] = plugin.CalcVolumeFromDist(step * i);

}
if (ImPlot.BeginPlot("##dbo:graph", new Vector2(-1, 80), ImPlotFlags.CanvasOnly))
{
ImPlot.PushStyleColor(ImPlotCol.FrameBg, new Vector4(0, 0, 0, 0));
ImPlot.PushStyleColor(ImPlotCol.AxisBgHovered, new Vector4(0, 0, 0, 0));
ImPlot.PushStyleColor(ImPlotCol.AxisText, ImGuiColors.DalamudGrey);

ImPlot.SetupMouseText(ImPlotLocation.North, ImPlotMouseTextFlags.None);
ImPlot.SetupLegend(ImPlotLocation.NorthEast, ImPlotLegendFlags.NoHighlightItem);

ImPlot.SetupAxisLimitsConstraints(ImAxis.X1, 0, 30);
ImPlot.SetupAxisLimitsConstraints(ImAxis.Y1,0, 1);
ImPlot.SetupAxisZoomConstraints(ImAxis.X1, 30,30);
ImPlot.SetupAxisZoomConstraints(ImAxis.Y1, 1, 1);
ImPlot.SetupAxes(null, null, ImPlotAxisFlags.None, ImPlotAxisFlags.NoTickLabels);
ImPlot.PopStyleColor();
ImPlot.SetupFinish();

ImPlot.PlotLine("volume", ref distancePoints[0], ref volumemPoints[0], steps);

ImPlot.EndPlot();
}
ImGui.Columns(2);

ImGuiHelpers.SafeTextColoredWrapped(headingColor, "Falloff Intensity");
var distanceFalloff = configuration.DistanceFalloff;
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
Expand All @@ -192,30 +251,31 @@ public void DrawSettingsWindow()
if (!distanceBasedOof) ImGui.EndDisabled();
ImGui.Columns(1);


if (!oofOnDeath) ImGui.EndDisabled();

SectionEnd(ref deathOptionsHeight, oofOnDeath ? ImGuiCol.PopupBg : ImGuiCol.TitleBg);

ImGui.Spacing();
ImGui.Spacing();

ImGui.Separator();
// watch video!
ImGui.Spacing();
/// watch video! --------
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.ExternalLinkSquareAlt, "Watch on Youtube")) OofPlugin.OpenVideo();
var desc = "Hot Tip: You can Macro the /oofvideo command to\n for easy and streamlined access to this video.";
if (ImGui.IsItemHovered()) ImGui.SetTooltip(desc);

ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudWhite2, "Learn about the history behind the Roblox Oof with Hbomberguy's Documentary:");
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, "Learn about the history behind the Roblox Oof with Hbomberguy's Documentary");

if (ImGui.Button("Watch on Youtube")) OofPlugin.OpenVideo();
var desc = "Hot Tip: You can Macro the /oofvideo command to\n for easy and streamlined access to this video.";


if (ImGui.IsItemHovered()) ImGui.SetTooltip(desc);
ImGui.Spacing();
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, "Original Oof sound by Joey Kuras");

ImGui.Spacing();

ImGui.Separator();
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, "Original Oof sound by Joey Kuras");

//logo
var size = new Vector2(this.creditsTexture.Width * (float)0.60, this.creditsTexture.Height * (float)0.60);
var size = new Vector2(this.creditsTexture.Width , this.creditsTexture.Height);
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 13);
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 0, 0, 0));
Expand Down
Loading

0 comments on commit 5525dca

Please sign in to comment.