48 lines
972 B
Go
48 lines
972 B
Go
package app
|
|
|
|
import "sync"
|
|
|
|
type RuntimeState struct {
|
|
mu sync.RWMutex
|
|
DiscordMuted bool
|
|
LastOCRText string
|
|
LastTranslate string
|
|
CurrentWorld string
|
|
}
|
|
|
|
var runtimeState = &RuntimeState{}
|
|
var guestTracker *GuestTracker
|
|
|
|
func SetGuestTracker(t *GuestTracker) { guestTracker = t }
|
|
func GetGuestTracker() *GuestTracker { return guestTracker }
|
|
|
|
func SetDiscordMuted(v bool) {
|
|
runtimeState.mu.Lock()
|
|
defer runtimeState.mu.Unlock()
|
|
runtimeState.DiscordMuted = v
|
|
}
|
|
|
|
func SetOCRText(v string) {
|
|
runtimeState.mu.Lock()
|
|
defer runtimeState.mu.Unlock()
|
|
runtimeState.LastOCRText = v
|
|
}
|
|
|
|
func SetTranslateText(v string) {
|
|
runtimeState.mu.Lock()
|
|
defer runtimeState.mu.Unlock()
|
|
runtimeState.LastTranslate = v
|
|
}
|
|
|
|
func SetCurrentWorld(v string) {
|
|
runtimeState.mu.Lock()
|
|
defer runtimeState.mu.Unlock()
|
|
runtimeState.CurrentWorld = v
|
|
}
|
|
|
|
func SnapshotRuntime() RuntimeState {
|
|
runtimeState.mu.RLock()
|
|
defer runtimeState.mu.RUnlock()
|
|
return *runtimeState
|
|
}
|