Repository navigation
UI Configuration and Development
Trakman UI plugin is a powerful tool which makes UI configuration and development easy. Changes to each widget placement and appearance can be made through configuration files without the need for any programming knowledge. Basic elements such as buttons can be added without any coding required.
Every UI component has its own config file (js file in the same directory as the component). These config can be used to modify appearance and behaviour of specific widgets for example change height, width or colours. There are also main UI configs in ui/config folder, which can be used to add simple elements, modify general UI appearance, widget placement, mods and IDS. The main configs are:
-
Buttons- Simple static buttons placement, appearance and utility. Modify this file if you want to add static buttons to your UI layout, or change the appearance of existing ones. -
RaceUi- General appearance of widgets used in race mode and widget layouts for each gamemode. Modify this file if you want to change position of a race mode widget, add a new widget to the layout or change stuff like background colours or margins. -
ResultUi- General appearance of widgets used in result mode and widget layout. Modify this file if you want to change position of a result mode widget, add a new widget to the layout or change stuff like background colours or margins. -
ComponentIds- Manialink ids of all UI components. If you want to add a new component add an entry for it in this file. Remember to keep gaps between ids because many widgets need multiple manialink ids for click features. (recommended gap size is 10000) -
Mod- Trackmania mods config. Supports multiple modes for each gamemode, has a random order option. Modify this file if you want to add a mod to your server. -
Icons- UI icons urls. Modify this file if you want to change some icon or add a new one. -
FlagIcons- UI flag icons urls. Modify this file if you want to change some flag or add a new one. -
PopupWindow- General appearance of UI pop-up windows (for example Maplist, Sector Records). Modify this file if you want to change stuff like background colours, margins or default window size. -
CustomUi- Special UI manialink config used to display or hide the default game appearance elements such as score table or chat. -
UtilsIds- Manialink ids of UI utils.
Abstract classes used to create manialink components.
Abstract class for static manialink components.
Methods:
-
constructor(id: number)
-
idComponent manialink ID
-
-
getRelativePosition(): { x: number, y: number, side: boolean }
Gets position relative to other static manialinks based on current static UI layout.-
ReturnsObject containing coordinates and side of the component
-
-
abstract display(params?: any): void
Displays the manialink to all the players**-
paramsOptional params
-
-
abstract displayToPlayer(login: string, params?: any): void
Displays the manialink to given player-
loginPlayer login -
paramsOptional params
-
-
hide(): void
Hides the manialink for all players -
abstract getHeight(): number
Gets component height. Used for static UI positioning
-
ReturnsComponent height
-
-
updatePosition(): void
Updates positionX, positionY, and side props, calls onPositionChange -
onPositionChange(): void
Executed on static UI layout change, by default calls the display() method -
updateIsDisplayed(): void
Updates _isDisplayed prop based on current static UI layout -
static onComponentCreated(callback: (component: StaticComponent) => void): void
Add a callback function to execute when new component object gets created-
callbackFunction to execute on event
-
-
static refreshStaticLayouts(): void
Refreshes static UI layouts and updates displayed components
Properties:
-
isDisplayedBoolean indicating whether component should be displayed according to preset display mode. -
idComponent manialink ID
Abstract class for dynamic manialink components.
Methods:
-
constructor(id: number)
-
idComponent manialink ID
-
-
abstract displayToPlayer(login: string, params?: any): void
Displays the manialink to given player-
loginPlayer login -
paramsOptional params
-
-
hideToPlayer(login: string) : void
Hides the manialink for given player-
loginPlayer login
-
Properties:
-
idComponent manialink ID
Abstract class for manialink popup windows.
generic <DisplayParams = any> DisplayParams is type passed from display function to construct functions.
Methods:
-
constructor(windowId: number, headerIcon: string, title: string, navbar: { name: string, actionId: number, privilege?: number }[] = [], windowWidth: number = config.windowWidth, windowHeight: number = config.windowHeight)
-
windowIdWindow ID. All PopupWindows have the same manialink ID. Use openId to access this property -
headerIconHeader image url -
titleHeader title -
navbarArray of objects containing navbar entry name, action ID and optional privilege -
windowWidthWindow width -
windowHeightWindow height
-
-
displayToPlayer(login: string, params?: DisplayParams, topRightText?: string, privilege?: number, title?: string, icon?: string): Promise
Displays window to given player based on manialink XML strings returned by construct methods. -
loginPlayer login -
paramsDisplay params to be passed to construct methods -
topRightTextText displayed in right part of the header -
privilegePlayer privilege -
titleIf set given title is displayed instead of the title passed in constructor -
iconIf set given icon is displayed instead of the icon passed in constructor -
abstract constructContent(login: string, params?: DisplayParams, privilege?: number): string | Promise
Method called on displayToPlayer. It returns manialink XML string to be displayed inside window content. -
loginPlayer login -
paramsDisplay params passed to displayToPlayer -
privilegePlayer privilege -
ReturnsContent XML string -
abstract constructFooter(login: string, params?: DisplayParams, privilege?: number): string | Promise
Method called on displayToPlayer. It returns manialink XML string to be displayed inside window footer. -
loginPlayer login -
paramsDisplay params passed to displayToPlayer -
privilegePlayer privilege -
ReturnsFooter XML string -
constructNavbar(login: string, params?: DisplayParams, privilege?: number): string
Method called on displayToPlayer, by default it constructs navbar from parameters passed to constructor. -
loginPlayer login -
paramsDisplay params passed to displayToPlayer -
privilegePlayer privilege -
ReturnsNavbar XML string -
onOpen(info: tm.ManialinkClickInfo): void
Method called on openId action ID. By default it displays the window to the player. -
infoManialink event info -
onClose(info: tm.ManialinkClickInfo): void
Method called on openId action ID. By default it hides the window to the player. -
infoManialink event info
Properties:
-
openIdAction ID used to open the window -
closeIdAction ID used to close the window -
headerIconHeader image url -
titleHeader title -
navbarNavbar object -
navbarHeightNavbar height -
windowWidthFull window width -
windowHeightFull window height -
contentWidthWindow content width (middle part) -
contentHeightWindow content height (middle part) -
headerHeightHeader height -
headerBackgroundHeader background colour -
backgroundBackground colour -
marginMargin between window parts -
footerHeightFooter height -
headerPageWidthRight header part width (usually used for page display)
Functions and classes providing utilities for manialink components.
Util to display tabular data in manialinks. It's used in almost every popup window and some static manialinks too.
Methods:
-
constructor(width: number, height: number, columnProportions: number[], rowProportions: number[], options?: { background?: string, margin?: number, headerBackground?: string })
-
widthGrid width -
heightGrid height -
columnProportionsGrid column proportions (proportions are relative to eachother like in CSS flexbox) -
rowProportionsGrid row proportions -
optionsOptional properties-
backgroundGrid cell background -
headerBackgroundGrid header cell background (1st row) -
marginMargin around grid cells
-
-
-
constructXml(objectsOrFunctions: (GridCellFunction | GridCellObject)[]): string
Creates grid XML string from passed callback functions. Use GridCellObjects if you want to change some property for specific grid cell eg. rowspan.-
objectsOrFunctionsArray of GridCellFunctions functions or GridCellObjects -
ReturnsGrid XML string
-
Properties:
-
widthGrid width -
heightGrid height -
columnWidthsWidth of each grid column -
rowHeightsHeight of each grid row -
columnsColumn count -
rowsRow count -
backgroundBackground colour -
marginMargin between cells and around grid -
headerBgHeader background colour
Util to display list data in manialinks. Displays 3 columns of data from which one is index. It's used in result screen static manialinks eg. Top Donations.
Methods:
-
constructor(entries: number, width: number, height: number, columnProportions: number[], options?: { background?: string, headerBg?: string })
-
entriesNumber of entries to display -
widthList width -
heightList height -
columnProportionsList column proportions (proportions are relative to eachother like in CSS flexbox) -
optionsOptional properties-
backgroundList cell background -
headerBackgroundList header background
-
-
-
constructXml(col1: string[], col2: string[]): string
Constructs list XML from passed string arrays
-
col1Array of strings to display in column 1 -
col2Array of strings to display in column 2 -
ReturnsList XML string
-
Properties:
-
entriesDisplayed entries count -
heightList height -
widthList width -
columnProportionsList column proportions (proportions are relative to eachother like in CSS flexbox) -
backgroundBackground colour -
headerBgHeader background colour
Util to display record data in manialinks. It has index, name and time columns, but it also can display more data on click eg. checkpoints. Records and time colours are displayed relative to players personal record. It's used in static record lists eg. Local Records.
Methods:
-
constructor(preset: 'result' | 'race', parentId: number, width: number, height: number, rows: number, side: boolean, topCount: number, maxCount: number, noRecordEntry: boolean, options?: { getColoursFromPb?: true })
-
presetDefault preset options to use -
parentIdParent element manialink ID -
widthList width -
heightList height -
rowsList row count -
sideSide on which list is positioned needed for click info display (true is right) -
topCountNumber of records which are always displayed regardless of player personal record -
maxCountMax record count needed for click actionIds -
noRecordEntryIf true, a placeholder entry gets displayed at the end of the list if the player has no personal record -
optionsOptional parameters-
getColoursFromPbIf true list time colours are relative to player personal records
-
-
-
onClick(callback: (info: tm.ManialinkClickInfo) => void): void
Registers a callback function to execute on record click-
callbackCallback function, it takes ManialinkClickInfo as a parameter
-
-
constructXml(login: string, allRecords: UiRecord[]): string
Constructs record list XML for given player from passed array of record objects.-
loginPlayer login -
allRecordsArray of record objects TODO LINK -
ReturnsRecord list XML string
-
Properties:
-
infoColumnsInfo grid column count -
infoColumnWidthInfo grid column width -
infoIconWidthInfo icon width -
infoIconInfo icon url -
infoBackgroundInfo background colour -
backgroundBackground colour -
headerBackgroundHeader background colour -
markerWidthMarker width -
parentIdParent element manialink ID -
configPresent config used -
columnWidthsList column widths -
rowsList row count -
rowHeightList row height -
widthList width -
sideList side (true is right) -
topCountNumber of records which are always displayed regardless of player personal record -
markersMarker icons -
downloadIconDownload icon url -
timeColours: Time string colours
Types:
-
RLImage
Record list image object-
urlImage url -
horizontalPaddingOptional horizontal padding, relative to the parent element -
verticalPaddingOptional vertical padding, relative to the parent element
-
-
RLRecord
Record list record object-
timeRecord time -
textText to display instead of time -
loginPlayer login (displayed on click) -
namePlayer name -
dateRecord date (displayed on click) -
checkpointsRecord checkpoints (displayed after click) -
urlIf set the menu displayed on click will have a button redirecting to given url -
pointsPoints amount displayed next to the record -
colourPoints amount background colour -
imageImage to display instead of time -
markerImageCustom marker image to display instead of default marker
-
Util to display horizontal navbar, used by popup windows.
Methods:
-
constructor(buttons: { name: string, actionId: number,
privilege?: number }[], width: number, height: number | null = config.height, background: string = config.background, hoverImgUrl: string = config.hoverImage)
-
buttonsArray of button objects -
widthNavbar width -
heightNavbar height -
backgroundNavbar background -
hoverImgUrlBackground image to display on button hover
-
-
getButtonCount(privilege: number = 0): number
Gets button count for given privilege-
privilegePrivilege (0 by default) -
ReturnsButton count
-
-
constructXml(privilege: number = 0): string
Creates navbar XML string for given privilege-
privilegePrivilege (0 by default) -
ReturnsNavbar XML string
-
Properties:
-
widthNavbar width -
heightNavbar height -
hoverImageBackground image displayed on button hover -
backgroundBackground colour
Util to display manialink headers in static UI. Methods:
-
constructor(preset: 'race' | 'result' = 'race', options: Partial = {})
-
presetDefault preset options to use -
optionsOptional parameters. Parameters in this object override preset parameters. TODO Interface
-
-
constructXml(text: string, icon: string, side: boolean, options: Partial = {}): string Constructs header manialink used in static UI
-
textHeader text -
iconHeader icon -
sideHeader side. Text and icon are displayed in different order depending on side (true is right) -
optionsOptional parameters. Parameters in this object override parameters in preset and constructor. TODO Interface -
ReturnsHeader XML string
-
Properties:
-
optionsHeader options TODO Interface -
raceHeightDefault height in race preset -
resultHeightDefualt height in result preset -
racePresetRace preset options -
resultPreset= Result preset options
Util to manage pagination and render page change buttons. It's used in almost every popup window. Use the onPageChange property to listen for page changes. Remember to use destroy() before deleting the object to avoid memory leaks.
Methods:
-
constructor(parentId: number, parentWidth: number, parentHeight: number, pageCount: number, defaultPage: number = 1, noMidGap?: true)
-
parentIdParent element manialink id -
parentWidthParent element width -
parentHeightParent element height -
pageCountInitial page count -
defaultPageDefault page (will be displayed if no page is specified) -
noMidGapIf true there will be no bonus gap between previous and next buttons
-
-
constructXml(page: number): string
Constructs page change buttons XML for given player login-
loginPlayer login -
ReturnsPage change buttons XML string
-
-
constructXml(login: string): string
Constructs page change buttons XML for given page number-
pagePage number -
ReturnsPage change buttons XML string
-
-
getPageByLogin(login: string): number
Gets current page of a given player.-
loginPlayer login -
ResetPage number
-
-
setPageForLogin(login: string, page: number): number
Sets page for a given player-
loginPlayer login -
pagePage number -
ReturnsPage number
-
-
setPageCount(pageCount: number): void
Sets page count-
pageCountPage count
-
-
resetPlayerPages(): void
Resets current player page positions. -
destroy(): void
Removes click listener. Use this before deleting the object to avoid memory leaks.
Properties:-
onPageChangeSets function to execute on page change -
pageCountAmount of pages -
buttonCountAmount of currently displayed buttons. It's relative to the page count -
parentIdParent element ID -
defaultPageDefault page (will be displayed if no page is specified) -
buttonWButton width -
buttonHButton height -
paddingIcon padding -
marginMargin between buttons -
iconWIcon width -
iconHIcon height -
idsIds used by paginator buttons -
widthPaginator width -
heightPaginator height -
yPosY axis position of paginator buttons -
xPosX axis positions of paginator buttons -
noMidGapIf true there is no bonus gap between previous and next buttons
-
Util to manage votes and render vote manialink window.
Methods:
-
constructor(callerLogin: string, goal: number, headerMessage: string, chatMessage: string, seconds: number, iconUrl: string)
-
callerLoginLogin of the player who called the vote -
goalRatio of votes needed to pass the vote (must be between 0 and 1) -
headerMessageMessage displayed in vote window header -
chatMessageChat message sent to chat on vote start -
secondsAmount of time to vote -
iconUrlIcon image url
-
-
startAndGetResult(eligibleLogins: string[]): Promise<boolean | { result: boolean, caller?: tm.Player }> | undefined
Starts the vote and awaits result.-
eligibleLoginsList of logins of players that can vote -
ReturnsVote result as boolean if time ran out or all the players voted, object containing result and optional caller player object if vote got passed or cancelled, undefined if there is another vote running
-
-
pass(caller?: tm.Player): void
Passes the vote-
callerCaller player object
-
-
cancel(caller?: tm.Player): void
Cancels the vote-
callerCaller player object
-
(actionId: number, parentWidth: number, parentHeight: number, options?: CloseButtonOptions): string
Constructs XML string for "X" button manialink. Used in popup windows.
-
actionIdAction ID to execute on click -
parentWidthWidth of parent element -
parentHeightHeight of parent element -
optionsOptional properties TODO LINK -
ReturnsButton XML string
(actionId: number, zIndex: number = -100): string
Constructs an invisible manialink covering the entire screen with given actionId and zIndex.
-
actionIdManialink Action ID -
zIndexManialink Z position -
ReturnsManialink XML string
(checkpoints: number[][]): ('best' | 'worst' | 'equal' | undefined)[][]
Finds best, equal and worst times for each checkpoint.
-
checkpoints2D array containing checkpoint times -
Returns2D array containing checkpoint types
(key: 'F5' | 'F6' | 'F7', callback: (info: tm.ManialinkClickInfo) => void, importance: number)
Registers a callback function to execute on given key press.
-
keyKey to register listener on -
callbackFunction to execute on key press, it takes ManialinkClickInfo as a parameter -
importanceImportance index - only the function with highest importance index will get executed
(callback: (info: tm.ManialinkClickInfo) => void)
Removes a key listener.
-
callbackReference to function to remove
(actionId: number, callback: (info: tm.ManialinkClickInfo) => void): void
Adds a callback function to execute on given Action ID.
-
actionIdManialink Action ID -
callbackCallback function, it takes ManialinkClickInfo as a parameter
(actionId: number, range: number, callback: (info: tm.ManialinkClickInfo, actionIdOffset: number) => void): void
Adds a callback function to execute on given Action ID range.
-
actionIdStarting manialink Action ID -
rangeRange of Action IDs (inludes starting Action ID) -
callbackCallback function, it takes ManialinkClickInfo and id offset as a parameter
(callback: (info: tm.ManialinkClickInfo) => void)
Removes a manialink listener.
-
callbackReference to function to remove
(iconUrl: string, text1: string, text2: string, width: number, height: number, options?: StaticButtonOptions): string
Constructs button manialink used in static UI.
-
iconUrlButton image url -
text1Top text -
text2Bottom text -
widthButton width -
heightButton height -
optionsOptional parameters TODO LINK -
ReturnsButton XML string
(text: string, parentWidth: number, parentHeight: number, options?: UITextOptions): string
Constructs manialink with centered text.
-
textText to display -
parentWidthParent element width -
parentHeightParent element height -
optionsOptional parameters TODO LINK -
ReturnsText XML string
(text: string, parentWidth: number, parentHeight: number, options?: UITextOptions): string
Constructs manialink with left aligned and vertically centered text.
-
textText to display -
parentWidthParent element width -
parentHeightParent element height -
optionsOptional parameters -
ReturnsText XML string
(text: string, parentWidth: number, parentHeight: number, options?: UITextOptions): string
Constructs manialink with right aligned and vertically centered text
-
textText to display -
parentWidthParent element width -
parentHeightParent element height -
optionsOptional parameters -
ReturnsText XML string
(text: string, parentWidth: number, parentHeight: number, options?: UITextOptions): string
Constructs manialink with horizontally centered text
-
textText to display -
parentWidthParent element width -
parentHeightParent element height -
optionsOptional parameters -
ReturnsText XML string