bl2mods/Mods/ModUtils/enums.py
2023-03-22 12:57:56 -04:00

155 lines
2.1 KiB
Python

from enum import IntEnum, auto
import enum
class StrEnum(str, enum.Enum):
def __new__(cls, value):
return str.__new__(cls, value)
def __str__(self):
return self.value
@classmethod
def parse(cls, value):
try:
if value in cls:
return cls[value]
return cls(value)
except ValueError:
pass
for item in cls:
if value.upper() in (item.value.upper(), item.name.upper()):
return item
raise KeyError(value)
class IntEnum(enum.IntEnum):
@classmethod
def parse(cls, value):
try:
if value in cls:
return cls[value]
return cls(value)
except ValueError:
pass
if isinstance(value, str):
for item in cls:
if value.upper() == item.name:
return item
raise KeyError(value)
class CurrencyType(IntEnum):
CREDITS = 0
ERIDIUM = 1
SERAPH = 2
GOLDKEYS = 3
RESERVED_B = 4
RESERVED_C = 5
RESERVED_D = 6
RESERVED_E = 7
RESERVED_F = 8
RESERVED_G = 9
RESERVED_H = 10
RESERVED_I = 11
RESERVED_J = 12
MAX = 13
# alias
MOONSTONE = CREDITS
class FrameRate(IntEnum):
SMOOTH = 0
CAP30 = 1
CAP50 = 2
CAP60 = 3
CAP72 = 4
CAP120 = 5
UNLIMITED = 6
class KeyboardInput(StrEnum):
# Letters
A = 'A'
B = 'B'
C = 'C'
D = 'D'
E = 'E'
F = 'F'
G = 'G'
H = 'H'
I = 'I'
J = 'J'
K = 'K'
L = 'L'
M = 'M'
N = 'N'
O = 'O'
P = 'P'
Q = 'Q'
R = 'R'
S = 'S'
T = 'T'
U = 'U'
V = 'V'
W = 'W'
X = 'X'
Y = 'Y'
Z = 'Z'
# Numbers
ZERO = 'zero'
ONE = 'one'
TWO = 'two'
THREE = 'three'
FOUR = 'four'
FIVE = 'five'
SIX = 'siz'
SEVEN = 'seven'
EIGHT = 'eight'
NINE = 'nine'
# Numpad Numbers
NUMPAD_ZERO = 'NumPadZero'
NUMPAD_ONE = 'NumPadOne'
NUMPAD_TWO = 'NumPadTwo'
NUMPAD_THREE = 'NumPadThree'
NUMPAD_FOUR = 'NumPadFour'
NUMPAD_FIVE = 'NumPadFive'
NUMPAD_SIX = 'NumPadSix'
NUMPAD_SEVEN = 'NumPadSeven'
NUMPAD_EIGHT = 'NumPadEight'
NUMPAD_NINE = 'NumPadNine'
# F-keys
F1 = 'F1'
F2 = 'F2'
F3 = 'F3'
F4 = 'F4'
F5 = 'F5'
F6 = 'F6'
F7 = 'F7'
F8 = 'F8'
F9 = 'F9'
F10 = 'F10'
F11 = 'F11'
F12 = 'F12'
@classmethod
def numbers(cls):
return tuple(
cls.ZERO, cls.ONE, cls.TWO, cls.THREE, cls.FOUR,
cls.FIVE, cls.SIX, cls.SEVEN, cls.EIGHT, cls.NINE
)