initial work on HighScoresDialog

This commit is contained in:
thrust26 2020-02-11 20:28:06 +01:00
parent d825ebc99e
commit 4b116b3aef
16 changed files with 366 additions and 10 deletions

View File

@ -507,6 +507,7 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo
{Event::UnwindAllMenu, KBDK_UP, MOD3},
{Event::ShowScore, KBDK_S, KBDM_SHIFT | KBDM_CTRL},
{Event::ShowVariation, KBDK_V, KBDM_SHIFT | KBDM_CTRL},
{Event::HighScoresMenuMode, KBDK_HOME},
#if defined(RETRON77)
{Event::ConsoleColorToggle, KBDK_F4}, // back ("COLOR","B/W")

View File

@ -120,7 +120,7 @@ class Event
ToggleFrameStats, ToggleSAPortOrder, ExitGame,
// add new events from here to avoid that user remapped events get overwritten
ShowScore, ShowVariation,
ShowScore, ShowVariation, HighScoresMenuMode,
LastType
};
@ -135,7 +135,7 @@ class Event
};
// Event list version, update only if the id of existing(!) event types changed
static constexpr Int32 VERSION = 3;
static constexpr Int32 VERSION = 4;
using EventSet = std::set<Event::Type>;

View File

@ -56,6 +56,7 @@
#ifdef GUI_SUPPORT
#include "Menu.hxx"
#include "CommandMenu.hxx"
#include "HighScoresMenu.hxx"
#include "MessageMenu.hxx"
#include "DialogContainer.hxx"
#include "Launcher.hxx"
@ -1057,6 +1058,15 @@ bool EventHandler::changeStateByEvent(Event::Type type)
handled = false;
break;
case Event::HighScoresMenuMode:
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
enterMenuMode(EventHandlerState::HIGHSCORESMENU);
else if(myState == EventHandlerState::HIGHSCORESMENU)
leaveMenuMode();
else
handled = false;
break;
case Event::TimeMachineMode:
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
enterTimeMachineMenuMode(0, false);
@ -1758,6 +1768,11 @@ void EventHandler::setState(EventHandlerState state)
enableTextEvents(true);
break;
case EventHandlerState::HIGHSCORESMENU:
myOverlay = &myOSystem.highscoresMenu();
enableTextEvents(true);
break;
case EventHandlerState::MESSAGEMENU:
myOverlay = &myOSystem.messageMenu();
enableTextEvents(true);

View File

@ -26,6 +26,7 @@ enum class EventHandlerState {
LAUNCHER,
OPTIONSMENU,
CMDMENU,
HIGHSCORESMENU,
MESSAGEMENU,
DEBUGGER,
NONE

View File

@ -42,6 +42,7 @@
#include "Launcher.hxx"
#include "Menu.hxx"
#include "CommandMenu.hxx"
#include "HighScoresMenu.hxx"
#include "MessageMenu.hxx"
#include "TimeMachine.hxx"
#endif
@ -332,6 +333,18 @@ void FrameBuffer::update(bool force)
break; // EventHandlerState::CMDMENU
}
case EventHandlerState::HIGHSCORESMENU:
{
force = force || myOSystem.highscoresMenu().needsRedraw();
if (force)
{
clear();
myTIASurface->render();
myOSystem.highscoresMenu().draw(force);
}
break; // EventHandlerState::HIGHSCORESMENU
}
case EventHandlerState::MESSAGEMENU:
{
force = force || myOSystem.messageMenu().needsRedraw();

View File

@ -33,6 +33,7 @@
#ifdef GUI_SUPPORT
#include "Menu.hxx"
#include "CommandMenu.hxx"
#include "HighScoresMenu.hxx"
#include "MessageMenu.hxx"
#include "Launcher.hxx"
#include "TimeMachine.hxx"
@ -180,6 +181,7 @@ bool OSystem::create()
// Create various subsystems (menu and launcher GUI objects, etc)
myMenu = make_unique<Menu>(*this);
myCommandMenu = make_unique<CommandMenu>(*this);
myHighScoresMenu = make_unique<HighScoresMenu>(*this);
myMessageMenu = make_unique<MessageMenu>(*this);
myTimeMachine = make_unique<TimeMachine>(*this);
myLauncher = make_unique<Launcher>(*this);

View File

@ -38,6 +38,7 @@ class AudioSettings;
#endif
#ifdef GUI_SUPPORT
class CommandMenu;
class HighScoresMenu;
class Launcher;
class Menu;
class MessageMenu;
@ -219,6 +220,13 @@ class OSystem
*/
CommandMenu& commandMenu() const { return *myCommandMenu; }
/**
Get the highscores menu of the system.
@return The highscores menu object
*/
HighScoresMenu& highscoresMenu() const { return *myHighScoresMenu; }
/**
Get the message menu of the system.
@ -506,12 +514,15 @@ class OSystem
// Pointer to the CommandMenu object
unique_ptr<CommandMenu> myCommandMenu;
// Pointer to the CommandMenu object
unique_ptr<MessageMenu> myMessageMenu;
// Pointer to the HighScoresMenu object
unique_ptr<HighScoresMenu> myHighScoresMenu;
// Pointer to the Launcher object
unique_ptr<Launcher> myLauncher;
// Pointer to the MessageMenu object
unique_ptr<MessageMenu> myMessageMenu;
// Pointer to the TimeMachine object
unique_ptr<TimeMachine> myTimeMachine;
#endif

View File

@ -18,7 +18,6 @@
#ifndef COMMAND_DIALOG_HXX
#define COMMAND_DIALOG_HXX
class Properties;
class CommandSender;
class DialogContainer;
class OSystem;

View File

@ -24,10 +24,6 @@
CommandMenu::CommandMenu(OSystem& osystem)
: DialogContainer(osystem)
{
if (osystem.settings().getBool("minimal_ui"))
myBaseDialog = new MinUICommandDialog(myOSystem, *this);
else
myBaseDialog = new CommandDialog(myOSystem, *this);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -39,5 +35,11 @@ CommandMenu::~CommandMenu()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog* CommandMenu::baseDialog()
{
if (myBaseDialog == nullptr)
if (myOSystem.settings().getBool("minimal_ui"))
myBaseDialog = new MinUICommandDialog(myOSystem, *this);
else
myBaseDialog = new CommandDialog(myOSystem, *this);
return myBaseDialog;
}

View File

@ -0,0 +1,138 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "Console.hxx"
#include "EventHandler.hxx"
#include "Font.hxx"
#include "FBSurface.hxx"
//#include "StringParser.hxx"
#include "EditTextWidget.hxx"
#include "PopUpWidget.hxx"
#include "HighScoresDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h)
: Dialog(osystem, parent, font, "High Scores")
{
const GUI::Font& ifont = instance().frameBuffer().infoFont();
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight(),
buttonHeight = font.getLineHeight() + 4;
//infoLineHeight = ifont.getLineHeight();
const int VBORDER = 8;
const int HBORDER = 10;
const int VGAP = 4;
int xpos, ypos, lwidth, fwidth, pwidth, tabID;
WidgetArray wid;
VariantList items;
_w = 400; // max_w - 20;
_h = 400; // max_h - 20;
ypos = VBORDER + _th; xpos = HBORDER;
//items.clear();
StaticTextWidget* s = new StaticTextWidget(this, font, xpos, ypos + 1, "Variation ");
myVariation = new PopUpWidget(this, font, s->getRight(), ypos,
font.getStringWidth("256"), lineHeight, items, "", 0, 0);
ypos += lineHeight + VGAP * 2;
int xposRank = HBORDER;
int xposScore = xposRank + font.getStringWidth("Rank") + 16;
int xposName = xposScore + font.getStringWidth("123456") + 24;
int xposExtra = xposName + font.getStringWidth("Date") + 16;
int xposDate = xposExtra + font.getStringWidth("Round") + 16;
int nWidth = font.getStringWidth("ABC") + 4;
new StaticTextWidget(this, font, xposRank, ypos + 1, "Rank");
new StaticTextWidget(this, font, xposScore, ypos + 1, "Score");
new StaticTextWidget(this, font, xposName - 2, ypos + 1, "Name");
new StaticTextWidget(this, font, xposExtra, ypos + 1, "Round");
new StaticTextWidget(this, font, xposDate+16, ypos + 1, "Date Time");
ypos += lineHeight + VGAP;
for (uInt32 p = 0; p < NUM_POSITIONS; ++p)
{
myPositions[p] = new StaticTextWidget(this, font, xposRank, ypos + 1,
(p < 9 ? " " : "") + std::to_string(p + 1) + ". ");
myScores[p] = new StaticTextWidget(this, font, xposScore, ypos + 1, "123456");
myNames[p] = new EditTextWidget(this, font, xposName, ypos + 1, nWidth, lineHeight, "JTZ");
myNames[p]->setEditable(false);
wid.push_back(myNames[p]);
new StaticTextWidget(this, font, xposExtra, ypos + 1, " 123");
//new StaticTextWidget(this, font, xposDate, ypos + 1, "12.02.20 17:15");
//new StaticTextWidget(this, font, xposDate, ypos + 1, "02/12/20 12:30am");
new StaticTextWidget(this, font, xposDate, ypos + 1, "12-02-20 17:15");
ypos += lineHeight + VGAP;
}
ypos += VGAP;
myMD5 = new StaticTextWidget(this, ifont, xpos, ypos + 1, "MD5: 9ad36e699ef6f45d9eb6c4cf90475c9f");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HighScoresDialog::~HighScoresDialog()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HighScoresDialog::loadConfig()
{
// Enable blending (only once is necessary)
if(!surface().attributes().blending)
{
surface().attributes().blending = true;
surface().attributes().blendalpha = 90;
surface().applyAttributes();
}
VariantList items;
items.clear();
for (Int32 i = 1; i <= 10; ++i)
VarList::push_back(items, i, i);
myVariation->addItems(items);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HighScoresDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
switch (cmd)
{
case kOKCmd:
case kCloseCmd:
instance().eventHandler().handleEvent(Event::ExitMode);
break;
default:
Dialog::handleCommand(sender, cmd, data, 0);
}
}

View File

@ -0,0 +1,64 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef MESSAGE_DIALOG_HXX
#define MESSAGE_DIALOG_HXX
//class Properties;
class CommandSender;
class DialogContainer;
class OSystem;
class EditTextWidget;
class PopUpWidget;
#include "Dialog.hxx"
/**
The dialog for displaying high scores in Stella.
@author Thomas Jentzsch
*/
class HighScoresDialog : public Dialog
{
public:
static const uInt32 NUM_POSITIONS = 10;
HighScoresDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h);
virtual ~HighScoresDialog();
protected:
void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
private:
PopUpWidget* myVariation;
StaticTextWidget* myPositions[NUM_POSITIONS];
StaticTextWidget* myScores[NUM_POSITIONS];
EditTextWidget* myNames[NUM_POSITIONS];
StaticTextWidget* myMD5;
private:
// Following constructors and assignment operators not supported
HighScoresDialog() = delete;
HighScoresDialog(const HighScoresDialog&) = delete;
HighScoresDialog(HighScoresDialog&&) = delete;
HighScoresDialog& operator=(const HighScoresDialog&) = delete;
HighScoresDialog& operator=(HighScoresDialog&&) = delete;
};
#endif

View File

@ -0,0 +1,43 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "Dialog.hxx"
#include "FrameBuffer.hxx"
#include "HighScoresDialog.hxx"
#include "HighScoresMenu.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HighScoresMenu::HighScoresMenu(OSystem& osystem)
: DialogContainer(osystem)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HighScoresMenu::~HighScoresMenu()
{
delete myHighScoresDialog; myHighScoresDialog = nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog* HighScoresMenu::baseDialog()
{
if (myHighScoresDialog == nullptr)
myHighScoresDialog = new HighScoresDialog(myOSystem, *this, myOSystem.frameBuffer().font(),
FBMinimum::Width, FBMinimum::Height);
return myHighScoresDialog;
}

View File

@ -0,0 +1,52 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef HIGHSCORES_MENU_HXX
#define HIGHSCORES_MENU_HXX
class OSystem;
class HighScoresDialog;
#include "DialogContainer.hxx"
/**
The base menu for the high scores dialog in Stella.
@author Thomas Jentzsch
*/
class HighScoresMenu : public DialogContainer
{
public:
/**
Create a new menu stack
*/
explicit HighScoresMenu(OSystem& osystem);
virtual ~HighScoresMenu();
private:
Dialog* baseDialog() override;
HighScoresDialog* myHighScoresDialog{nullptr};
private:
// Following constructors and assignment operators not supported
HighScoresMenu() = delete;
HighScoresMenu(const HighScoresMenu&) = delete;
HighScoresMenu(HighScoresMenu&&) = delete;
HighScoresMenu& operator=(const HighScoresMenu&) = delete;
HighScoresMenu& operator=(HighScoresMenu&&) = delete;
};
#endif

View File

@ -18,7 +18,6 @@
#ifndef MESSAGE_DIALOG_HXX
#define MESSAGE_DIALOG_HXX
class Properties;
class CommandSender;
class DialogContainer;
class OSystem;

View File

@ -517,6 +517,8 @@
<ClCompile Include="..\gui\ColorWidget.cxx" />
<ClCompile Include="..\gui\DeveloperDialog.cxx" />
<ClCompile Include="..\gui\FileListWidget.cxx" />
<ClCompile Include="..\gui\HighScoresDialog.cxx" />
<ClCompile Include="..\gui\HighScoresMenu.cxx" />
<ClCompile Include="..\gui\JoystickDialog.cxx" />
<ClCompile Include="..\gui\LoggerDialog.cxx" />
<ClCompile Include="..\gui\MessageDialog.cxx" />
@ -1254,6 +1256,8 @@
<ClInclude Include="..\gui\ConsoleMediumFont.hxx" />
<ClInclude Include="..\gui\DeveloperDialog.hxx" />
<ClInclude Include="..\gui\FileListWidget.hxx" />
<ClInclude Include="..\gui\HighScoresDialog.hxx" />
<ClInclude Include="..\gui\HighScoresMenu.hxx" />
<ClInclude Include="..\gui\JoystickDialog.hxx" />
<ClInclude Include="..\gui\LoggerDialog.hxx" />
<ClInclude Include="..\gui\MessageDialog.hxx" />

View File

@ -1008,6 +1008,12 @@
<ClCompile Include="..\common\HighScoresManager.cxx">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\gui\HighScoresMenu.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
<ClCompile Include="..\gui\HighScoresDialog.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\bspf.hxx">
@ -2060,6 +2066,12 @@
<ClInclude Include="..\common\HighScoresManager.hxx">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\gui\HighScoresMenu.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
<ClInclude Include="..\gui\HighScoresDialog.hxx">
<Filter>Source Files\gui</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="stella.ico">