help with MyGUI

Everything about development and the OpenMW source code.
User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

help with MyGUI

Post by gblues » 28 May 2016, 06:42

So, having finally got dev builds working, I'm trying to actually do something useful for the project. ;)

Question: How do I get the text size of the default font?

I know the method I need: MyGUI::ResourceTrueTypeFont::getDefaultHeight()
I know the resource I need: the "Magic Cards" font.
I know that "Magic Cards" is set as the default font in resources/mygui/openmw_settings.xml, which is then defined in openmw_font.xml

What I don't know is what MyGUI incantation I need to ask it "give me your default Font resource and call getDefaultHeight on it."

MyGUI is so horribly documented, I'm also going to ask if anyone's expressed any interest in ditching MyGUI for, I dunno, something with proper documentation? Or any documentation at all? :evil:

Thanks! :)

User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: help with MyGUI

Post by scrawl » 28 May 2016, 14:56

I agree that some documentation could be improved, but you could have picked a better example.

A google search for "MyGUI default font" leads to http://mygui.info/docs/class_my_g_u_i_1 ... nager.html

From there I'd say it's pretty obvious:

Code: Select all

MyGUI::FontManager& fontMgr = MyGUI::FontManager::getInstance();
int defaultHeight = fontMgr.getByName(fontMgr.getDefaultFont())->getDefaultHeight()
I'm also going to ask if anyone's expressed any interest in ditching MyGUI
I'm quite happy with MyGUI myself. The codebase is very solid and is modular enough that we could add any feature we wanted.

Some people have proposed switching to HTML/librocket, but no one stepped forward to do the work. Seems unlikely to happen, now that we already have ~25k lines of GUI code written using MyGUI ;)

I'd imagine we could add a "HTML widget" to MyGUI that lets you write HTML, so we would have HTML in addition to MyGUI rather than as complete replacement. Mod authors could take their pick.

User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

Re: help with MyGUI

Post by gblues » 28 May 2016, 16:40

Of course it's something simple... Thanks :lol:

Class docs are one thing, but anything else (like the files actually included in the "docs" folder) is all in Russian.

Is the xml schema actually documented anywhere? The only thing I've found is a short and outdated list on the ogre wiki.

User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

Re: help with MyGUI

Post by gblues » 28 May 2016, 23:41

Making some progress!

I didn't go into it in the OP, but I'm working on making the UI scale properly relative to the text size, because I'm old and can't read tiny text very well anymore. :) And because Morrowind has a ton of text in it, poor legibility is a huge barrier to enjoying the game. This is actually what put OpenMW on my radar in the first place.

Fortunately, increasing the text size was pretty easy! It also made all the UI glitches stand out like a sore thumb, so I'm exploring ways to fix them, whether it's XML editing or code changes.

First up: the player stats window.

Here's what it looks like without any code changes (roughly -- the level/race/class were cropped before some XML changes I didn't revert before making the screenshot):
screenshot004.png
ui - original
The first thing I did was to change the sLineHeight so it wasn't const, and setting it to the default font's height in the widget constructor. This solved part of the problem, but the tops of the lines were getting cut off:
screenshot000.png
UI scaling - before
I found the culprit where the "height" value of the coord1 was hard-set to a value (18) instead of using sLineHeight, and once I fixed that, the layout looks much better:
screenshot002.png
UI - scaling - after (WIP)
(note, the box around the skills is missing due to an XML edit, not a rendering bug)

Now to try to work the same magic for the left pane..

User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

Re: help with MyGUI

Post by gblues » 29 May 2016, 06:07

health/magicka/fatigue section is working now.
screenshot005.png

aesylwinn
Posts: 243
Joined: 14 Dec 2015, 20:30

Re: help with MyGUI

Post by aesylwinn » 29 May 2016, 07:54

Cool! Have you thought about handling cases where the text is too big and makes a part of the menu go off-screen?

User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

Re: help with MyGUI

Post by gblues » 29 May 2016, 08:26

Not in terms of throwing up an error dialog or anything, but I'll try scaling up to obscene sizes to see how it looks.

For sane text sizes, though, it works well.

Large text:
screenshot006.png
large txt
Small text:
screenshot007.png
small text

User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

Re: help with MyGUI

Post by gblues » 29 May 2016, 08:34

Just for fun I cranked up the size to 72 (the "large" text in earlier shots was size=36).

It actually does well! The only thing that doesn't scale up is the size of the health/magicka/fatigue bars. Everything else is perfect.

(slightly downscaled to fit into the attachment resolution limits)
screenshot008.png
huge text

User avatar
psi29a
Posts: 5050
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: help with MyGUI

Post by psi29a » 29 May 2016, 08:58

A good target should be 4K resolution... i usually have to switch to TTF to get something that looks good. ;)

User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

Re: help with MyGUI

Post by gblues » 29 May 2016, 09:12

All of the above shots are using the Pelagiad TTF linked in the Wiki.

Sadly I don't have a 4K monitor to test with, so the best I can do is to crank the size up to absurd levels and hope the rest of the UI scales properly. :)

Post Reply