axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

Extension issue - FairyGUI BMFont don't load #972

Closed theSlyest closed 1 year ago

theSlyest commented 1 year ago

Steps to Reproduce:

  1. Create a FairyGUI project
  2. Import a bitmap font in the FairyGUI project
  3. Use the font on a text field in a FairyGUI component
  4. Load the component in a scene

The the text field does not display the selected font, and there is an error message in the console log:

No file found at ui://[_fairyguiurl]. Possible missing file.

aismann commented 1 year ago

Source snippet?

theSlyest commented 1 year ago
bool HelloWorld::init()
{
    if (!Scene::init()) 
    {
        return false;
    }

    _groot = GRoot::create(this);
    _groot->retain();

    FileUtils::getInstance()->addSearchPath("fui");
    UIPackage::addPackage("Futura_White_Black_128");
    UIPackage::addPackage("HexGrid");
    GObject *grid = UIPackage::createObject("HexGrid", "HexGrid");
    grid->setPosition(_groot->getWidth() / 2.f, _groot->getHeight() / 2.f);
    _groot->addChild(grid);

    return true;
}

Futura_White_Black_128 is a bitmap font. There is a text field using this font in the HexGrid component. The component is displayed, but the text field appears with a wrong font and I get the following message:

axmol: fullPathForFilename: No file found at ui://6jswxvktmvpka. Possible missing file.

aismann commented 1 year ago

Where is this font (path correct, extension)? try this:

UIPackage::addPackage("fui/Futura_White_Black_128");   / / extension is missed?
UIPackage::addPackage("fui/HexGrid");
theSlyest commented 1 year ago

You don't need the extension when loading FairyGUI files. And this problem is also present in the FairyGUI test.

aismann commented 1 year ago

Wich FairyGUI test?

theSlyest commented 1 year ago

axmol/tests/fairyguitest-tests

aismann commented 1 year ago

Ok I have seen it: Cocos creator example: (https://www.fairygui.com/cocos-demo/) image

Axmol example (FairyGUI extension): image

I think the reason is: Not all is configuered on the "Basics.fui" Comparing both shows more differents (mostly axmol FairyGUI extension has a better demo example. "Basics.fui" is designed with the FairyGUI editor)

I have no time to check it with the FairyGUI editor. If there a missing part better write an issue on the FairyGUI extension page?

aismann commented 1 year ago

@halx99: maybe a label like: 'extension issue' or 'demo issue' is also helpfully?

aismann commented 1 year ago

It seems to be a FairyGUI bug (see preview)

I checked it on the FairyGUI Editor: image Here the preview on the editor (Bitmap Font is not correct) image

theSlyest commented 1 year ago

I just ran it with Cocos2d-x 4.0 and it works perfectly fine. After a small investigation, I think the glitches are caused by some of the changes in FontAtlasCache or FileUtils. Specifically, in the implementation of the method: FontAtlas* FontAtlasCache::getFontAtlasFNT(...)

aismann commented 1 year ago

@theSlyest maybe the title is wrong?

rh101 commented 1 year ago

@theSlyest Any chance you could try to re-add the code removed in this commit and see if it works correctly?

https://github.com/axmolengine/axmol/commit/6f4fe63208f768f1f297adb81dc23f8a0e1b72f7

theSlyest commented 1 year ago

@theSlyest Any chance you could try to re-add the code removed in this commit and see if it works correctly?

6f4fe63

Ok, I'll try

theSlyest commented 1 year ago

It requires more changes to be reverted. I can not test it for now.

aismann commented 1 year ago

@theSlyest Any chance you could try to re-add the code removed in this commit and see if it works correctly?

6f4fe63

Rebuild with the "latest" changes BEFORE [6f4fe63]

Edit: test it with axmol-1.0.0b7 too BitmapFont issue is same image

aismann commented 1 year ago

Test it on axmol-adxe-1.0-b3 also. (VS2022 64bit) got an exeption on runtuime (is not usefull for comparing)

I have no longer VS2019, I cannot build older versions of axmol.

aismann commented 1 year ago

adxe-1.0-a9 is the first one with the extension FairyGUI

rh101 commented 1 year ago

adxe-1.0-a9 is the first one with the extension FairyGUI

I'll test out that version since I still have VS2019 installed.

rh101 commented 1 year ago

No luck testing adxe-1.0-a9, since I can't download the external libraries from anywhere:

==> Prepare to download external libraries!
==> version file doesn't exist
==> Ready to download 'v56.zip' from 'https://github.com/c4games/engine-x-3rd/archive/v56.zip'
==> Error: Could not find the file from url: 'https://github.com/c4games/engine-x-3rd/archive/v56.zip'
==> Http request failed, error code: 404, reason: Not Found

That link doesn't exist any longer, and I don't have copies of the external library zip files. @halx99 Would you by any chance have all the external zip files, and if possible, upload them somewhere, like the https://github.com/axmolengine/archive repo?

halx99 commented 1 year ago

I prefer to check this issue in current version

rh101 commented 1 year ago

I prefer to check this issue in current version

Fair enough, then no point wasting time testing the older versions.