- completed scriptification of LoadSaveMenu.

This commit is contained in:
Christoph Oelckers 2017-02-18 18:01:24 +01:00
parent e46d378fb2
commit 6a65f02257
2 changed files with 94 additions and 134 deletions

View file

@ -72,6 +72,7 @@ FSavegameManager::~FSavegameManager()
{
ClearSaveGames();
}
//=============================================================================
//
// Save data maintenance
@ -313,6 +314,14 @@ void FSavegameManager::ReadSaveStrings()
}
}
DEFINE_ACTION_FUNCTION(FSavegameManager, ReadSaveStrings)
{
PARAM_SELF_STRUCT_PROLOGUE(FSavegameManager);
self->ReadSaveStrings();
return 0;
}
//=============================================================================
//
//
@ -579,6 +588,12 @@ void FSavegameManager::ClearSaveStuff()
}
}
DEFINE_ACTION_FUNCTION(FSavegameManager, ClearSaveStuff)
{
PARAM_SELF_STRUCT_PROLOGUE(FSavegameManager);
self->ClearSaveStuff();
return 0;
}
//=============================================================================
//
@ -751,94 +766,12 @@ DEFINE_ACTION_FUNCTION(FSavegameManager, RemoveNewSaveNode)
FSavegameManager savegameManager;
class DLoadSaveMenu : public DListMenu
DEFINE_ACTION_FUNCTION(FSavegameManager, GetManager)
{
DECLARE_CLASS(DLoadSaveMenu, DListMenu)
public:
FSavegameManager *manager;
int Selected;
int TopItem;
int savepicLeft;
int savepicTop;
int savepicWidth;
int savepicHeight;
int rowHeight;
int listboxLeft;
int listboxTop;
int listboxWidth;
int listboxRows;
int listboxHeight;
int listboxRight;
int listboxBottom;
int commentLeft;
int commentTop;
int commentWidth;
int commentHeight;
int commentRight;
int commentBottom;
bool mEntering;
DTextEnterMenu *mInput = nullptr;
DLoadSaveMenu(DMenu *parent = nullptr, DListMenuDescriptor *desc = nullptr);
void OnDestroy() override;
};
IMPLEMENT_CLASS(DLoadSaveMenu, false, false)
//=============================================================================
//
// End of static savegame maintenance code
//
//=============================================================================
DLoadSaveMenu::DLoadSaveMenu(DMenu *parent, DListMenuDescriptor *desc)
: DListMenu(parent, desc)
{
manager = &savegameManager;
manager->ReadSaveStrings();
savepicLeft = 10;
savepicTop = 54*CleanYfac;
savepicWidth = 216*screen->GetWidth()/640;
savepicHeight = 135*screen->GetHeight()/400;
manager->WindowSize = savepicWidth / CleanXfac;
rowHeight = (SmallFont->GetHeight() + 1) * CleanYfac;
listboxLeft = savepicLeft + savepicWidth + 14;
listboxTop = savepicTop;
listboxWidth = screen->GetWidth() - listboxLeft - 10;
int listboxHeight1 = screen->GetHeight() - listboxTop - 10;
listboxRows = (listboxHeight1 - 1) / rowHeight;
listboxHeight = listboxRows * rowHeight + 1;
listboxRight = listboxLeft + listboxWidth;
listboxBottom = listboxTop + listboxHeight;
commentLeft = savepicLeft;
commentTop = savepicTop + savepicHeight + 16;
commentWidth = savepicWidth;
commentHeight = (51+(screen->GetHeight()>200?10:0))*CleanYfac;
commentRight = commentLeft + commentWidth;
commentBottom = commentTop + commentHeight;
PARAM_PROLOGUE;
ACTION_RETURN_POINTER(&savegameManager);
}
void DLoadSaveMenu::OnDestroy()
{
manager->ClearSaveStuff ();
Super::OnDestroy();
}
DEFINE_FIELD(FSaveGameNode, SaveTitle);
@ -850,26 +783,3 @@ DEFINE_FIELD(FSaveGameNode, bNoDelete);
DEFINE_FIELD(FSavegameManager, WindowSize);
DEFINE_FIELD(FSavegameManager, quickSaveSlot);
DEFINE_FIELD(DLoadSaveMenu, manager);
DEFINE_FIELD(DLoadSaveMenu, Selected);
DEFINE_FIELD(DLoadSaveMenu, TopItem);
DEFINE_FIELD(DLoadSaveMenu, savepicLeft);
DEFINE_FIELD(DLoadSaveMenu, savepicTop);
DEFINE_FIELD(DLoadSaveMenu, savepicWidth);
DEFINE_FIELD(DLoadSaveMenu, savepicHeight);
DEFINE_FIELD(DLoadSaveMenu, rowHeight);
DEFINE_FIELD(DLoadSaveMenu, listboxLeft);
DEFINE_FIELD(DLoadSaveMenu, listboxTop);
DEFINE_FIELD(DLoadSaveMenu, listboxWidth);
DEFINE_FIELD(DLoadSaveMenu, listboxRows);
DEFINE_FIELD(DLoadSaveMenu, listboxHeight);
DEFINE_FIELD(DLoadSaveMenu, listboxRight);
DEFINE_FIELD(DLoadSaveMenu, listboxBottom);
DEFINE_FIELD(DLoadSaveMenu, commentLeft);
DEFINE_FIELD(DLoadSaveMenu, commentTop);
DEFINE_FIELD(DLoadSaveMenu, commentWidth);
DEFINE_FIELD(DLoadSaveMenu, commentHeight);
DEFINE_FIELD(DLoadSaveMenu, commentRight);
DEFINE_FIELD(DLoadSaveMenu, commentBottom);
DEFINE_FIELD(DLoadSaveMenu, mEntering);
DEFINE_FIELD(DLoadSaveMenu, mInput);

View file

@ -48,14 +48,15 @@ struct SavegameManager native
native int WindowSize;
native SaveGameNode quickSaveSlot;
//void ReadSaveStrings();
native static SavegameManager GetManager();
native void ReadSaveStrings();
native void UnloadSaveData();
native int RemoveSaveSlot(int index);
native void LoadSavegame(int Selected);
native void DoSave(int Selected, String savegamestring);
native int ExtractSaveData(int index);
//void ClearSaveStuff();
native void ClearSaveStuff();
native bool DrawSavePic(int x, int y, int w, int h);
native void DrawSaveComment(Font font, int cr, int x, int y, int scalefactor);
native void SetFileInfo(int Selected);
@ -68,37 +69,86 @@ struct SavegameManager native
class LoadSaveMenu : ListMenu native
class LoadSaveMenu : ListMenu
{
native SavegameManager manager;
native int TopItem;
native int Selected;
SavegameManager manager;
int TopItem;
int Selected;
native int savepicLeft;
native int savepicTop;
native int savepicWidth;
native int savepicHeight;
native int rowHeight;
native int listboxLeft;
native int listboxTop;
native int listboxWidth;
int savepicLeft;
int savepicTop;
int savepicWidth;
int savepicHeight;
int rowHeight;
int listboxLeft;
int listboxTop;
int listboxWidth;
native int listboxRows;
native int listboxHeight;
native int listboxRight;
native int listboxBottom;
int listboxRows;
int listboxHeight;
int listboxRight;
int listboxBottom;
native int commentLeft;
native int commentTop;
native int commentWidth;
native int commentHeight;
native int commentRight;
native int commentBottom;
int commentLeft;
int commentTop;
int commentWidth;
int commentHeight;
int commentRight;
int commentBottom;
native bool mEntering;
native TextEnterMenu mInput;
bool mEntering;
TextEnterMenu mInput;
//=============================================================================
//
//
//
//=============================================================================
override void Init(Menu parent, ListMenuDescriptor desc)
{
Super.Init(parent, desc);
manager = SavegameManager.GetManager();
manager.ReadSaveStrings();
savepicLeft = 10;
savepicTop = 54*CleanYfac;
savepicWidth = 216*screen.GetWidth()/640;
savepicHeight = 135*screen.GetHeight()/400;
manager.WindowSize = savepicWidth / CleanXfac;
rowHeight = (SmallFont.GetHeight() + 1) * CleanYfac;
listboxLeft = savepicLeft + savepicWidth + 14;
listboxTop = savepicTop;
listboxWidth = screen.GetWidth() - listboxLeft - 10;
int listboxHeight1 = screen.GetHeight() - listboxTop - 10;
listboxRows = (listboxHeight1 - 1) / rowHeight;
listboxHeight = listboxRows * rowHeight + 1;
listboxRight = listboxLeft + listboxWidth;
listboxBottom = listboxTop + listboxHeight;
commentLeft = savepicLeft;
commentTop = savepicTop + savepicHeight + 16;
commentWidth = savepicWidth;
commentHeight = (51+(screen.GetHeight()>200?10:0))*CleanYfac;
commentRight = commentLeft + commentWidth;
commentBottom = commentTop + commentHeight;
}
//=============================================================================
//
//
//
//=============================================================================
override void OnDestroy()
{
manager.ClearSaveStuff ();
Super.OnDestroy();
}
//=============================================================================
//
//