mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 00:42:24 +00:00
Fixed compilation with the current GUI
svn-id: r44914
This commit is contained in:
parent
0d98fa3fe4
commit
7755404f52
@ -1010,8 +1010,6 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
|
||||
return s->r_acc;
|
||||
}
|
||||
|
||||
static void _k_draw_control(EngineState *s, reg_t obj, bool inverse);
|
||||
|
||||
// Control types and flags
|
||||
enum {
|
||||
K_CONTROL_BUTTON = 1,
|
||||
@ -1068,7 +1066,7 @@ reg_t kDrawControl(EngineState *s, int argc, reg_t *argv) {
|
||||
reg_t obj = argv[0];
|
||||
|
||||
disableCertainButtons(s->_segMan, s->_gameName, obj);
|
||||
_k_draw_control(s, obj, false);
|
||||
s->_gui->drawControl(obj, false);
|
||||
// FULL_REDRAW();
|
||||
return NULL_REG;
|
||||
}
|
||||
@ -1076,7 +1074,7 @@ reg_t kDrawControl(EngineState *s, int argc, reg_t *argv) {
|
||||
reg_t kHiliteControl(EngineState *s, int argc, reg_t *argv) {
|
||||
reg_t obj = argv[0];
|
||||
|
||||
_k_draw_control(s, obj, true);
|
||||
s->_gui->drawControl(obj, true);
|
||||
|
||||
return s->r_acc;
|
||||
}
|
||||
@ -1090,137 +1088,6 @@ reg_t kEditControl(EngineState *s, int argc, reg_t *argv) {
|
||||
return s->r_acc;
|
||||
}
|
||||
|
||||
void _k_draw_control(EngineState *s, reg_t obj, bool hilite) {
|
||||
SegManager *segMan = s->_segMan;
|
||||
int x = (int16)GET_SEL32V(obj, nsLeft);
|
||||
int y = (int16)GET_SEL32V(obj, nsTop);
|
||||
int xl = (int16)GET_SEL32V(obj, nsRight) - x;
|
||||
int yl = (int16)GET_SEL32V(obj, nsBottom) - y;
|
||||
rect_t area = gfx_rect(x, y, xl, yl);
|
||||
|
||||
Common::Rect rect;
|
||||
rect = Common::Rect (x, y, (int16)GET_SEL32V(obj, nsRight), (int16)GET_SEL32V(obj, nsBottom));
|
||||
|
||||
int font_nr = GET_SEL32V(obj, font);
|
||||
reg_t text_pos = GET_SEL32(obj, text);
|
||||
Common::String text;
|
||||
if (!text_pos.isNull())
|
||||
text = s->_segMan->getString(text_pos);
|
||||
int view = GET_SEL32V(obj, view);
|
||||
int cel = sign_extend_byte(GET_SEL32V(obj, cel));
|
||||
int loop = sign_extend_byte(GET_SEL32V(obj, loop));
|
||||
int mode;
|
||||
|
||||
int type = GET_SEL32V(obj, type);
|
||||
int state = GET_SEL32V(obj, state);
|
||||
int cursor;
|
||||
int max;
|
||||
|
||||
switch (type) {
|
||||
case K_CONTROL_BUTTON:
|
||||
debugC(2, kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y);
|
||||
s->_gui->drawControlButton(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, state, hilite);
|
||||
return;
|
||||
|
||||
case K_CONTROL_TEXT:
|
||||
mode = (gfx_alignment_t) GET_SEL32V(obj, mode);
|
||||
debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d\n", PRINT_REG(obj), text.c_str(), x, y, mode);
|
||||
s->_gui->drawControlText(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, mode, state, hilite);
|
||||
return;
|
||||
|
||||
case K_CONTROL_EDIT:
|
||||
debugC(2, kDebugLevelGraphics, "drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d\n", PRINT_REG(obj), PRINT_REG(text_pos), text.c_str(), x, y);
|
||||
|
||||
max = GET_SEL32V(obj, max);
|
||||
cursor = GET_SEL32V(obj, cursor);
|
||||
|
||||
if (cursor > (signed)text.size())
|
||||
cursor = text.size();
|
||||
|
||||
// update_cursor_limits(&s->save_dir_edit_offset, &cursor, max); FIXME: get rid of this?
|
||||
ADD_TO_CURRENT_PICTURE_PORT(sciw_new_edit_control(s->port, obj, area, text.c_str(), font_nr, (unsigned)cursor, (int8)hilite));
|
||||
break;
|
||||
|
||||
case K_CONTROL_ICON:
|
||||
debugC(2, kDebugLevelGraphics, "drawing icon control %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y - 1);
|
||||
s->_gui->drawControlIcon(rect, obj, view, loop, cel, state, hilite);
|
||||
return;
|
||||
|
||||
case K_CONTROL_CONTROL:
|
||||
case K_CONTROL_CONTROL_ALIAS: {
|
||||
int entries_nr;
|
||||
int lsTop;
|
||||
int list_top = 0;
|
||||
int selection = 0;
|
||||
int entry_size = GET_SEL32V(obj, x);
|
||||
int i;
|
||||
|
||||
if (s->_kernel->_selectorCache.topString != -1) {
|
||||
// Games from early SCI1 onwards use topString
|
||||
lsTop = GET_SEL32V(obj, topString);
|
||||
} else {
|
||||
// Earlier games use lsTop
|
||||
lsTop = GET_SEL32V(obj, lsTop);
|
||||
}
|
||||
lsTop -= text_pos.offset;
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "drawing list control %04x:%04x to %d,%d, diff %d\n", PRINT_REG(obj), x, y, SCI_MAX_SAVENAME_LENGTH);
|
||||
cursor = GET_SEL32V(obj, cursor) - text_pos.offset;
|
||||
|
||||
entries_nr = 0;
|
||||
|
||||
// NOTE: most types of pointer dereferencing don't like odd offsets
|
||||
if (entry_size & 1) {
|
||||
warning("List control with odd entry_size %d. This is not yet implemented for all types of segments", entry_size);
|
||||
}
|
||||
|
||||
reg_t seeker = text_pos;
|
||||
// Count string entries in NULL terminated string list
|
||||
while (s->_segMan->strlen(seeker) > 0) {
|
||||
++entries_nr;
|
||||
seeker.offset += entry_size;
|
||||
}
|
||||
|
||||
// TODO: This is rather convoluted... It would be a lot cleaner
|
||||
// if sciw_new_list_control would take a list of Common::String
|
||||
Common::String *strings = 0;
|
||||
const char **entries_list = NULL;
|
||||
|
||||
if (entries_nr) { // determine list_top, selection, and the entries_list
|
||||
seeker = text_pos;
|
||||
entries_list = (const char**)malloc(sizeof(char *) * entries_nr);
|
||||
strings = new Common::String[entries_nr];
|
||||
for (i = 0; i < entries_nr; i++) {
|
||||
strings[i] = s->_segMan->getString(seeker);
|
||||
entries_list[i] = strings[i].c_str();
|
||||
seeker.offset += entry_size;
|
||||
if ((seeker.offset - text_pos.offset) == lsTop)
|
||||
list_top = i + 1;
|
||||
if ((seeker.offset - text_pos.offset) == cursor)
|
||||
selection = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
ADD_TO_CURRENT_PICTURE_PORT(sciw_new_list_control(s->port, obj, area, font_nr, entries_list, entries_nr,
|
||||
list_top, selection, (int8)hilite));
|
||||
free(entries_list);
|
||||
delete[] strings;
|
||||
}
|
||||
break;
|
||||
|
||||
case K_CONTROL_BOX:
|
||||
break;
|
||||
|
||||
default:
|
||||
warning("Unknown control type: %d at %04x:%04x, at (%d, %d) size %d x %d",
|
||||
type, PRINT_REG(obj), x, y, xl, yl);
|
||||
}
|
||||
|
||||
if (!s->pic_not_valid) {
|
||||
FULL_REDRAW();
|
||||
}
|
||||
}
|
||||
|
||||
void _k_view_list_mark_free(EngineState *s, reg_t off) {
|
||||
if (s->dyn_views) {
|
||||
|
||||
|
@ -357,6 +357,9 @@ void SciGui::drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId,
|
||||
_screen->copyToScreen();
|
||||
}
|
||||
|
||||
void SciGui::drawControl(reg_t controlObject, bool highlight) {
|
||||
}
|
||||
|
||||
void SciGui::editControl(reg_t controlObject, reg_t eventObject) {
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
virtual void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
|
||||
virtual void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);
|
||||
virtual void drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 style, bool hilite);
|
||||
virtual void drawControl(reg_t controlObject, bool highlight);
|
||||
virtual void editControl(reg_t controlObject, reg_t eventObject);
|
||||
|
||||
virtual void graphFillBoxForeground(Common::Rect rect);
|
||||
|
@ -654,7 +654,148 @@ void update_cursor_limits(int *display_offset, int *cursor, int max_displayed) {
|
||||
*display_offset = 12 + *cursor - max_displayed;
|
||||
}
|
||||
|
||||
void _k_draw_control(EngineState *s, reg_t obj, bool hilite);
|
||||
static inline int sign_extend_byte(int value) {
|
||||
if (value & 0x80)
|
||||
return value - 256;
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
void _k_draw_control(EngineState *s, reg_t obj, bool hilite) {
|
||||
SegManager *segMan = s->_segMan;
|
||||
int x = (int16)GET_SEL32V(obj, nsLeft);
|
||||
int y = (int16)GET_SEL32V(obj, nsTop);
|
||||
int xl = (int16)GET_SEL32V(obj, nsRight) - x;
|
||||
int yl = (int16)GET_SEL32V(obj, nsBottom) - y;
|
||||
rect_t area = gfx_rect(x, y, xl, yl);
|
||||
|
||||
Common::Rect rect;
|
||||
rect = Common::Rect (x, y, (int16)GET_SEL32V(obj, nsRight), (int16)GET_SEL32V(obj, nsBottom));
|
||||
|
||||
int font_nr = GET_SEL32V(obj, font);
|
||||
reg_t text_pos = GET_SEL32(obj, text);
|
||||
Common::String text;
|
||||
if (!text_pos.isNull())
|
||||
text = s->_segMan->getString(text_pos);
|
||||
int view = GET_SEL32V(obj, view);
|
||||
int cel = sign_extend_byte(GET_SEL32V(obj, cel));
|
||||
int loop = sign_extend_byte(GET_SEL32V(obj, loop));
|
||||
int mode;
|
||||
|
||||
int type = GET_SEL32V(obj, type);
|
||||
int state = GET_SEL32V(obj, state);
|
||||
int cursor;
|
||||
int max;
|
||||
|
||||
switch (type) {
|
||||
case K_CONTROL_BUTTON:
|
||||
debugC(2, kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y);
|
||||
s->_gui->drawControlButton(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, state, hilite);
|
||||
return;
|
||||
|
||||
case K_CONTROL_TEXT:
|
||||
mode = (gfx_alignment_t) GET_SEL32V(obj, mode);
|
||||
debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d\n", PRINT_REG(obj), text.c_str(), x, y, mode);
|
||||
s->_gui->drawControlText(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, mode, state, hilite);
|
||||
return;
|
||||
|
||||
case K_CONTROL_EDIT:
|
||||
debugC(2, kDebugLevelGraphics, "drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d\n", PRINT_REG(obj), PRINT_REG(text_pos), text.c_str(), x, y);
|
||||
|
||||
max = GET_SEL32V(obj, max);
|
||||
cursor = GET_SEL32V(obj, cursor);
|
||||
|
||||
if (cursor > (signed)text.size())
|
||||
cursor = text.size();
|
||||
|
||||
// update_cursor_limits(&s->save_dir_edit_offset, &cursor, max); FIXME: get rid of this?
|
||||
ADD_TO_CURRENT_PICTURE_PORT(sciw_new_edit_control(s->port, obj, area, text.c_str(), font_nr, (unsigned)cursor, (int8)hilite));
|
||||
break;
|
||||
|
||||
case K_CONTROL_ICON:
|
||||
debugC(2, kDebugLevelGraphics, "drawing icon control %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y - 1);
|
||||
s->_gui->drawControlIcon(rect, obj, view, loop, cel, state, hilite);
|
||||
return;
|
||||
|
||||
case K_CONTROL_CONTROL:
|
||||
case K_CONTROL_CONTROL_ALIAS: {
|
||||
int entries_nr;
|
||||
int lsTop;
|
||||
int list_top = 0;
|
||||
int selection = 0;
|
||||
int entry_size = GET_SEL32V(obj, x);
|
||||
int i;
|
||||
|
||||
if (s->_kernel->_selectorCache.topString != -1) {
|
||||
// Games from early SCI1 onwards use topString
|
||||
lsTop = GET_SEL32V(obj, topString);
|
||||
} else {
|
||||
// Earlier games use lsTop
|
||||
lsTop = GET_SEL32V(obj, lsTop);
|
||||
}
|
||||
lsTop -= text_pos.offset;
|
||||
|
||||
debugC(2, kDebugLevelGraphics, "drawing list control %04x:%04x to %d,%d, diff %d\n", PRINT_REG(obj), x, y, SCI_MAX_SAVENAME_LENGTH);
|
||||
cursor = GET_SEL32V(obj, cursor) - text_pos.offset;
|
||||
|
||||
entries_nr = 0;
|
||||
|
||||
// NOTE: most types of pointer dereferencing don't like odd offsets
|
||||
if (entry_size & 1) {
|
||||
warning("List control with odd entry_size %d. This is not yet implemented for all types of segments", entry_size);
|
||||
}
|
||||
|
||||
reg_t seeker = text_pos;
|
||||
// Count string entries in NULL terminated string list
|
||||
while (s->_segMan->strlen(seeker) > 0) {
|
||||
++entries_nr;
|
||||
seeker.offset += entry_size;
|
||||
}
|
||||
|
||||
// TODO: This is rather convoluted... It would be a lot cleaner
|
||||
// if sciw_new_list_control would take a list of Common::String
|
||||
Common::String *strings = 0;
|
||||
const char **entries_list = NULL;
|
||||
|
||||
if (entries_nr) { // determine list_top, selection, and the entries_list
|
||||
seeker = text_pos;
|
||||
entries_list = (const char**)malloc(sizeof(char *) * entries_nr);
|
||||
strings = new Common::String[entries_nr];
|
||||
for (i = 0; i < entries_nr; i++) {
|
||||
strings[i] = s->_segMan->getString(seeker);
|
||||
entries_list[i] = strings[i].c_str();
|
||||
seeker.offset += entry_size;
|
||||
if ((seeker.offset - text_pos.offset) == lsTop)
|
||||
list_top = i + 1;
|
||||
if ((seeker.offset - text_pos.offset) == cursor)
|
||||
selection = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
ADD_TO_CURRENT_PICTURE_PORT(sciw_new_list_control(s->port, obj, area, font_nr, entries_list, entries_nr,
|
||||
list_top, selection, (int8)hilite));
|
||||
free(entries_list);
|
||||
delete[] strings;
|
||||
}
|
||||
break;
|
||||
|
||||
case K_CONTROL_BOX:
|
||||
break;
|
||||
|
||||
default:
|
||||
warning("Unknown control type: %d at %04x:%04x, at (%d, %d) size %d x %d",
|
||||
type, PRINT_REG(obj), x, y, xl, yl);
|
||||
}
|
||||
|
||||
if (!s->pic_not_valid) {
|
||||
FULL_REDRAW();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SciGui32::drawControl(reg_t controlObject, bool highlight) {
|
||||
_k_draw_control(s, controlObject, highlight);
|
||||
}
|
||||
|
||||
void SciGui32::editControl(reg_t controlObject, reg_t eventObject) {
|
||||
SegManager *segMan = s->_segMan;
|
||||
@ -1028,13 +1169,6 @@ enum {
|
||||
_K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP = 4
|
||||
};
|
||||
|
||||
static inline int sign_extend_byte(int value) {
|
||||
if (value & 0x80)
|
||||
return value - 256;
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
static Common::Rect nsrect_clip(EngineState *s, int y, Common::Rect retval, int priority) {
|
||||
int pri_top;
|
||||
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
|
||||
void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);
|
||||
void drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo, int16 style, bool hilite);
|
||||
void drawControl(reg_t controlObject, bool highlight);
|
||||
void editControl(reg_t controlObject, reg_t eventObject);
|
||||
|
||||
void graphFillBoxForeground(Common::Rect rect);
|
||||
|
Loading…
x
Reference in New Issue
Block a user