forked from BlenderDumbass/DanisRace
162 lines
3.2 KiB
Python
162 lines
3.2 KiB
Python
|
import random
|
||
|
|
||
|
# Common things needed for various things
|
||
|
|
||
|
# Colors are used to make the
|
||
|
clr = {
|
||
|
"norm":"\033[00m", # Reset to normal
|
||
|
"bold":"\033[01m", # Bold Text
|
||
|
"ital":"\033[03m", # Italic Text
|
||
|
"undr":"\033[04m", # Underlined
|
||
|
"blnk":"\033[05m", # Blinking
|
||
|
|
||
|
# Text
|
||
|
"tdbl":"\033[30m", # Dark Black
|
||
|
"tdrd":"\033[31m", # Dark Red
|
||
|
"tdgr":"\033[32m", # Dark Green
|
||
|
"tdyl":"\033[33m", # Dark Yellow
|
||
|
"tdbu":"\033[34m", # Dark Blue
|
||
|
"tdma":"\033[35m", # Dark Magenta
|
||
|
"tdcy":"\033[36m", # Dark Cyan
|
||
|
"tdwh":"\033[37m", # Dark White
|
||
|
|
||
|
"tbbl":"\033[90m", # Bright Black
|
||
|
"tbrd":"\033[91m", # Bright Red
|
||
|
"tbgr":"\033[92m", # Bright Green
|
||
|
"tbyl":"\033[93m", # Bright Yellow
|
||
|
"tbbu":"\033[94m", # Bright Blue
|
||
|
"tbma":"\033[95m", # Bright Magenta
|
||
|
"tbcy":"\033[96m", # Bright Cyan
|
||
|
"tbwh":"\033[97m", # Bright White
|
||
|
# Background
|
||
|
"bdbl":"\033[40m", # Dark Black
|
||
|
"bdrd":"\033[41m", # Dark Red
|
||
|
"bdgr":"\033[42m", # Dark Green
|
||
|
"bdyl":"\033[43m", # Dark Yellow
|
||
|
"bdbu":"\033[44m", # Dark Blue
|
||
|
"bdma":"\033[45m", # Dark Magenta
|
||
|
"bdcy":"\033[46m", # Dark Cyan
|
||
|
"bdwh":"\033[47m", # Dark White
|
||
|
|
||
|
"bbbl":"\033[100m", # Bright Black
|
||
|
"bbrd":"\033[101m", # Bright Red
|
||
|
"bbgr":"\033[102m", # Bright Green
|
||
|
"bbyl":"\033[103m", # Bright Yellow
|
||
|
"bbbu":"\033[104m", # Bright Blue
|
||
|
"bbma":"\033[105m", # Bright Magenta
|
||
|
"bbcy":"\033[106m", # Bright Cyan
|
||
|
"bbwh":"\033[108m" # Bright White
|
||
|
}
|
||
|
|
||
|
keycodes = {
|
||
|
"A":23,
|
||
|
"B":24,
|
||
|
"C":25,
|
||
|
"D":26,
|
||
|
"E":27,
|
||
|
"F":28,
|
||
|
"G":29,
|
||
|
"H":30,
|
||
|
"I":31,
|
||
|
"J":32,
|
||
|
"K":33,
|
||
|
"L":34,
|
||
|
"M":35,
|
||
|
"N":36,
|
||
|
"O":37,
|
||
|
"P":38,
|
||
|
"Q":39,
|
||
|
"R":40,
|
||
|
"S":41,
|
||
|
"T":42,
|
||
|
"U":43,
|
||
|
"V":44,
|
||
|
"W":45,
|
||
|
"X":46,
|
||
|
"Y":47,
|
||
|
"Z":48,
|
||
|
|
||
|
"0":13,
|
||
|
"1":14,
|
||
|
"2":15,
|
||
|
"3":16,
|
||
|
"4":17,
|
||
|
"5":18,
|
||
|
"6":19,
|
||
|
"7":20,
|
||
|
"8":21,
|
||
|
"9":22,
|
||
|
|
||
|
"F1" :88,
|
||
|
"F2" :89,
|
||
|
"F3" :90,
|
||
|
"F4" :91,
|
||
|
"F5" :92,
|
||
|
"F6" :93,
|
||
|
"F7" :94,
|
||
|
"F8" :95,
|
||
|
"F9" :96,
|
||
|
"F10":97,
|
||
|
"F11":98,
|
||
|
"F12":99,
|
||
|
|
||
|
"LShift" :55,
|
||
|
"RShift" :54,
|
||
|
"LCtrl" :50,
|
||
|
"RCtrl" :53,
|
||
|
"LAlt" :51,
|
||
|
"RAlt" :52,
|
||
|
"Tab" :57,
|
||
|
"Space" :8,
|
||
|
"Enter" :7,
|
||
|
"BackSpace" :59,
|
||
|
"Delete" :60,
|
||
|
"Home" :110,
|
||
|
"End" :109,
|
||
|
"PageUp" :111,
|
||
|
"PageDown" :112,
|
||
|
|
||
|
"UpArrow" :72,
|
||
|
"DownArrow" :70,
|
||
|
"RightArrow":71,
|
||
|
"LeftArrow" :69
|
||
|
|
||
|
}
|
||
|
|
||
|
mousecodes = {
|
||
|
|
||
|
"RMB" : 118,
|
||
|
"MMB" : 117,
|
||
|
"LMB" : 116
|
||
|
}
|
||
|
|
||
|
IDColors = {}
|
||
|
|
||
|
def consoleForm(obj):
|
||
|
|
||
|
# Function that prints a pretty object info about
|
||
|
|
||
|
ID = hex(id(obj))[2:].upper()
|
||
|
NAME = str(obj)
|
||
|
|
||
|
c = IDcolor(ID)
|
||
|
|
||
|
return c + " " + ID + " " + NAME + " " + clr["norm"]
|
||
|
|
||
|
def IDcolor(ID):
|
||
|
|
||
|
# Coloring
|
||
|
if ID not in IDColors:
|
||
|
r = random.random()
|
||
|
g = random.random()
|
||
|
b = random.random()
|
||
|
|
||
|
ct = clr["tbwh"]
|
||
|
if max(r, g, b ) > 0.9 or sum((r, g, b))/3 > 0.5:
|
||
|
ct = clr["tdbl"]
|
||
|
|
||
|
c = clr["bold"] + "\033[48;2;"+str(int(r*256))+";"+str(int(g*256))+";"+str(int(b*256))+"m"+ct
|
||
|
IDColors[ID] = c
|
||
|
c = IDColors[ID]
|
||
|
return c
|