forked from challenge-project/challenge-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.Script.txt
More file actions
168 lines (146 loc) · 4.93 KB
/
Copy pathMap.Script.txt
File metadata and controls
168 lines (146 loc) · 4.93 KB
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
/*
// Map.Script.txt
// by BigBang1112
// part of Universe Library Set
// Enhancing functions for map related stuff.
// This library does depend on more libraries from the Universe Library Set:
// - Task.Script.txt
// You only need to use the libraries above, although it's recommended to use the whole set.
*/
/*
// Compatible contexts:
// - CManiaApp
// - CMode (only Solo)
*/
/*
// SMapInfo ToSMapInfo(CMapInfo _MapInfo)
// SMapInfo MapInfo(Text _Path, Integer _Scope)
// CTaskResult_MapList Get(Text _FileName)
// Void AsyncMapInfo(Text _FileName, Integer _Scope)
// SMapInfo AsyncGet(Text _FileName)
// Void AsyncDestroy(Text _FileName)
// Boolean AsyncIsCompleted(Text _FileName)
// Boolean AsyncIsSuccessful(Text _FileName)
// Task::STaskFail AsyncIsFailed(Text _FileName)
// Boolean IsCanceled(Text _FileName)
*/
#Include "TextLib" as TextLib
#Include "Libs/BigBang1112/Task.Script.txt" as Task
#Struct SMapInfo {
Text MapUid;
Text Comments;
Integer CopperPrice;
Text CollectionName;
Text AuthorLogin;
Text AuthorNickName;
Text AuthorZonePath;
Text AuthorZoneFlagUrl;
Text AuthorCountryFlagUrl;
Text MapType;
Text MapStyle;
Boolean Unlocked;
Boolean IsPlayable;
Boolean CreatedWithSimpleEditor;
Boolean CreatedWithPartyEditor;
Integer TMObjective_AuthorTime;
Integer TMObjective_GoldTime;
Integer TMObjective_SilverTime;
Integer TMObjective_BronzeTime;
Integer TMObjective_NbLaps;
Boolean TMObjective_IsLapRace;
Text Name;
Text Path;
Text FileName;
}
declare CTaskResult_MapList[Text] G_AsyncMaps;
SMapInfo ToSMapInfo(CMapInfo _MapInfo) {
declare SMapInfo Info;
Info.MapUid = _MapInfo.MapUid;
Info.Comments = _MapInfo.Comments;
Info.CopperPrice = _MapInfo.CopperPrice;
Info.CollectionName = _MapInfo.CollectionName;
Info.AuthorLogin = _MapInfo.AuthorLogin;
Info.AuthorNickName = _MapInfo.AuthorNickName;
Info.AuthorZonePath = _MapInfo.AuthorZonePath;
Info.AuthorZoneFlagUrl = _MapInfo.AuthorZoneFlagUrl;
Info.AuthorCountryFlagUrl = _MapInfo.AuthorCountryFlagUrl;
Info.MapType = _MapInfo.MapType;
Info.MapStyle = _MapInfo.MapStyle;
Info.Unlocked = _MapInfo.Unlocked;
Info.IsPlayable = _MapInfo.IsPlayable;
Info.CreatedWithSimpleEditor = _MapInfo.CreatedWithSimpleEditor;
Info.CreatedWithPartyEditor = _MapInfo.CreatedWithPartyEditor;
Info.TMObjective_AuthorTime = _MapInfo.TMObjective_AuthorTime;
Info.TMObjective_GoldTime = _MapInfo.TMObjective_GoldTime;
Info.TMObjective_SilverTime = _MapInfo.TMObjective_SilverTime;
Info.TMObjective_BronzeTime = _MapInfo.TMObjective_BronzeTime;
Info.TMObjective_NbLaps = _MapInfo.TMObjective_NbLaps;
Info.TMObjective_IsLapRace = _MapInfo.TMObjective_IsLapRace;
Info.Name = _MapInfo.Name;
Info.Path = _MapInfo.Path;
Info.FileName = _MapInfo.FileName;
return Info;
}
SMapInfo MapInfo(Text _Path, Integer _Scope) {
declare Folders = TextLib::Split("/",_Path);
declare Removed = Folders.removekey(Folders.count-1);
declare Path = TextLib::Join("/",Folders);
declare SMapInfo Info;
declare Result = Task::SyncMapList(DataFileMgr.Map_GetFilteredGameList(_Scope, Path, False));
foreach(MapInfo,Result.MapInfos)
if(MapInfo.FileName == _Path)
Info = ToSMapInfo(MapInfo);
return Info;
}
Boolean Exists(Text _Path, Integer _Scope) {
return MapInfo(_Path, _Scope).FileName != "";
}
CTaskResult_MapList Get(Text _FileName) {
if(!G_AsyncMaps.existskey(_FileName)) return Null;
return G_AsyncMaps[_FileName];
}
Void AsyncMapInfo(Text _FileName, Integer _Scope) {
declare Folders = TextLib::Split("/",_FileName);
declare Removed = Folders.removekey(Folders.count-1);
declare Path = TextLib::Join("/",Folders);
G_AsyncMaps[_FileName] = DataFileMgr.Map_GetFilteredGameList(_Scope, Path, False);
}
SMapInfo AsyncGet(Text _FileName) {
declare SMapInfo Info;
if(G_AsyncMaps.existskey(_FileName))
foreach(MapInfo,G_AsyncMaps[_FileName].MapInfos)
if(MapInfo.FileName == _FileName)
Info = ToSMapInfo(MapInfo);
return Info;
}
Void AsyncDestroy(Text _FileName) {
if(!G_AsyncMaps.existskey(_FileName)) return;
DataFileMgr.TaskResult_Release(G_AsyncMaps[_FileName].Id);
declare Removed = G_AsyncMaps.removekey(_FileName);
}
Boolean AsyncIsCompleted(Text _FileName) {
if(!G_AsyncMaps.existskey(_FileName)) return False;
return !Get(_FileName).IsProcessing;
}
Boolean AsyncIsSuccessful(Text _FileName) {
if(!G_AsyncMaps.existskey(_FileName)) return False;
return !Get(_FileName).IsProcessing
&& Get(_FileName).HasSucceeded;
}
Task::STaskFail AsyncIsFailed(Text _FileName) {
declare Task::STaskFail TaskFail;
if(!G_AsyncMaps.existskey(_FileName)) return TaskFail;
if(!Get(_FileName).IsProcessing && Get(_FileName).HasFailed) {
TaskFail.Failed = True;
TaskFail.ErrorType = Get(_FileName).ErrorType;
TaskFail.ErrorCode = Get(_FileName).ErrorCode;
TaskFail.ErrorDescription = Get(_FileName).ErrorDescription;
return TaskFail;
}
return TaskFail;
}
Boolean IsCanceled(Text _FileName) {
if(!G_AsyncMaps.existskey(_FileName)) return False;
return !Get(_FileName).IsProcessing
&& Get(_FileName).IsCanceled;
}