aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2002-05-08 00:27:09 +0000
committerMax Horn2002-05-08 00:27:09 +0000
commit02a75c052134b5aaffb015c9f604063e4eb54f73 (patch)
tree0ac19b030aa5b786383b72e509d4a68ace15416d
parentd3ceb767d85706a7db08c1381e84083cf5142fac (diff)
downloadscummvm-rg350-02a75c052134b5aaffb015c9f604063e4eb54f73.tar.gz
scummvm-rg350-02a75c052134b5aaffb015c9f604063e4eb54f73.tar.bz2
scummvm-rg350-02a75c052134b5aaffb015c9f604063e4eb54f73.zip
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
-rw-r--r--gfx.cpp2
-rw-r--r--gui.cpp120
-rw-r--r--gui.h77
-rw-r--r--guimaps.h4
-rw-r--r--scummvm.cpp2
5 files changed, 143 insertions, 62 deletions
diff --git a/gfx.cpp b/gfx.cpp
index fb55cfa3a1..4b654ae231 100644
--- a/gfx.cpp
+++ b/gfx.cpp
@@ -153,7 +153,7 @@ void Scumm::drawDirtyScreenParts()
}
/* Handle shaking */
- if (_shakeEnabled && !_gui->_active) {
+ if (_shakeEnabled && !_gui->isActive()) {
_shakeFrame = (_shakeFrame + 1) & (NUM_SHAKE_POSITIONS - 1);
_system->set_shake_pos(shake_positions[_shakeFrame]);
}
diff --git a/gui.cpp b/gui.cpp
index a8488773f9..2a646f61c7 100644
--- a/gui.cpp
+++ b/gui.cpp
@@ -43,6 +43,39 @@ uint16 _key_mapping_required;
#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 {
SAVELOAD_DIALOG,
PAUSE_DIALOG,
SOUND_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)
{
int i;
@@ -111,6 +171,10 @@ void Gui::drawChar(const char str, int xx, int yy)
tmp = &guifont[0];
tmp += 224 + (str + 1) * 8;
+ byte *ptr = getBasePtr(xx, yy);
+ if (ptr == NULL)
+ return;
+
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
unsigned char color;
@@ -120,8 +184,10 @@ void Gui::drawChar(const char str, int xx, int yy)
}
color = ((buffer & mask) != 0);
if (color)
- vline(xx + x, yy + y, yy + y);
+ ptr[x] = _color;
+// vline(xx + x, yy + y, yy + y);
}
+ ptr += 320;
}
_color = tempc;
@@ -169,7 +235,8 @@ void Gui::drawWidget(const GuiWidget * w)
case GUI_KEYTEXT:
case GUI_ACTIONTEXT:
case GUI_RESTEXT:
- case GUI_NEXTTEXT:{
+ case GUI_NEXTTEXT:
+ {
char text[500];
text[0] = '\0';
@@ -217,7 +284,40 @@ void Gui::drawWidget(const GuiWidget * w)
break;
}
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;
if (x2 < x)
- x2 ^= x ^= x2 ^= x;
+ x2 ^= x ^= x2 ^= x; // Swap x2 and x
if (y2 < y)
- y2 ^= y ^= y2 ^= y;
+ y2 ^= y ^= y2 ^= y; // Swap y2 and 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_STAT, 0xFF, GWF_DEFAULT, 6, 16, 170, 96, 0, 0},
- {GUI_RESTEXT, 0x01, GWF_DEFAULT, 180, 20, 16, 40, 0, 0},
- {GUI_RESTEXT, 0x01, GWF_DEFAULT, 180, 66, 16, 40, 0, 0},
- {GUI_RESTEXT, 0xFE, GWF_DEFAULT, 180, 20, 16, 40, 1, 0},
- {GUI_RESTEXT, 0xFE, GWF_DEFAULT, 180, 66, 16, 40, 2, 0},
+ {GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 20, 16, 40, 0, 0}, /* Up (dummy) */
+ {GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 66, 16, 40, 0, 1}, /* Down (dummy) */
+ {GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 20, 16, 40, 1, 0}, /* Up */
+ {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, 30, 160, 10, 21, 0},
@@ -653,7 +753,7 @@ void Gui::handleCommand(int cmd)
getSavegameNames(_slotIndex - 9);
draw(20, 28);
return;
- case 2:
+ case 2: /* down button */
if (_slotIndex > 80)
return;
getSavegameNames(_slotIndex + 9);
diff --git a/gui.h b/gui.h
index 034902ee5d..e1f66b1bf9 100644
--- a/gui.h
+++ b/gui.h
@@ -21,56 +21,37 @@
#if !defined(gui_h)
#define gui_h
-struct ResString {
- int num;
- 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;
-};
+// Forward declaration for GuiWidget
+struct GuiWidget;
#define SAVEGAME_NAME_LEN 32
class Gui {
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;
const GuiWidget *_widgets[4];
int _return_to;
int _curX, _curY;
VirtScreen *_vs;
- byte _color,_shadowcolor;
- byte _bgcolor;
- byte _textcolor;
- byte _textcolorhi;
bool _old_cursor_mode;
int _parentX, _parentY;
byte _active;
@@ -80,17 +61,17 @@ public:
int _clickWidget;
char *_queryMess;
- /* optiondialog specifics */
+ // optiondialog specifics
int _gui_variables[100];
- /* savedialog specifics */
+ // savedialog specifics
int _slotIndex;
int _editString;
int _editLen;
bool valid_games[9];
char game_names[9][SAVEGAME_NAME_LEN];
- void loop();
- void init(Scumm *s);
+
+ // Drawing
void draw(int start, int end);
void draw(int item) { draw(item,-1); }
void drawWidget(const GuiWidget *w);
@@ -104,6 +85,8 @@ public:
void widgetBorder(const GuiWidget *w);
byte *getBasePtr(int x, int y);
const GuiWidget *widgetFromPos(int x, int y);
+
+ // Actions
void leftMouseClick(int x, int y);
void handleCommand(int cmd);
void close();
@@ -117,12 +100,6 @@ public:
char _gui_scroller[255];
- // Dialogs
- void saveLoadDialog();
- void pause();
- void options();
- void launcher();
-
void handleSoundDialogCommand(int cmd);
void handleOptionsDialogCommand(int cmd);
void handleKeysDialogCommand(int cmd);
diff --git a/guimaps.h b/guimaps.h
index 363d24d610..400c08161d 100644
--- a/guimaps.h
+++ b/guimaps.h
@@ -21,6 +21,10 @@
#if !defined(guimaps_h)
#define guimaps_h
+struct ResString {
+ int num;
+ char string[80];
+};
// String maps
static const char* string_map_table_custom[] = {
diff --git a/scummvm.cpp b/scummvm.cpp
index c146ca2cbd..30f1b151a3 100644
--- a/scummvm.cpp
+++ b/scummvm.cpp
@@ -1282,7 +1282,7 @@ void Scumm::mainRun()
new_time = _system->get_msecs();
waitForTimer(delta * 15 + last_time - new_time);
last_time = _system->get_msecs();
- if (_gui->_active) {
+ if (_gui->isActive()) {
_gui->loop();
delta = 5;
} else {