Skip to content
This repository has been archived by the owner on Apr 4, 2021. It is now read-only.

Cannot read property 'DisplayText' of undefined when adding many Items #2

Open
5pHiNxX opened this issue Jul 9, 2019 · 4 comments
Open

Comments

@5pHiNxX
Copy link

5pHiNxX commented Jul 9, 2019

Adding a huge amount of strings (I added 138133 items) to the UIMenuListItem the console (F8) gets flooded with this error:

[10:26:56][Error] [V8] Exception at DemoGamemode.Client:includes/NativeUIMenu/items/UIMenuListItem.mjs:70
[10:26:56][Error]               ? this.Collection[this.Index].DisplayText
[10:26:56][Error]   TypeError: Cannot read property 'DisplayText' of undefined
    at UIMenuListItem.set Index [as Index] (includes/NativeUIMenu/items/UIMenuListItem.mjs:70:43)
    at NativeUI.GoLeft (includes/NativeUIMenu/NativeUI.mjs:200:21)
    at NativeUI.ProcessControl (includes/NativeUIMenu/NativeUI.mjs:446:18)
    at NativeUI.render (includes/NativeUIMenu/NativeUI.mjs:599:14)
@5pHiNxX
Copy link
Author

5pHiNxX commented Jul 9, 2019

My code (count is 138133):

    let animationMenu = new NativeUI.Menu('Animation', '', new NativeUI.Point(10, 50));
    //animationMenu.Close();
    let count = animationData.length;
    alt.log('Count: ' + count);
    let animationListItems = new NativeUI.ItemsCollection(buildStringRange(0, count));
    let animationList = new NativeUI.UIMenuListItem('Animationen', '', animationListItems);
    let animationFlagsLoop = new NativeUI.UIMenuCheckboxItem('Loop', false, 'Animation wird wiederholt.');
    let animationFlagsStopOnLastFrame = new NativeUI.UIMenuCheckboxItem('StopOnLastFrame', false, 'Animation wird nach dem letzten Frame beendet.');
    let animationFlagsUpperBody = new NativeUI.UIMenuCheckboxItem('UpperBody', false, 'Animiert nur den oberen Teil des Characters.');
    let animationFlagsAllowPlayerControl = new NativeUI.UIMenuCheckboxItem('AllowPlayerControl', false, 'Erlaubt das Steuern des Characters trotz Animation.');
    let animationFlagsCancelable = new NativeUI.UIMenuCheckboxItem('Cancelable', false, 'Erlaub das abbrechen der Animation.');

    animationMenu.AddItem(animationList);
    animationMenu.AddItem(new NativeUI.UIMenuItem('Flags:'));
    animationMenu.AddItem(animationFlagsLoop);
    animationMenu.AddItem(animationFlagsStopOnLastFrame);
    animationMenu.AddItem(animationFlagsUpperBody);
    animationMenu.AddItem(animationFlagsAllowPlayerControl);
    animationMenu.AddItem(animationFlagsCancelable);

    function buildStringRange(start, end) {
        let ret = new Array();
        for (let i = start; i < end; ++i) {
            ret.push('' + i);
        }
        return ret;
    }

@5pHiNxX
Copy link
Author

5pHiNxX commented Jul 9, 2019

Ok, I could break it down... It seems like the max number of ListItems is 100000 ...

@datWeazel
Copy link
Owner

It's been a while but I just rebased my project on a more up to date codebase. Would be awesome if you could recheck your issue and let me know if the problem still exists.

@DurtyFree
Copy link

Should be fixed with latest Version

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants