-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMapwindow.xml
260 lines (249 loc) · 8.26 KB
/
Mapwindow.xml
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.0">
<TriggerPackage/>
<TimerPackage/>
<AliasPackage/>
<ActionPackage/>
<ScriptPackage>
<ScriptGroup isActive="yes" isFolder="yes">
<name>Map Window</name>
<packageName></packageName>
<script>-------------------------------------------------
-- Put your Lua functions here. --
-- --
-- Note that you can also use external Scripts --
-------------------------------------------------
</script>
<eventHandlerList/>
<Script isActive="yes" isFolder="no">
<name>Load Map settings</name>
<packageName></packageName>
<script>mapwin = mapwin or {}
mapwin.windows = mapwin.windows or {}
mapwin.labelbox = mapwin.labelbox or {}
mapwin.labels = mapwin.labels or {}
mapwin.labelWidth = 100
mapwin.labelHeight = 25
mapwin.windowlist = {"Map", "Room Info", "Dir Queue"}
mapwin.width = "420"
mapwin.height = "300"
mapwin.border = 25
favorites = {}
favorites.labels = {}
function mapwin:ResetUI()
--width, height = getMainWindowSize()
--[[ mapwin.container = Geyser.Container:new({
fontSize = 8,
x=width-mapwin.width-mapwin.border,
y=height-mapwin.height-mapwin.border,
width=mapwin.width,
height=mapwin.height,
name="mapwinWindow",
})]]
end
function mapwinSwitch(win)
local oldwin = mapwin.currentWindow
if oldwin and mapwin.windows[oldwin] and mapwin.windows[win] then
if mapwin.windows[oldwin] then
mapwin.windows[oldwin]:hide()
end
mapwin.labels[oldwin]:setColor(50,50,50)
mapwin.labels[oldwin]:echo(oldwin, "white", "c")
end
mapwin.currentWindow = win
mapwin.windows[win]:show()
mapwin.labels[win]:setColor(0,125,0)
mapwin.labels[win]:echo(win, "cyan", "c")
end
function mapwin:create()
--reset the UI
mapwin:ResetUI()
width, height = getMainWindowSize()
local sx = width-mapwin.width-mapwin.border
local sy = height-mapwin.height-mapwin.border
--iterate the table of channels and create some windows and tabs
for i,tab in ipairs(mapwin.windowlist) do
mapwin.labels[tab] = Geyser.Label:new({
name=string.format("label%s", tab),
x=sx+mapwin.labelWidth*i,
y=sy,
width=mapwin.labelWidth,
height=mapwin.labelHeight,
nestable=true,
flyOut=true
})
mapwin.labels[tab]:echo(tab, "white", "c")
mapwin.labels[tab]:setColor(50,50,50)
if tab ~= "Dir Queue" then
mapwin.labels[tab]:setClickCallback("mapwinSwitch", tab)
end
if tab == "Map" then
mapwin.windows[tab] = Geyser.Mapper:new({
x = sx,
y = sy,
height = mapwin.height,
width = mapwin.width,
name = string.format("mapwin%s", tab),
})--, mapwin.container)
mapwin.windows[tab]:hide()
elseif tab == "Dir Queue" then
else
mapwin.windows[tab] = Geyser.MiniConsole:new({
x = sx,
y = sy+mapwin.labelHeight,
height = "100%",
width = "100%",
name = string.format("mapwin%s", tab),
})--, mapwin.container)
mapwin.windows[tab]:setFontSize(8)
mapwin.windows[tab]:setColor(0,0,0)
mapwin.windows[tab]:setWrap(60)
mapwin.windows[tab]:hide()
end
end
mapwinSwitch("Map")
end
function mapwin:ClearWindow(win)
clearUserWindow(string.format("mapwin%s", win))
end
function mapwin:AppendWindow(win, text)
mapwin.windows[win]:cecho(text)
end
function mapwin:AppendWindowClickable(win, text, command, tip)
echoLink(mapwin.windows[win].name, text, command, tip)
end
function mapwin:updateRoomInfo()
mapwin:ClearWindow("Room Info")
updatedesc = getRoomUserData( tmap.lastId, "description")
local exits = getAllExits(tmap.lastId)
local exitlist = "Exits: "
updatedesc = string.gsub(updatedesc, ".\n", " ")
mapwin:AppendWindow("Room Info", "<cyan>"..updatedesc.."\n")
local exitlen = 0 --for wrapping
if exits then
for v,i in pairs(exits) do
exitlen = exitlen+string.len(i)
if exitlen > 30 then
mapwin:AppendWindow("Room Info", "\n")
exitlen=0
end
mapwin:AppendWindowClickable("Room Info", i..", ", [[send("]]..i..[[");onFollow("]]..i..[[")]], i)
end
end
end
if not mapwin.windows["Map"] then
mapwin:create()
end
--mapwin:create()</script>
<eventHandlerList/>
</Script>
<Script isActive="yes" isFolder="no">
<name>Create Favorites</name>
<packageName></packageName>
<script>-------------------------------------------------
-- Put your Lua functions here. --
-- --
-- Note that you can also use external Scripts --
-------------------------------------------------
function mapwin:setupFavorites()
favTable = searchRoomUserData("favorite", "")
favSorted = {}
unsorted = {}
addMapMenu("Favorites")
for i,v in pairs(favTable) do
--repetitive but straightforward implementation
local entry = string.split(v,'|||')
local name, fav, room, parent = entry[1],entry[2],entry[3],entry[4]
if parent then
favSorted[parent] = favSorted[parent] or {}
favSorted[parent][fav]={name,room}
else
-- unsorted
end
--add parents to their respective list so the player can actually click on them
end
if favSorted['-1'] then
for i,v in pairs(favSorted['-1']) do
if favSorted[i] then
--designate -1 so we can keep the parent in order
favSorted[i]['-1']={v[1], v[2]}
end
end
end
nestItem=0
for i,v in pairs(favSorted) do
if v["-1"] then
local k=v["-1"]
local nest = k[1]..tostring(k[2])..tostring(nestItem)
addMapMenu(nest, "Favorites", k[1])
for j,t in pairs(v) do
if j~="-1" then
local entry=t[1]..tostring(t[2])..tostring(j)
addMapEvent(entry, "onFavorite", nest, t[1], t[2])
end
end
nestItem=nestItem+1
else
for j,k in pairs(v) do
addMapEvent(k[1]..tostring(k[2]), "onFavorite", "Favorites", k[1], k[2])
end
end
end
end
mapwin:setupFavorites()</script>
<eventHandlerList/>
</Script>
<Script isActive="no" isFolder="no">
<name>Direction Queue</name>
<packageName></packageName>
<script>-------------------------------------------------
-- Put your Lua functions here. --
-- --
-- Note that you can also use external Scripts --
-------------------------------------------------
function mapwin:updateDirQueue()
if not mapwin.dirLabels then
mapwin.dirLabels = {}
end
for i,v in pairs(mapwin.dirLabels) do
deleteLabel("dwin"..tostring(i))--mapwin.dirLabels[i]:hide()
end
if #tmap.comTable > 0 then
mapwin.labels["Dir Queue"]:echo(tmap.comTable[1],"white", "c")
end
if #tmap.comTable > 1 then
for i,v in ipairs(tmap.comTable) do
echo("fd")
mapwin.dirLabels[i] = mapwin.labels["Dir Queue"]:addChild({name="dwin"..tostring(i),
height=mapwin.labelHeight,
width=mapwin.labelWidth,
layoutDir="LV",
flyOut=true})
--display(mapwin.dirLabels)
echo("fs")
mapwin.dirLabels[i]:echo(v,"white", "c")
mapwin.dirLabels[i]:setClickCallback("mapwinDirClear", i)
mapwin.dirLabels[i]:show()
end
end
end
--table.insert(tmap.comTable,"east")
mapwin:updateDirQueue()
function mapwinDirClear(dirIndex)
display(dirIndex)
display(tmap.comTable)
for i=1,dirIndex do
table.remove(tmap.comTable,1)
end
mapwin:updateDirQueue()
end</script>
<eventHandlerList/>
</Script>
</ScriptGroup>
</ScriptPackage>
<KeyPackage/>
<HelpPackage>
<helpURL></helpURL>
</HelpPackage>
</MudletPackage>