Compare commits

...

5 Commits

7 changed files with 41 additions and 37 deletions

View File

@ -4,12 +4,16 @@ namespace EorzeaVotes.Config;
[Serializable]
internal class Configuration : IPluginConfiguration {
internal const int MinFreq = 60;
internal const int MaxFreq = 3_600;
public int Version { get; set; } = 1;
public string? UserId;
public string? ApiKey;
public bool OpenWhenNew = true;
public int CheckFrequency = 300;
public bool OnBoarded;
public Gender? Gender = null;

View File

@ -153,7 +153,7 @@ internal static class BreakdownExt {
"male",
},
Breakdown.CharacterHomeWorld => Keys[Breakdown.CharacterHomeWorld],
Breakdown.YearStartedPlaying => Enumerable.Range(2010, DateTime.UtcNow.Year - 2010)
Breakdown.YearStartedPlaying => Enumerable.Range(2010, DateTime.UtcNow.Year - 2010 + 1)
.Select(year => year.ToString())
.ToArray(),
Breakdown.MyersBriggs => Enum.GetNames<Mbti>()

View File

@ -53,7 +53,7 @@ public class Plugin : IDalamudPlugin {
private Commands Commands { get; }
private bool _checkNow = true;
private int _checkSeconds = 300;
private int _checkSeconds;
private Stopwatch Stopwatch { get; } = Stopwatch.StartNew();
public Plugin() {
@ -91,12 +91,15 @@ public class Plugin : IDalamudPlugin {
return;
}
if (!this._checkNow && this.Stopwatch.Elapsed < TimeSpan.FromSeconds(this._checkSeconds)) {
var wait = this._checkSeconds > 0
? this._checkSeconds
: Math.Clamp(this.Config.CheckFrequency, Configuration.MinFreq, Configuration.MaxFreq);
if (!this._checkNow && this.Stopwatch.Elapsed < TimeSpan.FromSeconds(wait)) {
return;
}
this._checkNow = false;
this._checkSeconds = 300;
this._checkSeconds = 0;
this.Stopwatch.Restart();
var safeToOpen = !this.DutyState.IsDutyStarted
@ -143,6 +146,7 @@ public class Plugin : IDalamudPlugin {
if (!safeToOpen) {
// try again real quick
this._checkSeconds = 5;
return;
}
Task.Run(async () => await this.Manager.Check());

View File

@ -22,7 +22,7 @@ internal class QuestionsTab {
using var endTabItem = new OnDispose(ImGui.EndTabItem);
if (this.Plugin.Manager.Count == 0) {
ImGuiHelpers.CenteredText("No questions yet - waiting for plugin approval.");
ImGuiHelpers.CenteredText("Fetching questions - please wait...");
return;
}

View File

@ -1,4 +1,5 @@
using Dalamud.Interface.Utility;
using EorzeaVotes.Config;
using EorzeaVotes.Utilities;
using ImGuiNET;
@ -27,6 +28,17 @@ internal class SettingsTab {
ImGui.TextUnformatted("The window will not open until you are not busy in most cases (not in combat, not in instance, etc.).");
}
anyChanged |= ImGuiHelper.VerticalInput(
"Check for new questions every",
label => ImGui.SliderInt(
label,
ref this.Plugin.Config.CheckFrequency,
Configuration.MinFreq,
Configuration.MaxFreq,
"%i second(s)"
)
);
ImGuiHelpers.CenteredText("Optional questions");
ImGui.Spacing();

View File

@ -1,16 +0,0 @@
[build]
rustflags = ['--cfg', 'uuid_unstable']
[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C",
"link-arg=-fuse-ld=/usr/bin/mold",
"--cfg",
"uuid_unstable",
]
[target.aarch64-unknown-linux-musl]
rustflags = [
"--cfg",
"uuid_unstable",
]

32
server/Cargo.lock generated
View File

@ -380,9 +380,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e"
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8"
dependencies = [
"libc",
"windows-sys",
@ -611,9 +611,9 @@ dependencies = [
[[package]]
name = "http"
version = "0.2.10"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150"
checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb"
dependencies = [
"bytes",
"fnv",
@ -1118,9 +1118,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.38.21"
version = "0.38.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e"
dependencies = [
"bitflags 2.4.1",
"errno",
@ -1250,9 +1250,9 @@ dependencies = [
[[package]]
name = "signature"
version = "2.1.0"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500"
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
dependencies = [
"digest",
"rand_core",
@ -1816,9 +1816,9 @@ dependencies = [
[[package]]
name = "uuid"
version = "1.5.0"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc"
checksum = "c58fe91d841bc04822c9801002db4ea904b9e4b8e6bbad25127b46eff8dc516b"
dependencies = [
"atomic",
"getrandom",
@ -2020,18 +2020,18 @@ dependencies = [
[[package]]
name = "zerocopy"
version = "0.7.25"
version = "0.7.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557"
checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.25"
version = "0.7.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b"
checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f"
dependencies = [
"proc-macro2",
"quote",
@ -2040,6 +2040,6 @@ dependencies = [
[[package]]
name = "zeroize"
version = "1.6.0"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"