Skip to content

Commit

Permalink
V.3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MeowServer committed Jun 6, 2024
1 parent 982c611 commit 4ba181c
Show file tree
Hide file tree
Showing 17 changed files with 357 additions and 179 deletions.
64 changes: 5 additions & 59 deletions Config.cs → Config/GeneralConfig.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@
using Exiled.API.Enums;
using Exiled.API.Interfaces;
using HintServiceMeow.UITemplates;
using PlayerRoles;
using Respawning;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HintServiceMeow
namespace HintServiceMeow.Config
{
public class Config:IConfig
public class GeneralConfig
{
public static Config instance;

public bool IsEnabled { get; set; } = true;
public bool Debug { get; set; } = false;

[Description("All of the following configs are used for PlayerUI")]
public bool EnablePlayerUI { get; set; } = true;

[Description("The text displayed for different ammo/armor status")]
public string NoArmor { get; set; } = "没有装甲";
public string NoAmmo { get; set; } = "没有备弹";
public string AmmoHint { get; set; } = "{Ammo}共{NumOfAmmo}发";
public string AmmoHint2 { get; set; } = "各种备弹共{NumOfAmmo}发";

[Description("The config for different templates")]

public GeneralHumanTemplateConfig generalHumanTemplateConfig { get; private set; } = new GeneralHumanTemplateConfig();

public SCPTemplateConfig scpTemplateConfig { get; private set; } = new SCPTemplateConfig();

public CustomHumanTemplateConfig customHumanTemplate { get; private set; } = new CustomHumanTemplateConfig();

public CustomSCPTemplateConfig customSCPTemplate { get; private set; } = new CustomSCPTemplateConfig();

[Description("Translation of different role types")]
public Dictionary<RoleTypeId, string> RoleName { get; private set; } = new Dictionary<RoleTypeId, string>()
{
Expand Down Expand Up @@ -165,35 +141,5 @@ public class Config:IConfig
{WarheadStatus.Detonated, "<color=#ce313f>已被引爆</color>" },
{WarheadStatus.InProgress, "<color=#d0652f>正在倒计时</color>" },
};

[Description("RespawnTimer: Time interval between each hint")]
public int HintDisplayInterval { get; set; } = 10;

[Description("RespawnTimer: A list of hints you want to display")]
public List<string> Hints { get; private set; } = new List<string>() { "Some hints", "Some other hints" };
}

public class GeneralHumanTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color={RoleColor}>{Role}</color>|{AmmoInfo}|{ArmorInfo}|<color=#7CB342>Meow</color>";
}

public class SCPTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color={RoleColor}>{Role}</color>|剩余{TeammateCount}队友|<color=#7CB342>Meow</color>";
}

public class CustomHumanTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color={RoleColor}>{Role}</color>|{AmmoInfo}|{ArmorInfo}|<color=#7CB342>Meow</color>";
}

public class CustomSCPTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color=#EC2222>{Role}</color>|剩余{TeammateCount}队友|{AmmoInfo}|{ArmorInfo}|<color=#7CB342>Meow</color>";
}
}
18 changes: 18 additions & 0 deletions Config/PlayerDisplayConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HintServiceMeow.Config
{
public class PlayerDisplayConfig
{
[Description("The minimum time between each updates for player displays. 0.5 is experimental value.")]
public TimeSpan MinUpdateInterval = TimeSpan.FromMilliseconds(500);

[Description("The minimum time wait before each update, you can shorten it if you're confident with your server's performance, count in miliseconds")]
public float MinTimeDelayBeforeUpdate = 50f;
}
}
21 changes: 21 additions & 0 deletions Config/PlayerUIConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HintServiceMeow.Config
{
public class PlayerUIConfig
{
[Description("Enable or disable common hints. Changing this option might cause error if other plugins are using CommonHints")]
public bool EnableCommonHints { get; set; } = true;

[Description("Enable or disable player effects. Changing this option might cause error if other plugins are using Effects")]
public bool EnableEffects { get; set; } = true;

[Description("Enable or disable playerUITemplate")]
public bool EnableUITemplates { get; set; } = true;
}
}
42 changes: 42 additions & 0 deletions Config/PlayerUITemplateConfigs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HintServiceMeow.Config
{
public class GeneralHumanTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color={RoleColor}>{Role}</color>|{AmmoInfo}|{ArmorInfo}|<color=#7CB342>Meow</color>";
}

public class SCPTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color={RoleColor}>{Role}</color>|剩余{TeammateCount}队友|<color=#7CB342>Meow</color>";
}

public class CustomHumanTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color={RoleColor}>{Role}</color>|{AmmoInfo}|{ArmorInfo}|<color=#7CB342>Meow</color>";
}

public class CustomSCPTemplateConfig
{
public string TopBar { get; set; } = "TPS:{TPS} | {PlayerName}";
public string BottomBar { get; set; } = "{PlayerNickname}|<color=#EC2222>{Role}</color>|剩余{TeammateCount}队友|{AmmoInfo}|{ArmorInfo}|<color=#7CB342>Meow</color>";
}

public class SpectatorTemplateConfig
{
[Description("RespawnTimer: Time interval between each hint")]
public int HintDisplayInterval { get; set; } = 10;

[Description("RespawnTimer: A list of hints you want to display")]
public List<string> Hints { get; private set; } = new List<string>() { "Some hints", "Some other hints" };
}
}
25 changes: 25 additions & 0 deletions Config/PlayerUIToolConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HintServiceMeow.Config
{

public class PlayerUIToolsConfig
{
[Description("Message template when the player has no armor")]
public string NoArmor { get; set; } = "没有装甲";

[Description("Message template when the player has no ammo")]
public string NoAmmo { get; set; } = "没有备弹";

[Description("Message template when the player has 1 type of ammo")]
public string AmmoHint1 { get; set; } = "{Ammo}共{NumOfAmmo}发";

[Description("Message template when the player has multiple types of ammo")]
public string AmmoHint2 { get; set; } = "各种备弹共{NumOfAmmo}发";
}
}
51 changes: 51 additions & 0 deletions Config/PluginConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Exiled.API.Enums;
using Exiled.API.Interfaces;
using HintServiceMeow.UITemplates;
using PlayerRoles;
using Respawning;

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace HintServiceMeow.Config
{
public class PluginConfig:IConfig
{
public static PluginConfig instance;

public bool IsEnabled { get; set; } = true;
public bool Debug { get; set; } = false;

[Description("Configs for PlayerDisplay. Changing these configs might leads to errors")]
public PlayerDisplayConfig PlayerDisplayConfig { get; set; } = new PlayerDisplayConfig();


[Description("The config for general names")]
public GeneralConfig GeneralConfig { get; set; } = new GeneralConfig();

[Description("All of the following configs are used for PlayerUI")]
public bool EnablePlayerUI { get; set; } = true;

[Description("The config for PlayerUI")]
public PlayerUIConfig PlayerUIConfig { get; set; } = new PlayerUIConfig();

[Description("The config for PlayerUITools, will affect multiple templates")]
public PlayerUIToolsConfig PlayerUIToolsConfig { get; private set; } = new PlayerUIToolsConfig();

[Description("The config for general human tempalte")]
public GeneralHumanTemplateConfig GeneralHumanTemplateConfig { get; private set; } = new GeneralHumanTemplateConfig();

[Description("The config for scp tempalte")]
public SCPTemplateConfig ScpTemplateConfig { get; private set; } = new SCPTemplateConfig();

[Description("The config for custom human tempalte")]
public CustomHumanTemplateConfig CustomHumanTemplate { get; private set; } = new CustomHumanTemplateConfig();

[Description("The config for custom scp tempalte")]
public CustomSCPTemplateConfig CustomSCPTemplate { get; private set; } = new CustomSCPTemplateConfig();

[Description("The config for spectator tempalte")]
public SpectatorTemplateConfig SpectatorTemplateConfig { get; private set; } = new SpectatorTemplateConfig();
}
}
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions PlayerDisplay/PlayerDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal bool UpdatedRecently()
}

//Update Rate Management stuff
private TimeSpan UpdateInterval { get; } = TimeSpan.FromMilliseconds(500); //By experiment, the fastest update rate is 2 times per second.
private TimeSpan UpdateInterval { get; } = Config.PluginConfig.instance.PlayerDisplayConfig.MinUpdateInterval; //By experiment, the fastest update rate is 2 times per second.
internal DateTime lastTimeUpdate { get; set; } = DateTime.MinValue;
private bool plannedUpdate { get; set; } = false; // Tells whether a update had been planned

Expand All @@ -78,7 +78,8 @@ internal void UpdateWhenReady()
plannedUpdate = true;

var TimeToWait = (float)((lastTimeUpdate + UpdateInterval) - DateTime.Now).TotalMilliseconds;
TimeToWait = TimeToWait < 50f ? 50f : TimeToWait; //0.05f to make sure that all of the changes are updated beofre the next update
var MinDelay = Config.PluginConfig.instance.PlayerDisplayConfig.MinTimeDelayBeforeUpdate;
TimeToWait = TimeToWait < MinDelay ? MinDelay : TimeToWait; //Having a min delay to make sure that all of the changes are updated beofre the next update

Timing.CallDelayed(TimeToWait/1000, () =>
{
Expand Down
4 changes: 2 additions & 2 deletions PlayerUI/Effects.cs → PlayerUI/Effects/Effects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Text;
using System.Threading.Tasks;

namespace HintServiceMeow
namespace HintServiceMeow.Effect
{
//Not implemented
//Not implemented yet
public abstract class UIEffectBase
{
Player player;
Expand Down
Loading

0 comments on commit 4ba181c

Please sign in to comment.