altv-os-menu-framework

Overview

alt:V Open Source MenuFramework

MenuFramework is a menu framework written for alt:V. This framework will help you implement intuitive menus quickly. Currently this framework is only available in JS. In case you want to help me adding TS support, please check the contact details on the bottom of this page.

Features

  • Components (default items, list items, checkbox items, input items, confirm items)
  • Built-in event handlers
  • For each component an item description
  • Support for emojis
  • Fully configurable design pattern (colours, scale, positioning)
  • Support for controllers and built in menu navigation using arrow keys, enter and backspace
  • all items, descriptions and menu titels can contain plain html markup language -> You could even add a video player to the description box if you want to
  • Colored text is supported with the feature mentioned above. Please see the example resource to get help.

Compile files

MenuFramework uses Svelte, Tailwind CSS with NodeJS. Before compiling the files make sure you have the latest Node.js version installed. Run following commands to download all necessary dependencies:

npm install

Now you can build the source by running following command:

npm run build

After the command is executed you will see a dist folder containing all the resource files. Copy the content of this folder to your own resource, or if you are using the example resource paste the files in menuframework-example/client/src/html.

Menu usage

To run the example resource copy it into your servers resources folder and add menuframework-example to your server.cfg. Now start and join your server and press M to open the example resource.

Menu Development

Menu creation

Make sure you import the source file by adding following import to your file:

import * as MenuFramework from './src/menu';

Create a menu by calling the MenuFramework.Menu constructor.

const menu = new MenuFramework.Menu(title);

Example:

const menu = new MenuFramework.Menu('Example');

Menu item creation

Use one of the following examples to create a new menu item.

// CREATE A BUTTON
new MenuFramework.MenuItem(text: string, description?: string, emoji?: string, disabled?: bool, data?: any, rightText?: string);

//CREATE A CONFIRM
new MenuFramework.ConfirmItem(text: string, confirmDenyText?: string, confirmAcceptText?: string, confirmed?: bool, description?: string, emoji?: string, disabled:? bool, data?: any);

//CREATE A RANGESLIDER
new MenuFramework.RangeSliderItem(text: string, min: int, max: int, currentSelection?: int, description?: string, emoji?: string, disabled?: bool, data?: any);

//CREATE A CHECKBOX
new MenuFramework.CheckboxItem(text: string, checked?: bool, description?: string, emoji?: string, disabled?: bool, data?: any);

//CREATE A LIST
new MenuFramework.ListItem(text: string, values?: Array[], initialIndex?: int, description?: string, emoji?: string, disabled?: bool, data?: any);

//CREATE AN AUTOLIST
new MenuFramework.AutoListItem(text: string, min: int, max:int, initialIndex?: int, description?: string, emoji?: string, disabled?: bool, data?: any);

//CREATE AN INPUT
new MenuFramework.InputItem(text: string, maxLength?: int, placeholder?: string, value?: any, description?: string, emoji?: string, disabled?: bool, data?: any);

Example:

const menu = new MenuFramework.Menu('Menu');
const item = new MenuFramework.MenuItem('Hello World');
menu.addItem(item);

//Or in shorthand version
const menu = new MenuFramework.Menu('Menu');
menu.addItem(new MenuFramework.MenuItem('Hello World');

Important notice to menu items!

Items can be shared across multiple menus. To change attributes of the menu item use the setters and getters, not the variables starting with _ You need to add items to a menu, so you can interact with it.

menu.addItem(item);

Events

You can listen to events that are emitted by user inputs.

Listen to an event by adding a handler:

    menu.itemSelect.on((item,index) => {
        alt.log(`Selected item ${item.text} @${index}`);
    });

AVAILBALE EVENTS

menuOpen() //Called on menu open -> called BEFORE the menu is actually opened and sent to the webView, so if you do changes on each menu open, it won't cause lags
menuClose(noParentMenuOpened) // called on menu close
checkboxChange(item,state) //called on checkbox change
rangeSliderChange(item,newValue) //called on range slider change
itemSelect(item,index) // called when selecting an item
confirmationSubmit(item,confirmed) //called when selecting an confirmation item
confirmationChange(item,confirmed) //called when confirmation item changes
inputSubmit(item,newValue) //called when selecting an input item
inputChange(item,newValue) //called when typing into an input item
listChange(item,newIndex,oldIndex,newValue) //called when the list value changed (left arrow, right arrow)
autoListChange(item,newIndex,newValue) //called when the auto list changes (left arrow, right arrow)
indexChange(item,newIndex) //called when the current selected item changes (arrow up, arrow down)

Design Configuration

Menus can be designed in bundles as follows: Change the values for MenuFramework.menuConfiguration It contains following attributes:

left
top
height
fontSize
highlightColor
backgroundColor
fontColor
fontWeight
fontType
sound

If you want to add more fonts to the menu, please check the main.css in src/assets/css

Metas

The menu is using metas that you can use in any resource to process information you may need

  1. You can disable any menu input by giving the local player follwing meta
MenuFramework::State::PreventInput
  1. While the player is hovering over an input item, it will get focused and the game controls disabled. Also it will set following meta to true
MenuFramework::Action::IsTypingText

Functions

To get the most recent used Menu use MenuFramework.Menu.current

Menu functions:

addItem(item)
hasItem(item)
removeItem(item)
addSubmenu(subMenu,item)
removeSubmenu(item)
clear()
open()
close()

Menu variables you can set:

visible: bool
title: string
currentIndex: int

To manipulate menu items after creation check the attributes from the constructors above. Any attribute can be changed during runtime and will be applied to the item

Screenshots

The screenshots have been taken from the example resource

Example1 Example2 Example3
Example1 Example2 Example3

Help

In case you have any questions or concerns regarding this, feel free to contact me on Discord. Kaniggel#7263 Alternatively you can join my Discord and create a ticket: https://corrosive.eu/discord

License

This project is written by Kaniggel and published under MIT License

You might also like...

Pure JavaScript (VanillaJS) dropdown menu, with multiple select and searching support

JS Select Pure JavaScript (VanillaJS) dropdown menu, with multiple select and searching support How to use To use the select plugins, two main file mu

Mar 17, 2022

An Awesome Toggle Menu created with HTML,CSS,JQuery,font-awesome and line by line comment.

An Awesome Toggle Menu created with HTML,CSS,JQuery,font-awesome and line by line comment.

Demo : https://blackx-732.github.io/AwesomeMenu/ Under open source license No ©copyright issues Anyone can be modify this code as well Specifically we

Feb 9, 2021

Simple and lightweight vertical 3-dot context menu

3-dot Context Menu Thanks for taking a look at our 3-dot context menu for web development. The 3-dot context menu allows a simple and lightweight impl

Nov 6, 2022

A dependency-free Vanilla JS Accordion Menu Nested

🚀 A dependency-free Vanilla JS Accordion Menu Nested No dependencies, no automation build tools. Copy/paste and ready to use. CSS and JS are inlined

Dec 18, 2022

Responsive Dropdown Menu Bar

Responsive Dropdown Menu Watch it on youtube Responsive Dropdown Menu Beautiful and clean responsive navigation bar includes a beautiful drop-down sid

Oct 21, 2022

A lightweight vanilla JavaScript context menu library with FontAwesome support.

A lightweight vanilla JavaScript context menu library with FontAwesome support.

Contextify A lightweight vanilla JavaScript context menu library with FontAwesome support. This library was written for use in a personal project of m

Jun 1, 2022

A library that helps you write a static dropdown menu that follows the digital accessibility recommendations.

JSPanel A library that helps you write a static dropdown menu, a panel, that follows the digital accessibility recommendations. Get started First of a

Apr 29, 2021

The best UI framework out there 🦆 In development 🚀

The best UI framework out there 🦆 In development 🚀

Noia UI Getting Started | Community | Creators | 🚧 Noia UI 🚀 in development... 🚧 Getting Started # First clone this repository $ git clone https://

Mar 10, 2022

Typescript/Javascript framework for zk-SNARKs and snapps

snarkyJS snarkyJS is a Typescript/Javascript framework for writing zk-SNARKs and snapps. It allows you to construct zk-SNARK circuits in Typescript an

Jan 2, 2023
Comments
Owner
Kaniggel
Kaniggel
Obsidian-dataview-table-filter-menu - Dynamically created filter menu for dataview tables in obsidian

Dataview table Filter Menu for Obsidian Dynamically created filter menu for data

shiro 17 Sep 24, 2022
A little animation for a big menu where the letters of a word shuffle to become the first letter of each menu item.

Letter Shuffle Animation for a Menu A little animation for a big menu where the letters of a word shuffle to become the first letter of each menu item

Codrops 29 Dec 4, 2022
This restaurant project is a SPA (single-page application) website. The user can navigate between the home, menu and contact page. I used the MealDB API to display some menu items.

Fresh Cuisine This restaurant project is from the Odin Project and it is a SPA (single-page application) website. The user can navigate between the ho

Virag Kormoczy 7 Nov 2, 2022
jSide Menu is a well designed, simple and clean side navigation menu with dropdowns.

jQuery jSide Menu jSide Menu is a well designed, simple and clean side navigation menu with dropdowns. Browse: Live Demo & Using Guide Main Features F

CodeHim 24 Feb 14, 2022
Navigation-Menu-Javascript - A simple Navbar navigation using vanilla javascript, to change links to the active link when clicked.

Navigation-Menu-Javascript A simple Navbar navigation using vanilla javascript, to change links to the active link when clicked. Desktop view Mobile v

Ellis 2 Feb 16, 2021
MenuSlider-Javascript - How to create a menu slider with vanilla javascript

MenuSlider-Javascript How to create a menu slider with vanilla javascript Instal

Tarokh Mohammadi 1 Feb 8, 2022
A simple library to draw option menu or other popup inputs and layout on Node.js console.

console-gui-tools A simple library to draw option menu or other popup inputs and layout on Node.js console. console-gui-tools A simple Node.js library

Elia Lazzari 12 Dec 24, 2022
⛴ Manage Docker containers from the menu bar.

Captain INTRODUCTION Manage Docker containers. Instantly from the menu bar. See which containers are running and which have stopped. Conveniently star

Rick Wong 19 Dec 8, 2022
MetisMenu: Collapsible menu plugin with Vanilla-JS

metismenujs MetisMenu: Collapsible menu plugin with Vanilla-JS This plugin does not support any version of IE browser. Please consider following this

Osman Nuri Okumuş 115 Dec 23, 2022
Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu

Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu. More info in User Guide.

Oleksii Bilyk 5 Jul 31, 2022