Coder Social home page Coder Social logo

monstertaeratto / alt-v-nativeui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from durtyfree/alt-v-nativeui

0.0 0.0 0.0 268 KB

NativeUI for GTA V alt:V Multiplayer mod written in Javascript / TypeScript

Home Page: https://altv.mp/

License: Apache License 2.0

TypeScript 47.24% JavaScript 52.76%

alt-v-nativeui's Introduction

alt:V-NativeUI

This project is a (fully TypeScript compatible) port of RageMP-NativeUI Kar for alt:V. It provides a simple way to use NativeUI menus in your clientside scripts. A lot of credits to datWeazel who made the initial port of the RageMP-NativeUI.

Usage:

With bundler:

  1. Create in your package.json location a file named .npmrc and add this line:
    @durtyfree:registry=https://npm.pkg.github.com
    
  2. Install by run npm install --save @durtyfree/altv-nativeui.
  3. Add this line to top of file where you want to use NativeUI.
    import * as NativeUI from "@durtyfree/altv-nativeui";

Without bundler:

  1. Download .zip archive you want from releases page.
  2. Unpack archive in client's folder, and import like any other file:
    # nativeui-min
    import * as NativeUI from "nativeui/nativeui.min.js";
    # nativeui
    import * as NativeUi from "nativeui/nativeui.js";
    • Don't forget include nativeui folder in client-files section of your resource.cfg (if needed)

See examples folder for alt:V resource examples.

Example Menu

import * as NativeUI from 'includes/NativeUIMenu/NativeUI.mjs';

const ui = new NativeUI.Menu("NativeUI Test", "Test Subtitle", new NativeUI.Point(50, 50));
ui.AddItem(new NativeUI.UIMenuListItem(
  	"List Item",
   	"Description for List Item",
   	new NativeUI.ItemsCollection(["Item 1", "Item 2", "Item 3"])
));

ui.AddItem(new NativeUI.UIMenuSliderItem(
  	"Slider Item",
   	["Fugiat", "pariatur", "consectetur", "ex", "duis", "magna", "nostrud", "et", "dolor", "laboris"],
   	5,
   	"Fugiat pariatur consectetur ex duis magna nostrud et dolor laboris est do pariatur amet sint.",
   	true
));

ui.AddItem(new NativeUI.UIMenuCheckboxItem(
  	"Checkbox Item",
   	false,
   	"Fugiat pariatur consectetur ex duis magna nostrud et dolor laboris est do pariatur amet sint."
));

ui.ItemSelect.on(item => {
  	if (item instanceof NativeUI.UIMenuListItem) {
  		alt.log(item.SelectedItem.DisplayText, item.SelectedItem.Data);
   	} else if (item instanceof NativeUI.UIMenuSliderItem) {
   		alt.log(item.Text, item.Index, item.IndexToItem(item.Index));
   	} else {
   		alt.log(item.Text);
   	}
});

Result:
Result

alt-v-nativeui's People

Contributors

durtyfree avatar omermecitoglu avatar xmgamingmaster avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.