Skip to content

EGPParent still having issue with reuse #3487

@AlexALX

Description

@AlexALX

Describe the bug

mainly related to this probably: #3039

I think this isn't fixed or something. here is another example of issue

@name EGP test 
@inputs EGP:wirelink
@outputs 
@persist DialogData:table GpuData:table LAST_I
@trigger none 
@strict

if (first() | duped()) {
DialogData = table()
GpuData = table()
LAST_I = 0
}

function alxos_closemenu() {
    if (!DialogData[0,number] | DialogData[0,number]==1) { return }
    local Parent = DialogData[-1,number]
    for(I=Parent,Parent+5) {
        EGP:egpRemove(I)   
    }
    local Rm = DialogData[-3,table]
    for(I=1,Rm:count()) {
        EGP:egpRemove(Rm[I,table][4,number])
    }
    LAST_I = Parent
    DialogData = table()
}

function alxos_closedialog() {
    if (!DialogData[0,number] | DialogData[0,number]==2) { return }
    local Parent = DialogData[-1,number]
    for(I=Parent,Parent+5) {
        EGP:egpRemove(I)
    }   
    local Rm = DialogData[-10,table]
    for(I=1,Rm:count()) {
        EGP:egpRemove(Rm[I,number])
    }
    LAST_I = Parent
    DialogData = table()
}

function alxos_menubg(Title:string,Width,Height,Col:table) {
    local Parent = LAST_I
    
    local ReDraw = DialogData[-101,number]
    if (ReDraw) {
        local Parent = DialogData[-1,number]

        EGP:egpSize(Parent,vec2(Width,Height))
        EGP:egpPos(Parent,vec2(256-(Width/2),256-(Height/2)))
        
        EGP:egpSize(Parent+1,vec2(Width-16,Height-16))
        EGP:egpPos(Parent+1,vec2((256+8)-(Width/2),(256+8)-(Height/2)))
        EGP:egpSize(Parent+2,vec2(Width-22,Height-22))
        EGP:egpPos(Parent+2,vec2((256+11)-(Width/2),(256+11)-(Height/2)))
        
        local Sz = Title:length()*12
        EGP:egpPos(Parent+3,vec2(Width/2-Sz/2,0))
        EGP:egpSize(Parent+3,vec2(Sz,22))
        
        EGP:egpSetText(Parent+4,Title)
        
        return   
    }
    EGP:egpBox(LAST_I,vec2(256-(Width/2),256-(Height/2)),vec2(Width,Height))
    EGP:egpColor(LAST_I,Col[1,vector4]) LAST_I++
    
    EGP:egpBoxOutline(LAST_I,vec2((256+8)-(Width/2),(256+8)-(Height/2)),vec2(Width-16,Height-16))
    EGP:egpColor(LAST_I,Col[2,vector4]) LAST_I++
    
    EGP:egpBoxOutline(LAST_I,vec2((256+11)-(Width/2),(256+11)-(Height/2)),vec2(Width-22,Height-22))
    EGP:egpColor(LAST_I,Col[2,vector4]) LAST_I++
    
    local Sz = Title:length()*12
    EGP:egpBox(LAST_I,vec2(Width/2-Sz/2,0),vec2(Sz,22))
    EGP:egpParent(LAST_I,Parent)
    EGP:egpColor(LAST_I,Col[1,vector4]) LAST_I++
    
    EGP:egpText(LAST_I,Title,vec2(Width/2,0))
    EGP:egpParent(LAST_I,Parent)
    EGP:egpAlign(LAST_I,1)
    EGP:egpColor(LAST_I,Col[2,vector4]) LAST_I++
    
    DialogData[-1,number] = Parent
    DialogData[-101,number] = 1
}

function alxos_menubg(Title:string,Width,Height) {
    alxos_menubg(Title,Width,Height,table(vec4(0,168,168,255),vec4(255,255,255,255)))
}

function alxos_menu(Title:string,MenuTree:table,Width,Keys:table) {
    if (DialogData[0,number]==1) { alxos_closedialog() }   
        
    local ReDraw = DialogData[-101,number]
    local Height = MenuTree:count()*20+40
    alxos_menubg(Title,Width,Height)

    local Parent = DialogData[-1,number]
    local LAST_Y = 20 #-Height/2
    local LeftPos = 20 #-Width/2
    
    print(LAST_I)
    
    if (ReDraw) {
        local Tbl = DialogData[-3,table]
        
        local BoxID = DialogData[-2,number]
        EGP:egpSize(BoxID,vec2(Width-32,20))
        EGP:egpPos(BoxID,vec2(LeftPos-4,LAST_Y))
        
        for(I=1,MenuTree:count()) {
            local OldID = Tbl[I,table][4,number]
            MenuTree[I,table][6,table] = MenuTree[I,table][4,table]
            MenuTree[I,table][4,number] = OldID
            MenuTree[I,table][5,vector2] = vec2(LeftPos-4,LAST_Y)
            
            EGP:egpSetText(OldID,MenuTree[I,table][2,string])
            EGP:egpPos(OldID,vec2(LeftPos,LAST_Y))
            LAST_Y+=20
        }
    } else {    
        DialogData[-2,number] = LAST_I
        EGP:egpBox(LAST_I,vec2(LeftPos-4,LAST_Y),vec2(Width-32,20))
        EGP:egpParent(LAST_I,Parent)
        EGP:egpColor(LAST_I,0,0,0,255) LAST_I++
    
        for(I=1,MenuTree:count()) {
            MenuTree[I,table][6,table] = MenuTree[I,table][4,table]
            MenuTree[I,table][4,number] = LAST_I
            MenuTree[I,table][5,vector2] = vec2(LeftPos-4,LAST_Y)
            
            EGP:egpText(LAST_I,MenuTree[I,table][2,string],vec2(LeftPos,LAST_Y))
            EGP:egpParent(LAST_I,Parent)
            EGP:egpColor(LAST_I,vec4(255,255,255,255)) LAST_I++ LAST_Y+=20
        }
    }

    DialogData[-3,table] = MenuTree
    DialogData[-4,number] = 1
    DialogData[-5,number] = MenuTree:count()
    DialogData[-6,table] = Keys
    DialogData[0,number] = 2
    
}

function alxos_menu(Title:string,MenuTree:table,Width) {
    alxos_menu(Title,MenuTree,Width,table())
}

function alxos_explorer_menu(Title:string,MenuTree:table,Width) {
    alxos_menu(Title,MenuTree,Width)

    if (!GpuData[-104,array]:count()) {
        #GpuData[-102,string] = ExplorerKeyH
        GpuData[-104,array] = GpuData[-103,array]
    }
    #ExplorerKeyH = "mainmenu"
    #alxos_explorer_ft(array("Quit"))  
}

function alxos_explorer_mainmenu(Info:table) {
    local Entry = Info[3,table]
    if (Entry["name",string]==".") { return }

    local MenuTree = table(
        table(0,"File Information","alxos_explorer_fileinfo",Info),
        table(0,"Rename file","alxos_explorer_rename",Info),
        table(0,"Copy file","alxos_explorer_copy",Info),
        table(0,"Paste file","alxos_explorer_paste"),
        table(0,"Send file","alxos_explorer_send",Info),
        table(0,"Download file","alxos_explorer_dw",Info),
        table(0,"System Information","alxos_explorer_sysinfo"),
        table(0,"Change volume","alxos_explorer_chvolume"),
        table(0,"Start Sharing Server","alxos_explorer_sharesv"),
        table(0,"Shutdown PC","alxos_explorer_shutdown")
    )    
    local Ind = 4
    #[if (alxos_wm1_isdir(Entry)) {
        MenuTree:removeTable(6)
        MenuTree:removeTable(5)
        MenuTree:removeTable(3)
        Ind = 3
    }
    if (ExplorerFS["read_only",number] | !ExplorerCopy:count()) {
        MenuTree:removeTable(Ind)
    }]#
    MenuTree:removeTable(Ind)    
    alxos_explorer_menu("Menu",MenuTree,280)
}

            local Info = table() #GpuData[6,table][Index,table]
            alxos_explorer_mainmenu(Info)

just reload chip and each time will be 1 item less displayed, LAST_I which are index for reuse same ID always same, something still broken. can't fix my pc because of this bug since it affects ALL menus and dialogs.

How to reproduce the bug

  1. upload chip code i provided
  2. connect with EGP
  3. reload chip multiple times to see issue

Exact same code WORKS just fine with wiremod 2023 version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions