Skip to content

Commit b956f86

Browse files
Add remaining 15 gui element types (Closes #13)
1 parent f4be1f7 commit b956f86

18 files changed

+82
-9
lines changed

elements/GUI/gui-button.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-button
2+
description: |
3+
The **GUI button** class represents GUI buttons in MTA's GUI system. It's only functionality is to detect whether client has clicked it.

elements/GUI/gui-checkbox.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-checkbox
2+
description: |
3+
The GUI checkbox class represents GUI checkboxes in MTA's GUI system. These can be checked or unchecked.

elements/GUI/gui-combobox.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-combobox
2+
description: |
3+
The GUI combobox class represents GUI comboboxes in MTA's GUI system. These are drop down lists that can contain large number of items.

elements/GUI/gui-edit.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-edit
2+
description: |
3+
The GUI edit field class represents GUI edit fields in MTA's GUI system. You can input text in these which you can afterwards check from the script. It can be used, for example when making a registration system.

elements/GUI/gui-gridlist.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-gridlist
2+
description: |
3+
The GUI gridlist class represents GUI gridlists in MTA's GUI system. It can be used for example as a selection list or as a list to view information about players (see [old scoreboard resource](/Resource:OldScoreboard)).

elements/GUI/gui-label.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-label
2+
description: |
3+
The GUI label class represents GUI labels in MTA's GUI system. These are simply a bunch of text which client cannot modify.

elements/GUI/gui-memo.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-memo
2+
description: |
3+
The GUI memo class represents GUI memos in MTA's GUI system. These are big multiline text fields to what you can type text by default. It is recommended to use [edit fields](/gui-edit) for smaller text inputting.

elements/GUI/gui-progressbar.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-progressbar
2+
description: |
3+
The GUI progress bar class represents GUI progress bars in MTA's GUI system. These are mostly used as loading bars because you can alter the percentage amount of progress in it.

elements/GUI/gui-radiobutton.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-radiobutton
2+
description: |
3+
The GUI radio button class represents GUI radio buttons in MTA's GUI system. These can be checked or unchecked and work quite similiar as the GUI checkboxes.

elements/GUI/gui-scrollbar.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-scrollbar
2+
description: |
3+
The GUI scrollbar class represents GUI scrollbars in MTA's GUI system. These can be moved with cursor and it's position can be checked and set by script. These are built by default to certain GUI elements ([gridlists](/gui-gridlist)) if they exceed the given size.

elements/GUI/gui-scrollpane.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-scrollpane
2+
description: |
3+
Todo

elements/GUI/gui-staticimage.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-staticimage
2+
description: |
3+
The GUI static image class represents GUI static images in MTA's GUI system. These are custom images which can be loaded to clients screen.

elements/GUI/gui-tab.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-tab
2+
description: |
3+
The GUI tab class represents GUI tabs in MTA's GUI system. These highly rely on GUI [tab panels](/gui-tabpanel) as they only can be created to them.

elements/GUI/gui-tabpanel.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-tabpanel
2+
description: |
3+
The GUI tab panel class represents GUI tab panels in MTA's GUI system. These are just layouts for GUI [tabs](/gui-tab) and highly rely on them. It is recommended to use GUI [windows](/gui-window) if you are not adding tabs to a tab panel.

elements/GUI/gui-window.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: gui-window
2+
description: |
3+
The GUI window class represents GUI windows in MTA's GUI system. These are mainly used as layout for other GUI elements. They can be moved and resized by default.

elements/info.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GUI and General category names are hardcoded

web/src/pages/[element].astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export async function getStaticPaths() {
1717
1818
const { element } = Astro.props;
1919
element.data.itemType = 'element';
20-
20+
element.data.niceName = element.data.name.charAt(0).toUpperCase() + element.data.name.slice(1);
21+
2122
---
2223
<StarlightPage frontmatter={{
2324
template: 'doc',

web/src/utils/general.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { marked } from 'marked';
22
import path from 'path';
33
import { getFunctionsByTypeByCategory } from '@src/utils/functions';
44
import { getEventsByTypeByCategory } from '@src/utils/events';
5+
import { getElementsByCategory, getElementCategory } from '@src/utils/elements';
56
import { getOOPClassesByCategory } from '@src/utils/classes';
67

78
export function renderInlineMarkdown(markdown: string): string | Promise<string> {
@@ -23,12 +24,15 @@ const titleCase = (str: string) =>
2324
str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
2425

2526
const makeTitle = (subType: string, category: string, type: string): string => {
26-
const categoryPart = titleCase(category);
27+
const isUpperCase = category === category.toUpperCase();
28+
const categoryPart = isUpperCase ? category : titleCase(category);
2729
const typePart = titleCase(type);
2830
if (subType === 'any') {
2931
return `${categoryPart} ${typePart}`;
3032
} else {
31-
return `${titleCase(subType)} ${categoryPart} ${typePart}`;
33+
const isUpperCase2 = subType === subType.toUpperCase();
34+
const subTypePart = isUpperCase2 ? subType : titleCase(subType);
35+
return `${subTypePart} ${categoryPart} ${typePart}`;
3236
}
3337
};
3438

@@ -53,6 +57,10 @@ const getItemsInCategory = (type: string, subType: string, category: string): an
5357
]
5458
: evByType?.[subType as keyof typeof evByType]?.[category] || [];
5559
}
60+
case 'elements': {
61+
const elementsByCategory = getElementsByCategory();
62+
return elementsByCategory?.[category] || [];
63+
}
5664
case 'classes': {
5765
const classesByCategory = getOOPClassesByCategory();
5866
return classesByCategory?.[category] || [];
@@ -142,12 +150,30 @@ export function getSeeAlsoLinksForItem(theItem: any): SeeAlsoLinkGroup[] {
142150
break;
143151
case 'element':
144152
seeAlso = see_also ?? [];
145-
addToSeeAlso = [
146-
`functions:any:${niceName}`,
147-
`events:any:${niceName}`,
148-
`functions:any:Element`,
149-
`events:any:Element`,
150-
];
153+
const elementCategory = getElementCategory(theItem);
154+
if (elementCategory === 'GUI') {
155+
// Show GUI functions, events and other GUI element types
156+
addToSeeAlso = [
157+
`functions:any:${elementCategory}`,
158+
`events:any:${elementCategory}`,
159+
`elements:any:${elementCategory}`,
160+
];
161+
} else if (elementCategory === 'General') {
162+
// Also show generic Element functions and events if category is General
163+
addToSeeAlso = [
164+
`functions:any:${niceName}`,
165+
`events:any:${niceName}`,
166+
`functions:any:Element`,
167+
`events:any:Element`,
168+
];
169+
}
170+
else {
171+
// Show all functions and events for the element type
172+
addToSeeAlso = [
173+
`functions:any:${niceName}`,
174+
`events:any:${niceName}`,
175+
];
176+
}
151177
break;
152178
case 'class':
153179
seeAlso = see_also ?? [];

0 commit comments

Comments
 (0)