forked from kshman/DutyContent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WorkerAct.cs
62 lines (53 loc) · 1.27 KB
/
WorkerAct.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Advanced_Combat_Tracker;
namespace DutyContent
{
static class WorkerAct
{
public delegate object ObjectReturnerDelegate();
private static object _lock_effect_sound = new object();
private static long _last_effect_sound;
// main invoker
public static object Invoker(ObjectReturnerDelegate dgt)
{
return ActGlobals.oFormActMain.Invoke(dgt);
}
//
public static void Invoker(Action dgt)
{
ActGlobals.oFormActMain.Invoke(dgt);
}
//
public static void Tts(string msg)
{
ActGlobals.oFormActMain.TTS(msg);
}
//
public static void PlaySound(string filename, int volume_percent = 100)
{
ActGlobals.oFormActMain.PlaySoundWinApi(filename, volume_percent);
}
//
public static void PlayEffectSound(string filename, int volume_percent = 100)
{
if (string.IsNullOrWhiteSpace(filename) || !File.Exists(filename))
return;
lock (_lock_effect_sound)
{
long now = DateTime.Now.Ticks;
long delta = now - _last_effect_sound;
TimeSpan span = new TimeSpan(delta);
if (span.TotalSeconds > 2)
{
_last_effect_sound = now;
PlaySound(filename, volume_percent);
}
}
}
}
}