Code Monkey home page Code Monkey logo

nativeui's Introduction

NativeUI is now deprecated!

Existing projects should migrate to LemonUI. Please check issue #136 for more information.

Feel free to check the LemonUI repository at https://github.com/justalemon/LemonUI

NativeUI

NativeUI Example

NativeUI is a ScriptHookDotNet based library that helps you quickly and easily build Rockstar-like menus.

Documentation

Take a look at our wiki page.

Features

  • Support for simple buttons, checkboxes and lists.
  • Support for custom banners from game sprites and your own textures.
  • Easy nested menus for fast and painless nested menu system.
  • Controller support.
  • Mouse controls.
  • Custom instructional buttons.
  • Support for all screen resolutions.
  • Item descriptions.
  • Rebindable keys and controls.
  • Badges to decorate your items.
  • Event-based callbacks.

Distribution

Please, do not distribute the .dll with your mod. This causes many old versions floating around on the internet. Instead, point your users to this post.

Special Thanks

Thanks to jedijosh920 for helping out on natives and making it look a lot more like Rockstar, thanks man.

License

Copyright (c) 2016 Phillipp

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nativeui's People

Contributors

benjaminfaal avatar camxxcore avatar edgekiller avatar guad avatar justalemon avatar kagikn avatar mcmtroffaes avatar romgerman avatar streetgt avatar tomilovsenya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativeui's Issues

ScriptHookV.Net 3.0 compatability

[21:53:42] [ERROR] Failed to instantiate script 'GTA_Realism.Realism' because constructor threw an exception:
System.TypeInitializationException: The type initializer for 'GTA_Realism.Menu' threw an exception. ---> System.MissingMethodException: Method not found: 'Void GTA.Scaleform..ctor(Int32)'.
at NativeUI.UIMenu..ctor(String title, String subtitle, Point offset, String spriteLibrary, String spriteName)
at NativeUI.UIMenu..ctor(String title, String subtitle)
at GTA_Realism.Menu..cctor()
--- End of inner exception stack trace ---
at GTA_Realism.Menu.Init()
at GTA_Realism.Realism..ctor()

Move camera with mouse (like inside los santos custom)

Can I move camera with mouse like inside los santos custom?
Becoz i'm currently creating a Premium Deluxe Motorsport in VB so character will be in teleport to a vehicle while in menu. so how to lock the gas, brake, left right turn controls and able to move the camera with mouse?

Move static methods to a helper class

Methods like

  • DisEnableControls
  • GetScreenResolutionMantainRatio
  • IsMouseInBounds
  • GetSafezoneBounds

Also normalize and make them return integer instead of floats:

  • GetScreenResolutionMantainRatio
  • GetSafezoneBounds

Modifying an UIMenuListItem

Is it possible to modify an UIMenuListItem in an UIMenu which has been loaded but not visible? I wish to update the list in background while another menu is visible.

Sprite.DrawTexture issue

When I use the DrawTexture function from Sprite it only shows my texture for what feels like 0.1 second and then removes it for screen.

Use it in GTA Network

Hi,
How can I add it into a GTA Network server? I tried it, but doesn't work...
How to inport DLL to JS script?

No License Intentional?

Is it intentional that you have not chosen a license for this repository?

Citation of GitHub's documentation about open source licensing:

You're under no obligation to choose a license. It's your right not to include one with your code or project, but please be aware of the implications. Generally speaking, the absence of a license means that the default copyright laws apply. This means that you retain all rights to your source code and that nobody else may reproduce, distribute, or create derivative works from your work. This might not be what you intend.

The reason why I'm asking is that I'm thinking about porting this project to the Python 3 Script Hook for GTA V. But without your permission, I have no right to do so (the same applies to many others, of course).

UIMenuItem extra properties (Sub Item)?

Currently have Text, Description, can we have extra field?
for Example I need to read a list of item from a database

Example Database:
.Text .SetRightLabel .SubItem(index)
AK47 | $7000 | ak47ModelNameHere
MG6 | $12000 | mg6ModelNameHere

How can I format a menu?

I cannot find any properties for

  • font size of the title
  • alignment of the title (left, center)
  • width of the menu box
  • color of the title box

Error with latest GitHub release (not 0.9)

Here's the error:
(Code has no errors, I think its something with the nativeUI calling the screenresolution, but it's typed wrong)
[09:07:33] [ERROR] Caught fatal unhandled exception:
System.MissingMethodException: Method not found: 'System.Drawing.Size GTA.Game.get_ScreenResolution()'.
at NativeUI.UIMenu.GetSafezoneBounds(Int32& safezoneX, Int32& safezoneY)
at NativeUI.UIMenu.ProcessMouse()
at NativeUI.MenuPool.ProcessMouse()
at Main.OnTick(Object sender, EventArgs e)
at GTA.Script.raise_Tick(Object value0, EventArgs value1)
at GTA.Script.MainLoop()

UIMenuListItem still triggers the event handler when Enabled is set to false

I have two UIMenuListItem entries on a menu and when one of them is set to a certain value, I want to disable the other one as the function of that item is no longer used.

However, if you set UIMenuListItem.Enabled = false; all it does is draw the text in grey and continues to change the values and trigger the event handler..

Enabled = false should mean don't trigger the event, don't change the values, don't do anything.

Another Error with latest GitHub release (not 0.9)

Sir, another error after update to your latest source code on github
Both your example menu and my menu wasn't show while i press the hotkey

[17:02:00] [DEBUG] Instantiating script 'PremiumDeluxeMotorsport.NET.pdmcarshop' in script domain 'ScriptDomain_E9FE744' ...
[17:02:00] [DEBUG] Started script 'PremiumDeluxeMotorsport.NET.pdmcarshop'.
[17:02:00] [ERROR] Caught fatal unhandled exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at NativeUI.MenuPool.<>c.b__8_0(UIMenu menu)
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at NativeUI.MenuPool.ProcessControl()
at NativeUI.MenuPool.ProcessMenus()
at PremiumDeluxeMotorsport.NET.pdmcarshop.OnTick(Object o, EventArgs e)
at GTA.Script.raise_Tick(Object value0, EventArgs value1)
at GTA.Script.MainLoop()

[Question] Small notifications.

Is there a way to make a small notification message that pops up on the bottom left of the screen, above the minimap? Kind of like a text message I guess. If not do you know where I could look to find that?

Can't get BigMessageThread working.

I'm fairly new to GTA scripting but I do have a good amount of training in C#. I've been trying to use this library (I'm currently making a mod), but I can't seem to get this to do anything... I'm not trying to actually show the message everytime I press 'b', I'm just test it out. Although nothing appears on screen. Maybe I read the documentation incorrectly. Hopefully you can help me out.

Here's a snippet:

public TreasurMapGTAV ()
    {
        KeyUp += TreasurMapGTAV_KeyUp;
    }

    private void TreasurMapGTAV_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.B)
        {
            BigMessageThread.MessageInstance.ShowMissionPassedMessage("Treasure Map Successfully loaded!");
        }
    }

Thanks in advance! :)

Can I pack NativeUI.dll into my mod rar?

Hi,
after ScriptHookVDotNet's menu functionality got messed up I switched to NativeUI. Alas the gamers have to download and install another dll now. To make it slightly more convenient for them I'd like to pack the NativeUI.dll along with my mod into the rar which I am about to upload. Do you give permission or do you insist that I just provide the link to here?

MenuPool - SubMenu "none Dynamic UIMenuItem"

NativeUI/blob/shvdn3/MenuPool.cs

Hey All,
I am proposing a Change to NativeUI.MenuPool
I needed to Enable / Disable a Submenu's button depending on another Menu's selection.

So if i change....
public UIMenu AddSubMenu(UIMenu menu, string text, string description)
{
  var item = new UIMenuItem(text, description);
  menu.AddItem(item);
  var submenu = new UIMenu(menu.Title.Caption, text);
  this.Add(submenu);
  menu.BindMenuToItem(submenu, item);
  return submenu;
}

To Become ....
public UIMenu AddSubMenu(UIMenu menu, UIMenuItem item)
{
menu.AddItem(item);
var submenu = new UIMenu(menu.Title.Caption, item.Text);
this.Add(submenu);
menu.BindMenuToItem(submenu, item);
return submenu;
}

  1. The Input of Strings Text, Description is swapped for a UIMenuItem input.

This allows for the same Submenu system creation but the user now has the ability to reference the submenu object. This changes the submenu item from being a dynamic private to a public static.

  1. The Overload method will no longer be required.

Let me know if i missed a simpler way of doing this, it works well in my Dev copy.

The only change users need to make is to Wrap the existing text, Description
AddSubMenu(UIMenu menu, text, description)
to
AddSubMenu(UIMenu menu, new UIMenuItem (text, description))

Or to keep reference..
UIMenuItem subMenuButton = new UIMenuItem (text, description);
AddSubMenu(UIMenu menu, subMenuButton);

subMenuButton can then be manipulated such as subMenuButton.Enabled = false;

Trying to display a custom image

I have been trying to display a custom image in gta 5 with your sprite example

                    Sprite.DrawTexture(Sprite.WriteFileFromResources(Assembly.GetExecutingAssembly(), "BTTF Time Travel.amber0.pung", Application.StartupPath + "\\image.png"), new Point(0, 1), new Size(10, 10));

the game keeps crashing with

fatal: directx "path of the image" texture creation failed.

Game exits.

GTA 5
dot net script hook 2.1
latest nativeUI

any help?

directx texture

when i use this
mainMenu = new UIMenu("CRIME LIFE", "rby Marhex");
mainMenu.SetBannerType(Sprite.WriteFileFromResources(Assembly.GetExecutingAssembly(), "team_fight.image.png"));
_menuPool.Add(mainMenu);

i get this error
[16:58:08] CORE: Creating texture 'C:\Users\heythem\AppData\Local\Temp\tmpD6A8.tmp', id 0
[16:58:08] FATAL: directx texture 'C:\Users\heythem\AppData\Local\Temp\tmpD6A8.tmp' creation failed

move renderingCamera

Hi all,

I have a function which sets the camera to the sky.

        public static void attatchToVeh2(Vehicle veh) {
            Vector3 pos = veh.Position;
            World.DestroyAllCameras();
            Vector3 position = pos;
            float fov = 60.0f;
            Camera camera = World.CreateCamera(position, new Vector3(-90f, 0f, 0f), fov);
            Function.Call(Hash.SET_CAM_INHERIT_ROLL_VEHICLE, camera.Handle, true);

            camera.AttachTo(veh, new Vector3(0f, 0f, 40f));
            camera.IsActive = true;
            World.RenderingCamera = camera;
        }

Everything is ok without calling the function via the menu.

When ever I call this function, when in the menu, it will force the next frame of the camera to the different rotation ( and this is fixed, I can't move).

How can I change the camera rotation while in the menu?

Using in-game texture for banner

Hi i seem to have an issue with your latest release see below:
image
i was testing this in the example menu, here is my code:
image

thanks for any help you can give :)

P.S Amazing work!!!

text rendering issue with UIMenuListItem

When I use a screen ratio that is not 16:9 UIMenuListItem does not properly render the text between the two arrows.
Resolutions tested:
With the Aspect Ratio setting set to auto

width height Works
800 600 No
1024 729 No
1280 600 No
1280 720 Yes
1280 729 No
1350 729 No
1366 768 Yes

800x600
image

how to make camera like in Benny's Motorworks?

how to make camera like in Benny's Motorworks?
and disable controls like Accelerate, Left, Right, Brake?
I try using Controls.DisableControl(0, Control.VehicleAccelerate) but its not working for me :(

ScriptHook.net V3 Compatability

Hey,

Im using the latest dev version of scripthook.net which has alot of changes that break NativeUI,
For my own use i made changes to your source to compile with my version of the library.

To save you time, i thought i would post you a copy.
Once the official V3 releases you could just finish off any remaining change.

The comments wouldn't let me attach a zip so ive hosted it on my webserver.
Download

Regards,
Tanj

Accented characters mess up the rest of the text

When using accented characters in item text or description, the in game result is very buggy:
nativeui
What was supposed to be written was:

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ.A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9

As you can see on the first line, the text doesn't automatically creates a new line and there are missing characters in the text:
M N O P Q R 7 8 9
M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9

It is very annoying when you need to write something in a language using accented characters...
I saw the same kind of problem with Russian characters, so maybe the problem comes from NativeUI only supporting simple ASCII characters?

At the moment, I put spaces in my text where the letters are "eaten" but it is ugly af.

Colour control characters causing bias in string width evaluation.

If you have the strings "This is a yellow string" and "This is a yyellow string", the width is being evaluated taking into account the colour control characters. The consequence of this is text wrapping when there is sufficient space left to display the wrapped words.

To see an example of this, create a UIMenuItem with the following properties.

new UIMenuItem("Some text", "~w~Type: ~y~Off-Road, ~w~Difficulty: ~y~Professional")

and another with these

new UIMenuItem("Some text", "Type: ~y~Off-Road, ~w~Difficulty: ~y~Professional")

Even though the visible textual content is identical, the top one will force the word Professional onto the second line, whereas the second one will leave everything on one line. The second one is fine if you want the first word to be white but it fails if you don't.

Ideally, upon creation of any menu item subtitle, the string needs to be passed through a control code removal function before being passed to the string width checking and then the width of that processed string storing as a value in the class. That way, the only additional processing that occurs is at creation time, which won't impact on performance... plus you get accurately wrapped coloured strings. There is an ideal Dictionary based solution on this page: https://stackoverflow.com/questions/1321331/replace-multiple-string-elements-in-c-sharp

You can see an example of how this affects presentation in this image. The amount of space in the top box makes it look really bad.

text-wrapping

Should add support for controls

Currently only custom keys can be used. This should either be switched to use custom native controls or both key presses and controls.

Random game crash with scripthookdotnet v2.0

Launching the menu like in your example:

if (!Pool.IsAnyMenuOpen())
TrainerMainMenu.Visible = !TrainerMainMenu.Visible;

it randomly crashes the game in the first or sometimes second launch:

Application: GTA5.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at nativeCall()
at GTA.Native.?A0xc46f6644.NativeTask.Run()
at GTA.ScriptDomain.DoTick()
at GTA.ScriptDomain.DoTick()
at .ManagedTick()


Faulting application name: GTA5.exe, version: 1.0.393.4, time stamp: 0x55a62e42
Faulting module name: KERNELBASE.dll, version: 10.0.10240.16384, time stamp: 0x559f38c3
Exception code: 0xe0434352
Fault offset: 0x000000000002a1c8


OS: windows 10
GTA ver: 393.4
Scripthookdotnet: 2.0
NativeUI: latest build from your latest source

Make Menu not closebale?

Hey, it would be pretty nice to let a menu be not closeable.
Is there anything I didn't see?

Right now I have to do it like this:

changeSkinMenu.OnMenuClose += ( sender ) => { changeSkinMenu.Visible = true; };

It's not a very clean solution.

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.