aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2009-10-28 23:04:56 +0000
committerFilippos Karapetis2009-10-28 23:04:56 +0000
commit2d9d9bca13244b398c08fe2980e130cb205b57f6 (patch)
tree26fbd9855ba4c36d9e581beabad03a636be6ab21 /engines/sci
parent21323a8d12624c33236f6397be559a238b36d845 (diff)
downloadscummvm-rg350-2d9d9bca13244b398c08fe2980e130cb205b57f6.tar.gz
scummvm-rg350-2d9d9bca13244b398c08fe2980e130cb205b57f6.tar.bz2
scummvm-rg350-2d9d9bca13244b398c08fe2980e130cb205b57f6.zip
Changed some of the menu code to use new graphics functions
svn-id: r45493
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kmenu.cpp11
-rw-r--r--engines/sci/gfx/menubar.cpp24
-rw-r--r--engines/sci/gfx/menubar.h8
-rw-r--r--engines/sci/gui/gui.cpp3
4 files changed, 20 insertions, 26 deletions
diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp
index b8c652b607..a8834adfc2 100644
--- a/engines/sci/engine/kmenu.cpp
+++ b/engines/sci/engine/kmenu.cpp
@@ -39,14 +39,17 @@ reg_t kAddMenu(EngineState *s, int argc, reg_t *argv) {
Common::String name = s->_segMan->getString(argv[0]);
Common::String contents = s->_segMan->getString(argv[1]);
+ int titlebarFont = 0;
+
#ifdef INCLUDE_OLDGFX
- s->_menubar->addMenu(s->gfx_state, name,
- contents, s->titlebar_port->_font, argv[1]);
+ titlebarFont = s->titlebar_port->_font;
#else
- // TODO
- warning("TODO: kAddMenu()");
+ // TODO: titlebar port font
#endif
+ s->_menubar->addMenu(s->gfx_state, name,
+ contents, titlebarFont, argv[1]);
+
return s->r_acc;
}
diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp
index cf3c3a7414..417172ccb0 100644
--- a/engines/sci/gfx/menubar.cpp
+++ b/engines/sci/gfx/menubar.cpp
@@ -31,6 +31,7 @@
#include "sci/sci.h"
#include "sci/engine/state.h"
#include "sci/gfx/menubar.h"
+#include "sci/gui/gui.h"
#include "sci/engine/kernel.h"
namespace Sci {
@@ -77,15 +78,14 @@ MenuItem::MenuItem() {
_tag = 0;
}
-#ifdef INCLUDE_OLDGFX
-
int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const char *right,
int font, int key, int modifiers, int tag, reg_t text_pos) {
// Returns the total text size, plus MENU_BOX_CENTER_PADDING if (right != NULL)
MenuItem newItem;
MenuItem *item;
int total_left_size = 0;
- int width, height;
+ int16 width = 10, height = 10;
+ EngineState *s = ((SciEngine *)g_engine)->getEngineState(); // HACK
item = &newItem;
item->_type = type;
@@ -108,18 +108,14 @@ int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const ch
}
if (right) {
-#ifdef INCLUDE_OLDGFX
- gfxop_get_text_params(state, font, item->_keytext.c_str(), SIZE_INF, &width, &height, 0, NULL, NULL, NULL);
-#endif
+ s->_gui->textSize(item->_keytext.c_str(), font, -1, &width, &height);
total_left_size = MENU_BOX_CENTER_PADDING + width;
}
item->_enabled = 1;
item->_tag = tag;
item->_textPos = text_pos;
-#ifdef INCLUDE_OLDGFX
- gfxop_get_text_params(state, font, left, SIZE_INF, &width, &height, 0, NULL, NULL, NULL);
-#endif
+ s->_gui->textSize(left, font, -1, &width, &height);
_items.push_back(newItem);
@@ -132,15 +128,15 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common
reg_t left_origin = entries_base;
int string_len = 0;
int tag = 0, c_width, max_width = 0;
- int height;
+ int16 height = 10;
+ EngineState *s = ((SciEngine *)g_engine)->getEngineState(); // HACK
Menu menu;
menu._title = title;
+ menu._titleWidth = 10;
-#ifdef INCLUDE_OLDGFX
- gfxop_get_text_params(state, font, title.c_str(), SIZE_INF, &(menu._titleWidth), &height, 0, NULL, NULL, NULL);
-#endif
+ s->_gui->textSize(title.c_str(), font, -1, &(menu._titleWidth), &height);
const char *entries_p = entries.c_str();
@@ -278,8 +274,6 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common
_menus.push_back(menu);
}
-#endif
-
bool MenuItem::matchKey(int message, int modifiers) {
if ((_key == message) && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == _modifiers))
return true;
diff --git a/engines/sci/gfx/menubar.h b/engines/sci/gfx/menubar.h
index 4c7281a36d..3343e5f05e 100644
--- a/engines/sci/gfx/menubar.h
+++ b/engines/sci/gfx/menubar.h
@@ -121,10 +121,10 @@ public:
Common::String _title;
/** Width of the title in pixels */
- int _titleWidth;
+ int16 _titleWidth;
/** Pixel width of the menu window */
- int _width;
+ int16 _width;
/**
* Actual entries into the menu.
@@ -139,10 +139,8 @@ public:
//protected:
// FIXME: This should be (partially) turned into a MenuItem constructor
-#ifdef INCLUDE_OLDGFX
int addMenuItem(GfxState *state, MenuType type, const char *left, const char *right,
int font, int key, int modifiers, int tag, reg_t text_pos);
-#endif
};
@@ -174,9 +172,7 @@ public:
* @param[in] font The font which is to be used for drawing
* @param[in] entries_base Segmented VM address of the entries string
*/
-#ifdef INCLUDE_OLDGFX
void addMenu(GfxState *state, const Common::String &title, const Common::String &entries, int font, reg_t entries_base);
-#endif
/**
* Sets the attributes for a menu item.
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index b6e116be2f..3d5a0728ab 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -270,7 +270,8 @@ void SciGui::display(const char *text, int argc, reg_t *argv) {
void SciGui::textSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) {
Common::Rect rect(0, 0, *textWidth, *textHeight);
_text->Size(rect, text, font, maxWidth);
- *textWidth = rect.width(); *textHeight = rect.height();
+ *textWidth = rect.width();
+ *textHeight = rect.height();
}
// Used SCI1+ for text codes