2005-02-27 23:41:19 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2011-12-31 21:56:36 +00:00
|
|
|
// Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2005-02-27 23:41:19 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2005-02-27 23:41:19 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2005-03-10 22:59:40 +00:00
|
|
|
//
|
|
|
|
// Based on code from ScummVM - Scumm Interpreter
|
|
|
|
// Copyright (C) 2002-2004 The ScummVM project
|
2005-02-27 23:41:19 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef DIALOG_HXX
|
|
|
|
#define DIALOG_HXX
|
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
class FBSurface;
|
2005-03-11 23:36:30 +00:00
|
|
|
class OSystem;
|
2005-05-04 19:04:47 +00:00
|
|
|
class DialogContainer;
|
2005-08-10 12:23:42 +00:00
|
|
|
class TabWidget;
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
#include "Command.hxx"
|
|
|
|
#include "Widget.hxx"
|
|
|
|
#include "GuiObject.hxx"
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
#include "bspf.hxx"
|
2005-02-27 23:41:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This is the base class for all dialog boxes.
|
|
|
|
|
|
|
|
@author Stephen Anthony
|
2009-05-13 13:55:40 +00:00
|
|
|
@version $Id$
|
2005-02-27 23:41:19 +00:00
|
|
|
*/
|
2005-03-11 23:36:30 +00:00
|
|
|
class Dialog : public GuiObject
|
2005-02-27 23:41:19 +00:00
|
|
|
{
|
2005-05-04 19:04:47 +00:00
|
|
|
friend class DialogContainer;
|
2005-03-14 04:08:15 +00:00
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
struct Focus {
|
|
|
|
Widget* focusedWidget;
|
|
|
|
WidgetArray focusList;
|
|
|
|
};
|
Moved the Array class from namespace GUI to Common, since it's used in
many places other than the GUI code.
As a diversion from the joystick stuff, I'm experimenting with event
recording. Eventually, this will allow one to record a state + events,
and then load that INP file again. When loaded, Stella will replay the
events, and you'll be able to see exactly what happened before. Since
this is based on frames, the replaying can speed up and slow
down by changing the emulation framerate. And it can be exited at any
point, and normal emulation can continue. Or at least that's how I
want it to work.
A preliminary spec for the event stream is -X A B A B ... -X ...,
where X represents how many frames to wait, and 'A B' are event/value
pairs representing an event in Stella. I think this is very similar
to the scheme that Thomas J. recently added to z26, so converting to
a Stella eventstream should be easy.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@905 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2005-12-09 01:16:14 +00:00
|
|
|
typedef Common::Array<Focus> FocusList;
|
2005-08-10 12:23:42 +00:00
|
|
|
|
2005-02-27 23:41:19 +00:00
|
|
|
public:
|
2005-05-10 19:20:45 +00:00
|
|
|
Dialog(OSystem* instance, DialogContainer* parent,
|
2008-06-13 13:14:52 +00:00
|
|
|
int x, int y, int w, int h, bool isBase = false);
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
virtual ~Dialog();
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
bool isVisible() const { return _visible; }
|
2008-06-13 13:14:52 +00:00
|
|
|
bool isBase() const { return _isBase; }
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-03-12 01:47:15 +00:00
|
|
|
virtual void open();
|
|
|
|
virtual void close();
|
OK, some huge changes across the board, so lets see if I get it all:
After much request, added ability to access the settings menu from the
ROM browser dialog. This menu now contains almost all items that can
be selected in Stella, and can be accessed in-game as before.
Completely removed pause functionality from the core code. It made
sense back when Stella was a single-mode program: there were two modes;
emulation and pause. Now that there are other event modes, the
EventHandler state machine is getting too complicated. If you want to
pause, you can simply enter one of the in-game menus. Related to this,
when the app is minimized, Stella enters the menu dialog state.
Previously, minimizing the app caused a pause, but since there was no
onscreen feedback, many people assumed the app locked up.
Added centering to all Dialog boxes, which is done dynamically, as they're
placed on the dialog stack to be drawn to the screen.
Cleaned up the API of Console/FrameBuffer/OSystem classes wrt to palettes
and timing. Parts of each were being done in different classes; now it
should be more consistent.
Started infrastructure for user-selectable UI palettes. For now, there's
no way to change it in the GUI, and it defaults to the normal palette.
Eventually, there will be several choices selectable from an in-game
menu.
Removed '-channels' commandline argument, since that feature can be
set from the ROM properties.
Added '128' to the choices for fragment size in AudioDialog.
Tweaked the OpenGL dynamic loading code to test both the given GL
lib, and if that fails to use auto-detection. It seems in the OSX port,
the first approach works for some people, and not the other (and vice-versa),
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1255 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-12-30 22:26:29 +00:00
|
|
|
virtual void center();
|
2005-03-10 22:59:40 +00:00
|
|
|
virtual void drawDialog();
|
2005-03-15 22:28:05 +00:00
|
|
|
virtual void loadConfig() {}
|
|
|
|
virtual void saveConfig() {}
|
2005-03-26 19:26:48 +00:00
|
|
|
virtual void setDefaults() {}
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
void addFocusWidget(Widget* w);
|
|
|
|
void addToFocusList(WidgetArray& list, int id = -1);
|
2007-01-24 19:17:33 +00:00
|
|
|
void addBGroupToFocusList(WidgetArray& list) { _ourButtonGroup = list; }
|
2005-08-10 12:23:42 +00:00
|
|
|
void redrawFocus();
|
|
|
|
void addTabWidget(TabWidget* w) { _ourTab = w; }
|
2006-11-28 21:48:56 +00:00
|
|
|
void addOKWidget(Widget* w) { _okWidget = w; }
|
|
|
|
void addCancelWidget(Widget* w) { _cancelWidget = w; }
|
Removed the ability to emulate the mouse cursor with the joystick while
in GUI menu mode. The code was too troublesome to fix, and navigating
a GUI with a joystick simulating a mouse is a broken concept anyway.
In place of joy-is-mouse navigation, added the ability to use the cursor
keys or joysticks axes to 'tab' between different focused objects in
GUI mode. This is much more intuitive, and is how navigation works in
a mouse-less, game console based system. Also, any joystick button (or
enter/space keys) activate the currently focused item.
For now, only the CommandDialog can be accessed this way. It really
only makes sense here anyway, since many GUI objects in the other menus
really need access to a keyboard and mouse, and if you have those, one
can already navigate the menu.
Overall, this should make arcade cabinet style access much easier. One
can map the CommandDialog to a joystick button, navigate with the joystick
axes, and select an item with any joystick button. So Stella can be
started, play a game, and then exit, all by just using the joystick. It
also solves quite a few usability problems for the WinCE and PSP ports.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@918 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2005-12-19 02:19:49 +00:00
|
|
|
void setFocus(Widget* w);
|
2005-08-10 12:23:42 +00:00
|
|
|
|
2011-05-10 15:04:19 +00:00
|
|
|
FBSurface& surface() { return *_surface; }
|
2008-06-13 13:14:52 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
protected:
|
|
|
|
virtual void draw();
|
2005-03-12 01:47:15 +00:00
|
|
|
void releaseFocus();
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-05-13 18:28:06 +00:00
|
|
|
virtual void handleKeyDown(int ascii, int keycode, int modifiers);
|
|
|
|
virtual void handleKeyUp(int ascii, int keycode, int modifiers);
|
2005-03-10 22:59:40 +00:00
|
|
|
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
|
|
|
virtual void handleMouseUp(int x, int y, int button, int clickCount);
|
|
|
|
virtual void handleMouseWheel(int x, int y, int direction);
|
|
|
|
virtual void handleMouseMoved(int x, int y, int button);
|
More cleanups to the UI.
Context menus, both as right-mouse button popups and those part of
PopupWidgets now have arrows that support scrolling, without having to
continuously click the mouse button. The scroll arrow color also
changes to disabled when they reach the upper or lower range.
Also, the maximum number of items shown in a ContextMenu is now 16,
which looks quite a bit nicer than showing 30 or so all at once.
ScrollBarWidget now looks a little nicer, as the scroll bar is a little
wider, and the arrows are larger (same ones from ContextMenu). As well,
click and hold works on the scroll buttons, even during mouse movement.
This means you no longer have to hold the mouse completely still to
get continuous mouse click events.
Dialogs can now register whether they want to receive continuous mouse
click events (aka, click and hold of a mouse button). Most dialogs
don't need it, and some even work incorrectly when it's activated.
This fixes a bug in ContextMenu, where click and hold on a PopupWidget
would continuously open and close the list of items.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2080 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-07-30 17:25:28 +00:00
|
|
|
virtual bool handleMouseClicks(int x, int y, int button);
|
2005-05-26 15:43:44 +00:00
|
|
|
virtual void handleJoyDown(int stick, int button);
|
|
|
|
virtual void handleJoyUp(int stick, int button);
|
2005-12-07 20:46:49 +00:00
|
|
|
virtual void handleJoyAxis(int stick, int axis, int value);
|
2006-03-02 13:10:53 +00:00
|
|
|
virtual bool handleJoyHat(int stick, int hat, int value);
|
2005-07-05 15:25:45 +00:00
|
|
|
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
2005-12-24 22:09:36 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2009-01-06 23:02:18 +00:00
|
|
|
void addOKCancelBGroup(WidgetArray& wid, const GUI::Font& font,
|
|
|
|
const string& okText = "",
|
|
|
|
const string& cancelText = "");
|
2008-03-23 16:22:46 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
void setResult(int result) { _result = result; }
|
|
|
|
int getResult() const { return _result; }
|
2005-02-27 23:41:19 +00:00
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
private:
|
|
|
|
void buildFocusWidgetList(int id);
|
2011-05-10 15:04:19 +00:00
|
|
|
bool handleNavEvent(Event::Type e);
|
2005-08-10 12:23:42 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
protected:
|
|
|
|
Widget* _mouseWidget;
|
|
|
|
Widget* _focusedWidget;
|
2005-04-24 01:57:47 +00:00
|
|
|
Widget* _dragWidget;
|
2006-11-28 21:48:56 +00:00
|
|
|
Widget* _okWidget;
|
|
|
|
Widget* _cancelWidget;
|
2005-03-10 22:59:40 +00:00
|
|
|
bool _visible;
|
2008-06-13 13:14:52 +00:00
|
|
|
bool _isBase;
|
2005-03-10 22:59:40 +00:00
|
|
|
|
|
|
|
private:
|
2007-01-24 19:17:33 +00:00
|
|
|
FocusList _ourFocusList;
|
|
|
|
TabWidget* _ourTab;
|
|
|
|
WidgetArray _ourButtonGroup;
|
2008-06-13 13:14:52 +00:00
|
|
|
FBSurface* _surface;
|
2005-08-10 12:23:42 +00:00
|
|
|
|
2005-03-10 22:59:40 +00:00
|
|
|
int _result;
|
2005-08-10 12:23:42 +00:00
|
|
|
int _focusID;
|
2008-12-12 15:51:07 +00:00
|
|
|
int _surfaceID;
|
2005-03-10 22:59:40 +00:00
|
|
|
};
|
2005-02-27 23:41:19 +00:00
|
|
|
|
|
|
|
#endif
|