Interface administrators, moderator
2,601
edits
No edit summary |
No edit summary |
||
(25 intermediate revisions by 3 users not shown) | |||
Line 37: | Line 37: | ||
p.categoryWords = { | p.categoryWords = { | ||
-- Category Names. (String(s) to look for in an item name, case-INsensitive.) | -- Category Names. (String(s) to look for in an item name, case-INsensitive.) | ||
'Blip', 'Building', 'Camera', 'Chatbox | 'Blip', 'Building', 'Camera', 'Chatbox', 'Cheat', 'Client', 'Command', 'Cursor', 'Debug', 'Dodo', | ||
'Element', 'Entity', 'Event', 'File', 'Font', 'Garage', 'HTTP', 'HUD', 'Key', 'Mission', 'Mouse', 'Network', 'Object', | 'Element', 'Entity', 'Event', 'File', 'Font', 'Garage', 'HTTP', 'HUD', 'Key', 'Mission', 'Mouse', 'NetFlags', 'Network', 'Object', | ||
'Pause', 'Ped', 'Pickup', 'Player', 'Process', 'Render', 'Resource', 'Screen', 'Socket', 'Sphere', 'Time | 'Pause', 'Ped', 'Pickup', 'Player', 'Process', 'Render', 'Resource', 'Screen', 'Socket', 'Sphere', 'Time', 'Vehicle', 'Weather', 'World' | ||
} | } | ||
Line 63: | Line 63: | ||
-- item page types | -- item page types | ||
function p.showVariablePage(frame) | function p.showVariablePage(frame) | ||
return p.showPage(frame, { "Value" }) | |||
return p.showPage(frame, | |||
end | end | ||
function p.showFunctionPage(frame) | function p.showFunctionPage(frame) | ||
return p.showPage(frame, { "Parameters", "Return", "Callbacks" }) | |||
end | end | ||
function p.showPropertyPage(frame) | function p.showPropertyPage(frame) | ||
return p.showPage(frame, { "Value" }) | |||
return p.showPage(frame, | |||
end | end | ||
function p.showMethodPage(frame) | function p.showMethodPage(frame) | ||
return p.showPage(frame, { "Parameters", "Return", "Callbacks" }) | |||
end | end | ||
function p.showEventPage(frame) | function p.showEventPage(frame) | ||
return p.showPage(frame, { "Parameters", "Attributes" }) | |||
end | end | ||
-- item page | -- item page | ||
function p.showPage(frame, parts) | function p.showPage(frame, parts) | ||
local args = p.getArgs(frame) | |||
if args.type ~= 'event' then | if args.type ~= 'event' then | ||
table.insert(parts, "Types") | table.insert(parts, "Types") | ||
end | end | ||
table.insert(parts, "Symbols" | --table.insert(parts, "Symbols") | ||
local lines = p.getPageTopLines(frame) | local lines = p.getPageTopLines(frame) | ||
for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do | for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do | ||
Line 114: | Line 109: | ||
local lines = {} | local lines = {} | ||
table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}")) | table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}")) | ||
-- Added for discord embed styling | |||
--table.insert(lines, "<meta content='"..p.getDisplayedName(frame).."' property='og:title' />")) | |||
--table.insert(lines, "<meta content='"..p.description(frame).."' property='og:description' />")) | |||
--table.insert(lines, "<meta content='#04C765' data-react-helmet='true' name='theme-color' />")) | |||
table.insert(lines, "__NOTOC__"..p.getPageTopBoxes(frame).."\n") | table.insert(lines, "__NOTOC__"..p.getPageTopBoxes(frame).."\n") | ||
table.insert(lines, "<div style='margin-top: 20px;'>Available since "..p.since(frame).."</div>\n") | table.insert(lines, "<div style='margin-top: 20px;'>Available since "..p.since(frame).."</div>\n") | ||
Line 301: | Line 302: | ||
function p.onlineBox(frame) | function p.onlineBox(frame) | ||
local args = p.getArgs(frame) | local args = p.getArgs(frame) | ||
if args.sp == 'true' then | if args.sp == 'true' or args.online == 'false' then | ||
return p.loadTemplate(frame, 'RedInformationBox', {'Offline Only',id='online'}); | return p.loadTemplate(frame, 'RedInformationBox', {'Offline Only',id='online'}); | ||
elseif args.sp == 'false' or args.offline == 'false' then | |||
return p.loadTemplate(frame, 'RedInformationBox', {'Online Only',id='online'}); | |||
else | else | ||
return p.loadTemplate(frame, 'GreenInformationBox', {'Online and Offline',id='online'}); | return p.loadTemplate(frame, 'GreenInformationBox', {'Online and Offline',id='online'}); | ||
Line 368: | Line 371: | ||
local entries = p.getIndexedArgs(frame, 'description') | local entries = p.getIndexedArgs(frame, 'description') | ||
local startTextFirstLine = "The <span style=\"font-family: 'Source Code Pro', monospace;\">"..p.getDisplayedNameColoured(frame).."</span> "..args.type.." is "..(args.type == "event" and "invoked when" or "used to").." " | local startTextFirstLine = "The <span style=\"font-family: 'Source Code Pro', monospace;\">"..p.getDisplayedNameColoured(frame).."</span> [[HowTo/Functions|"..args.type.."]] is "..(args.type == "event" and "invoked when" or "used to").." " | ||
for i,entry in ipairs(entries) do | for i,entry in ipairs(entries) do | ||
Line 808: | Line 811: | ||
local args = p.getArgs(frame) | local args = p.getArgs(frame) | ||
if p.isOOP(frame) then | if p.isOOP(frame) then | ||
return args.class | return p.lowerFirstCharCase(args.class).."."..args.name | ||
else | else | ||
return args.name | return args.name | ||
Line 827: | Line 830: | ||
local args = p.getArgs(frame) | local args = p.getArgs(frame) | ||
if p.isOOP(frame) then | if p.isOOP(frame) then | ||
return "<span style='color:"..typeRgb..";'>"..args.class | return "<span style='color:"..typeRgb..";'>"..p.lowerFirstCharCase(args.class).."</span>.<span style='color:"..nameRgb.."';>"..args.name.."</span>" | ||
else | else | ||
return "<span style='color:"..nameRgb.."';>"..args.name.."</span>" | return "<span style='color:"..nameRgb.."';>"..args.name.."</span>" | ||
Line 876: | Line 879: | ||
local derivedTypes = { | local derivedTypes = { | ||
ped = { | ped = {'Player'}, | ||
physical = {'Object', 'Ped', 'Vehicle | physical = {'Object', 'Ped', 'Vehicle', 'Player'}, | ||
entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle | entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'}, | ||
element = {'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'}, | |||
vehicle = {'Train'}, | |||
event = {'CancellableEvent', 'KeyEvent'}, | |||
surface = {'RenderTarget', 'Texture'} | |||
} | } | ||
local serverTypes = { | local serverTypes = {} | ||
local sharedTypes = { | local sharedTypes = { | ||
'Client', 'Effect', 'Event | 'Building', 'Client', 'Effect', 'Event', 'Timer', 'ReflectedFunction', 'Resource', 'Stream', 'Vec2', 'Vec3', 'Matrix4x4', | ||
'Element | 'Element', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle', 'Train', 'XmlDocument', 'XmlElement', | ||
'CancellableEvent', 'KeyEvent', 'Marker', 'Object', 'Ped', 'Player' | |||
} | } | ||
local out = {} | |||
local getTypeSide = function(type) | local getTypeSide = function(type) | ||
Line 951: | Line 957: | ||
rows[#parts][2] = p.properCase(args.type) | rows[#parts][2] = p.properCase(args.type) | ||
rows[#parts][3] = #parts == 1 and 'Global' or 'Namespace: '..parts[#parts-1] | rows[#parts][3] = #parts == 1 and 'Global' or 'Namespace: '..parts[#parts-1] | ||
rows[#parts][4] = #parts == 1 and parts[ | rows[#parts][4] = #parts == 1 and parts[1]..' is a '..p.properCase(args.type)..', which exists in the global namespace.' or parts[#parts]..' is a '..p.properCase(args.type)..', which exists in the '..parts[#parts-1]..' namespace.' | ||
elseif args.type == 'method' or args.type == 'property' then | elseif args.type == 'method' or args.type == 'property' then | ||
local parts = p.split(p.getDisplayedName(frame), ".") | |||
rows[1] = {} | rows[1] = {} | ||
rows[1][1] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[1].."</span>" | rows[1][1] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[1].."</span>" | ||
Line 973: | Line 980: | ||
--table.insert(out, "<div style='margin-top: 20px;'></div>") | --table.insert(out, "<div style='margin-top: 20px;'></div>") | ||
table.insert(out, "\n"..p.table( | local headers = { 'Symbol Name', 'Symbol Type', 'Container', 'Description' } | ||
table.insert(out, "\n"..p.table(headers, rows, { 120, 120, 400 }, false)) | |||
if args.type ~= 'event' then | if args.type ~= 'event' then | ||
Line 993: | Line 1,001: | ||
line = language..' uses the '..languageSymbols[language][args.type]..' symbol to get or set a property.' | line = language..' uses the '..languageSymbols[language][args.type]..' symbol to get or set a property.' | ||
end | end | ||
table.insert(out, " | table.insert(out, "<br>"..line) | ||
end | end | ||
end | end | ||
Line 1,014: | Line 1,022: | ||
function p.formatSource(type, frame) | function p.formatSource(type, frame) | ||
return frame:preprocess('< | return frame:preprocess('<syntaxhighlight>'..type..'</syntaxhighlight>') | ||
end | end | ||
Line 1,148: | Line 1,156: | ||
function p.properCase(text) | function p.properCase(text) | ||
return text:sub(1,1):upper()..text:sub(2):lower() | return text:sub(1,1):upper()..text:sub(2):lower() | ||
end | |||
function p.lowerFirstCharCase(text) | |||
return text:sub(1,1):lower()..text:sub(2) | |||
end | end | ||