/
context.py
203 lines (150 loc) · 4.99 KB
/
context.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# 2016.02.14 12:43:16 Støední Evropa (bìžný èas)
# Embedded file name: scripts/client/tutorial/control/context.py
from abc import ABCMeta, abstractmethod
from tutorial.control import TutorialProxyHolder
from tutorial.logger import LOG_MEMORY, LOG_ERROR
__all__ = ('StartReqs', 'BonusesRequester', 'SoundPlayer', 'GlobalStorage')
class StartReqs(object):
def __del__(self):
LOG_MEMORY('StartReqs deleted: {0:>s}'.format(self))
def isEnabled(self):
raise NotImplementedError
def prepare(self, ctx):
raise NotImplementedError
def process(self, descriptor, ctx):
raise NotImplementedError
class BonusesRequester(TutorialProxyHolder):
__meta__ = ABCMeta
def __init__(self, completed):
super(BonusesRequester, self).__init__()
self._completed = completed
def getCompleted(self):
return self._completed
def setCompleted(self, completed):
self._completed = completed
def isStillRunning(self):
return False
def getChapter(self, chapterID = None):
chapter = self._data
if chapterID is not None and len(chapterID):
chapter = self._descriptor.getChapter(chapterID)
return chapter
@abstractmethod
def request(self, chapterID = None):
pass
class SOUND_EVENT:
TASK_FAILED = 0
TASK_COMPLETED = 1
NEXT_CHAPTER = 2
SPEAKING = 3
class SoundPlayer(object):
__meta__ = ABCMeta
def __init__(self):
super(SoundPlayer, self).__init__()
self._muted = False
self._enabled = False
def setMuted(self, value):
self._muted = value
def isMuted(self):
return self._muted
def setEnabled(self, value):
self._enabled = value
def isEnabled(self):
return self._enabled
@abstractmethod
def play(self, event, sndID = None):
pass
@abstractmethod
def stop(self):
pass
def isPlaying(self, event, sndID = None):
return False
def goToNextChapter(self):
pass
class NoSound(SoundPlayer):
def play(self, event, sndID = None):
pass
def stop(self):
pass
class GLOBAL_VAR(object):
LAST_HISTORY_ID = '_TutorialLastHistoryID'
SERVICE_MESSAGES_IDS = '_TutorialServiceMessagesIDs'
PLAYER_VEHICLE_NAME = '_TutorialPlayerVehicleName'
ALL = (LAST_HISTORY_ID, SERVICE_MESSAGES_IDS, PLAYER_VEHICLE_NAME)
class GLOBAL_FLAG(object):
IS_FLAGS_RESET = '_TutorialIsFlagsReset'
SHOW_HISTORY = '_TutorialShowHistory'
HISTORY_NOT_AVAILABLE = '_TutorialHistoryNotAvailable'
IN_QUEUE = '_InTutorialQueue'
ALL_BONUSES_RECEIVED = '_AllBonusesReceived'
ALL = (IS_FLAGS_RESET,
SHOW_HISTORY,
HISTORY_NOT_AVAILABLE,
IN_QUEUE,
ALL_BONUSES_RECEIVED)
class GlobalStorage(object):
__slots__ = ('attribute',)
__storage = {}
__default = {}
def __init__(self, attribute, defaultValue):
self.attribute = attribute
if attribute not in self.__storage:
self.__storage[attribute] = defaultValue
if attribute in GLOBAL_VAR.ALL:
self.__default[attribute] = defaultValue
def __repr__(self):
return 'GlobalStorage {0:s}: {1!r:s}'.format(self.attribute, self.__storage.get(self.attribute))
def __set__(self, _, value):
self.__storage[self.attribute] = value
def __get__(self, instance, owner = None):
if instance is None:
return self
else:
return self.__storage[self.attribute]
def value(self):
return self.__storage[self.attribute]
@classmethod
def setFlags(cls, flags):
for flag, value in flags.iteritems():
if flag not in GLOBAL_FLAG.ALL:
LOG_ERROR('It is not global flag', flag)
continue
cls.__storage[flag] = value
@classmethod
def clearFlags(cls):
for flag in GLOBAL_FLAG.ALL:
if flag in cls.__storage:
cls.__storage[flag] = False
@classmethod
def clearVars(cls):
for var in GLOBAL_VAR.ALL:
if var in cls.__storage:
if var in cls.__default:
cls.__storage[var] = cls.__default[var]
else:
cls.__storage[var] = None
return
@classmethod
def all(cls):
return cls.__storage.copy()
@classmethod
def getValue(cls, attribute):
result = None
if attribute in cls.__storage:
result = cls.__storage[attribute]
return result
@classmethod
def setValue(cls, attribute, value):
cls.__storage[attribute] = value
class ClientCtx(object):
@classmethod
def fetch(cls, *args):
pass
@classmethod
def makeCtx(cls, record):
pass
def makeRecord(self):
pass
# okay decompyling c:\Users\PC\wotsources\files\originals\res\scripts\client\tutorial\control\context.pyc
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed
# 2016.02.14 12:43:16 Støední Evropa (bìžný èas)