MainWindow_LoadGame_DoLoadGame_Changed(_Slot)

» Siedler Map Source Forum » Siedler DEdK Script Forum » MainWindow_LoadGame_DoLoadGame_Changed(_Slot)

Seiten: 1

AdeBont
#1
16.03.2015 19:36
Beiträge: 666

MainWindow_LoadGame_DoLoadGame_Changed(_Slot)

I'm trying to hack MainWindow_LoadGame_DoLoadGame_Changed(_Slot) in order to determine the save slot of the saved game that is clicked in the load saved game window.

So for this I started to copy the complete original code in the hacked function, but somehow it always returns _Slot in sequence of the maps as listed in the load saved game window (on date) instead of in sequence of the saved game slots.

This is the original function (in chat.lua):

function
MainWindow_LoadGame_DoLoadGame( _Slot )

	local Index = MainWindow_SaveGame_LoadListOffset + _Slot
	
	local SaveGameData = { Framework.GetSaveGameNames( Index, 1 ) }
	if SaveGameData[ 1 ] == 1 then
		local Name = SaveGameData[ 2 ]
		Framework.LoadGame( Name )
		GUI.AddNote( XGUIEng.GetStringTableText( "InGameMessages/GUI_GameLoaded" ) )
	end

	GUIAction_ToggleMenu( XGUIEng.GetWidgetID("MainMenuWindow"),0)
	
end



Perhaps someone has a way to determine which saved map is clicked in the list?

____________________
AdB
---------------------------------
Now faith is the substance of things hoped for,
the evidence of things not seen.
Heb 11:1

Zedeg
#2
16.03.2015 20:14
Beiträge: 428

Not tested in this function:

function MainWindow_LoadGame_DoLoadGame(_Slot)
    local Index = MainWindow_SaveGame_LoadListOffset + _Slot
    local SaveGameData = {Framework.GetSaveGameNames(Index, 1)}
    if SaveGameData[1] == 1 then
        local Name = SaveGameData[2]
        slotNumber = string.sub(Name, 1, 3) -- takes the first, second and third char and names them "slotNumber", spaces will be ignored
        if string.find(slotNumber, "-") then -- if the third char was a hyphen ...
            slotNumber = string.sub(slotNumber, 1, 2) -- ... it will be cut off
        end
        GUI.AddNote(slotNumber)
        Framework.LoadGame(Name)
        GUI.AddNote(XGUIEng.GetStringTableText"InGameMessages/GUI_GameLoaded")
    end
    GUIAction_ToggleMenu(XGUIEng.GetWidgetID"MainMenuWindow", 0)
end



____________________
Journalisten erkundigen sich bei Wissenschaftlern meist nicht nach Grundlagen, sondern eher nach Ergebnissen und Folgerungen. Das erklärt womöglich auch, warum sich Forschungsberichte in den Medien so häufig als feststehende Erkenntnisse lesen, nicht aber als Ideen, Entdeckungen oder Indizien, um die es sich genau genommen in den meisten Fällen handelt. -Axel Bojowski

AdeBont
#3
16.03.2015 21:15
Beiträge: 666

No, same results

____________________
AdB
---------------------------------
Now faith is the substance of things hoped for,
the evidence of things not seen.
Heb 11:1

AdeBont
#4
16.03.2015 22:24
Beiträge: 666

I found this piece of code in the script reference: MainWindow_SaveGames_Sort()
This seems to cause the sorting of saved games per save date/time, but I fear this is not scripted in the lua codes?

____________________
AdB
---------------------------------
Now faith is the substance of things hoped for,
the evidence of things not seen.
Heb 11:1

Dieser Beitrag wurde von AdeBont am 16.03.2015 um 22:37 editiert.

Zedeg
#5
16.03.2015 22:33
Beiträge: 428

Zitat von AdeBont:
but I fear this is not scripted in the lua codes



It is:

function MainWindow_SaveGames_Sort(_left, _right)
    return string.upper(_left.Desc) < string.upper(_right.Desc)
end



Only used in this function:

function MainWindow_LoadGame_GenerateList()
    MainWindow_LoadGame_NameList = {}
    local Index = 0
    local SaveGame
    local SaveGameIndex = 1
    while true do
        SaveGame = { Framework.GetSaveGameNames(Index, 1) }
        if SaveGame[1] == 0 then
            break
        end
        if Framework.IsSaveGameValid(SaveGame[2]) == true then
            MainWindow_LoadGame_NameList[SaveGameIndex] = {}
            MainWindow_LoadGame_NameList[SaveGameIndex].Name = SaveGame[2]
            MainWindow_LoadGame_NameList[SaveGameIndex].Desc = Framework.GetSaveGameString( SaveGame[2] )
            local Name = string.gsub(SaveGame[2], "save_", "", 1)
            MainWindow_LoadGame_NameList[SaveGameIndex].Index = tonumber(Name)
            SaveGameIndex = SaveGameIndex + 1
        end
        Index = Index + 1
    end
    table.sort(MainWindow_LoadGame_NameList, MainWindow_SaveGames_Sort)
end



____________________
Journalisten erkundigen sich bei Wissenschaftlern meist nicht nach Grundlagen, sondern eher nach Ergebnissen und Folgerungen. Das erklärt womöglich auch, warum sich Forschungsberichte in den Medien so häufig als feststehende Erkenntnisse lesen, nicht aber als Ideen, Entdeckungen oder Indizien, um die es sich genau genommen in den meisten Fällen handelt. -Axel Bojowski

AdeBont
#6
16.03.2015 22:46
Beiträge: 666

Hi Zedeg

In which script file is this?

____________________
AdB
---------------------------------
Now faith is the substance of things hoped for,
the evidence of things not seen.
Heb 11:1

Zedeg
#7
16.03.2015 22:52
Beiträge: 428

patch.bba -> script -> interface

____________________
Journalisten erkundigen sich bei Wissenschaftlern meist nicht nach Grundlagen, sondern eher nach Ergebnissen und Folgerungen. Das erklärt womöglich auch, warum sich Forschungsberichte in den Medien so häufig als feststehende Erkenntnisse lesen, nicht aber als Ideen, Entdeckungen oder Indizien, um die es sich genau genommen in den meisten Fällen handelt. -Axel Bojowski

AdeBont
#8
16.03.2015 23:23
Beiträge: 666

Found the issue, I was using the code from the data.bba, but I had to use the reworked code from the patch.bba

____________________
AdB
---------------------------------
Now faith is the substance of things hoped for,
the evidence of things not seen.
Heb 11:1

Dieser Beitrag wurde von AdeBont am 17.03.2015 um 07:33 editiert.

Seiten: 1

SiteEngine v1.5.0 by nevermind, ©2005-2007
Design by SpiderFive (www.siedler-games.de) - English translation by juja

Impressum