Closed StakFallT closed 4 months ago
Hiya! Sorry for the delayed response, I will dig into this in the next couple days.
I would also recommend stopping by the discord: https://discord.gg/8krYCqr As it will be easier for me to follow up with you if I need more info, or help you with future issues ;)
@StakFallT Okay I read through your description. Unfortunately currently YUI doesn't support sprite fonts, though this is just a circumstance of how I've set things up, because I made this for myself and I haven't used sprite fonts. I think it should be fairly easy for me to add the support though. Do you have a repo I can clone so that I can leverage your sprite font set up without having to figure that out myself?
No worries, and will do!
Gotcha. I can put up a repo. Do you need a Minimal Reproducible Example (MRE)? Right now, I'm basically just using the yui-master zip file with another folder I duplicated and modified for the yui files. If you need an MRE, I'm not sure, I have a thorough enough understanding of the library to know what parts I can strip out and which parts I can't (as I'm sure some of the code is example-related stuff) The font I'm using comes from: https://spicygame.itch.io/fonts and is the "Blocky Pixel" one. It's licensed under the CC0 so including it in the repo shouldn't be an issue. I just don't know if you're really hoping for an MRE or basically just an upload of the yui-master project contents as I have them modified right now.
It doesn't need to be MRE, just something I can run locally to make sure I'm adding the feature correctly
Awesome, ok I should have something up with a an hour or two. When it comes to Git, my skill level isn't so great. When it's just me, I can create repos and push commits, but beyond that (branches, remerging, rebasing, etc.), my mind just never wants to be able to understand it to the point of being able to troubleshoot. The reason that's relevant, is because, the separate GMS 2 project I'm using (I try to keep things like libraries, etc. separate from my actual game project until I'm ready to actually incorporate it), is basically yours, and the Git folder and files are going to (probably?) point to your repo -- as I guess the origin?? (sigh why did they have to over-complicate things, what really was so bad about svn??). I may just delete the Git folder and files and create a new repo and push the code to it almost like a new repo. I don't like doing that though because it would lose history of some kind I think (that and it would wind up causing it to look like my work, even though it's not, it's yours! :) ). But I'll play around with it a little.
I guess I would start by:
My worry is, because I changed some of the code, in an attempt to troubleshoot why it might not have been working for me (before I reached out to you), Git is going to throw all kinds of errors. Normally, I'd just merge those changes in, but I've had times where, through a similar situation to this whole process, the "history" gets flubbed and then the rebasing, remerging, etc. are all out of whack. But I really love the library you created, want like heck to use it in my game (since I think it fulfills my needs beautifully), and you've been pretty responsive and helpful so far.
Ok, it took a little doing but I think I managed to create a fork, update it so my repository's main branch is still at 0.6.1 (since that's what my work was done on, and a large part of the issues of the whole process was in regards to history descrepencies -- ugh, I hate Git!). Here's the link: https://github.com/StakFallT/YUI_BitMapFont_TestPrj.git
I understand, git drives me nuts all the time 😅. I'll check it out today or tomorrow
Awesome, thanks!
Okay I did a little work to try to get this working, but I don't think your font is set up correctly.
For reference: https://manual.gamemaker.io/beta/en/GameMaker_Language/GML_Reference/Asset_Management/Fonts/font_add_sprite_ext.htm
where each sub-image would be an individual symbol or letter Your font sprite is one big image, but it needs to be broken up into sub images.
I would suggest getting your sprite font working with regular GML draw calls, then I can finish the work to make YUI support it. It doesn't look like it will take much on my end, but the sprite font needs to be working properly for me to verify.
I'm also going to suggest a few things for setting up the project correctly:
1) Instead of forking YUI, create a new GM Project (and new repo), then import the YUI .yymps asset from the releases page into that project.
2) When creating your UI files, don't try to replace/rename/edit the files in datafiles/YUI
. Instead, make a new folder like datafiles/GameUI
and put your files there.
3) Really try not to edit any of the actual files in GM asset browser under Packages - YUI
-- I get you were trying your best to make the sprite font work, but in the long run it will make it harder to upgrade YUI as any time you import an updated package it would reset all your changes
If you want help with any of the above, I would recommend asking in the Discord (I saw that you joined). It really makes it easier to do some back and forth chatting to help me get things working.
I haven't made a new release for this fix yet, but it's pretty easy too apply from the commit 18ec6f7 (it's just three lines). That said, there are a couple things you need to do to actually use the fix:
1) when you create the font, you also need to get the font name. For added fonts, GM generates a name internally like __newfont##, which you can just get via font_get_name
:
BlkyFnt = font_add_sprite_ext(
fntBlockyPixel,
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
true,
1);
BlkyFntName = font_get_name(BlkyFnt);
2) Next you need to actually be able to refer to that font from the .yui file. The way I set this up for testing was:
body:
font: @@ (FontGlobals|gm_object).BlkyFntName
color: &text_color
Accessing GM objects from .yui is a bit hacky as you can see. The details here are:
|
is the 'directive' operator which is basically just a hacky thing that lets me apply arbitrary logic to whatever is to the left. The string to the right is the name of the directive.
gm_object
directive tells GM to find the object with the name on the left. Together, it's the same as just using FontGlobals
in gml, and will only access the *first*
instance of that object (just like gml)
Then we just use .BlkyFontName
to get the name of the font from the variable on the GM object.
(technically the parentheses aren't needed here but I include them for clarity)
Important Note: It's going to get the font name only when the theme is initially set up, which means your FontGlobals object (or whatever name you choose) needs to be created before any yui_documents. You won't be able to change the font name variable and have it automatically update. If you find yourself wishing you could change the font at runtime I can give you advice in the discord.
Holy hell I've been banging my head against the wall on this... I'm starting with the github repo and opening that as a project. I finally seem to have a fair understanding of how all the YUI files integrate into each other. I even think I'm beginning to understand YUI's scripting language. However, I cannot for the life of me get a bitmap font to work right. I either get nothing where the text is supposed to be (i.e. indicative of a font not being found -- and this I know, because if I just type gobbldy-gok as the font name it's the same result) or I get an error stating a font name string needed to be specified. Is this even possible? It seems like it should be based on my understanding of how the YUI files work and the ability of YUI's scripting language.
The set up: a sprite-resource named: fntBlockyPixel a main player screen YUI named UI_CustomMainScr.YUI (if memory serves correct, I based this off of welcome_screen.yui but with most of everything stripped out from for the tabs and the content of the tabs)
Things I've tried (keeping it generic because there's been many multiple variations of each that I've tried, so I'll keep the spam to a minimum):
adding the lines:
(forcing scribble to use the font for all text in-case I messed up somewhere else -- just to see if it's even possible)
putting the above two lines of code in the YuiExampleManager's constructor instead and referring to it in the YUI file.
Creating a static function variable called Get_Font, that just returns font_get_name(BlkyFnt) -- hardsetting the arg for font_get_name for testing purposes.
Creating a non-static function variable (once I read in the documentation that a static function can have issues referencing variables if it's being called from the YUI file) that also just returns font_get_name(BlkyFnt)
Adding the two lines in the create event of YuiGlobals.
In all cases, I've tried to do something like this in the default.yui file (I left SOME, there were a TON more variations which also didn't work):
I feel like I should have hit the solution by now, but I'm so fried. Please someone save me from this madness lol