Skip to content

Commit

Permalink
data: add screen max. fps
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <82flex@gmail.com>
  • Loading branch information
Lessica committed Feb 2, 2024
1 parent 7810175 commit 0529d67
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Reveil/GlobalTimer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protocol GlobalTimerObserver {
}

final class GlobalTimer: ObservableObject {
struct Observer {
private struct Observer {
let value: any GlobalTimerObserver
var registeredCount: Int
}
Expand All @@ -36,7 +36,7 @@ final class GlobalTimer: ObservableObject {
unregisterNotifications()
}

func registerNotifications() {
private func registerNotifications() {
NotificationCenter.default.addObserver(
self,
selector: #selector(applicationDidEnterBackground(_:)),
Expand All @@ -51,21 +51,21 @@ final class GlobalTimer: ObservableObject {
)
}

func unregisterNotifications() {
private func unregisterNotifications() {
NotificationCenter.default.removeObserver(self)
}

@objc
func applicationWillEnterForeground(_: Notification) {
private func applicationWillEnterForeground(_: Notification) {
setupTimer()
}

@objc
func applicationDidEnterBackground(_: Notification) {
private func applicationDidEnterBackground(_: Notification) {
tearDownTimer()
}

func setupTimer() {
private func setupTimer() {
timer?.invalidate()
timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [unowned self] _ in
if observers.isEmpty {
Expand All @@ -79,7 +79,7 @@ final class GlobalTimer: ObservableObject {
timer?.fire()
}

func tearDownTimer() {
private func tearDownTimer() {
timer?.invalidate()
timer = nil
}
Expand Down
5 changes: 5 additions & 0 deletions Reveil/ViewModels/Enums/EntryKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {
case ScreenPhysicalScale
case ScreenLogicalResolution
case ScreenLogicalScale
case ScreenMaximumFramesPerSecond

// Operating System
case System
Expand Down Expand Up @@ -241,6 +242,8 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {
self = .ScreenLogicalResolution
case "ScreenLogicalScale":
self = .ScreenLogicalScale
case "ScreenMaximumFramesPerSecond":
self = .ScreenMaximumFramesPerSecond
case "System":
self = .System
case "UserAgent":
Expand Down Expand Up @@ -519,6 +522,8 @@ enum EntryKey: Codable, Equatable, Hashable, RawRepresentable {
"ScreenLogicalResolution"
case .ScreenLogicalScale:
"ScreenLogicalScale"
case .ScreenMaximumFramesPerSecond:
"ScreenMaximumFramesPerSecond"
case .System:
"System"
case .UserAgent:
Expand Down
7 changes: 7 additions & 0 deletions Reveil/ViewModels/Modules/ScreenInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ final class ScreenInformation: Module {
.ScreenPhysicalScale,
.ScreenLogicalResolution,
.ScreenLogicalScale,
.ScreenMaximumFramesPerSecond,
]

func basicEntry(key: EntryKey, style: ValueStyle = .detailed) -> BasicEntry? {
Expand Down Expand Up @@ -83,6 +84,12 @@ final class ScreenInformation: Module {
name: style == .dashboard ? NSLocalizedString("SCREEN_LOGICAL_SCALE", comment: "Screen Logical Scale") : NSLocalizedString("LOGICAL_SCALE", comment: "Logical Scale"),
value: String(format: "%.3f", mainScreen.scale)
)
case .ScreenMaximumFramesPerSecond:
return BasicEntry(
key: .ScreenMaximumFramesPerSecond,
name: style == .dashboard ? NSLocalizedString("SCREEN_MAXIMUM_FPS", comment: "Screen Maximum FPS") : NSLocalizedString("MAXIMUM_FPS", comment: "Maximum FPS"),
value: String(format: "%d", mainScreen.maximumFramesPerSecond)
)
default:
break
}
Expand Down
6 changes: 6 additions & 0 deletions Reveil/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@
/* Max Socket Buffer Size */
"MAX_SOCKET_BUFFER_SIZE" = "Max Socket Buffer Size";

/* Maximum FPS */
"MAXIMUM_FPS" = "Maximum FPS";

/* Active */
"MEMORY_ACTIVE" = "Active";

Expand Down Expand Up @@ -877,6 +880,9 @@
/* Screen Logical Scale */
"SCREEN_LOGICAL_SCALE" = "Screen Logical Scale";

/* Screen Maximum FPS */
"SCREEN_MAXIMUM_FPS" = "Screen Maximum FPS";

/* Screen Physical Resolution */
"SCREEN_PHYSICAL_RESOLUTION" = "Screen Physical Resolution";

Expand Down
6 changes: 6 additions & 0 deletions Reveil/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@
/* Max Socket Buffer Size */
"MAX_SOCKET_BUFFER_SIZE" = "Tamaño Máximo de Búfer de Socket";

/* TODO: Maximum FPS */
"MAXIMUM_FPS" = "Maximum FPS";

/* Active */
"MEMORY_ACTIVE" = "Activo";

Expand Down Expand Up @@ -877,6 +880,9 @@
/* TODO: Screen Logical Scale */
"SCREEN_LOGICAL_SCALE" = "Screen Logical Scale";

/* TODO: Screen Maximum FPS */
"SCREEN_MAXIMUM_FPS" = "Screen Maximum FPS";

/* TODO: Screen Physical Resolution */
"SCREEN_PHYSICAL_RESOLUTION" = "Screen Physical Resolution";

Expand Down
6 changes: 6 additions & 0 deletions Reveil/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@
/* Max Socket Buffer Size */
"MAX_SOCKET_BUFFER_SIZE" = "套接字最大缓冲区尺寸";

/* Maximum FPS */
"MAXIMUM_FPS" = "最高显示帧速率";

/* Active */
"MEMORY_ACTIVE" = "活动";

Expand Down Expand Up @@ -877,6 +880,9 @@
/* Screen Logical Scale */
"SCREEN_LOGICAL_SCALE" = "屏幕逻辑缩放率";

/* Screen Maximum FPS */
"SCREEN_MAXIMUM_FPS" = "屏幕最高显示帧速率";

/* Screen Physical Resolution */
"SCREEN_PHYSICAL_RESOLUTION" = "屏幕物理分辨率";

Expand Down

0 comments on commit 0529d67

Please sign in to comment.