Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mdl_system_ior import CIOR
- from random import randint
- from random import choice
- from os import system
- from os import name
- from os import open
- # from os import ctermid
- from os import O_RDONLY
- from os import close
- from sys import stdout
- from subprocess import Popen
- from time import strftime
- from time import sleep
- import platform
- import shutil
- import itertools
- import threading
- import time
- import locale
- class CColors:
- try:
- from colorama import init
- from colorama import Fore
- from colorama import Back
- from colorama import Style
- except ImportError:
- sblack = ""
- sred = ""
- sgreen = ""
- syellow = ""
- sblue = ""
- swhite = ""
- bgblack = ""
- bgred = ""
- bggreen = ""
- bgyellow = ""
- bgblue = ""
- bgmagenta = ""
- bgwhite = ""
- stbright = ""
- stnormal = ""
- none = "" #---N O T H I N G---#
- else:
- init()
- sblack = Fore.BLACK
- sred = Fore.RED
- sgreen = Fore.GREEN
- syellow = Fore.YELLOW
- sblue = Fore.BLUE
- swhite = Fore.WHITE
- bgblack = Back.BLACK
- bgred = Back.RED
- bggreen = Back.GREEN
- bgyellow = Back.YELLOW
- bgblue = Back.BLUE
- bgmagenta = Back.MAGENTA
- bgwhite = Back.WHITE
- stbright = Style.BRIGHT
- stnormal = Style.NORMAL
- none = "" #---N O T H I N G---#
- endc = Style.RESET_ALL
- class CTools:
- def FClearSaves():
- if name in ("nt","dos","ce"):
- (stdout,stderr) = Popen("os_nt_saves_clear.bat",cmd=r".").communicate()
- elif name == "posix":
- system("chmod +x os_nix_saves_clear.sh && ./os_nix_saves_clear.sh")
- def FPopen(fileName):
- if name in ("nt","dos","ce"):
- (stdout,stderr) = Popen(fileName,cmd=r".").communicate()
- elif name == "posix":
- system("chmod +x %s && ./%s" % (fileName,fileName))
- currentTime = strftime("%H:%M:%S")
- currentDateDMY = strftime("%d/%m/%y")
- currentDateMDY = strftime("%m/%d/%y")
- currentLocale = locale.getdefaultlocale()[0]
- # def FCallFunction(key,*fs):
- # for i in fs:
- # fs[key]()
- def FCheckEmptyBlock(listName):
- for key,value in listName:
- for item in value:
- print("%d:\tFull Block\t[%s]" % (key,item) if item != '' else print('%d:\tEMPTY BLOCK\t[ ]' % key))
- def FTerminalSize():
- import os
- env = os.environ
- def ioctl_GWINSZ(fd):
- try:
- import fcntl, termios, struct, os
- cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,
- '1234'))
- except:
- return
- return cr
- cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
- if not cr:
- try:
- fd = os.open(os.ctermid(), os.O_RDONLY)
- cr = ioctl_GWINSZ(fd)
- os.close(fd)
- except:
- pass
- if not cr:
- cr = (env.get('LINES', 25), env.get('COLUMNS', 80))
- return int(cr[1]), int(cr[0])
- class CMagic(CColors):
- #class with the small and good anon. functions#
- if name in ("nt","dos","ce"):
- FClearScreen = lambda: system("cls")
- elif name == "posix": FClearScreen = lambda: system("clear")
- FSleep = lambda s: sleep(s)
- FPressKey = lambda e: input(""+e)
- FExit = lambda m: exit(m)
- class CShow(CTools,CColors):
- #<show function>(CColors.FONT_COLOR_NAME,CColor.BACKGROUND_COLOR_NAME,text,options for delay)#
- def FShowDelay(fontColor,backgroundColor,textArray,delayArray,delayEnd,pressKeyValue):
- textArray = [t for t in textArray]
- if name in ("nt","dos","ce"):
- for i in range(len(textArray)):
- print(fontColor+backgroundColor+textArray[i]+CColors.endc,end="")
- sleep(delayArray)
- elif name == "posix":
- for i in range(len(textArray)):
- stdout.write(fontColor+backgroundColor+textArray[i]+CColors.endc,end="")
- stdout.flush()
- sleep(delayArray)
- if pressKeyValue == 0:
- sleep(delayEnd)
- elif pressKeyValue == 1:
- input(fontColor+backgroundColor+CIOR.dictIO[CTools.currentLocale]["gameInput"]["gamePressKey"]+CColors.endc)
- elif pressKeyValue == 2:
- input("<...>")
- def FShowInMiddle(fontColor,backgroundColor,*textArray):
- columns = shutil.get_terminal_size().columns
- for i in textArray:
- # center = "{0}".center(columns).format(i)
- center = "{0}".center(CTools.FTerminalSize()[0]-20).format(i)
- print(fontColor+backgroundColor+center)
- def FShowLoad(fontColor,backgroundColor,textLoading,countLoading,delayArray,delayEnd,loadingValue):
- for i in countLoading:
- if loadingValue == 0:
- print(fontColor+backgroundColor+textLoading+i+CColors.endc,end="")
- system("clear")
- sleep(delayArray)
- elif loadingValue == 1:
- print(fontColor+backgroundColor+CIOR.dictIO["gameOutput"]["gameLoading"]+i+CColors.endc,end="")
- system("clear")
- sleep(delayArray)
- sleep(delayEnd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement