Skip to content

Commit ae20290

Browse files
Refactor see_also code, add See Also to element pages
1 parent fef3321 commit ae20290

34 files changed

+245
-185
lines changed

elements/blip.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ description: |
66
77
The list of blip icons are available on the [Radar Blips](/radar_blips) page.
88
9-
TODO

elements/building.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ description: |
44
55
The element type of this class is **"building"**.
66
7-
TODO
87
notes:
98
- |
109
There is a distinction in GTA: San Andreas between static and dynamic models (these use a separate streaming system). Examples of buildings include building models, roads, and terrain. Objects created as [Buildings](/building) can contain **glass** and **shadows**, unlike those created as [Objects](/building) (which are missing these features).

elements/camera.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ description: |
44
55
The element type of this class is **"camera"**.
66
7-
TODO

elements/col.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ description: |
1010
Collision data can also be embedded in DFF files. At the moment, vehicle collision replacement works with DFF embedded collisions only.
1111
1212
The element type of this class is **"col"**.
13-
14-
TODO
13+
see_also:
14+
- 'functions:any:Engine'
15+
- 'events:any:Engine'

elements/collision_shape.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ description: |
33
The collision shape class represents invisible collision detection shapes that can be created in the GTA world. Collision shapes are typically used to detect physical entities moving through them and perform actions when they do.
44
55
The element type for this class is **"colshape"**.
6-
7-
TODO
6+
see_also:
7+
- 'functions:any:ColShape'
8+
- 'events:any:ColShape'

elements/console.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ description: |
88
99
You can view all latest available server console commands by entering **"help"** into the server console window.
1010
11-
TODO
1211
preview_images:
1312
- path: '/assets/server_console_help.jpg'
1413
description: 'Help output inside server console:'
14+
15+
# see_also:
16+
# - 'article:Server_Commands'

elements/dff.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ description: |
66
77
The element type of this class is **"dff"**.
88
9-
TODO
9+
see_also:
10+
- 'functions:any:Engine'
11+
- 'events:any:Engine'

elements/effect.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ description: |
44
55
The element type of this class is **"effect"**.
66
7-
TODO: add all the effects as a table...
7+
TODO all effects table

elements/light.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ description: |
33
The light class represents colored, 3D lights in the GTA world. There are a couple different types of lights, which are point lights, spot lights and dark lights.
44
55
The element type of this class is **"light"**.
6-
7-
TODO

elements/marker.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ description: |
44
55
The element type of this class is **"marker"**.
66
7-
TODO

elements/object.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ description: |
44
55
The element type of this class is **"object"**.
66
7-
TODO
87
notes:
98
- |
109
Objects only represent models **created by a script**, they do not represent objects that are part of GTA's default landscape (these belong to the "building pool").

elements/ped.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ description: |
66
77
The element type of a NPC is **"ped"**.
88
9-
TODO

elements/pickup.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ description: |
44
55
The element type of this class is **"pickup"**.
66
7-
TODO

elements/player.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ description: |
44
55
The element type of this class is **"player"**.
66
7-
TODO

elements/projectile.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ description: |
44
55
The element type of this class is **"projectile"**.
66
7-
TODO
87
notes:
98
- |
109
**16: Grenade**

elements/radar_area.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ description: |
44
55
The element type of this class is **"radararea"**.
66
7-
TODO
7+
8+
see_also:
9+
- 'functions:any:RadarArea'
10+
- 'events:any:RadarArea'
11+

elements/searchlight.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ description: |
44
55
The element type of this class is **"searchlight"**.
66
7-
TODO

elements/sound.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ description: |
88
99
The element type of this class is **"sound"**.
1010
11-
TODO
11+
12+
see_also:
13+
- 'functions:any:Audio'
14+
- 'events:any:Audio'
15+

elements/team.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ description: |
66
77
The element type of this class is **"team"**.
88
9-
TODO

elements/txd.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ description: |
44
55
The element type of this class is **"txd"**.
66
7-
TODO
7+
see_also:
8+
- 'functions:any:Engine'
9+
- 'events:any:Engine'

elements/vehicle.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ description: |
44
55
The element type of this class is **"vehicle"**.
66
7-
TODO

elements/water.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ description: |
66
77
The element type of this class is **"water"**.
88
9-
TODO

elements/weapon.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ description: |
44
55
The element type of this class is **"weapon"**.
66
7-
TODO
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
addCommandHandler("myname", function(ply)
2+
outputChatBox("Your name: "..getPlayerName(ply), ply)
3+
end)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
addCommandHandler("myname", function()
2+
-- output local player's name to the chatbox
3+
outputChatBox(getPlayerName(localPlayer))
4+
end)

functions/Player/getPlayerName.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
shared: &shared
2+
name: 'getPlayerName'
3+
oop:
4+
entity: player
5+
method: getName
6+
variable: name
7+
pair: 'setPlayerName'
8+
description: |
9+
This function returns a string containing the name of the specified [player](/player).
10+
parameters:
11+
- name: 'thePlayer'
12+
type: 'player'
13+
description: "The [player](/player) you want to get the name of."
14+
returns:
15+
description: |
16+
Returns a *string* containing the requested player's name, or *false* if the player passed to the function is invalid.
17+
values:
18+
- type: 'string'
19+
name: 'name'
20+
21+
server:
22+
<<: *shared
23+
examples:
24+
- path: 'examples/getPlayerName-1.lua'
25+
description: |
26+
This example outputs the name of the player who executed the command to their chatbox.
27+
28+
client:
29+
<<: *shared
30+
examples:
31+
- path: 'examples/getPlayerName-2.lua'
32+
description: |
33+
This example outputs the local player name to the chatbox.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
import type { SeeAlsoLinkGroup } from '@src/utils/general';
3+
4+
export interface Props {
5+
seeAlsoLinks: SeeAlsoLinkGroup[];
6+
currentId: string;
7+
}
8+
9+
const { seeAlsoLinks, currentId } = Astro.props;
10+
---
11+
12+
{seeAlsoLinks.length > 0 && (
13+
<div class="see-also-section">
14+
<h4>See Also</h4>
15+
{seeAlsoLinks.map((group) => (
16+
<div class="see-also-group">
17+
<h5>{group.title}</h5>
18+
<ul>
19+
{group.links.map((link) => (
20+
<li>
21+
{link.name === currentId ? (
22+
<strong>{link.name}</strong>
23+
) : (
24+
<a href={link.link}>{link.name}</a>
25+
)}
26+
</li>
27+
))}
28+
</ul>
29+
</div>
30+
))}
31+
</div>
32+
)}

web/src/pages/Element_tree.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,3 @@ You can start the resource *elementbrowser* to see a live view of the element tr
109109

110110
</StarlightPage>
111111

112-
{/* TODO: see also */}

web/src/pages/[element].astro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
33
import { getCollection } from 'astro:content';
44
import { marked } from 'marked';
5+
import { getPageSeeAlsoLinks } from '@src/utils/general';
6+
7+
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
58
69
export async function getStaticPaths() {
710
const elements = await getCollection('elements');
@@ -12,12 +15,17 @@ export async function getStaticPaths() {
1215
}
1316
1417
const { element } = Astro.props;
18+
element.data.itemType = 'element';
19+
element.data.niceName = element.data.name.charAt(0).toUpperCase() + element.data.name.slice(1);
20+
1521
---
1622
<StarlightPage frontmatter={{
1723
template: 'doc',
1824
title: element.data.name,
1925
tableOfContents: false,
2026
}}>
2127
<Fragment set:html={marked(element.data.description)} />
28+
29+
<SeeAlsoSection seeAlsoLinks={getPageSeeAlsoLinks(element)} currentId={element.id} />
2230
</StarlightPage>
2331

web/src/pages/[event].astro

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import fs from "fs";
66
import path from "path";
77
import { Code } from '@astrojs/starlight/components';
88
import '@src/styles/function-page.css';
9-
import { getEventSeeAlsoLinks } from '@src/utils/events';
9+
import { getPageSeeAlsoLinks } from '@src/utils/general';
1010
1111
import NoteBox from '@src/components/NoteBox.astro';
1212
import type { NotesType } from '@src/utils/types';
1313
14+
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
15+
1416
export async function getStaticPaths() {
1517
const events = await getCollection('events');
1618
return events.map(event => ({
@@ -20,6 +22,7 @@ export async function getStaticPaths() {
2022
}
2123
2224
const { event } = Astro.props;
25+
event.data.itemType = 'event';
2326
2427
const eventType = event.data.type;
2528
const eventPath = path.dirname(event.filePath ?? "");
@@ -57,7 +60,6 @@ if (Array.isArray(event.data.notes) && event.data.notes.length > 0) {
5760
notesContent = event.data.notes;
5861
}
5962
60-
const seeAlsoLinks = getEventSeeAlsoLinks(event);
6163
---
6264

6365
<div class={"show-type-badge-" + eventType}>
@@ -108,31 +110,15 @@ const seeAlsoLinks = getEventSeeAlsoLinks(event);
108110
<h4>Code Examples</h4>
109111
{eventExamples.map((example: any) => (
110112
<div class="function-example">
111-
<Fragment set:html={marked(example.description)}></p>
113+
{example.description && (
114+
<Fragment set:html={marked(example.description)} />
115+
)}
112116
<Code code={example.luaCode} lang="lua"/>
113117
</div>
114118
))}
115119
</div>
116120
)}
117121

118-
<!-- See Also -->
119-
{seeAlsoLinks.length > 0 && (
120-
<div class="see-also-section">
121-
<h4>See Also</h4>
122-
<ul>
123-
{seeAlsoLinks.map((link: any) => (
124-
(link.name === event.id) && (
125-
<li>
126-
<strong>{link.name}</strong>
127-
</li>
128-
) || (
129-
<li>
130-
<a href={link.link}>{link.name}</a>
131-
</li>
132-
)
133-
))}
134-
</ul>
135-
</div>
136-
)}
122+
<SeeAlsoSection seeAlsoLinks={getPageSeeAlsoLinks(event)} currentId={event.id} />
137123
</StarlightPage>
138124
</div>

0 commit comments

Comments
 (0)