mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- made some of the load/save menu's data a bit more scripting friendly, this mostly means removal of static string buffers.
This commit is contained in:
parent
0ffd475d8c
commit
128dfdeee6
5 changed files with 145 additions and 25 deletions
|
@ -120,8 +120,7 @@ int SavegameManager::InsertSaveNode(FSaveGameNode *node)
|
|||
unsigned int i;
|
||||
for (i = 0; i < SaveGames.Size(); i++)
|
||||
{
|
||||
if (SaveGames[i]->bOldVersion ||
|
||||
stricmp(node->Title, SaveGames[i]->Title) <= 0)
|
||||
if (SaveGames[i]->bOldVersion || node->SaveTitle.CompareNoCase(SaveGames[i]->SaveTitle) <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -212,7 +211,7 @@ void SavegameManager::ReadSaveStrings()
|
|||
node->Filename = filepath;
|
||||
node->bOldVersion = oldVer;
|
||||
node->bMissingWads = missing;
|
||||
strncpy(node->Title, title.GetChars(), SAVESTRINGSIZE);
|
||||
node->SaveTitle = title;
|
||||
InsertSaveNode(node);
|
||||
delete savegame;
|
||||
}
|
||||
|
@ -287,7 +286,7 @@ void SavegameManager::ReadSaveStrings()
|
|||
node->Filename = filepath;
|
||||
node->bOldVersion = true;
|
||||
node->bMissingWads = false;
|
||||
memcpy(node->Title, title, SAVESTRINGSIZE);
|
||||
node->SaveTitle = title;
|
||||
InsertSaveNode(node);
|
||||
}
|
||||
fclose(file);
|
||||
|
@ -324,7 +323,7 @@ void SavegameManager::NotifyNewSave(const char *file, const char *title, bool ok
|
|||
if (node->Filename.CompareNoCase(file) == 0)
|
||||
#endif
|
||||
{
|
||||
strcpy(node->Title, title);
|
||||
node->SaveTitle = title;
|
||||
node->bOldVersion = false;
|
||||
node->bMissingWads = false;
|
||||
if (okForQuicksave)
|
||||
|
@ -337,7 +336,7 @@ void SavegameManager::NotifyNewSave(const char *file, const char *title, bool ok
|
|||
}
|
||||
|
||||
node = new FSaveGameNode;
|
||||
strcpy(node->Title, title);
|
||||
node->SaveTitle = title;
|
||||
node->Filename = file;
|
||||
node->bOldVersion = false;
|
||||
node->bMissingWads = false;
|
||||
|
@ -597,7 +596,6 @@ protected:
|
|||
|
||||
// this needs to be kept in memory so that the texture can access it when it needs to.
|
||||
bool mEntering;
|
||||
char savegamestring[SAVESTRINGSIZE];
|
||||
DTextEnterMenu *mInput = nullptr;
|
||||
|
||||
DLoadSaveMenu(DMenu *parent = nullptr, DListMenuDescriptor *desc = nullptr);
|
||||
|
@ -756,7 +754,7 @@ void DLoadSaveMenu::Drawer ()
|
|||
if (!mEntering)
|
||||
{
|
||||
screen->DrawText (SmallFont, color,
|
||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->Title,
|
||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->SaveTitle.GetChars(),
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
else
|
||||
|
@ -770,7 +768,7 @@ void DLoadSaveMenu::Drawer ()
|
|||
else
|
||||
{
|
||||
screen->DrawText (SmallFont, color,
|
||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->Title,
|
||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->SaveTitle.GetChars(),
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
@ -936,7 +934,7 @@ bool DLoadSaveMenu::Responder (event_t *ev)
|
|||
{
|
||||
FString EndString;
|
||||
EndString.Format("%s" TEXTCOLOR_WHITE "%s" TEXTCOLOR_NORMAL "?\n\n%s",
|
||||
GStrings("MNU_DELETESG"), manager->SaveGames[Selected]->Title, GStrings("PRESSYN"));
|
||||
GStrings("MNU_DELETESG"), manager->SaveGames[Selected]->SaveTitle.GetChars(), GStrings("PRESSYN"));
|
||||
M_StartMessage (EndString, 0);
|
||||
}
|
||||
return true;
|
||||
|
@ -991,7 +989,7 @@ IMPLEMENT_CLASS(DSaveMenu, false, false)
|
|||
DSaveMenu::DSaveMenu(DMenu *parent, DListMenuDescriptor *desc)
|
||||
: DLoadSaveMenu(parent, desc)
|
||||
{
|
||||
strcpy (NewSaveNode.Title, GStrings["NEWSAVE"]);
|
||||
NewSaveNode.SaveTitle = GStrings["NEWSAVE"];
|
||||
NewSaveNode.bNoDelete = true;
|
||||
manager->SaveGames.Insert(0, &NewSaveNode);
|
||||
TopItem = 0;
|
||||
|
@ -1042,15 +1040,8 @@ bool DSaveMenu::MenuEvent (int mkey, bool fromcontroller)
|
|||
|
||||
if (mkey == MKEY_Enter)
|
||||
{
|
||||
if (Selected != 0)
|
||||
{
|
||||
strcpy (savegamestring, manager->SaveGames[Selected]->Title);
|
||||
}
|
||||
else
|
||||
{
|
||||
savegamestring[0] = 0;
|
||||
}
|
||||
mInput = new DTextEnterMenu(this, savegamestring, SAVESTRINGSIZE, 1, fromcontroller);
|
||||
const char *SavegameString = (Selected != 0)? manager->SaveGames[Selected]->SaveTitle.GetChars() : "";
|
||||
mInput = new DTextEnterMenu(this, SavegameString, SAVESTRINGSIZE, 1, fromcontroller);
|
||||
M_ActivateMenu(mInput);
|
||||
mEntering = true;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ extern FGameStartup GameStartupInfo;
|
|||
|
||||
struct FSaveGameNode
|
||||
{
|
||||
char Title[SAVESTRINGSIZE];
|
||||
FString SaveTitle;
|
||||
FString Filename;
|
||||
bool bOldVersion;
|
||||
bool bMissingWads;
|
||||
|
|
|
@ -548,7 +548,7 @@ DQuickSaveMenu::DQuickSaveMenu(bool playsound)
|
|||
{
|
||||
FString tempstring;
|
||||
|
||||
tempstring.Format(GStrings("QSPROMPT"), savegameManager.quickSaveSlot->Title);
|
||||
tempstring.Format(GStrings("QSPROMPT"), savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
Init(NULL, tempstring, 0, playsound);
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ void DQuickSaveMenu::HandleResult(bool res)
|
|||
{
|
||||
if (res)
|
||||
{
|
||||
G_SaveGame (savegameManager.quickSaveSlot->Filename.GetChars(), savegameManager.quickSaveSlot->Title);
|
||||
G_SaveGame (savegameManager.quickSaveSlot->Filename.GetChars(), savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/dismiss", snd_menuvolume, ATTN_NONE);
|
||||
M_ClearMenus();
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ CCMD (quicksave)
|
|||
// [mxd]. Just save the game, no questions asked.
|
||||
if (!saveloadconfirmation)
|
||||
{
|
||||
G_SaveGame(savegameManager.quickSaveSlot->Filename.GetChars(), savegameManager.quickSaveSlot->Title);
|
||||
G_SaveGame(savegameManager.quickSaveSlot->Filename.GetChars(), savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -644,7 +644,7 @@ DQuickLoadMenu::DQuickLoadMenu(bool playsound)
|
|||
{
|
||||
FString tempstring;
|
||||
|
||||
tempstring.Format(GStrings("QLPROMPT"), savegameManager.quickSaveSlot->Title);
|
||||
tempstring.Format(GStrings("QLPROMPT"), savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
Init(NULL, tempstring, 0, playsound);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "zscript/menu/optionmenuitems.txt"
|
||||
#include "zscript/menu/colorpickermenu.txt"
|
||||
#include "zscript/menu/joystickmenu.txt"
|
||||
#include "zscript/menu/loadsavemenu.txt"
|
||||
#include "zscript/menu/playermenu.txt"
|
||||
#include "zscript/menu/playerdisplay.txt"
|
||||
#include "zscript/menu/playercontrols.txt"
|
||||
|
|
128
wadsrc/static/zscript/menu/loadsavemenu.txt
Normal file
128
wadsrc/static/zscript/menu/loadsavemenu.txt
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
** loadsavemenu.cpp
|
||||
** The load game and save game menus
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2001-2010 Randy Heit
|
||||
** Copyright 2010-2017 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
/*
|
||||
struct SavegameManager native
|
||||
{
|
||||
native int LastSaved;
|
||||
native int LastAccessed;
|
||||
native int WindowSize;
|
||||
//SaveGameNode quickSaveSlot = nullptr;
|
||||
//FBrokenLines *SaveComment = nullptr;
|
||||
|
||||
void ClearSaveGames();
|
||||
int InsertSaveNode(FSaveGameNode *node);
|
||||
int RemoveSaveSlot(int index);
|
||||
void ReadSaveStrings();
|
||||
void NotifyNewSave(const char *file, const char *title, bool okForQuicksave);
|
||||
void LoadSavegame(int Selected);
|
||||
void DoSave(int Selected, const char *savegamestring);
|
||||
void DeleteEntry(int Selected);
|
||||
void ExtractSaveData(int index);
|
||||
void UnloadSaveData();
|
||||
void ClearSaveStuff();
|
||||
bool DrawSavePic(int x, int y, int w, int h);
|
||||
void SetFileInfo(int Selected);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
class LoadSaveMenu : ListMenu native
|
||||
{
|
||||
//native SavegameManager manager;
|
||||
//native int TopItem;
|
||||
//native int Selected;
|
||||
}
|
||||
|
||||
class SaveMenu : LoadSaveMenu native
|
||||
{
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class LoadMenu : LoadSaveMenu native
|
||||
{
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
override void Init(Menu parent, ListMenuDescriptor desc)
|
||||
{
|
||||
Super.Init(parent, desc);
|
||||
TopItem = 0;
|
||||
if (manager.LastAccessed != -1)
|
||||
{
|
||||
Selected = manager.LastAccessed;
|
||||
}
|
||||
manager.ExtractSaveData (Selected);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
override bool MenuEvent (int mkey, bool fromcontroller)
|
||||
{
|
||||
if (Super.MenuEvent(mkey, fromcontroller))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Selected == -1 || manager.SaveGames.Size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mkey == MKEY_Enter)
|
||||
{
|
||||
manager.LoadSavegame(Selected);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in a new issue