Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Guad

[.NET] NativeUI

Recommended Posts

unknown modder

Hello Again, sorry for asking so many questions but can someone help me with this code, it doesnt seem to work.

Thanks :D

http://pastebin.com/D7D52tmb

Whats not working. It wont compile, it throws an error when you run it - in which case post error logs(scripthookvdotnet), the menu doesnt show, the menu shows but options dont work etc

Share this post


Link to post
Share on other sites
ISOFX

 

Hello Again, sorry for asking so many questions but can someone help me with this code, it doesnt seem to work.

Thanks :D

http://pastebin.com/D7D52tmb

Whats not working. It wont compile, it throws an error when you run it - in which case post error logs(scripthookvdotnet), the menu doesnt show, the menu shows but options dont work etc

 

Oh no i was so stupid i got the sub menu parts wrong but i got it all working perfectly :) but now im going to learn how to use check boxes from the example menu. :) btw @Guad Nice Menu Base! (BEST) :)

Share this post


Link to post
Share on other sites
frodzet

Suggestion:

 

New feature: when you hover over your screen's edge, the camera will rotate and the cursor will change sprites.

 

should be disabled by default :-) The feature only occurs at a few of GTA's own menus.

Edited by frodzet

Share this post


Link to post
Share on other sites
Guad

Suggestion:

 

New feature: when you hover over your screen's edge, the camera will rotate and the cursor will change sprites.

 

should be disabled by default :-) The feature only occurs at a few of GTA's own menus.

 

Well you can disable it yourself if you wish to.

Share this post


Link to post
Share on other sites
frodzet

 

Suggestion:

 

New feature: when you hover over your screen's edge, the camera will rotate and the cursor will change sprites.

 

should be disabled by default :-) The feature only occurs at a few of GTA's own menus.

 

Well you can disable it yourself if you wish to.

 

Oh, i'm aware of that :-) Just saying being disabled by default would make more sense :-)

 

Nevermind! I just figured it is actually on my default, it's just that the screen turns even when the mouse is hovering an item in the menu (this should not be the case) :-)

Edited by frodzet

Share this post


Link to post
Share on other sites
frodzet

Is it possible to prevent the menu from going back one step when pressing P and instead open the pause menu? :-) I've tried to suppress the key, but can't seem to get it working :-)

 

Thanks :-)

Share this post


Link to post
Share on other sites
Guad

Is it possible to prevent the menu from going back one step when pressing P and instead open the pause menu? :-) I've tried to suppress the key, but can't seem to get it working :-)

 

Thanks :-)

 

myMenu.ResetKey(MenuControls.Back);

myMenu.SetKey(MenuControls.Back, GTA.Control.PhoneCancel);

Share this post


Link to post
Share on other sites
frodzet

 

Is it possible to prevent the menu from going back one step when pressing P and instead open the pause menu? :-) I've tried to suppress the key, but can't seem to get it working :-)

 

Thanks :-)

 

myMenu.ResetKey(MenuControls.Back);

myMenu.SetKey(MenuControls.Back, GTA.Control.PhoneCancel);

 

 

Alright, so is there a way that i can override the Menu so that the pause menu opens on P (or any other keypress for that matter)? :-) Because i want to be able to set a marker on the map while the menu is open so that when i exit the pause menu i'm back at the same place in my menu as before :-) Else i would have to first close the menu, set a marker, then open the menu and go to my TeleportToMarkerButton.

Edited by frodzet

Share this post


Link to post
Share on other sites
GeorgeZhang

is it possible to make a picture attach to an item (much like how the item descriptions work)?

it would be even more amazing

 

EDIT:also, is it possible to add support for "foreach" method to MenuPool? 'cause when i was trying to get all menus in _menupool with "foreach", it says " NativeUI.MenuPool does not contain a public definition for GetEnumerator"

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
Guad

is it possible to make a picture attach to an item (much like how the item descriptions work)?

it would be even more amazing

 

EDIT:also, is it possible to add support for "foreach" method to MenuPool? 'cause when i was trying to get all menus in _menupool with "foreach", it says " NativeUI.MenuPool does not contain a public definition for GetEnumerator"

For the picture, you can call Sprite.DrawTexture in a loop.

 

And for the menupool use the ToList() method

Share this post


Link to post
Share on other sites
GeorgeZhang

 

is it possible to make a picture attach to an item (much like how the item descriptions work)?

it would be even more amazing

 

EDIT:also, is it possible to add support for "foreach" method to MenuPool? 'cause when i was trying to get all menus in _menupool with "foreach", it says " NativeUI.MenuPool does not contain a public definition for GetEnumerator"

For the picture, you can call Sprite.DrawTexture in a loop.

 

And for the menupool use the ToList() method

 

ok thanks. btw, i am still having trouble changing controls, like i cannot set control keys to numpad keys, i use this code:

mainmenu.ResetKey(UIMenu.MenuControls.Up);mainmenu.SetKey(UIMenu.MenuControls.Up, Keys.NumPad8);

please help

Share this post


Link to post
Share on other sites
Guad

 

 

is it possible to make a picture attach to an item (much like how the item descriptions work)?

it would be even more amazing

 

EDIT:also, is it possible to add support for "foreach" method to MenuPool? 'cause when i was trying to get all menus in _menupool with "foreach", it says " NativeUI.MenuPool does not contain a public definition for GetEnumerator"

For the picture, you can call Sprite.DrawTexture in a loop.

 

And for the menupool use the ToList() method

 

ok thanks. btw, i am still having trouble changing controls, like i cannot set control keys to numpad keys, i use this code:

mainmenu.ResetKey(UIMenu.MenuControls.Up);mainmenu.SetKey(UIMenu.MenuControls.Up, Keys.NumPad8);

please help

 

If you're using Keys, you need to have a menuPool.ProcessKey(key.KeyCode) in your OnKeyDown event

Share this post


Link to post
Share on other sites
alex8b

Bug:

If an item in the list is double then there are problems with displaying 0.0 and 0.1 (-0.1). It shows something like E323483480984092238489023+32423423423

Share this post


Link to post
Share on other sites
frodzet

Bug:

If an item in the list is double then there are problems with displaying 0.0 and 0.1 (-0.1). It shows something like E323483480984092238489023+32423423423

 

It's something on your side, not something related to NativeUI. As you can see in the picture below, lists accepts double values:

 

tDVjEi2.jpg

Share this post


Link to post
Share on other sites
alex8b

 

Bug:

If an item in the list is double then there are problems with displaying 0.0 and 0.1 (-0.1). It shows something like E323483480984092238489023+32423423423

 

It's something on your side, not something related to NativeUI. As you can see in the picture below, lists accepts double values:

 

It's because of the way I generate the list. I iterate and add 0.1. But it should apply rounding when displays it anyway... :/

Share this post


Link to post
Share on other sites
frodzet

 

 

Bug:

If an item in the list is double then there are problems with displaying 0.0 and 0.1 (-0.1). It shows something like E323483480984092238489023+32423423423

 

It's something on your side, not something related to NativeUI. As you can see in the picture below, lists accepts double values:

 

It's because of the way I generate the list. I iterate and add 0.1. But it should apply rounding when displays it anyway... :/

 

You're sure you are iterating using the right type? :-)

Share this post


Link to post
Share on other sites
GeorgeZhang

ok i have another problem; when i set my own key, the menu will process the key multiple times, for instance i have four layers of menu and when i select the item in mainmenu it jumped straight to 4th. menu... tested, only happens when i set my own key, thanks for all your help!

 

EDIT: how to i set a "game sprite" to the banner? also is there a way to make the menu only takes keyboard commands but not mouse buttons?

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
Guad

 

 

Bug:

If an item in the list is double then there are problems with displaying 0.0 and 0.1 (-0.1). It shows something like E323483480984092238489023+32423423423

 

It's something on your side, not something related to NativeUI. As you can see in the picture below, lists accepts double values:

 

It's because of the way I generate the list. I iterate and add 0.1. But it should apply rounding when displays it anyway... :/

 

 

The list just calls the ToString method of your dynamic item. You can do it yourself by rounding it, calling ToString and then add it to the list.

Edited by Guad

Share this post


Link to post
Share on other sites
frodzet

Can i ask why OnItemSelect has an index identifier while OnCheckChange does not? :-)

Share this post


Link to post
Share on other sites
ardaozkal

Looks awesome! Will take a while to recode ~6000 lines of code with this, but that's what the community wants :)http://strawpoll.me/5094464/r

Share this post


Link to post
Share on other sites
Guad

Can i ask why OnItemSelect has an index identifier while OnCheckChange does not? :-)

Dunno, but you can always access your checkbox item's Parent property, which returns the menu, and then access CurrentSelection.

Share this post


Link to post
Share on other sites
frodzet

 

Can i ask why OnItemSelect has an index identifier while OnCheckChange does not? :-)

Dunno, but you can always access your checkbox item's Parent property, which returns the menu, and then access CurrentSelection.

 

 

Yeah, i figured :-) Just wondering why the behavior of those two events are working differently :-)

Share this post


Link to post
Share on other sites
GeorgeZhang

ok i have another problem; when i set my own key, the menu will process the key multiple times, for instance i have four layers of menu and when i select the item in mainmenu it jumped straight to 4th. menu... tested, only happens when i set my own key, thanks for all your help!

 

EDIT: how to i set a "game sprite" to the banner? also is there a way to make the menu only takes keyboard commands but not mouse buttons?

please help me

 

EDIT: ok i figured out how to fix the key:

if (e.KeyCode == Keys.F9)   _pool.ProcessKey(Keys.F9);

but still, how to set the banner to game sprite??

Edited by GeorgeZhang

Share this post


Link to post
Share on other sites
Guad

 

ok i have another problem; when i set my own key, the menu will process the key multiple times, for instance i have four layers of menu and when i select the item in mainmenu it jumped straight to 4th. menu... tested, only happens when i set my own key, thanks for all your help!

 

EDIT: how to i set a "game sprite" to the banner? also is there a way to make the menu only takes keyboard commands but not mouse buttons?

please help me

 

EDIT: ok i figured out how to fix the key:

if (e.KeyCode == Keys.F9)   _pool.ProcessKey(Keys.F9);

but still, how to set the banner to game sprite??

 

 

myMenu.SetBannerType(new Sprite("yourSpriteLibrary", "yourSpriteName", new Point(0,0), new Size(0,0));

also you should have set it to _pool.ProcessKey(e.KeyCode); at the beginning of your OnKeyDown event handler

Share this post


Link to post
Share on other sites
GTA Imperium

Would awesome to have this base in C++:).

Share this post


Link to post
Share on other sites
GeorgeZhang

Hello I have a question, i thought you might know how to use UI.DrawTexture? What is the param "filename"? Where can I find textures to draw, like radar blips or weapon icons?

Share this post


Link to post
Share on other sites
Guad

Hello I have a question, i thought you might know how to use UI.DrawTexture? What is the param "filename"? Where can I find textures to draw, like radar blips or weapon icons?

You can use NativeUI.Sprite.DrawTexture(string filename, Point position, Size size)

filename parameter is the path to your custom texture, you can place your picture in the scripts folder and pass "scripts\\mypic.png" as the filename.

You can also use pictures embedded in your project. For that drag your picture to your project in the project solution, and select it's property as "Embedded Resource". then call once string myPicturePath = NativeUI.Sprite.WriteFileFromResources(Assembly.GetExecutingAssembly(), "myNamespace.mypic.png"); and then use it in DrawTexture. Note that you have to include your default namespace in WriteFileFromResources. You can view it in Properties.

 

As for what textures, that's up to you.

Share this post


Link to post
Share on other sites
GeorgeZhang

 

Hello I have a question, i thought you might know how to use UI.DrawTexture? What is the param "filename"? Where can I find textures to draw, like radar blips or weapon icons?

You can use NativeUI.Sprite.DrawTexture(string filename, Point position, Size size)

filename parameter is the path to your custom texture, you can place your picture in the scripts folder and pass "scripts\\mypic.png" as the filename.

You can also use pictures embedded in your project. For that drag your picture to your project in the project solution, and select it's property as "Embedded Resource". then call once string myPicturePath = NativeUI.Sprite.WriteFileFromResources(Assembly.GetExecutingAssembly(), "myNamespace.mypic.png"); and then use it in DrawTexture. Note that you have to include your default namespace in WriteFileFromResources. You can view it in Properties.

 

As for what textures, that's up to you.

 

The first one worked. but the second one crashed the game...I guess it's my problem. What about ingame textures?

Share this post


Link to post
Share on other sites
dehan

Any way to disable backspace/right click making the menu close, Guad?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 4 Users Currently Viewing
    0 Members, 0 Anonymous, 4 Guests

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.