25 lines
861 B
Python
25 lines
861 B
Python
from dial_configs.dial_config import DialConfig
|
|
from vu1 import RGBColor
|
|
|
|
class GameloaderGamescopeFPS(DialConfig):
|
|
def __init__(self, target_dial, asset_path):
|
|
super().__init__(target_dial, asset_path, "fps.png")
|
|
|
|
def transform_color(self, value):
|
|
if fps < 60:
|
|
color = RGBColor(1.0, 0, 0)
|
|
else:
|
|
color = super().Colors.get_gradient_color(self, value, 30, 0)
|
|
return color
|
|
|
|
def transform_value(self, json_data):
|
|
FPS_MAX = 120
|
|
fps = float(json_data.get("fields", {}).get("fps", 0))
|
|
value = int((fps/FPS_MAX)*100)
|
|
return value
|
|
|
|
def __eq__(self, other):
|
|
try:
|
|
return (other.get("name", "") == "gamescope" and "fps" in other.get("fields", {}).keys() and other.get("tags", {}).get("host", "") == "gameloader")
|
|
except Exception:
|
|
return False
|