made most stuff in gui class protected, as it should be; moved internal definitions from gui.h to gui.cpp; added up/down arrows to save dialog (ugly, but better than nothing IMO
svn-id: r4234
This commit is contained in:
parent
d3ceb767d8
commit
02a75c0521
5 changed files with 143 additions and 62 deletions
2
gfx.cpp
2
gfx.cpp
|
@ -153,7 +153,7 @@ void Scumm::drawDirtyScreenParts()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle shaking */
|
/* Handle shaking */
|
||||||
if (_shakeEnabled && !_gui->_active) {
|
if (_shakeEnabled && !_gui->isActive()) {
|
||||||
_shakeFrame = (_shakeFrame + 1) & (NUM_SHAKE_POSITIONS - 1);
|
_shakeFrame = (_shakeFrame + 1) & (NUM_SHAKE_POSITIONS - 1);
|
||||||
_system->set_shake_pos(shake_positions[_shakeFrame]);
|
_system->set_shake_pos(shake_positions[_shakeFrame]);
|
||||||
}
|
}
|
||||||
|
|
120
gui.cpp
120
gui.cpp
|
@ -42,6 +42,39 @@ bool get_key_mapping;
|
||||||
uint16 _key_mapping_required;
|
uint16 _key_mapping_required;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum {
|
||||||
|
GUI_NONE = 0,
|
||||||
|
GUI_RESTEXT = 1,
|
||||||
|
GUI_IMAGE = 2,
|
||||||
|
GUI_STAT = 3,
|
||||||
|
GUI_CUSTOMTEXT = 4,
|
||||||
|
GUI_VARTEXT = 5,
|
||||||
|
GUI_ACTIONTEXT = 6,
|
||||||
|
GUI_KEYTEXT = 7,
|
||||||
|
GUI_SCROLLTEXT = 8,
|
||||||
|
GUI_NEXTTEXT = 9,
|
||||||
|
GUI_UPDOWNARROW = 10
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
GWF_BORDER = 1,
|
||||||
|
GWF_CLEARBG = 2,
|
||||||
|
GWF_PARENT = 4,
|
||||||
|
GWF_DELAY = 8,
|
||||||
|
GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
|
||||||
|
GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GuiWidget {
|
||||||
|
byte _type;
|
||||||
|
byte _page;
|
||||||
|
byte _flags;
|
||||||
|
int16 _x,_y;
|
||||||
|
uint16 _w,_h;
|
||||||
|
uint16 _id;
|
||||||
|
byte _string_number;
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SAVELOAD_DIALOG,
|
SAVELOAD_DIALOG,
|
||||||
PAUSE_DIALOG,
|
PAUSE_DIALOG,
|
||||||
|
@ -53,6 +86,33 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define IMG_SIZE 8
|
||||||
|
|
||||||
|
// Triangles pointing up-/downwards, used for save/load dialog
|
||||||
|
static uint32 up_arrow[IMG_SIZE] = {
|
||||||
|
0x00011000,
|
||||||
|
0x00011000,
|
||||||
|
0x00100100,
|
||||||
|
0x00100100,
|
||||||
|
0x01000010,
|
||||||
|
0x01000010,
|
||||||
|
0x10000001,
|
||||||
|
0x10000001,
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint32 down_arrow[IMG_SIZE] = {
|
||||||
|
0x10000001,
|
||||||
|
0x10000001,
|
||||||
|
0x01000010,
|
||||||
|
0x01000010,
|
||||||
|
0x00100100,
|
||||||
|
0x00100100,
|
||||||
|
0x00011000,
|
||||||
|
0x00011000,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Gui::draw(int start, int end)
|
void Gui::draw(int start, int end)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -111,6 +171,10 @@ void Gui::drawChar(const char str, int xx, int yy)
|
||||||
tmp = &guifont[0];
|
tmp = &guifont[0];
|
||||||
tmp += 224 + (str + 1) * 8;
|
tmp += 224 + (str + 1) * 8;
|
||||||
|
|
||||||
|
byte *ptr = getBasePtr(xx, yy);
|
||||||
|
if (ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
for (y = 0; y < 8; y++) {
|
for (y = 0; y < 8; y++) {
|
||||||
for (x = 0; x < 8; x++) {
|
for (x = 0; x < 8; x++) {
|
||||||
unsigned char color;
|
unsigned char color;
|
||||||
|
@ -120,8 +184,10 @@ void Gui::drawChar(const char str, int xx, int yy)
|
||||||
}
|
}
|
||||||
color = ((buffer & mask) != 0);
|
color = ((buffer & mask) != 0);
|
||||||
if (color)
|
if (color)
|
||||||
vline(xx + x, yy + y, yy + y);
|
ptr[x] = _color;
|
||||||
|
// vline(xx + x, yy + y, yy + y);
|
||||||
}
|
}
|
||||||
|
ptr += 320;
|
||||||
}
|
}
|
||||||
_color = tempc;
|
_color = tempc;
|
||||||
|
|
||||||
|
@ -169,7 +235,8 @@ void Gui::drawWidget(const GuiWidget * w)
|
||||||
case GUI_KEYTEXT:
|
case GUI_KEYTEXT:
|
||||||
case GUI_ACTIONTEXT:
|
case GUI_ACTIONTEXT:
|
||||||
case GUI_RESTEXT:
|
case GUI_RESTEXT:
|
||||||
case GUI_NEXTTEXT:{
|
case GUI_NEXTTEXT:
|
||||||
|
{
|
||||||
char text[500];
|
char text[500];
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
|
|
||||||
|
@ -217,7 +284,40 @@ void Gui::drawWidget(const GuiWidget * w)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GUI_IMAGE:
|
case GUI_IMAGE:
|
||||||
;
|
break;
|
||||||
|
case GUI_UPDOWNARROW:
|
||||||
|
{
|
||||||
|
uint32 *data;
|
||||||
|
byte color = (_clickWidget && _clickWidget == w->_id) ? _textcolorhi : _textcolor;
|
||||||
|
|
||||||
|
if (w->_string_number == 0)
|
||||||
|
data = up_arrow;
|
||||||
|
else
|
||||||
|
data = down_arrow;
|
||||||
|
|
||||||
|
// Center the image
|
||||||
|
x += w->_w/2 - IMG_SIZE/2;
|
||||||
|
y += w->_h/2 - IMG_SIZE/2;
|
||||||
|
if (w->_flags & GWF_BORDER) {
|
||||||
|
x -= 4;
|
||||||
|
y -= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte *ptr = getBasePtr(x, y);
|
||||||
|
if (ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int y2 = 0; y2 < IMG_SIZE; y2++) {
|
||||||
|
uint32 mask = 0xF0000000;
|
||||||
|
for (int x2 = 0; x2 < IMG_SIZE; x2++) {
|
||||||
|
if (data[y2] & mask)
|
||||||
|
ptr[x2] = color;
|
||||||
|
mask >>= 4;
|
||||||
|
}
|
||||||
|
ptr += 320;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,10 +413,10 @@ void Gui::lineto(int x, int y)
|
||||||
_curY = y;
|
_curY = y;
|
||||||
|
|
||||||
if (x2 < x)
|
if (x2 < x)
|
||||||
x2 ^= x ^= x2 ^= x;
|
x2 ^= x ^= x2 ^= x; // Swap x2 and x
|
||||||
|
|
||||||
if (y2 < y)
|
if (y2 < y)
|
||||||
y2 ^= y ^= y2 ^= y;
|
y2 ^= y ^= y2 ^= y; // Swap y2 and y
|
||||||
|
|
||||||
ptr = getBasePtr(x, y);
|
ptr = getBasePtr(x, y);
|
||||||
|
|
||||||
|
@ -449,10 +549,10 @@ const GuiWidget save_load_dialog[] = {
|
||||||
{GUI_RESTEXT, 0x04, 0, 40, 5, 128, 16, 0, 3}, /* Name your SAVE game */
|
{GUI_RESTEXT, 0x04, 0, 40, 5, 128, 16, 0, 3}, /* Name your SAVE game */
|
||||||
|
|
||||||
{GUI_STAT, 0xFF, GWF_DEFAULT, 6, 16, 170, 96, 0, 0},
|
{GUI_STAT, 0xFF, GWF_DEFAULT, 6, 16, 170, 96, 0, 0},
|
||||||
{GUI_RESTEXT, 0x01, GWF_DEFAULT, 180, 20, 16, 40, 0, 0},
|
{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 20, 16, 40, 0, 0}, /* Up (dummy) */
|
||||||
{GUI_RESTEXT, 0x01, GWF_DEFAULT, 180, 66, 16, 40, 0, 0},
|
{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 66, 16, 40, 0, 1}, /* Down (dummy) */
|
||||||
{GUI_RESTEXT, 0xFE, GWF_DEFAULT, 180, 20, 16, 40, 1, 0},
|
{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 20, 16, 40, 1, 0}, /* Up */
|
||||||
{GUI_RESTEXT, 0xFE, GWF_DEFAULT, 180, 66, 16, 40, 2, 0},
|
{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 66, 16, 40, 2, 1}, /* Down */
|
||||||
|
|
||||||
{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 20, 160, 10, 20, 0},
|
{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 20, 160, 10, 20, 0},
|
||||||
{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 30, 160, 10, 21, 0},
|
{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 30, 160, 10, 21, 0},
|
||||||
|
@ -653,7 +753,7 @@ void Gui::handleCommand(int cmd)
|
||||||
getSavegameNames(_slotIndex - 9);
|
getSavegameNames(_slotIndex - 9);
|
||||||
draw(20, 28);
|
draw(20, 28);
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2: /* down button */
|
||||||
if (_slotIndex > 80)
|
if (_slotIndex > 80)
|
||||||
return;
|
return;
|
||||||
getSavegameNames(_slotIndex + 9);
|
getSavegameNames(_slotIndex + 9);
|
||||||
|
|
77
gui.h
77
gui.h
|
@ -21,56 +21,37 @@
|
||||||
#if !defined(gui_h)
|
#if !defined(gui_h)
|
||||||
#define gui_h
|
#define gui_h
|
||||||
|
|
||||||
struct ResString {
|
// Forward declaration for GuiWidget
|
||||||
int num;
|
struct GuiWidget;
|
||||||
char string[80];
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
GUI_NONE = 0,
|
|
||||||
GUI_RESTEXT = 1,
|
|
||||||
GUI_IMAGE = 2,
|
|
||||||
GUI_STAT = 3,
|
|
||||||
GUI_CUSTOMTEXT = 4,
|
|
||||||
GUI_VARTEXT = 5,
|
|
||||||
GUI_ACTIONTEXT = 6,
|
|
||||||
GUI_KEYTEXT = 7,
|
|
||||||
GUI_SCROLLTEXT = 8,
|
|
||||||
GUI_NEXTTEXT = 9
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
GWF_BORDER = 1,
|
|
||||||
GWF_CLEARBG = 2,
|
|
||||||
GWF_PARENT = 4,
|
|
||||||
GWF_DELAY = 8,
|
|
||||||
GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
|
|
||||||
GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GuiWidget {
|
|
||||||
byte _type;
|
|
||||||
byte _page;
|
|
||||||
byte _flags;
|
|
||||||
int16 _x,_y;
|
|
||||||
uint16 _w,_h;
|
|
||||||
uint16 _id;
|
|
||||||
byte _string_number;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SAVEGAME_NAME_LEN 32
|
#define SAVEGAME_NAME_LEN 32
|
||||||
|
|
||||||
class Gui {
|
class Gui {
|
||||||
public:
|
public:
|
||||||
|
byte _color,_shadowcolor;
|
||||||
|
byte _bgcolor;
|
||||||
|
byte _textcolor;
|
||||||
|
byte _textcolorhi;
|
||||||
|
|
||||||
|
// Init
|
||||||
|
void init(Scumm *s);
|
||||||
|
|
||||||
|
// Dialogs
|
||||||
|
void saveLoadDialog();
|
||||||
|
void pause();
|
||||||
|
void options();
|
||||||
|
void launcher();
|
||||||
|
|
||||||
|
void loop();
|
||||||
|
|
||||||
|
bool isActive() { return _active; }
|
||||||
|
|
||||||
|
protected:
|
||||||
Scumm *_s;
|
Scumm *_s;
|
||||||
const GuiWidget *_widgets[4];
|
const GuiWidget *_widgets[4];
|
||||||
int _return_to;
|
int _return_to;
|
||||||
int _curX, _curY;
|
int _curX, _curY;
|
||||||
VirtScreen *_vs;
|
VirtScreen *_vs;
|
||||||
byte _color,_shadowcolor;
|
|
||||||
byte _bgcolor;
|
|
||||||
byte _textcolor;
|
|
||||||
byte _textcolorhi;
|
|
||||||
bool _old_cursor_mode;
|
bool _old_cursor_mode;
|
||||||
int _parentX, _parentY;
|
int _parentX, _parentY;
|
||||||
byte _active;
|
byte _active;
|
||||||
|
@ -80,17 +61,17 @@ public:
|
||||||
int _clickWidget;
|
int _clickWidget;
|
||||||
char *_queryMess;
|
char *_queryMess;
|
||||||
|
|
||||||
/* optiondialog specifics */
|
// optiondialog specifics
|
||||||
int _gui_variables[100];
|
int _gui_variables[100];
|
||||||
|
|
||||||
/* savedialog specifics */
|
// savedialog specifics
|
||||||
int _slotIndex;
|
int _slotIndex;
|
||||||
int _editString;
|
int _editString;
|
||||||
int _editLen;
|
int _editLen;
|
||||||
bool valid_games[9];
|
bool valid_games[9];
|
||||||
char game_names[9][SAVEGAME_NAME_LEN];
|
char game_names[9][SAVEGAME_NAME_LEN];
|
||||||
void loop();
|
|
||||||
void init(Scumm *s);
|
// Drawing
|
||||||
void draw(int start, int end);
|
void draw(int start, int end);
|
||||||
void draw(int item) { draw(item,-1); }
|
void draw(int item) { draw(item,-1); }
|
||||||
void drawWidget(const GuiWidget *w);
|
void drawWidget(const GuiWidget *w);
|
||||||
|
@ -104,6 +85,8 @@ public:
|
||||||
void widgetBorder(const GuiWidget *w);
|
void widgetBorder(const GuiWidget *w);
|
||||||
byte *getBasePtr(int x, int y);
|
byte *getBasePtr(int x, int y);
|
||||||
const GuiWidget *widgetFromPos(int x, int y);
|
const GuiWidget *widgetFromPos(int x, int y);
|
||||||
|
|
||||||
|
// Actions
|
||||||
void leftMouseClick(int x, int y);
|
void leftMouseClick(int x, int y);
|
||||||
void handleCommand(int cmd);
|
void handleCommand(int cmd);
|
||||||
void close();
|
void close();
|
||||||
|
@ -117,12 +100,6 @@ public:
|
||||||
|
|
||||||
char _gui_scroller[255];
|
char _gui_scroller[255];
|
||||||
|
|
||||||
// Dialogs
|
|
||||||
void saveLoadDialog();
|
|
||||||
void pause();
|
|
||||||
void options();
|
|
||||||
void launcher();
|
|
||||||
|
|
||||||
void handleSoundDialogCommand(int cmd);
|
void handleSoundDialogCommand(int cmd);
|
||||||
void handleOptionsDialogCommand(int cmd);
|
void handleOptionsDialogCommand(int cmd);
|
||||||
void handleKeysDialogCommand(int cmd);
|
void handleKeysDialogCommand(int cmd);
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
#if !defined(guimaps_h)
|
#if !defined(guimaps_h)
|
||||||
#define guimaps_h
|
#define guimaps_h
|
||||||
|
|
||||||
|
struct ResString {
|
||||||
|
int num;
|
||||||
|
char string[80];
|
||||||
|
};
|
||||||
|
|
||||||
// String maps
|
// String maps
|
||||||
static const char* string_map_table_custom[] = {
|
static const char* string_map_table_custom[] = {
|
||||||
|
|
|
@ -1282,7 +1282,7 @@ void Scumm::mainRun()
|
||||||
new_time = _system->get_msecs();
|
new_time = _system->get_msecs();
|
||||||
waitForTimer(delta * 15 + last_time - new_time);
|
waitForTimer(delta * 15 + last_time - new_time);
|
||||||
last_time = _system->get_msecs();
|
last_time = _system->get_msecs();
|
||||||
if (_gui->_active) {
|
if (_gui->isActive()) {
|
||||||
_gui->loop();
|
_gui->loop();
|
||||||
delta = 5;
|
delta = 5;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue