Dismiss Notice
This Section is READ ONLY - All Posts Are Archived

[Responded] Lua generated text is above menu text

Discussion in 'User Interface (Including Launcher)' started by that_shawn_guy, Nov 16, 2019.

Thread Status:
Not open for further replies.
  1. that_shawn_guy

    that_shawn_guy Bug Hunter

    Messages:
    1,414
    Likes Received:
    3,748
    Trophy Points:
    125
    Location:
    earth... mostly
    11/16/2019 18:58
    Title: Lua generated text is above menu text
    Reproduction Rate: 100%
    Blocker? nope
    Details:
    [​IMG]
    Steps to Reproduce:
    User Specs:
    OS: Mac OS X 10.14.6
    CPU: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16) System RAM: 32768
    GPU: AMD Radeon Pro Vega 20 GPU RAM: 4080
    SotA.QA.OSX.64.888.Date.11.16.19
    Area: POT_forest_metropolis_02_template/Crossroads
    Area Display Name: Crossroads
    Loc: (60.2, 36.0, -136.8)
    Debug: UE9UX2ZvcmVzdF9tZXRyb3BvbGlzXzAyX3RlbXBsYXRlfENyb3Nzcm9hZHN8KDYwLjE5MywgMzYuMDAyLCAtMTM2LjgzMSl8KDAsIDAuMDIzLCAwLCAxKXwtMTY3Mi44MDl8MjkuNDA2MjF8MTg=
     
  2. that_shawn_guy

    that_shawn_guy Bug Hunter

    Messages:
    1,414
    Likes Received:
    3,748
    Trophy Points:
    125
    Location:
    earth... mostly
    Also overlays the loading screens

    [​IMG]
     
  3. Ravalox

    Ravalox Chief Cook and Bottle Washer Moderator SOTA Developer

    Messages:
    1,746
    Likes Received:
    5,002
    Trophy Points:
    125
    Gender:
    Male
    Location:
    Dallas, TX
    If possible, please post the script used. (I know it's not likely to be relevant in this case, but makes thing easier for testing for reproduction etc)
     
    Merrik and Jaesun like this.
  4. that_shawn_guy

    that_shawn_guy Bug Hunter

    Messages:
    1,414
    Likes Received:
    3,748
    Trophy Points:
    125
    Location:
    earth... mostly
    Code:
    -- libsota start
    -- libsota.0.3.1 by Catweazle Waldschrath
    client = {
        started = os.time(),
        fps = 0,
        accuracy = 0,
        _frame = 0,
        _ts = os.time(),
        screen = nil,
        _statEnum = {},
    }
    player = {
        name = nil,
        x = function() return ShroudPlayerX end,
        y = function() return ShroudPlayerY end,
        z = function() return ShroudPlayerZ end,
        health = function() return { total = player.stat(30).value, current = player.stat(14).value, percentage = 0 } end,
        focus = function() return { total = player.stat(27).value, current = player.stat(13).value, percentage = 0 } end,
        stat = function(index)
            local ret = {
                number = -1,
                name = "invalid",
                value = -999,
                description = "",
            }
            if tonumber(index) == nil then
                index = client._statEnum[index]
            else
                index = tonumber(index)
            end
            if index and index <= #client._statEnum then
                ret.number = index
                ret.name = client._statEnum[index]
                ret.value = ShroudGetStatValueByNumber(index)
                --ret.description = ShroudGetStatDescriptionByNumber(index)
            end
            return ret
        end,
    }
    ui = {
        timer = {
            _ts = os.time(),
            _granulaty = 0.120,
            create = function(timeout, once, callback)
                local index = #ui.timer + 1
                local interval = nil
    
                if not once then
                    interval = timeout
                end
    
                ui.timer[index] = {
                    index = index,
                    time = os.time() + timeout,
                    interval = interval,
                    func = callback,
                }
                return index
            end,
        },
    
        text = {
            create = function(string)
                local index = #ui.text + 1
    
                ui.text = {
                    value = string,
                    format = "%s",
                    bold = false,
                    italic = false,
                    color = "",
                    size = 0,
                }
                return index
            end,
            get = function(index)
                local t = ui.text[index]
    
                t.format = "%s"
                if t.bold then
                    t.format = "<b>"..t.format.."</b>"
                end
                if t.italic then
                    t.format = "<i>"..t.format.."</i>"
                end
                if t.size > 0 then
                    t.format = "<size="..t.size..">"..t.format.."</size>"
                end
                if t.color != "" then
                    t.format = "<color="..t.color..">"..t.format.."</color>"
                end
    
                return string.format(t.format, t.value)
            end
        },
    
        label = {
            create = function(left, top, width, height, string)
                local index = #ui.label + 1
    
                if left == "c" then left = (client.screen.width - width) / 2 end
                if top == "c" then top = (client.screen.height - height) / 2 end
    
                ui.label[index] = {
                    left = left,
                    top = top,
                    width = width,
                    height = height,
                    text = string,
                    visible = false,
                }
                return index
            end
        },
    }
    
    
    -- timer utility functions
    
    function setTimeout(timeout, callback)
        return ui.timer.create(timeout, true, callback)
    end
    
    function setInterval(interval, callback)
        return ui.timer.create(interval, false, callback)
    end
    
    function cancelTimer(index)
        ui.timer[index] = nil;
    end
    
    
    -- label utility functions
    
    function createLabel(left, top, width, height, text)
        return ui.label.create(left, top, width, height, text)
    end
    
    function getLabel(index)
        return ui.label[index]
    end
    
    --[[function getLabelText(index)
        return ui.text[ui.label[index].text]
    end
    
    function setLabelString(index, string)
        ui.text[ui.label[index].text].value = string
    end]]
    function getLabelText(index)
        return ui.label[index].text
    end
    function setLabelText(index, text)
        ui.label[index].text = text
    end
    
    function removeLabel(index)
        ui.label[index] = nil
    end
    
    function showLabel(index)
        ui.label[index].visible = true
    end
    
    function hideLabel(index)
        ui.label[index].visible = false
    end
    
    function moveLabelBy(index, x, y)
        ui.label[index].left = ui.label[index].left + x
        ui.label[index].top = ui.label[index].top + y
    end
    
    function moveLabelTo(index, x, y)
        ui.label[index].left = x
        ui.label[index].top = y
    end
    
    
    
    -- shroud hooks
    
    function ShroudOnUpdate()
    
        -- init
        if not client.screen then
            client.screen = {
                width = ShroudGetScreenX(),
                height = ShroudGetScreenY(),
                isFullScreen = ShroudGetFullScreen(),
            }
            local i
            for i=0, ShroudGetStatCount()-1, 1 do
                local name = ShroudGetStatNameByNumber(i)
                client._statEnum[tostring(name)] = i
                client._statEnum[i] = name
            end
            if ui.onInit then ui.onInit() end
        end
    
        -- client stats
        client._frame = client._frame + 1;
        if os.time() - client._ts >= 1 then
            client.fps = client._frame;
            client._frame = 0;
            client.accuracy = (os.time() - client._ts - 1) * 100
            client._ts = os.time();
            ui.timer._granulaty = 0.120 - (client.accuracy / 100)
        end
    
        -- timers
        if os.time() - ui.timer._ts >= ui.timer._granulaty then
            ui.timer._ts = os.time()
            for _,t in next, ui.timer do
                if type(t) == "table" and os.time() >= t.time then
                    if t.interval then
                        t.time = os.time() + t.interval
                    else
                        ui.timer[t.index] = nil;
                    end
                    t.func();
                end
            end
        end
    
        if ui.onUpdate then ui.onUpdate() end
    end
    
    function ShroudOnStart()
        ConsoleLog("Started main in root")
    end
    
    function OffsetCenterLabel(x, y, width, height, str)
        local s, n = string.gsub(str,"<[^>]*>","",n)
        local offset = string.len(s)*3.5
        local newx = (ShroudGetScreenX()/2 - x) - offset
        local newy = ShroudGetScreenY()/2 - y
        ShroudGUILabel(newx, newy, width, height, str)
    end
    
    function ShroudOnGUI()
        for _,l in next, ui.label do
            if type(l) == "table" and l.visible then
                ShroudGUILabel(l.left, l.top, l.width, l.height, l.text);
            end
        end
    
        OffsetCenterLabel(0,-150,512,124, string.format("<color=#FF688B><b>%d</b></color> / <color=#3399FF><b>%d</b></color>", ShroudPlayerCurrentHealth, ShroudPlayerCurrentFocus));
        OffsetCenterLabel(0,-175,512,124, string.format("%s", ShroudGetCurrentSceneName()));
    
        -- OffsetCenterLabel(0,-150,512,124, string.format("<color=#FF0000>✿</color>FPS: %d, Accuracy: %f ms", client.fps, client.accuracy));
        -- OffsetCenterLabel(0,0,512,124, string.format("1234567890"));
        -- OffsetCenterLabel(0,15,512,124, string.format("12345678901234567890"));
        -- OffsetCenterLabel(0,30,512,124, string.format("123456789012345678901234567890"));
        -- OffsetCenterLabel(0,45,512,124, string.format("1234567890123456789012345678901234567890"));
        -- ShroudGUILabel(30,30,512,124, string.format("<color=#F55D42>✿ FPS: %d, Accuracy: %f ms", client.fps, client.accuracy));
    
    end
    
    function ShroudOnConsoleInput(type, src, msg)
        --ConsoleLog(type .. "|" .. src .. "|" .. msg)
        local s, dst, msg = string.match(msg, "^(.-) to (.-) %[.-:%s*(.*)")
        local cmd, arg = string.match(msg, "^\\(%w+)%s*(%w*)");
        if not player.name and dst == "everyone" then player.name = src end
        if src == "" then src = s end
        if cmd and player.name and ui.onConsoleCommand then
            ui.onConsoleCommand(cmd, src, dst, arg)
        elseif ui.onConsoleInput then
            ui.onConsoleInput(type, src, dst, msg)
        end
    end
    -- libsota end
     
    Jaesun likes this.
  5. Ravalox

    Ravalox Chief Cook and Bottle Washer Moderator SOTA Developer

    Messages:
    1,746
    Likes Received:
    5,002
    Trophy Points:
    125
    Gender:
    Male
    Location:
    Dallas, TX
    Possible layer issue in API ... Creating Issue# 66046
     
    Jaesun likes this.
  6. CatweazleX

    CatweazleX Avatar

    Messages:
    653
    Likes Received:
    777
    Trophy Points:
    93
    Location:
    Veritas Sanctuary
    libsota.0.3.5 now hides the labels on loading screen. this was able because of a change when ShroudOnUpdate is called. (only if you use ui.label instead of your own)

    ... and please do not stop to call ShroudOnGui during load.. this is needed to figure out when the client is loading a scene or is in scene.
     
Thread Status:
Not open for further replies.