mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- sciptified DLoadSaveMenu::Drawer.
This commit is contained in:
parent
4a6d0f1fa5
commit
e46d378fb2
2 changed files with 124 additions and 115 deletions
|
@ -593,6 +593,16 @@ bool FSavegameManager::DrawSavePic(int x, int y, int w, int h)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(FSavegameManager, DrawSavePic)
|
||||||
|
{
|
||||||
|
PARAM_SELF_STRUCT_PROLOGUE(FSavegameManager);
|
||||||
|
PARAM_INT(x);
|
||||||
|
PARAM_INT(y);
|
||||||
|
PARAM_INT(w);
|
||||||
|
PARAM_INT(h);
|
||||||
|
ACTION_RETURN_BOOL(self->DrawSavePic(x, y, w, h));
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -618,6 +628,18 @@ void FSavegameManager::DrawSaveComment(FFont *font, int cr, int x, int y, int sc
|
||||||
CleanYfac = sy;
|
CleanYfac = sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(FSavegameManager, DrawSaveComment)
|
||||||
|
{
|
||||||
|
PARAM_SELF_STRUCT_PROLOGUE(FSavegameManager);
|
||||||
|
PARAM_POINTER(fnt, FFont);
|
||||||
|
PARAM_INT(cr);
|
||||||
|
PARAM_INT(x);
|
||||||
|
PARAM_INT(y);
|
||||||
|
PARAM_INT(fac);
|
||||||
|
self->DrawSaveComment(fnt, cr, x, y, fac);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
|
@ -770,8 +792,6 @@ public:
|
||||||
|
|
||||||
DLoadSaveMenu(DMenu *parent = nullptr, DListMenuDescriptor *desc = nullptr);
|
DLoadSaveMenu(DMenu *parent = nullptr, DListMenuDescriptor *desc = nullptr);
|
||||||
void OnDestroy() override;
|
void OnDestroy() override;
|
||||||
|
|
||||||
void Drawer ();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DLoadSaveMenu, false, false)
|
IMPLEMENT_CLASS(DLoadSaveMenu, false, false)
|
||||||
|
@ -820,117 +840,6 @@ void DLoadSaveMenu::OnDestroy()
|
||||||
Super::OnDestroy();
|
Super::OnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DLoadSaveMenu::Drawer ()
|
|
||||||
{
|
|
||||||
Super::Drawer();
|
|
||||||
|
|
||||||
FSaveGameNode *node;
|
|
||||||
int i;
|
|
||||||
unsigned j;
|
|
||||||
bool didSeeSelected = false;
|
|
||||||
|
|
||||||
// Draw picture area
|
|
||||||
if (gameaction == ga_loadgame || gameaction == ga_loadgamehidecon || gameaction == ga_savegame)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
V_DrawFrame (savepicLeft, savepicTop, savepicWidth, savepicHeight);
|
|
||||||
if (!manager->DrawSavePic(savepicLeft, savepicTop, savepicWidth, savepicHeight))
|
|
||||||
{
|
|
||||||
screen->Clear (savepicLeft, savepicTop,
|
|
||||||
savepicLeft+savepicWidth, savepicTop+savepicHeight, 0, 0);
|
|
||||||
|
|
||||||
if (manager->SavegameCount() > 0)
|
|
||||||
{
|
|
||||||
const char *text =
|
|
||||||
(Selected == -1 || !manager->GetSavegame(Selected)->bOldVersion)
|
|
||||||
? GStrings("MNU_NOPICTURE") : GStrings("MNU_DIFFVERSION");
|
|
||||||
const int textlen = SmallFont->StringWidth (text)*CleanXfac;
|
|
||||||
|
|
||||||
screen->DrawText (SmallFont, CR_GOLD, savepicLeft+(savepicWidth-textlen)/2,
|
|
||||||
savepicTop+(savepicHeight-rowHeight)/2, text,
|
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw comment area
|
|
||||||
V_DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
|
|
||||||
screen->Clear (commentLeft, commentTop, commentRight, commentBottom, 0, 0);
|
|
||||||
|
|
||||||
manager->DrawSaveComment(SmallFont, CR_GOLD, commentLeft, commentTop, CleanYfac);
|
|
||||||
|
|
||||||
// Draw file area
|
|
||||||
V_DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
|
||||||
screen->Clear (listboxLeft, listboxTop, listboxRight, listboxBottom, 0, 0);
|
|
||||||
|
|
||||||
if (manager->SavegameCount() == 0)
|
|
||||||
{
|
|
||||||
const char * text = GStrings("MNU_NOFILES");
|
|
||||||
const int textlen = SmallFont->StringWidth (text)*CleanXfac;
|
|
||||||
|
|
||||||
screen->DrawText (SmallFont, CR_GOLD, listboxLeft+(listboxWidth-textlen)/2,
|
|
||||||
listboxTop+(listboxHeight-rowHeight)/2, text,
|
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0, j = TopItem; i < listboxRows && j < manager->SavegameCount(); i++,j++)
|
|
||||||
{
|
|
||||||
int color;
|
|
||||||
node = manager->GetSavegame(j);
|
|
||||||
if (node->bOldVersion)
|
|
||||||
{
|
|
||||||
color = CR_BLUE;
|
|
||||||
}
|
|
||||||
else if (node->bMissingWads)
|
|
||||||
{
|
|
||||||
color = CR_ORANGE;
|
|
||||||
}
|
|
||||||
else if ((int)j == Selected)
|
|
||||||
{
|
|
||||||
color = CR_WHITE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
color = CR_TAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((int)j == Selected)
|
|
||||||
{
|
|
||||||
screen->Clear (listboxLeft, listboxTop+rowHeight*i,
|
|
||||||
listboxRight, listboxTop+rowHeight*(i+1), -1,
|
|
||||||
mEntering ? MAKEARGB(255,255,0,0) : MAKEARGB(255,0,0,255));
|
|
||||||
didSeeSelected = true;
|
|
||||||
if (!mEntering)
|
|
||||||
{
|
|
||||||
screen->DrawText (SmallFont, color,
|
|
||||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->SaveTitle.GetChars(),
|
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FString s = mInput->GetText() + SmallFont->GetCursor();
|
|
||||||
screen->DrawText (SmallFont, CR_WHITE,
|
|
||||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, s,
|
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
screen->DrawText (SmallFont, color,
|
|
||||||
listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node->SaveTitle.GetChars(),
|
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_FIELD(FSaveGameNode, SaveTitle);
|
DEFINE_FIELD(FSaveGameNode, SaveTitle);
|
||||||
DEFINE_FIELD(FSaveGameNode, Filename);
|
DEFINE_FIELD(FSaveGameNode, Filename);
|
||||||
|
|
|
@ -56,8 +56,8 @@ struct SavegameManager native
|
||||||
native void DoSave(int Selected, String savegamestring);
|
native void DoSave(int Selected, String savegamestring);
|
||||||
native int ExtractSaveData(int index);
|
native int ExtractSaveData(int index);
|
||||||
//void ClearSaveStuff();
|
//void ClearSaveStuff();
|
||||||
//bool DrawSavePic(int x, int y, int w, int h);
|
native bool DrawSavePic(int x, int y, int w, int h);
|
||||||
//void DrawSaveComment(Font font, int cr, int x, int y, int scalefactor);
|
native void DrawSaveComment(Font font, int cr, int x, int y, int scalefactor);
|
||||||
native void SetFileInfo(int Selected);
|
native void SetFileInfo(int Selected);
|
||||||
native int SavegameCount();
|
native int SavegameCount();
|
||||||
native SaveGameNode GetSavegame(int i);
|
native SaveGameNode GetSavegame(int i);
|
||||||
|
@ -99,6 +99,106 @@ class LoadSaveMenu : ListMenu native
|
||||||
native TextEnterMenu mInput;
|
native TextEnterMenu mInput;
|
||||||
|
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
override void Drawer ()
|
||||||
|
{
|
||||||
|
Super.Drawer();
|
||||||
|
|
||||||
|
SaveGameNode node;
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
bool didSeeSelected = false;
|
||||||
|
|
||||||
|
// Draw picture area
|
||||||
|
if (gameaction == ga_loadgame || gameaction == ga_loadgamehidecon || gameaction == ga_savegame)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Screen.DrawFrame (savepicLeft, savepicTop, savepicWidth, savepicHeight);
|
||||||
|
if (!manager.DrawSavePic(savepicLeft, savepicTop, savepicWidth, savepicHeight))
|
||||||
|
{
|
||||||
|
screen.Clear (savepicLeft, savepicTop, savepicLeft+savepicWidth, savepicTop+savepicHeight, 0, 0);
|
||||||
|
|
||||||
|
if (manager.SavegameCount() > 0)
|
||||||
|
{
|
||||||
|
String text = (Selected == -1 || !manager.GetSavegame(Selected).bOldVersion)? Stringtable.Localize("$MNU_NOPICTURE") : Stringtable.Localize("$MNU_DIFFVERSION");
|
||||||
|
int textlen = SmallFont.StringWidth(text) * CleanXfac;
|
||||||
|
|
||||||
|
screen.DrawText (SmallFont, Font.CR_GOLD, savepicLeft+(savepicWidth-textlen)/2,
|
||||||
|
savepicTop+(savepicHeight-rowHeight)/2, text, DTA_CleanNoMove, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw comment area
|
||||||
|
Screen.DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
|
||||||
|
screen.Clear (commentLeft, commentTop, commentRight, commentBottom, 0, 0);
|
||||||
|
|
||||||
|
manager.DrawSaveComment(SmallFont, Font.CR_GOLD, commentLeft, commentTop, CleanYfac);
|
||||||
|
|
||||||
|
// Draw file area
|
||||||
|
Screen.DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
|
||||||
|
screen.Clear (listboxLeft, listboxTop, listboxRight, listboxBottom, 0, 0);
|
||||||
|
|
||||||
|
if (manager.SavegameCount() == 0)
|
||||||
|
{
|
||||||
|
String text = Stringtable.Localize("$MNU_NOFILES");
|
||||||
|
int textlen = SmallFont.StringWidth(text) * CleanXfac;
|
||||||
|
|
||||||
|
screen.DrawText (SmallFont, Font.CR_GOLD, listboxLeft+(listboxWidth-textlen)/2, listboxTop+(listboxHeight-rowHeight)/2, text, DTA_CleanNoMove, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = TopItem;
|
||||||
|
for (i = 0; i < listboxRows && j < manager.SavegameCount(); i++)
|
||||||
|
{
|
||||||
|
int colr;
|
||||||
|
node = manager.GetSavegame(j);
|
||||||
|
if (node.bOldVersion)
|
||||||
|
{
|
||||||
|
colr = Font.CR_BLUE;
|
||||||
|
}
|
||||||
|
else if (node.bMissingWads)
|
||||||
|
{
|
||||||
|
colr = Font.CR_ORANGE;
|
||||||
|
}
|
||||||
|
else if (j == Selected)
|
||||||
|
{
|
||||||
|
colr = Font.CR_WHITE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colr = Font.CR_TAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j == Selected)
|
||||||
|
{
|
||||||
|
screen.Clear (listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1), mEntering ? Color(255,255,0,0) : Color(255,0,0,255));
|
||||||
|
didSeeSelected = true;
|
||||||
|
if (!mEntering)
|
||||||
|
{
|
||||||
|
screen.DrawText (SmallFont, colr, listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node.SaveTitle, DTA_CleanNoMove, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String s = mInput.GetText() .. SmallFont.GetCursor();
|
||||||
|
screen.DrawText (SmallFont, Font.CR_WHITE, listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, s, DTA_CleanNoMove, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screen.DrawText (SmallFont, colr, listboxLeft+1, listboxTop+rowHeight*i+CleanYfac, node.SaveTitle, DTA_CleanNoMove, true);
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue