mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
Merged sciw_select_item() and sciw_unselect_item()
svn-id: r39689
This commit is contained in:
parent
0501542b79
commit
4723f80fe2
@ -300,8 +300,8 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
/* Remove the active menu item, if neccessary */
|
||||
if (item_nr != old_item) {
|
||||
port = sciw_unselect_item(s, port, &(s->_menubar->_menus[menu_nr]), old_item);
|
||||
port = sciw_select_item(s, port, &(s->_menubar->_menus[menu_nr]), item_nr);
|
||||
port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), old_item, false);
|
||||
port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), item_nr, true);
|
||||
FULL_REDRAW;
|
||||
}
|
||||
|
||||
|
@ -313,13 +313,13 @@ gfxw_list_t *sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, c
|
||||
list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.width + 1, zone.height + 1),
|
||||
port->color, port->color, GFX_BOX_SHADE_FLAT)));
|
||||
|
||||
if (!inverse)
|
||||
if (!inverse) {
|
||||
list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.width - 1, zone.height),
|
||||
text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out);
|
||||
|
||||
if (!inverse)
|
||||
list->add(GFXWC(list),
|
||||
GFXW(gfxw_new_rect(zone, *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL)));
|
||||
}
|
||||
|
||||
if (inverse)
|
||||
list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.width - 1, zone.height),
|
||||
@ -582,7 +582,7 @@ gfxw_port_t *sciw_new_menu(EngineState *s, gfxw_port_t *status_bar, Menubar *men
|
||||
retval->set_visual(GFXW(retval), s->visual);
|
||||
|
||||
for (i = 0; i < (int)menu->_items.size(); i++)
|
||||
sciw_unselect_item(s, retval, menu, i);
|
||||
sciw_toggle_item(retval, menu, i, false);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -635,36 +635,21 @@ gfxw_widget_t *_make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_col
|
||||
return GFXW(list);
|
||||
}
|
||||
|
||||
gfxw_port_t *sciw_unselect_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection) {
|
||||
gfxw_port_t *sciw_toggle_item(gfxw_port_t *menu_port, Menu *menu, int selection, bool selected) {
|
||||
if (selection < 0 || selection >= (int)menu->_items.size())
|
||||
return menu_port;
|
||||
|
||||
gfx_color_t fgColor = !selected ? menu_port->color : menu_port->bgcolor;
|
||||
gfx_color_t bgColor = !selected ? menu_port->bgcolor : menu_port->color;
|
||||
|
||||
MenuItem *item = &menu->_items[selection];
|
||||
|
||||
if (item->_type == MENU_TYPE_NORMAL)
|
||||
menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.width + 1,
|
||||
menu_port, menu_port->color, menu_port->bgcolor, selection + MAGIC_ID_OFFSET,
|
||||
item->_enabled)));
|
||||
menu_port, fgColor, bgColor, selection + MAGIC_ID_OFFSET, item->_enabled)));
|
||||
else
|
||||
menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.width + 1,
|
||||
menu_port, menu_port->color, menu_port->bgcolor, selection + MAGIC_ID_OFFSET)));
|
||||
|
||||
return menu_port;
|
||||
}
|
||||
|
||||
gfxw_port_t *sciw_select_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection) {
|
||||
if (selection < 0 || selection >= (int)menu->_items.size())
|
||||
return menu_port;
|
||||
|
||||
MenuItem *item = &menu->_items[selection];
|
||||
|
||||
if (item->_type == MENU_TYPE_NORMAL)
|
||||
menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.width + 1,
|
||||
menu_port, menu_port->bgcolor, menu_port->color, selection + MAGIC_ID_OFFSET,
|
||||
item->_enabled)));
|
||||
else
|
||||
menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.width + 1,
|
||||
menu_port, menu_port->bgcolor, menu_port->color, selection + MAGIC_ID_OFFSET)));
|
||||
menu_port, fgColor, bgColor, selection + MAGIC_ID_OFFSET)));
|
||||
|
||||
return menu_port;
|
||||
}
|
||||
|
@ -172,22 +172,12 @@ gfxw_port_t *sciw_new_menu(EngineState *s, gfxw_port_t *status_bar, Menubar *men
|
||||
** Returns : (gfxw_port_t *) The result port
|
||||
*/
|
||||
|
||||
gfxw_port_t *sciw_unselect_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection);
|
||||
/* Unselects a previously selected item from a menu port
|
||||
** Parameters: (EngineState *) s: The state to operate on
|
||||
** (gfxw_port_t *) menu_port: The port modify
|
||||
gfxw_port_t *sciw_toggle_item(gfxw_port_t *menu_port, Menu *menu, int selection, bool selected);
|
||||
/* Toggle the selection of a menu item from a menu port
|
||||
** Parameters: (gfxw_port_t *) menu_port: The port to modify
|
||||
** (Menu *) menu: The menu the menu port corresponds to
|
||||
** (int) selection: Number of the menu entry to unselect, or -1 to do a NOP
|
||||
** Returns : (gfxw_port_t *) The modified menu
|
||||
*/
|
||||
|
||||
gfxw_port_t *
|
||||
sciw_select_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection);
|
||||
/* Selects a menu item from a menu port
|
||||
** Parameters: (EngineState *) s: The state to operate on
|
||||
** (gfxw_port_t *) menu_port: The port modify
|
||||
** (Menu *) menu: The menu the menu port corresponds to
|
||||
** (int) selection: Number of the menu entry to select, or -1 to do a NOP
|
||||
** (bool) selected: Whether to set the item's state to selected or not
|
||||
** Returns : (gfxw_port_t *) The modified menu
|
||||
*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user