Laufschrift

Parameter

(_text,_lenght,_Callback,_lines,_music,_textColor)

Name Typ Beschreibung
_text Table Table mit allen Textzeilen, abgetrennt durch Kommata.
_lenght Number Anzeigezeit auf dem Bildschirm in Zehntelsekunden.
_Callback Function Funktion, die nach Beendigung ausgeführt wird.
_lines Number Anzahl an angezeigten Zeilen (3-28).
_music String optional: gespielter Musiktitel
_textColor String optional: Zeichenkette mit Farbcode

Functionscode

Kopiere diesen Code in dein globales Skript.

twA_Lauf = {}

function twA_Laufschrift_Start(_text,_lenght,_Callback,_lines,_music,_textColor)
    assert((type(_text) == "table"), "Laufschrift: Argument #1 '_text' muss ein Table sein.")
    assert((type(_lenght) == "number"), "Laufschrift: Argument #2 '_lenght' muss eine Zahl sein.")
    assert((type(_Callback) == "function"), "Laufschrift: Argument #3 '_Callback' muss eine Funktion sein.")
    if not _textColor then _textColor = "{@color:255,255,255,255}" end
    if not _pos then _pos = {X = 500, Y = 500,}end
    if not _lines then _lines = 5 end
    assert(_lines <= 28 and _lines >= 3, "Laufschrift: Argument #4: 3 up to 28 lines allowed.")
    -- add empty lines
    _text[#_text +1] = ""
    _text[#_text +1] = ""
    -- convert table
    local text = {}
    for i=1,table.getn(_text)do
        text[i] = {_text[i]}
    end

    twA_Lauf = {
        musicVolium = 70,
        music = _music,
        lines = _lines,
        text = text,
        Ctime = _lenght,
        CMax = _lenght,
        Position = _pos,
        Callback = _Callback,
        textColor = _textColor,
        MaxTime = ((table.getn(text)*_lenght)+(_lenght*(_lines-1))),
        IsActive = true,
    }

    local index = _lines
    for i=1,#twA_Lauf.text do
        index = index + 1
        table.insert(twA_Lauf.text[i],index)
    end
    -- hide GUI
    Logic.ExecuteInLuaLocalState([[
        XGUIEng.ShowAllSubWidgets('/InGame/Root/Normal',0)
        XGUIEng.SetWidgetPositionAndSize('/InGame/Root/Normal/NotesWindow',300,100,700,800)
        local size = {GUI.GetScreenSize()}
        XGUIEng.SetWidgetSize('/InGame/Root/Normal/NotesWindow',size[1],size[2])
        XGUIEng.SetWidgetSize('/InGame/Root/Normal/NotesWindow/NotesWindowOutput',size[1],size[2])
        Game.GameTimeSetFactor(GUI.GetPlayerID(), 1)
        Camera.SwitchCameraBehaviour(2)
        GUI.ClearNotes()
        Camera.FreeView_SetPosition(".._pos.X..",".._pos.Y..")
        Display.SetRenderSky(0)

        g_Lauf_VoiceBackup = VolumesTable.SpeechVolume
        g_Lauf_MusicBackup = VolumesTable.MusicVolume
        g_Lauf_AtmoBackup = VolumesTable.FXAtmoVolume
    ]])
    -- display
    twA_Lauf.Display = {}
    for i=1,_lines do
        twA_Lauf.Display[i] = ""
    end
    twA_Lauf.Job = StartSimpleHiResJob("twA_Laufschrift_Job")
end
function twA_Laufschrift_Job()
    twA_Lauf.MaxTime = twA_Lauf.MaxTime - 1
    if twA_Lauf.MaxTime > 0 then
        -- avoid that a briefing start
        if BriefingSystem then
            BriefingSystem.isActive = true
        end
        -- hide ui
        Logic.ExecuteInLuaLocalState("XGUIEng.ShowAllSubWidgets('/InGame/Root/Normal',0)")
        Logic.ExecuteInLuaLocalState("XGUIEng.ShowWidget('/InGame/Root/Normal/NotesWindow',1)")
        -- print
        twA_Lauf.Ctime = twA_Lauf.Ctime - 1
        if twA_Lauf.Ctime == 0 then
            -- init music
            if not twA_Lauf.musicInit then
                Logic.ExecuteInLuaLocalState([[
                    Sound.SetSpeechVolume(0)
                    Sound.SetFXAtmoVolume(0)
                    Sound.SetMusicVolume(0)
                ]])
                if twA_Lauf.music ~= nil then
                    Logic.ExecuteInLuaLocalState([[
                        Sound.PlayVoice("ImportantStuff","]]..twA_Lauf.music..[[")
                        Sound.SetSpeechVolume(]]..twA_Lauf.musicVolium..[[)
                        Sound.SetFXAtmoVolume(0)
                        Sound.SetMusicVolume(0)
                    ]])
                    twA_Lauf.musicInit = true
                end
            end
            for i=1,#twA_Lauf.text do
                twA_Lauf.text[i][2] = twA_Lauf.text[i][2] - 1
                if twA_Lauf.text[i][2] < twA_Lauf.lines+1 and twA_Lauf.text[i][2] > 0 then
                    twA_Lauf.Display[twA_Lauf.text[i][2]] = twA_Lauf.text[i][1]
                end
            end
            twA_Laufschrift_Anzeige()
            twA_Lauf.Ctime = twA_Lauf.CMax
        end
        -- fade music out
        if twA_Lauf.MaxTime <= 71 then
            twA_Lauf.musicVolium = twA_Lauf.musicVolium -1
            Logic.ExecuteInLuaLocalState([[Sound.SetSpeechVolume(]]..twA_Lauf.musicVolium..[[)]])
        end
    else
        twA_Lauf.Job = nil
        -- briefings can start now
        if BriefingSystem then
            BriefingSystem.isActive = false
        end
        -- music
        if twA_Lauf.music ~= nil then
            Logic.ExecuteInLuaLocalState([[Sound.StopVoice("ImportantStuff","]]..twA_Lauf.music..[[")]])
        end
        Logic.ExecuteInLuaLocalState([[
            VolumesTable.SpeechVolume    = g_Lauf_VoiceBackup
            VolumesTable.MusicVolume    = g_Lauf_MusicBackup
            VolumesTable.FXAtmoVolume    = g_Lauf_AtmoBackup
            Sound.SetFXAtmoVolume(g_Lauf_AtmoBackup)
            Sound.SetSpeechVolume(g_Lauf_VoiceBackup)
            Sound.SetMusicVolume(g_Lauf_MusicBackup)
            g_Lauf_VoiceBackup    = nil
            g_Lauf_MusicBackup    = nil
            g_Lauf_AtmoBackup    = nil
        ]])
        twA_Lauf.musicInit = nil
        -- ui
        local pos = {X = Logic.WorldGetSize()/2, Y = Logic.WorldGetSize()/2}
        Logic.ExecuteInLuaLocalState([[
            XGUIEng.ShowWidget("/InGame/Root/Normal/AlignBottomRight",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/AlignBottomLeft",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/AlignTopLeft",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/AlignTopLeft/TopBar",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/InteractiveObjects",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/InteractiveObjects/Update",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/AlignTopRight",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/Selected_Merchant",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/AlignTopCenter",1)
            if g_PatchIdentifierExtra1 then
                XGUIEng.ShowWidget("/InGame/Root/Normal/Selected_Tradepost",1)
            end
            XGUIEng.ShowWidget("/InGame/Root/Normal/TextMessages",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/PauseScreen",0)
            XGUIEng.ShowWidget("/InGame/Root/3dOnScreenDisplay",1)
            XGUIEng.ShowWidget("/InGame/Root/Normal/ShowUi",1)
            XGUIEng.ShowWidget("/InGame/Root/3dWorldView",1)

            Camera.RTS_SetLookAtPosition(]]..pos.X..[[,]]..pos.Y..[[)
            Camera.SwitchCameraBehaviour(0)
            Display.SetRenderSky(1)
            GUI.ClearNotes()
        ]])
        twA_Lauf.Callback()
        twA_Lauf.IsActive = false
        -- end job
        return true
    end
end
function twA_Laufschrift_Anzeige()
    local printing = "{center}"
    -- empty lines
    local emptyLines = {}
        emptyLines[3]  = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[4]  = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[5]  = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[6]  = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[7]  = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[8]  = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[9]  = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[10] = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[11] = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[12] = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[13] = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[14] = "{cr}{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[15] = "{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[16] = "{cr}{cr}{cr}{cr}{cr}{cr}"
        emptyLines[17] = "{cr}{cr}{cr}{cr}{cr}"
        emptyLines[18] = "{cr}{cr}{cr}{cr}{cr}"
        emptyLines[19] = "{cr}{cr}{cr}{cr}"
        emptyLines[20] = "{cr}{cr}{cr}{cr}"
        emptyLines[21] = "{cr}{cr}{cr}"
        emptyLines[22] = "{cr}{cr}{cr}"
        emptyLines[23] = "{cr}{cr}"
        emptyLines[24] = "{cr}{cr}"
        emptyLines[25] = "{cr}"
        emptyLines[26] = "{cr}"
        emptyLines[27] = ""
        emptyLines[28] = ""

    local empty = emptyLines[twA_Lauf.lines]
    printing = printing..""..empty
    -- print text
    for j= 1,twA_Lauf.lines do
        printing = tostring(printing.." "..twA_Lauf.textColor.." "..twA_Lauf.Display[j].." {cr} ")
    end
    Logic.ExecuteInLuaLocalState([[
        GUI.ClearNotes()
        GUI.AddNote(Umlaute("]]..printing..[["))
    ]])
end

Rückgabewerte

keine

Beschreibung

Diese Funktion lässt Schrift von unten nach oben über den Bildschirm laufen.

global ✔

lokal ✘

by totalwarANGEL

Beispiel

...

Demo-Map

<nicht vorhanden>

Zurück zu Funktionssammlungen | Drucken | Tags
Sofern nicht anders angegeben, steht der Inhalt dieser Seite unter Lizenz Creative Commons Attribution-ShareAlike 3.0 License