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 »

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 »

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 »

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 »

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):
ui - original
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:
UI scaling - before
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:
UI - scaling - after (WIP)
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 »

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 »

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 »

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:
large txt
large txt
Small text:
small text
small text
User avatar
gblues
Posts: 33
Joined: 25 Apr 2015, 06:31

Re: help with MyGUI

Post by gblues »

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)
huge text
huge text
User avatar
psi29a
Posts: 5361
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: help with MyGUI

Post by psi29a »

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 »

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