From 6f13850161c75151a24356ab94b3d25b2fe9964c Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 21 Feb 2009 22:50:35 +0000 Subject: SCI: Moved include/menubar.h -> gfx/menubar.h, untangled headers some more svn-id: r38761 --- engines/sci/engine/game.cpp | 2 + engines/sci/engine/kevent.cpp | 1 + engines/sci/engine/kmenu.cpp | 1 + engines/sci/engine/kpathing.cpp | 1 + engines/sci/engine/savegame.cfsml | 6 +- engines/sci/engine/savegame.cpp | 6 +- engines/sci/engine/scriptdebug.cpp | 1 + engines/sci/gfx/menubar.cpp | 2 +- engines/sci/gfx/menubar.h | 215 +++++++++++++++++++++++++++++++++++++ engines/sci/gfx/sci_widgets.cpp | 2 +- engines/sci/include/engine.h | 3 +- engines/sci/include/menubar.h | 212 ------------------------------------ engines/sci/include/sci_widgets.h | 2 + 13 files changed, 233 insertions(+), 221 deletions(-) create mode 100644 engines/sci/gfx/menubar.h delete mode 100644 engines/sci/include/menubar.h (limited to 'engines/sci') diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 870f27829d..4fd9b0208c 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -30,6 +30,8 @@ #include "sci/include/versions.h" #include "sci/include/kernel.h" #include "sci/engine/kernel_types.h" +#include "sci/gfx/gfx_widgets.h" +#include "sci/gfx/menubar.h" namespace Sci { diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 5723a72115..b03ef45c19 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -24,6 +24,7 @@ */ #include "sci/include/engine.h" +#include "sci/gfx/gfx_widgets.h" namespace Sci { diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp index 21374f555d..7546c8b712 100644 --- a/engines/sci/engine/kmenu.cpp +++ b/engines/sci/engine/kmenu.cpp @@ -26,6 +26,7 @@ #include "sci/include/sciresource.h" #include "sci/include/engine.h" #include "sci/include/sci_widgets.h" +#include "sci/gfx/menubar.h" namespace Sci { diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 222231e009..e61bee0391 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -30,6 +30,7 @@ #include "sci/include/engine.h" #include "sci/include/aatree.h" #include "sci/include/list.h" +#include "sci/gfx/gfx_widgets.h" namespace Sci { diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml index a52a102c77..d977ec8eb9 100644 --- a/engines/sci/engine/savegame.cfsml +++ b/engines/sci/engine/savegame.cfsml @@ -29,15 +29,15 @@ ** savegame.cfsml. If this doesn't solve your problem, contact the maintainer. */ -#include #include // FIXME: For struct tm +#include "common/stream.h" +#include "common/system.h" #include "sci/include/sci_memory.h" #include "sci/gfx/gfx_operations.h" +#include "sci/gfx/menubar.h" #include "sci/sfx/sfx_engine.h" #include "sci/include/engine.h" #include "sci/engine/heap.h" -#include "common/stream.h" -#include "common/system.h" #ifdef _MSC_VER #include diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index c8ce52f141..2fd439bf4f 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -29,15 +29,15 @@ ** savegame.cfsml. If this doesn't solve your problem, contact the maintainer. */ -#include #include // FIXME: For struct tm +#include "common/stream.h" +#include "common/system.h" #include "sci/include/sci_memory.h" #include "sci/gfx/gfx_operations.h" +#include "sci/gfx/menubar.h" #include "sci/sfx/sfx_engine.h" #include "sci/include/engine.h" #include "sci/engine/heap.h" -#include "common/stream.h" -#include "common/system.h" #ifdef _MSC_VER #include diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 4760fdf286..bb6ea309d1 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -35,6 +35,7 @@ #include "sci/include/sci_midi.h" #include "sci/include/sci_widgets.h" #include "sci/sci.h" +#include "sci/gfx/gfx_widgets.h" #include "common/util.h" #include "common/savefile.h" diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp index 57ecc6cc44..c125f48593 100644 --- a/engines/sci/gfx/menubar.cpp +++ b/engines/sci/gfx/menubar.cpp @@ -30,7 +30,7 @@ #include "sci/include/sci_memory.h" #include "sci/include/engine.h" -#include "sci/include/menubar.h" +#include "sci/gfx/menubar.h" namespace Sci { diff --git a/engines/sci/gfx/menubar.h b/engines/sci/gfx/menubar.h new file mode 100644 index 0000000000..7b163532f7 --- /dev/null +++ b/engines/sci/gfx/menubar.h @@ -0,0 +1,215 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* Header for SCI0 menu bar management */ + +#ifndef _SCI_MENUBAR_H_ +#define _SCI_MENUBAR_H_ + +#include "sci/include/vm_types.h" +#include "sci/gfx/gfx_operations.h" +#include "sci/gfx/gfx_widgets.h" + +namespace Sci { + +struct EngineState; + +#define MENU_FREESCI_BLATANT_PLUG 0xfff0 +/* This adds an "About FreeSCI" menu option to the first menu */ + + +#define MENU_HBAR_STRING_1 "--!" +#define MENU_HBAR_STRING_2 "-!" +#define MENU_HBAR_STRING_3 "!--" +/* These strings are used in SCI to determine an empty menu line */ + +#define MENU_BORDER_SIZE 0 +/* The number of pixels added to the left and right to the text of a menu on the menu bar */ + +#define MENU_LEFT_BORDER 5 +/* The number of pixels added to the left of the first menu */ + +#define MENU_BOX_CENTER_PADDING 10 +/* Number of pixels to leave in between the left and the right centered text content in boxes +** that use right centered content +*/ + +#define MENU_BOX_LEFT_PADDING 0 +/* Number of pixels to pad to the left */ +#define MENU_BOX_RIGHT_PADDING 2 +/* Number of pixels to pad to the right */ + +#define MENU_BAR_HEIGHT 10 + + +#define MENU_TYPE_NORMAL 0 +#define MENU_TYPE_HBAR 1 /* Horizontal bar */ + +/* Special characters used while building the menu bar */ +#define SCI_SPECIAL_CHAR_FUNCTION 'F' +#define SCI_SPECIAL_CHAR_CTRL 3 +#define SCI_SPECIAL_CHAR_ALT 2 + +/* Maximum number of bytes per SAID spec */ +#define MENU_SAID_SPEC_SIZE 64 + +#define MENU_ATTRIBUTE_SAID 0x6d +#define MENU_ATTRIBUTE_TEXT 0x6e +#define MENU_ATTRIBUTE_KEY 0x6f +#define MENU_ATTRIBUTE_ENABLED 0x70 +#define MENU_ATTRIBUTE_TAG 0x71 + +/* Those flags determine whether the corresponding menu_item_t entries are valid */ +#define MENU_ATTRIBUTE_FLAGS_KEY 0x01 +#define MENU_ATTRIBUTE_FLAGS_SAID 0x02 + +struct menu_item_t { + int type; /* Normal or hbar */ + char *keytext; /* right-centered part of the text (the key) */ + int keytext_size; /* Width of the right-centered text */ + + int flags; + byte said[MENU_SAID_SPEC_SIZE]; /* Said spec for this item */ + reg_t said_pos; + char *text; + reg_t text_pos; + int modifiers, key; /* Hotkey for this item */ + int enabled; + int tag; + +}; + + +struct menu_t { + char *title; + + int title_width; /* Width of the title in pixels */ + int width; /* Pixel width of the menu window */ + + int items_nr; /* Window height equals to intems_nr * 10 */ + menu_item_t *items; /* Actual entries into the menu */ + +}; + + + +struct menubar_t { + + int menus_nr; + menu_t *menus; /* The actual menus */ + +}; + +struct gfx_port; +struct gfx_picture; /* forward declarations for graphics.h */ + + +/********** function definitions *********/ + +menubar_t *menubar_new(); +/* Creates a new menubar struct +** Parameters: (void) +** Returns : (menubar_t *) A pointer to the new menubar entity +** To free the entity, call menubar_free. +*/ + + +void menubar_free(menubar_t *menubar); +/* Frees all memory associated with a menubar +** Parameters: (menubar_t *) menubar: The menubar to free +** Returns : (void) +*/ + + +void menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entries, int font, reg_t entries_base); +/* Adds a menu to the menubar. +** Parameters: (gfx_state_t *) state: The state the fonts are stored in +** (menubar_t *) menubar: The menubar to operate on +** (char *) title: The menu title +** (char *) entries: A string of menu entries +** (int) font: The font which is to be used for drawing +** (reg_t) entries_base: Segmented VM address of the entries string +** Returns : (void) +** The menu entries use the following special characters: +** '`' : Right justify the following part +** ':' : End of this entry +** '#' : Function key (replaced by 'F') +** '^' : Control key (replaced by \002, which looks like "CTRL") +** '=' : Initial tag value +** and the special string "--!", which represents a horizontal bar in the menu. +** +** If MENU_FREESCI_BLATANT_PLUG is defined, an additional option "About FreeSCI" will be +** added if this was the first menu to be added to the menu bar. +*/ + + +int menubar_set_attribute(EngineState *s, int menu, int item, int attribute, reg_t value); +/* Sets the (currently unidentified) foo and bar values. +** Parameters: (state_t *) s: The current state +** (int) menu: The menu number to edit +** (int) item: The menu item to change +** (int) attribute: The attribute to modify +** (int) value: The value the attribute should be set to +** Returns : (int) 0 on success, 1 if either menu or item were invalid +*/ + + +reg_t menubar_get_attribute(EngineState *s, int menu, int item, int attribute); +/* Sets the (currently unidentified) foo and bar values. +** Parameters: (state_t *) s: The current state +** (int) menu: The menu number +** (int) item: The menu item to read +** (int) attribute: The attribute to read from +** Returns : (int) The attribute value, or -1 on error +*/ + + +int menubar_item_valid(EngineState *s, int menu, int item); +/* Determines whether the specified menu entry may be activated +** Parameters: (state_t *) s: The current state +** (int x int) (menu, item): The menu item to check +** Returns : (int) 1 if the menu item may be selected, 0 otherwise +*/ + + +int menubar_map_pointer(EngineState *s, int *menu_nr, int *item_nr, gfxw_port_t *port); +/* Maps the pointer position to a (menu,item) tuple. +** Parameters: (state_t *) s: The current state +** ((int *) x (int *)) (menu_nr, item_nr): Pointers to the current menu/item tuple +** (port_t *) port: The port of the currently active menu (if any) +** Returns : (int) 1 if the pointer is outside a valid port, 0 otherwise. +*/ + +int menubar_match_key(menu_item_t *item, int message, int modifiers); +/* Determines whether a message/modifiers key pair matches a menu item's key parameters +** Parameters: (menu_item_t *) item: The menu item to match +** (int x int) message, modifiers: The input to compare +** Returns : (int) 1 on match, 0 otherwise +*/ + +} // End of namespace Sci + +#endif /* !_SCI_MENUBAR_H_ */ + diff --git a/engines/sci/gfx/sci_widgets.cpp b/engines/sci/gfx/sci_widgets.cpp index 7e853904db..68182ec0d0 100644 --- a/engines/sci/gfx/sci_widgets.cpp +++ b/engines/sci/gfx/sci_widgets.cpp @@ -26,7 +26,7 @@ #include "sci/gfx/gfx_operations.h" #include "sci/gfx/gfx_widgets.h" #include "sci/include/engine.h" -#include "sci/include/menubar.h" +#include "sci/gfx/menubar.h" #include "sci/include/sci_widgets.h" namespace Sci { diff --git a/engines/sci/include/engine.h b/engines/sci/include/engine.h index 37c52d8af1..2a588153db 100644 --- a/engines/sci/include/engine.h +++ b/engines/sci/include/engine.h @@ -38,7 +38,6 @@ namespace Common { #include "sci/include/script.h" #include "sci/include/sciconsole.h" #include "sci/include/vm.h" -#include "sci/include/menubar.h" #include "sci/include/versions.h" #include "sci/include/kernel.h" #include "sci/engine/seg_manager.h" @@ -47,6 +46,8 @@ namespace Common { namespace Sci { +struct menubar_t; + #define FREESCI_CURRENT_SAVEGAME_VERSION 8 #define FREESCI_MINIMUM_SAVEGAME_VERSION 8 diff --git a/engines/sci/include/menubar.h b/engines/sci/include/menubar.h deleted file mode 100644 index aed7b2de73..0000000000 --- a/engines/sci/include/menubar.h +++ /dev/null @@ -1,212 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* Header for SCI0 menu bar management */ - -#ifndef _SCI_MENUBAR_H_ -#define _SCI_MENUBAR_H_ - -#include "sci/gfx/gfx_operations.h" -#include "sci/gfx/gfx_widgets.h" - -namespace Sci { - -#define MENU_FREESCI_BLATANT_PLUG 0xfff0 -/* This adds an "About FreeSCI" menu option to the first menu */ - - -#define MENU_HBAR_STRING_1 "--!" -#define MENU_HBAR_STRING_2 "-!" -#define MENU_HBAR_STRING_3 "!--" -/* These strings are used in SCI to determine an empty menu line */ - -#define MENU_BORDER_SIZE 0 -/* The number of pixels added to the left and right to the text of a menu on the menu bar */ - -#define MENU_LEFT_BORDER 5 -/* The number of pixels added to the left of the first menu */ - -#define MENU_BOX_CENTER_PADDING 10 -/* Number of pixels to leave in between the left and the right centered text content in boxes -** that use right centered content -*/ - -#define MENU_BOX_LEFT_PADDING 0 -/* Number of pixels to pad to the left */ -#define MENU_BOX_RIGHT_PADDING 2 -/* Number of pixels to pad to the right */ - -#define MENU_BAR_HEIGHT 10 - - -#define MENU_TYPE_NORMAL 0 -#define MENU_TYPE_HBAR 1 /* Horizontal bar */ - -/* Special characters used while building the menu bar */ -#define SCI_SPECIAL_CHAR_FUNCTION 'F' -#define SCI_SPECIAL_CHAR_CTRL 3 -#define SCI_SPECIAL_CHAR_ALT 2 - -/* Maximum number of bytes per SAID spec */ -#define MENU_SAID_SPEC_SIZE 64 - -#define MENU_ATTRIBUTE_SAID 0x6d -#define MENU_ATTRIBUTE_TEXT 0x6e -#define MENU_ATTRIBUTE_KEY 0x6f -#define MENU_ATTRIBUTE_ENABLED 0x70 -#define MENU_ATTRIBUTE_TAG 0x71 - -/* Those flags determine whether the corresponding menu_item_t entries are valid */ -#define MENU_ATTRIBUTE_FLAGS_KEY 0x01 -#define MENU_ATTRIBUTE_FLAGS_SAID 0x02 - -struct menu_item_t { - int type; /* Normal or hbar */ - char *keytext; /* right-centered part of the text (the key) */ - int keytext_size; /* Width of the right-centered text */ - - int flags; - byte said[MENU_SAID_SPEC_SIZE]; /* Said spec for this item */ - reg_t said_pos; - char *text; - reg_t text_pos; - int modifiers, key; /* Hotkey for this item */ - int enabled; - int tag; - -}; - - -struct menu_t { - char *title; - - int title_width; /* Width of the title in pixels */ - int width; /* Pixel width of the menu window */ - - int items_nr; /* Window height equals to intems_nr * 10 */ - menu_item_t *items; /* Actual entries into the menu */ - -}; - - - -struct menubar_t { - - int menus_nr; - menu_t *menus; /* The actual menus */ - -}; - -struct gfx_port; -struct gfx_picture; /* forward declarations for graphics.h */ - - -/********** function definitions *********/ - -menubar_t *menubar_new(); -/* Creates a new menubar struct -** Parameters: (void) -** Returns : (menubar_t *) A pointer to the new menubar entity -** To free the entity, call menubar_free. -*/ - - -void menubar_free(menubar_t *menubar); -/* Frees all memory associated with a menubar -** Parameters: (menubar_t *) menubar: The menubar to free -** Returns : (void) -*/ - - -void menubar_add_menu(gfx_state_t *state, menubar_t *menubar, char *title, char *entries, int font, reg_t entries_base); -/* Adds a menu to the menubar. -** Parameters: (gfx_state_t *) state: The state the fonts are stored in -** (menubar_t *) menubar: The menubar to operate on -** (char *) title: The menu title -** (char *) entries: A string of menu entries -** (int) font: The font which is to be used for drawing -** (reg_t) entries_base: Segmented VM address of the entries string -** Returns : (void) -** The menu entries use the following special characters: -** '`' : Right justify the following part -** ':' : End of this entry -** '#' : Function key (replaced by 'F') -** '^' : Control key (replaced by \002, which looks like "CTRL") -** '=' : Initial tag value -** and the special string "--!", which represents a horizontal bar in the menu. -** -** If MENU_FREESCI_BLATANT_PLUG is defined, an additional option "About FreeSCI" will be -** added if this was the first menu to be added to the menu bar. -*/ - - -int menubar_set_attribute(EngineState *s, int menu, int item, int attribute, reg_t value); -/* Sets the (currently unidentified) foo and bar values. -** Parameters: (state_t *) s: The current state -** (int) menu: The menu number to edit -** (int) item: The menu item to change -** (int) attribute: The attribute to modify -** (int) value: The value the attribute should be set to -** Returns : (int) 0 on success, 1 if either menu or item were invalid -*/ - - -reg_t menubar_get_attribute(EngineState *s, int menu, int item, int attribute); -/* Sets the (currently unidentified) foo and bar values. -** Parameters: (state_t *) s: The current state -** (int) menu: The menu number -** (int) item: The menu item to read -** (int) attribute: The attribute to read from -** Returns : (int) The attribute value, or -1 on error -*/ - - -int menubar_item_valid(EngineState *s, int menu, int item); -/* Determines whether the specified menu entry may be activated -** Parameters: (state_t *) s: The current state -** (int x int) (menu, item): The menu item to check -** Returns : (int) 1 if the menu item may be selected, 0 otherwise -*/ - - -int menubar_map_pointer(EngineState *s, int *menu_nr, int *item_nr, gfxw_port_t *port); -/* Maps the pointer position to a (menu,item) tuple. -** Parameters: (state_t *) s: The current state -** ((int *) x (int *)) (menu_nr, item_nr): Pointers to the current menu/item tuple -** (port_t *) port: The port of the currently active menu (if any) -** Returns : (int) 1 if the pointer is outside a valid port, 0 otherwise. -*/ - -int menubar_match_key(menu_item_t *item, int message, int modifiers); -/* Determines whether a message/modifiers key pair matches a menu item's key parameters -** Parameters: (menu_item_t *) item: The menu item to match -** (int x int) message, modifiers: The input to compare -** Returns : (int) 1 on match, 0 otherwise -*/ - -} // End of namespace Sci - -#endif /* !_SCI_MENUBAR_H_ */ - diff --git a/engines/sci/include/sci_widgets.h b/engines/sci/include/sci_widgets.h index d2b8e0320d..4c03b072de 100644 --- a/engines/sci/include/sci_widgets.h +++ b/engines/sci/include/sci_widgets.h @@ -32,6 +32,8 @@ namespace Sci { +struct menu_t; + /* The following flags are applicable to windows in SCI0: */ #define WINDOW_FLAG_TRANSPARENT 0x01 -- cgit v1.2.3