Jump to content

Qt to Lua - Create your MTA GUI outside of MTA


Kayl

Recommended Posts

Hello there,

Being quite active in scripting this past months, I inevitably had, at some point, to script some GUI.

Happy to discover the lua functions provided by MTA team, I followed the tutorial and created my first GUI.

Then, when I started to have more complex interfaces to create, I was discouraged by the time I spent playing with margins, positions, sizing in order to have something decent.

I had a look at the guieditor resource, which I liked, but then I was a bit disappointed by some of the aspects of GUI creation within MTA itself.

I create my scripts outside of MTA (notepad++ ftw, sorry I didn't try the unofficial script editor :D ), so why not my interfaces?

Furthermore, with my additional geeky/nerdy activities, I already happened to use the Qt Framework quite a lot for normal applications. Qt comes with a GUI Editor that I really like (especially the layout/space concept).

I therefore decided (a while ago, this is a late release) to create a small application - Qt to Lua - that converts the interfaces created with Qt Designer (the GUI editor of Qt) into lua code usable in your MTA resources.

Two screenshots for you to have a quick idea of the result (more available on the paged provided below):

In Qt Designer

xfdjs8.png

The result in MTA

sbu5gi.png

If you are interested, feel free to grab it and test it at the following URL:

http://dkrclan.com/?p=qttolua&large

MODERATION: http://www.mediafire.com/download/u24e3 ... tToLua.rar

You can just play with it without reading the shit load of details I provide in the URL above.

However if you want to really control what's going on, I suggest you take 10 minutes to have a look at the details, to make sure you can, from now on, create the best MTA interfaces ever 8):shock:

Most of the work I do for MTA is confined/reserved to the server I script for but this is my gift (if of course anyone is interested by it) to the community.

On a site note, I release this application just before a small week of holiday, I may not be able to respond to your questions/comments before a week. I apologize in advance for that.

------------------------

Updates:

- 17 June: Version 0.1.4

guiWindowSetSizable using the name of the window instead of _root > fixed

- 31 August: Version 0.1.5

Support of comboboxes (for MTA 1.1)

viewtopic.php?f=91&t=27739&start=15#p319392

- 15 October: Version 0.1.6

Support of scrollbars and label color

viewtopic.php?f=91&t=27739&p=323628#p323628

- 20 January 2011: Version 0.1.7

Fix of scrollbar export bug (scrollarea's own scrollbars where also exported)

viewtopic.php?p=335732#p335732

Edited by Guest
Link to comment
  • Replies 88
  • Created
  • Last Reply

Top Posters In This Topic

Cool!!

Now I don't really need to go into MTA SA to make GUIs anymore

Thanks very much Kayl, probably useful if you want to make GUI, but you don't have MTA SA. :D

Any ideas to make this sticky?

One suggestion: Now add DX things to the editor!

Edit: Wow, now this topic has a great adhesive glue! :P

Edited by Guest
Link to comment
  • 3 weeks later...

Really great job! One thing I ran into though:

Window name: wndLogin

Created code (not working): guiWindowSetSizable(gui["wndLogin"], false)

Should be (I guess): guiWindowSetSizable(gui["_root"], false)

Furthermore, the size of some elements is not very accurate in the actual MTA dialog compared to the draft in QT. But one can definitely live with that, and your tool is still a wonderful help and time-saver!

Link to comment

Thank you all for your comments and feedback.

And thanks to whoever glued the topic.

Jason_Gregory > Qt is a cross-plateform framework. It got extended to mobile phones first through QTopia and Trolltech was bought by Nokia only recently in the company's history. But it's more than suitable for normal desktop applications. Qt is also used as the core of KDE (linux).

XX3 > Indeed, good idea (dx functions integration). I'll have to think about that.

Ayanami > Indeed, the name of the main widget is not used (beside function name) and is accessible through gui._root or gui["root"]. This allows the rest of your code (window show/hide, destruction, etc) to always work with the same _root object.

As for the difference of size: make sure you use layouts as mentioned in the help but yes, I concur that for some widgets (mainly gridlist) there is still a difference. As you said, most of the time we can live with that so I didn't try to hack into it to make a perfect match.

Spider pork > Images can be used, have a look at the web page and the test resource. In QtDesigner use a QLabel and set its pixmap attribute (look at the example .qrc file). However it only works fine if the images and .qrc file are at the same level as the .ui file. The generated code contains, as expected, calls to guiCreateStaticImage.

Link to comment
One thing I ran into though:

Window name: wndLogin

Created code (not working): guiWindowSetSizable(gui["wndLogin"], false)

Should be (I guess): guiWindowSetSizable(gui["_root"], false)

Thanks. I misunderstood your post and I thought it was a question.

Indeed it was buggy. Fixed it now in 0.1.4.

Link to comment
  • 2 weeks later...
  • 1 month later...
  • 3 weeks later...
  • 2 weeks later...
  • 3 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...