You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
836 B
31 lines
836 B
import threading
|
|
|
|
from modules.views import *
|
|
|
|
|
|
class ViewManager(object):
|
|
_instance_lock = threading.Lock()
|
|
_init_flag = False
|
|
|
|
def __init__(self):
|
|
self.__views = {
|
|
'SwitchLevel': SwitchLevelView(),
|
|
'GameOver': GameOverView(),
|
|
'GameStart': GameStartView(),
|
|
'GameLevelView': GameLevelView(),
|
|
}
|
|
|
|
def __new__(cls, *args, **kwargs):
|
|
if not hasattr(ViewManager, "_instance"):
|
|
with ViewManager._instance_lock:
|
|
if not hasattr(ViewManager, "_instance"):
|
|
ViewManager._instance = object.__new__(cls)
|
|
return ViewManager._instance
|
|
|
|
def show(self, view: str):
|
|
if view not in self.__views:
|
|
raise Exception('View is not found!')
|
|
else:
|
|
self.__views[view].show()
|
|
|