2007-05-30 21:56:52 +00:00
/* 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 .
2002-09-19 17:44:41 +00:00
*
2021-12-26 18:47:58 +01:00
* 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 3 of the License , or
* ( at your option ) any later version .
2002-09-19 17:44:41 +00:00
*
* 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
2021-12-26 18:47:58 +01:00
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
2014-02-18 02:34:24 +01:00
*
2002-09-19 17:44:41 +00:00
*/
2003-11-03 23:26:13 +00:00
# include "common/config-manager.h"
2005-10-01 21:13:38 +00:00
# include "common/savefile.h"
2005-01-10 22:06:49 +00:00
# include "common/system.h"
2007-06-03 17:32:42 +00:00
# include "common/events.h"
2011-08-20 12:51:22 +01:00
# include "common/localization.h"
2010-06-15 10:47:31 +00:00
# include "common/translation.h"
2020-06-17 01:27:23 +05:30
# include "common/ustr.h"
2006-02-20 20:29:02 +00:00
# include "graphics/scaler.h"
2003-11-03 23:26:13 +00:00
2010-11-16 10:19:01 +00:00
# include "gui/gui-manager.h"
2016-04-14 13:29:08 +03:00
# include "gui/widget.h"
2008-08-08 10:37:58 +00:00
# include "gui/ThemeEval.h"
2003-11-03 23:26:13 +00:00
2003-10-03 18:33:57 +00:00
# include "scumm/dialogs.h"
# include "scumm/sound.h"
# include "scumm/scumm.h"
2006-02-20 20:57:26 +00:00
# include "scumm/imuse/imuse.h"
2003-10-03 18:33:57 +00:00
# include "scumm/verbs.h"
2002-09-19 17:44:41 +00:00
2003-06-14 21:18:14 +00:00
# ifndef DISABLE_HELP
2003-10-03 18:33:57 +00:00
# include "scumm/help.h"
2003-06-14 21:18:14 +00:00
# endif
2008-11-12 14:30:16 +00:00
using Graphics : : kTextAlignCenter ;
using Graphics : : kTextAlignLeft ;
2003-12-01 22:16:29 +00:00
using GUI : : WIDGET_ENABLED ;
2003-11-11 00:40:35 +00:00
2003-10-03 18:33:57 +00:00
namespace Scumm {
2002-09-19 17:44:41 +00:00
struct ResString {
int num ;
char string [ 80 ] ;
} ;
2006-10-15 01:24:17 +00:00
static const ResString string_map_table_v8 [ ] = {
2006-03-04 05:44:48 +00:00
{ 0 , " /BT_100/Please insert disk %d. Press ENTER " } ,
{ 0 , " /BT__003/Unable to Find %s, (%s %d) Press Button. " } ,
{ 0 , " /BT__004/Error reading disk %c, (%c%d) Press Button. " } ,
{ 0 , " /BT__002/Game Paused. Press SPACE to Continue. " } ,
{ 0 , " /BT__005/Are you sure you want to restart? (Y/N) " } , //BOOT.004
{ 0 , " /BT__006/Are you sure you want to quit? (Y/N) " } , //BOOT.005
{ 0 , " /BT__008/Save " } ,
{ 0 , " /BT__009/Load " } ,
{ 0 , " /BT__010/Play " } ,
{ 0 , " /BT__011/Cancel " } ,
{ 0 , " /BT__012/Quit " } ,
{ 0 , " /BT__013/OK " } ,
{ 0 , " " } ,
{ 0 , " /BT__014/You must enter a name " } ,
{ 0 , " /BT__015/The game was NOT saved (disk full?) " } ,
{ 0 , " /BT__016/The game was NOT loaded " } ,
{ 0 , " /BT__017/Saving '%s' " } ,
{ 0 , " /BT__018/Loading '%s' " } ,
{ 0 , " /BT__019/Name your SAVE game " } ,
{ 0 , " /BT__020/Select a game to LOAD " }
} ;
2006-10-15 01:24:17 +00:00
static const ResString string_map_table_v7 [ ] = {
2002-09-19 17:44:41 +00:00
{ 96 , " game name and version " } , //that's how it's supposed to be
2006-03-01 04:32:44 +00:00
{ 83 , " Unable to Find %s, (%c%d) Press Button. " } ,
{ 84 , " Error reading disk %c, (%c%d) Press Button. " } ,
2006-03-04 05:44:48 +00:00
{ 85 , " /BOOT.003/Game Paused. Press SPACE to Continue. " } ,
{ 86 , " /BOOT.004/Are you sure you want to restart? (Y/N) " } ,
{ 87 , " /BOOT.005/Are you sure you want to quit? (Y/N) " } ,
{ 70 , " /BOOT.008/Save " } ,
{ 71 , " /BOOT.009/Load " } ,
{ 72 , " /BOOT.010/Play " } ,
2007-09-19 08:40:12 +00:00
{ 73 , " /BOOT.011/Cancel " } ,
2006-03-04 05:44:48 +00:00
{ 74 , " /BOOT.012/Quit " } ,
{ 75 , " /BOOT.013/OK " } ,
2006-03-01 04:32:44 +00:00
{ 0 , " " } ,
2006-03-04 05:44:48 +00:00
{ 78 , " /BOOT.014/You must enter a name " } ,
{ 81 , " /BOOT.015/The game was NOT saved (disk full?) " } ,
{ 82 , " /BOOT.016/The game was NOT loaded " } ,
{ 79 , " /BOOT.017/Saving '%s' " } ,
{ 80 , " /BOOT.018/Loading '%s' " } ,
{ 76 , " /BOOT.019/Name your SAVE game " } ,
{ 77 , " /BOOT.020/Select a game to LOAD " }
2003-03-06 17:58:13 +00:00
2006-03-01 01:17:40 +00:00
/* This is the complete string map for v7
2006-03-04 05:44:48 +00:00
{ 68 , " /BOOT.007/c: \\ dig " } ,
{ 69 , " /BOOT.021/The Dig " } ,
{ 70 , " /BOOT.008/Save " } ,
{ 71 , " /BOOT.009/Load " } ,
{ 72 , " /BOOT.010/Play " } ,
{ 73 , " /BOOT.011/Cancel " } ,
{ 74 , " /BOOT.012/Quit " } ,
{ 75 , " /BOOT.013/OK " } ,
{ 76 , " /BOOT.019/Name your SAVE game " } ,
{ 77 , " /BOOT.020/Select a game to LOAD " } ,
{ 78 , " /BOOT.014/You must enter a name " } ,
{ 79 , " /BOOT.017/Saving '%s' " } ,
{ 80 , " /BOOT.018/Loading '%s' " } ,
{ 81 , " /BOOT.015/The game was NOT saved (disk full?) " } ,
{ 82 , " /BOOT.016/The game was NOT loaded " } ,
2006-03-01 01:17:40 +00:00
{ 83 , " Unable to Find %s, (%c%d) Press Button. " } ,
{ 84 , " Error reading disk %c, (%c%d) Press Button. " } ,
2006-03-04 05:44:48 +00:00
{ 85 , " /BOOT.003/Game Paused. Press SPACE to Continue. " } ,
{ 86 , " /BOOT.004/Are you sure you want to restart? (Y/N) " } ,
{ 87 , " /BOOT.005/Are you sure you want to quit? (Y/N) " } ,
{ 90 , " /BOOT.022/Music " } ,
{ 91 , " /BOOT.023/Voice " } ,
{ 92 , " /BOOT.024/Sfx " } ,
{ 93 , " /BOOT.025/disabled " } ,
{ 94 , " /BOOT.026/Text speed " } ,
{ 95 , " /BOOT.027/Display Text " } ,
2006-03-01 01:17:40 +00:00
{ 96 , " The Dig v1.0 " } ,
2006-03-04 05:44:48 +00:00
{ 138 , " /BOOT.028/Spooled Music " ) ,
{ 139 , " /BOOT.029/Do you want to replace this saved game? (Y/N) " } ,
2006-03-01 01:17:40 +00:00
{ 141 , " Voice Only " } ,
{ 142 , " Voice and Text " } ,
2006-03-01 04:32:44 +00:00
{ 143 , " Text Display Only " } , */
2005-07-30 21:11:48 +00:00
2002-09-19 17:44:41 +00:00
} ;
2006-10-15 01:24:17 +00:00
static const ResString string_map_table_v6 [ ] = {
2006-03-01 04:32:44 +00:00
{ 90 , " Insert Disk %c and Press Button to Continue. " } ,
{ 91 , " Unable to Find %s, (%c%d) Press Button. " } ,
{ 92 , " Error reading disk %c, (%c%d) Press Button. " } ,
{ 93 , " Game Paused. Press SPACE to Continue. " } ,
2016-05-24 10:11:33 +02:00
{ 94 , " Are you sure you want to restart? (Y/N)Y " } ,
{ 95 , " Are you sure you want to quit? (Y/N)Y " } ,
2005-07-30 21:11:48 +00:00
{ 96 , " Save " } ,
{ 97 , " Load " } ,
{ 98 , " Play " } ,
{ 99 , " Cancel " } ,
{ 100 , " Quit " } ,
{ 101 , " OK " } ,
2006-03-01 04:32:44 +00:00
{ 102 , " Insert save/load game disk " } ,
{ 103 , " You must enter a name " } ,
{ 104 , " The game was NOT saved (disk full?) " } ,
{ 105 , " The game was NOT loaded " } ,
{ 106 , " Saving '%s' " } ,
{ 107 , " Loading '%s' " } ,
{ 108 , " Name your SAVE game " } ,
{ 109 , " Select a game to LOAD " } ,
2006-03-01 05:00:25 +00:00
{ 117 , " How may I serve you? " }
2002-09-19 17:44:41 +00:00
} ;
2006-10-15 01:24:17 +00:00
static const ResString string_map_table_v345 [ ] = {
2011-08-20 10:59:16 +01:00
{ 1 , _s ( " Insert Disk %c and Press Button to Continue. " ) } ,
{ 2 , _s ( " Unable to Find %s, (%c%d) Press Button. " ) } ,
{ 3 , _s ( " Error reading disk %c, (%c%d) Press Button. " ) } ,
{ 4 , _s ( " Game Paused. Press SPACE to Continue. " ) } ,
2011-08-20 15:11:47 +01:00
// I18N: You may specify 'Yes' symbol at the end of the line, like this:
// "Moechten Sie wirklich neu starten? (J/N)J"
// Will react to J as 'Yes'
2014-10-13 09:12:52 +02:00
{ 5 , _s ( " Are you sure you want to restart? (Y/N)Y " ) } ,
2012-09-26 04:17:31 +02:00
// I18N: you may specify 'Yes' symbol at the end of the line. See previous comment
2014-10-13 09:12:52 +02:00
{ 6 , _s ( " Are you sure you want to quit? (Y/N)Y " ) } ,
2006-03-01 04:32:44 +00:00
// Added in SCUMM4
2011-08-20 10:59:16 +01:00
{ 7 , _s ( " Save " ) } ,
{ 8 , _s ( " Load " ) } ,
{ 9 , _s ( " Play " ) } ,
{ 10 , _s ( " Cancel " ) } ,
{ 11 , _s ( " Quit " ) } ,
{ 12 , _s ( " OK " ) } ,
{ 13 , _s ( " Insert save/load game disk " ) } ,
{ 14 , _s ( " You must enter a name " ) } ,
{ 15 , _s ( " The game was NOT saved (disk full?) " ) } ,
{ 16 , _s ( " The game was NOT loaded " ) } ,
{ 17 , _s ( " Saving '%s' " ) } ,
{ 18 , _s ( " Loading '%s' " ) } ,
{ 19 , _s ( " Name your SAVE game " ) } ,
{ 20 , _s ( " Select a game to LOAD " ) } ,
{ 28 , _s ( " Game title) " ) }
2002-09-19 17:44:41 +00:00
} ;
# pragma mark -
2010-04-06 09:26:04 +00:00
# ifndef DISABLE_HELP
class HelpDialog : public ScummDialog {
public :
HelpDialog ( const GameSettings & game ) ;
2020-02-09 12:05:32 +01:00
void handleCommand ( GUI : : CommandSender * sender , uint32 cmd , uint32 data ) override ;
2010-04-06 09:26:04 +00:00
2020-02-09 12:05:32 +01:00
void reflowLayout ( ) override ;
2010-04-06 09:26:04 +00:00
protected :
typedef Common : : String String ;
GUI : : ButtonWidget * _nextButton ;
GUI : : ButtonWidget * _prevButton ;
GUI : : StaticTextWidget * _title ;
GUI : : StaticTextWidget * _key [ HELP_NUM_LINES ] ;
GUI : : StaticTextWidget * _dsc [ HELP_NUM_LINES ] ;
int _page ;
int _numPages ;
int _numLines ;
const GameSettings _game ;
void displayKeyBindings ( ) ;
} ;
# endif
# pragma mark -
2010-01-05 22:18:09 +00:00
ScummDialog : : ScummDialog ( int x , int y , int w , int h ) : GUI : : Dialog ( x , y , w , h ) {
_backgroundType = GUI : : ThemeEngine : : kDialogBackgroundSpecial ;
}
2008-08-13 17:46:00 +00:00
ScummDialog : : ScummDialog ( String name ) : GUI : : Dialog ( name ) {
2008-11-10 11:24:55 +00:00
_backgroundType = GUI : : ThemeEngine : : kDialogBackgroundSpecial ;
2006-01-28 23:03:39 +00:00
}
2002-09-19 17:44:41 +00:00
# pragma mark -
2003-06-14 21:18:14 +00:00
# ifndef DISABLE_HELP
2005-05-14 22:47:00 +00:00
2010-05-26 19:54:50 +00:00
ScummMenuDialog : : ScummMenuDialog ( ScummEngine * scumm )
: MainMenuDialog ( scumm ) {
2006-04-29 23:23:32 +00:00
_helpDialog = new HelpDialog ( scumm - > _game ) ;
2010-05-26 19:54:50 +00:00
_helpButton - > setEnabled ( true ) ;
2003-06-14 21:18:14 +00:00
}
2008-07-07 06:05:48 +00:00
ScummMenuDialog : : ~ ScummMenuDialog ( ) {
2003-06-14 21:18:14 +00:00
delete _helpDialog ;
2009-07-22 19:25:53 +00:00
}
2010-11-01 16:00:17 +00:00
void ScummMenuDialog : : handleCommand ( GUI : : CommandSender * sender , uint32 cmd , uint32 data ) {
2002-09-19 17:44:41 +00:00
switch ( cmd ) {
2003-06-14 21:18:14 +00:00
case kHelpCmd :
_helpDialog - > runModal ( ) ;
break ;
2002-09-19 17:44:41 +00:00
default :
2010-05-26 19:54:50 +00:00
MainMenuDialog : : handleCommand ( sender , cmd , data ) ;
2002-10-19 01:22:41 +00:00
}
}
2003-06-14 21:18:14 +00:00
# pragma mark -
enum {
kNextCmd = ' NEXT ' ,
kPrevCmd = ' PREV '
} ;
2006-04-29 23:23:32 +00:00
HelpDialog : : HelpDialog ( const GameSettings & game )
2008-08-10 18:26:14 +00:00
: ScummDialog ( " ScummHelp " ) , _game ( game ) {
2020-11-15 18:15:58 +00:00
_title = new GUI : : StaticTextWidget ( this , " ScummHelp.Title " , Common : : U32String ( ) ) ;
2006-05-18 16:44:44 +00:00
_page = 1 ;
2008-11-10 11:24:55 +00:00
_backgroundType = GUI : : ThemeEngine : : kDialogBackgroundDefault ;
2006-05-18 16:44:44 +00:00
_numPages = ScummHelp : : numPages ( _game . id ) ;
2011-08-20 15:11:47 +01:00
// I18N: Previous page button
2020-11-15 18:15:58 +00:00
_prevButton = new GUI : : ButtonWidget ( this , " ScummHelp.Prev " , _ ( " ~P~revious " ) , Common : : U32String ( ) , kPrevCmd ) ;
2011-08-20 15:11:47 +01:00
// I18N: Next page button
2020-11-15 18:15:58 +00:00
_nextButton = new GUI : : ButtonWidget ( this , " ScummHelp.Next " , _ ( " ~N~ext " ) , Common : : U32String ( ) , kNextCmd ) ;
new GUI : : ButtonWidget ( this , " ScummHelp.Close " , _ ( " ~C~lose " ) , Common : : U32String ( ) , GUI : : kCloseCmd ) ;
2006-05-18 16:44:44 +00:00
_prevButton - > clearFlags ( WIDGET_ENABLED ) ;
2019-12-28 10:43:58 +01:00
GUI : : ContainerWidget * placeHolder = new GUI : : ContainerWidget ( this , " ScummHelp.HelpText " ) ;
placeHolder - > setBackgroundType ( GUI : : ThemeEngine : : kWidgetBackgroundNo ) ;
2009-07-16 17:44:05 +00:00
_numLines = HELP_NUM_LINES ;
2009-07-16 17:29:31 +00:00
2006-05-18 16:44:44 +00:00
// Dummy entries
for ( int i = 0 ; i < HELP_NUM_LINES ; i + + ) {
2020-11-15 18:15:58 +00:00
_key [ i ] = new GUI : : StaticTextWidget ( this , 0 , 0 , 10 , 10 , Common : : U32String ( ) , Graphics : : kTextAlignRight ) ;
_dsc [ i ] = new GUI : : StaticTextWidget ( this , 0 , 0 , 10 , 10 , Common : : U32String ( ) , Graphics : : kTextAlignLeft ) ;
2006-05-18 16:44:44 +00:00
}
}
2006-08-04 13:55:53 +00:00
void HelpDialog : : reflowLayout ( ) {
ScummDialog : : reflowLayout ( ) ;
2006-05-18 16:44:44 +00:00
2005-06-03 12:51:37 +00:00
int lineHeight = g_gui . getFontHeight ( ) ;
2008-08-10 18:26:14 +00:00
int16 x , y ;
2020-05-09 21:04:53 +02:00
int16 w , h ;
2009-01-01 15:06:43 +00:00
2015-11-28 00:03:49 +01:00
assert ( lineHeight ) ;
2020-06-06 16:05:37 +05:30
g_gui . xmlEval ( ) - > getWidgetData ( " ScummHelp.HelpText " , x , y , w , h ) ;
2009-01-01 15:06:43 +00:00
2009-07-16 17:39:16 +00:00
// Make sure than we don't have more lines than what we can fit
// on the space that the layout reserves for text
2009-07-16 17:44:05 +00:00
_numLines = MIN ( HELP_NUM_LINES , ( int ) ( h / lineHeight ) ) ;
2009-07-16 17:29:31 +00:00
2008-08-10 18:26:14 +00:00
int keyW = w * 20 / 100 ;
2008-08-15 16:44:44 +00:00
int dscX = x + keyW + 32 ;
2008-08-10 18:26:14 +00:00
int dscW = w * 80 / 100 ;
2009-01-01 15:06:43 +00:00
2008-08-15 16:44:44 +00:00
int xoff = ( _w > > 1 ) - ( w > > 1 ) ;
2003-06-14 21:18:14 +00:00
2009-07-16 17:29:31 +00:00
for ( int i = 0 ; i < _numLines ; i + + ) {
2021-04-01 00:48:39 +02:00
_key [ i ] - > resize ( xoff + x , y + lineHeight * i , keyW , lineHeight , false ) ;
_dsc [ i ] - > resize ( xoff + dscX , y + lineHeight * i , dscW , lineHeight , false ) ;
2003-06-14 21:18:14 +00:00
}
displayKeyBindings ( ) ;
}
void HelpDialog : : displayKeyBindings ( ) {
2020-07-02 04:53:38 +05:30
U32String titleStr , * keyStr , * dscStr ;
2003-06-14 21:18:14 +00:00
2006-04-29 23:23:32 +00:00
ScummHelp : : updateStrings ( _game . id , _game . version , _game . platform , _page , titleStr , keyStr , dscStr ) ;
2003-06-14 21:18:14 +00:00
_title - > setLabel ( titleStr ) ;
2009-07-16 17:39:16 +00:00
for ( int i = 0 ; i < _numLines ; i + + ) {
2003-06-14 21:18:14 +00:00
_key [ i ] - > setLabel ( keyStr [ i ] ) ;
_dsc [ i ] - > setLabel ( dscStr [ i ] ) ;
}
2008-05-07 14:31:45 +00:00
delete [ ] keyStr ;
delete [ ] dscStr ;
2003-06-14 21:18:14 +00:00
}
2010-11-01 16:00:17 +00:00
void HelpDialog : : handleCommand ( GUI : : CommandSender * sender , uint32 cmd , uint32 data ) {
2003-07-15 00:20:04 +00:00
2003-06-14 21:18:14 +00:00
switch ( cmd ) {
case kNextCmd :
_page + + ;
if ( _page > = _numPages ) {
_nextButton - > clearFlags ( WIDGET_ENABLED ) ;
}
if ( _page > = 2 ) {
_prevButton - > setFlags ( WIDGET_ENABLED ) ;
}
displayKeyBindings ( ) ;
2018-01-06 16:13:29 +01:00
g_gui . scheduleTopDialogRedraw ( ) ;
2003-06-14 21:18:14 +00:00
break ;
case kPrevCmd :
_page - - ;
if ( _page < = _numPages ) {
_nextButton - > setFlags ( WIDGET_ENABLED ) ;
}
if ( _page < = 1 ) {
_prevButton - > clearFlags ( WIDGET_ENABLED ) ;
}
displayKeyBindings ( ) ;
2018-01-06 16:13:29 +01:00
g_gui . scheduleTopDialogRedraw ( ) ;
2003-06-14 21:18:14 +00:00
break ;
default :
ScummDialog : : handleCommand ( sender , cmd , data ) ;
}
}
# endif
2002-10-27 12:26:41 +00:00
# pragma mark -
2021-07-16 15:23:20 +03:00
static bool isCJKLanguage ( Common : : Language lang ) {
switch ( lang ) {
case Common : : KO_KOR :
case Common : : JA_JPN :
case Common : : ZH_TWN :
2021-11-04 16:49:21 -04:00
case Common : : ZH_CHN :
2021-07-16 15:23:20 +03:00
return true ;
default :
return false ;
}
}
2003-11-02 02:18:16 +00:00
InfoDialog : : InfoDialog ( ScummEngine * scumm , int res )
2020-10-25 01:38:05 +02:00
: ScummDialog ( 0 , 0 , 0 , 0 ) , _vm ( scumm ) , _style ( GUI : : ThemeEngine : : kFontStyleBold ) { // dummy x and w
2007-06-02 12:01:09 +00:00
_message = queryResString ( res ) ;
2021-07-16 15:23:20 +03:00
Common : : Language lang = isCJKLanguage ( _vm - > _language ) ? _vm - > _language : Common : : UNK_LANG ;
2020-10-25 01:38:05 +02:00
2007-06-02 12:01:09 +00:00
// Width and height are dummy
2020-10-25 01:38:05 +02:00
_text = new GUI : : StaticTextWidget ( this , 0 , 0 , 10 , 10 , _message , kTextAlignCenter , Common : : U32String ( ) , GUI : : ThemeEngine : : kFontStyleBold , lang ) ;
// Store this for the calls to getStringWidth() and getStringHeight() in reflowLayout().
if ( lang ! = Common : : UNK_LANG )
_style = GUI : : ThemeEngine : : kFontStyleLangExtra ;
2002-10-27 12:26:41 +00:00
}
2020-06-30 03:40:13 +05:30
InfoDialog : : InfoDialog ( ScummEngine * scumm , const U32String & message )
2020-10-25 01:38:05 +02:00
: ScummDialog ( 0 , 0 , 0 , 0 ) , _vm ( scumm ) , _style ( GUI : : ThemeEngine : : kFontStyleBold ) { // dummy x and w
2002-10-27 12:26:41 +00:00
2006-05-18 16:44:44 +00:00
_message = message ;
2006-05-18 19:37:38 +00:00
// Width and height are dummy
2010-11-01 16:00:17 +00:00
_text = new GUI : : StaticTextWidget ( this , 0 , 0 , 10 , 10 , _message , kTextAlignCenter ) ;
2006-05-18 16:44:44 +00:00
}
2020-06-30 03:40:13 +05:30
void InfoDialog : : setInfoText ( const U32String & message ) {
2007-06-02 12:01:09 +00:00
_message = message ;
_text - > setLabel ( _message ) ;
//reflowLayout(); // FIXME: Should we call this here? Depends on the usage patterns, I guess...
}
2006-08-04 13:55:53 +00:00
void InfoDialog : : reflowLayout ( ) {
2005-05-16 12:26:44 +00:00
const int screenW = g_system - > getOverlayWidth ( ) ;
const int screenH = g_system - > getOverlayHeight ( ) ;
2020-10-25 01:38:05 +02:00
int width = g_gui . getStringWidth ( _message , _style ) + 16 ;
int height = g_gui . getFontHeight ( _style ) + 8 ;
2003-03-06 17:58:13 +00:00
2002-10-27 12:26:41 +00:00
_w = width ;
2005-05-16 12:26:44 +00:00
_h = height ;
_x = ( screenW - width ) / 2 ;
_y = ( screenH - height ) / 2 ;
2002-10-27 12:26:41 +00:00
2009-08-16 11:28:59 +00:00
_text - > setSize ( _w , _h ) ;
2002-10-27 12:26:41 +00:00
}
2020-08-29 14:59:58 +05:30
const Common : : U32String InfoDialog : : queryResString ( int stringno ) {
2006-04-29 23:23:32 +00:00
byte buf [ 256 ] ;
2021-07-16 15:23:00 +03:00
byte reverseBuf [ 256 ] ;
2006-10-24 09:44:20 +00:00
const byte * result ;
2006-04-29 23:23:32 +00:00
if ( stringno = = 0 )
return String ( ) ;
2014-08-20 08:36:40 +10:00
if ( _vm - > _game . heversion > = 80 )
return _ ( string_map_table_v6 [ stringno - 1 ] . string ) ;
else if ( _vm - > _game . version = = 8 )
2006-10-24 09:44:20 +00:00
result = ( const byte * ) string_map_table_v8 [ stringno - 1 ] . string ;
2006-04-29 23:23:32 +00:00
else if ( _vm - > _game . version = = 7 )
result = _vm - > getStringAddressVar ( string_map_table_v7 [ stringno - 1 ] . num ) ;
else if ( _vm - > _game . version = = 6 )
result = _vm - > getStringAddressVar ( string_map_table_v6 [ stringno - 1 ] . num ) ;
else if ( _vm - > _game . version > = 3 )
result = _vm - > getStringAddress ( string_map_table_v345 [ stringno - 1 ] . num ) ;
else
2011-08-20 10:59:16 +01:00
return _ ( string_map_table_v345 [ stringno - 1 ] . string ) ;
2006-04-29 23:23:32 +00:00
if ( result & & * result = = ' / ' ) {
_vm - > translateText ( result , buf ) ;
result = buf ;
}
if ( ! result | | * result = = ' \0 ' ) { // Gracelessly degrade to english :)
2011-08-20 10:59:16 +01:00
return _ ( string_map_table_v345 [ stringno - 1 ] . string ) ;
2006-04-29 23:23:32 +00:00
}
2021-07-16 15:23:00 +03:00
if ( _vm - > reverseIfNeeded ( result , reverseBuf ) )
result = reverseBuf ;
2006-04-29 23:23:32 +00:00
// Convert to a proper string (take care of FF codes)
byte chr ;
String tmp ;
while ( ( chr = * result + + ) ) {
if ( chr = = 0xFF ) {
result + = 3 ;
} else if ( chr ! = ' @ ' ) {
tmp + = chr ;
}
}
2020-09-13 01:39:41 +02:00
2021-07-16 15:23:00 +03:00
const Common : : CodePage convertFromCodePage = _vm - > getDialogCodePage ( ) ;
2020-11-15 16:20:35 +01:00
return convertFromCodePage = = Common : : kCodePageInvalid ? _ ( tmp ) : U32String ( tmp , convertFromCodePage ) ;
2006-04-29 23:23:32 +00:00
}
2002-10-27 12:26:41 +00:00
# pragma mark -
2004-07-20 11:30:15 +00:00
PauseDialog : : PauseDialog ( ScummEngine * scumm , int res )
: InfoDialog ( scumm , res ) {
2002-12-14 10:46:00 +00:00
}
2002-10-27 12:26:41 +00:00
2007-06-30 12:26:59 +00:00
void PauseDialog : : handleKeyDown ( Common : : KeyState state ) {
if ( state . ascii = = ' ' ) // Close pause dialog if space key is pressed
2003-07-28 01:36:16 +00:00
close ( ) ;
2003-12-14 20:36:37 +00:00
else
2007-06-30 12:26:59 +00:00
ScummDialog : : handleKeyDown ( state ) ;
2003-07-28 01:36:16 +00:00
}
2006-03-01 04:32:44 +00:00
ConfirmDialog : : ConfirmDialog ( ScummEngine * scumm , int res )
2010-09-13 23:35:55 +00:00
: InfoDialog ( scumm , res ) , _yesKey ( ' y ' ) , _noKey ( ' n ' ) {
2020-06-30 03:40:13 +05:30
if ( _message . empty ( ) )
return ;
if ( _message [ _message . size ( ) - 1 ] ! = ' ) ' ) {
_yesKey = _message [ _message . size ( ) - 1 ] ;
2010-09-13 23:35:55 +00:00
_message . deleteLastChar ( ) ;
if ( _yesKey > = ' A ' & & _yesKey < = ' Z ' )
_yesKey + = ' a ' - ' A ' ;
_text - > setLabel ( _message ) ;
reflowLayout ( ) ;
}
2003-12-14 15:04:05 +00:00
}
2007-06-30 12:26:59 +00:00
void ConfirmDialog : : handleKeyDown ( Common : : KeyState state ) {
2011-08-20 12:51:22 +01:00
Common : : KeyCode keyYes , keyNo ;
2011-08-20 19:36:54 +02:00
Common : : getLanguageYesNo ( keyYes , keyNo ) ;
2011-08-20 12:51:22 +01:00
if ( state . keycode = = Common : : KEYCODE_n | | state . ascii = = _noKey | | state . ascii = = keyNo ) {
2003-12-14 15:04:05 +00:00
setResult ( 0 ) ;
close ( ) ;
2011-08-20 12:51:22 +01:00
} else if ( state . keycode = = Common : : KEYCODE_y | | state . ascii = = _yesKey | | state . ascii = = keyYes ) {
2003-12-14 15:04:05 +00:00
setResult ( 1 ) ;
close ( ) ;
} else
2007-06-30 12:26:59 +00:00
ScummDialog : : handleKeyDown ( state ) ;
2003-12-14 15:04:05 +00:00
}
2005-03-06 18:00:54 +00:00
# pragma mark -
2020-07-21 04:24:04 +05:30
ValueDisplayDialog : : ValueDisplayDialog ( const Common : : U32String & label , int minVal , int maxVal ,
2006-08-04 17:59:53 +00:00
int val , uint16 incKey , uint16 decKey )
2010-01-05 22:18:09 +00:00
: GUI : : Dialog ( 0 , 0 , 0 , 0 ) ,
2006-08-04 17:59:53 +00:00
_label ( label ) , _min ( minVal ) , _max ( maxVal ) ,
2016-11-26 20:48:22 +01:00
_value ( val ) , _incKey ( incKey ) , _decKey ( decKey ) , _timer ( 0 ) {
2005-03-06 18:00:54 +00:00
assert ( _min < = _value & & _value < = _max ) ;
2006-08-04 15:48:37 +00:00
}
2018-01-07 10:39:22 +01:00
void ValueDisplayDialog : : drawDialog ( GUI : : DrawLayer layerToDraw ) {
Dialog : : drawDialog ( layerToDraw ) ;
2006-08-04 15:48:37 +00:00
const int labelWidth = _w - 8 - _percentBarWidth ;
2006-08-04 17:59:53 +00:00
g_gui . theme ( ) - > drawText ( Common : : Rect ( _x + 4 , _y + 4 , _x + labelWidth + 4 ,
_y + g_gui . theme ( ) - > getFontHeight ( ) + 4 ) , _label ) ;
g_gui . theme ( ) - > drawSlider ( Common : : Rect ( _x + 4 + labelWidth , _y + 4 , _x + _w - 4 , _y + _h - 4 ) ,
_percentBarWidth * ( _value - _min ) / ( _max - _min ) ) ;
2006-08-04 15:48:37 +00:00
}
void ValueDisplayDialog : : handleTickle ( ) {
2010-03-11 23:41:28 +00:00
if ( g_system - > getMillis ( ) > _timer ) {
2006-08-04 15:48:37 +00:00
close ( ) ;
}
}
void ValueDisplayDialog : : reflowLayout ( ) {
2005-05-27 13:14:39 +00:00
const int screenW = g_system - > getOverlayWidth ( ) ;
const int screenH = g_system - > getOverlayHeight ( ) ;
2008-11-12 13:14:44 +00:00
_percentBarWidth = screenW * 100 / 640 ;
2005-05-27 13:14:39 +00:00
2006-08-04 15:48:37 +00:00
int width = g_gui . getStringWidth ( _label ) + 16 + _percentBarWidth ;
2005-06-03 12:51:37 +00:00
int height = g_gui . getFontHeight ( ) + 4 * 2 ;
2005-03-06 18:00:54 +00:00
2005-05-27 13:14:39 +00:00
_x = ( screenW - width ) / 2 ;
_y = ( screenH - height ) / 2 ;
2005-03-06 18:00:54 +00:00
_w = width ;
2005-05-27 13:14:39 +00:00
_h = height ;
2005-03-06 18:00:54 +00:00
}
2007-06-30 12:26:59 +00:00
void ValueDisplayDialog : : handleKeyDown ( Common : : KeyState state ) {
if ( state . ascii = = _incKey | | state . ascii = = _decKey ) {
if ( state . ascii = = _incKey & & _value < _max )
2005-03-06 18:00:54 +00:00
_value + + ;
2007-06-30 12:26:59 +00:00
else if ( state . ascii = = _decKey & & _value > _min )
2005-03-06 18:00:54 +00:00
_value - - ;
2005-07-30 21:11:48 +00:00
2005-03-06 18:00:54 +00:00
setResult ( _value ) ;
2010-03-11 23:41:28 +00:00
_timer = g_system - > getMillis ( ) + kDisplayDelay ;
2018-01-06 16:13:29 +01:00
g_gui . scheduleTopDialogRedraw ( ) ;
2005-03-06 18:00:54 +00:00
} else {
close ( ) ;
}
}
2005-03-08 23:44:07 +00:00
void ValueDisplayDialog : : open ( ) {
2010-04-06 09:25:44 +00:00
GUI : : Dialog : : open ( ) ;
2005-03-08 23:44:07 +00:00
setResult ( _value ) ;
2010-03-11 23:41:28 +00:00
_timer = g_system - > getMillis ( ) + kDisplayDelay ;
2005-03-08 23:44:07 +00:00
}
2007-09-19 08:40:12 +00:00
SubtitleSettingsDialog : : SubtitleSettingsDialog ( ScummEngine * scumm , int value )
2020-11-15 18:15:58 +00:00
: InfoDialog ( scumm , U32String ( ) ) , _value ( value ) , _timer ( 0 ) {
2007-06-03 17:32:42 +00:00
}
void SubtitleSettingsDialog : : handleTickle ( ) {
InfoDialog : : handleTickle ( ) ;
2010-03-11 23:41:28 +00:00
if ( g_system - > getMillis ( ) > _timer )
2007-06-03 17:32:42 +00:00
close ( ) ;
}
2007-06-30 12:26:59 +00:00
void SubtitleSettingsDialog : : handleKeyDown ( Common : : KeyState state ) {
2010-02-21 04:04:13 +00:00
if ( state . keycode = = Common : : KEYCODE_t & & state . hasFlags ( Common : : KBD_CTRL ) ) {
2007-06-03 17:32:42 +00:00
cycleValue ( ) ;
reflowLayout ( ) ;
2018-01-06 16:13:29 +01:00
g_gui . scheduleTopDialogRedraw ( ) ;
2007-06-03 17:32:42 +00:00
} else {
close ( ) ;
}
}
void SubtitleSettingsDialog : : open ( ) {
cycleValue ( ) ;
InfoDialog : : open ( ) ;
2008-04-30 12:53:05 +00:00
setResult ( _value ) ;
2007-06-03 17:32:42 +00:00
}
void SubtitleSettingsDialog : : cycleValue ( ) {
2011-09-08 20:13:13 +02:00
static const char * const subtitleDesc [ ] = {
2011-08-20 10:34:12 +01:00
_s ( " Speech Only " ) ,
_s ( " Speech and Subtitles " ) ,
_s ( " Subtitles Only " )
2007-06-03 17:32:42 +00:00
} ;
2007-09-19 08:40:12 +00:00
2008-04-30 12:53:05 +00:00
_value + = 1 ;
if ( _value > 2 )
_value = 0 ;
2007-06-03 17:32:42 +00:00
2008-08-15 19:10:37 +00:00
if ( _value = = 1 & & g_system - > getOverlayWidth ( ) < = 320 )
2020-08-20 11:45:58 +05:30
setInfoText ( _c ( " Speech & Subs " , " lowres " ) ) ;
2008-08-15 19:10:37 +00:00
else
2011-08-20 10:34:12 +01:00
setInfoText ( _ ( subtitleDesc [ _value ] ) ) ;
2007-06-03 17:32:42 +00:00
2010-03-11 23:41:28 +00:00
_timer = g_system - > getMillis ( ) + 1500 ;
2007-06-03 17:32:42 +00:00
}
2007-05-30 16:40:11 +00:00
Indy3IQPointsDialog : : Indy3IQPointsDialog ( ScummEngine * scumm , char * text )
2020-07-04 03:13:05 +05:30
: InfoDialog ( scumm , Common : : U32String ( text ) ) {
2007-05-30 16:40:11 +00:00
}
2005-03-06 18:00:54 +00:00
2007-06-30 12:26:59 +00:00
void Indy3IQPointsDialog : : handleKeyDown ( Common : : KeyState state ) {
2007-09-19 08:40:12 +00:00
if ( state . ascii = = ' i ' )
2007-05-30 16:40:11 +00:00
close ( ) ;
else
2007-06-30 12:26:59 +00:00
ScummDialog : : handleKeyDown ( state ) ;
2007-05-30 16:40:11 +00:00
}
2005-03-06 18:00:54 +00:00
2007-09-20 20:50:38 +00:00
DebugInputDialog : : DebugInputDialog ( ScummEngine * scumm , char * text )
2020-06-17 01:27:23 +05:30
: InfoDialog ( scumm , U32String ( text ) ) {
2007-09-20 20:50:38 +00:00
mainText = text ;
done = 0 ;
}
void DebugInputDialog : : handleKeyDown ( Common : : KeyState state ) {
if ( state . keycode = = Common : : KEYCODE_BACKSPACE & & buffer . size ( ) > 0 ) {
buffer . deleteLastChar ( ) ;
Common : : String total = mainText + ' ' + buffer ;
setInfoText ( total ) ;
2018-01-06 16:13:29 +01:00
g_gui . scheduleTopDialogRedraw ( ) ;
2007-09-20 20:50:38 +00:00
reflowLayout ( ) ;
} else if ( state . keycode = = Common : : KEYCODE_RETURN ) {
done = 1 ;
close ( ) ;
return ;
} else if ( ( state . ascii > = ' 0 ' & & state . ascii < = ' 9 ' ) | | ( state . ascii > = ' A ' & & state . ascii < = ' Z ' ) | | ( state . ascii > = ' a ' & & state . ascii < = ' z ' ) | | state . ascii = = ' . ' | | state . ascii = = ' ' ) {
buffer + = state . ascii ;
Common : : String total = mainText + ' ' + buffer ;
2018-01-06 16:13:29 +01:00
g_gui . scheduleTopDialogRedraw ( ) ;
2007-09-20 20:50:38 +00:00
reflowLayout ( ) ;
setInfoText ( total ) ;
2008-01-27 19:47:41 +00:00
}
2007-09-20 20:50:38 +00:00
}
2011-12-24 21:09:46 +01:00
LoomTownsDifficultyDialog : : LoomTownsDifficultyDialog ( )
2021-04-15 21:20:04 +02:00
: Dialog ( " LoomTownsDifficultyDialog " ) , _difficulty ( - 1 ) {
2011-12-24 21:09:46 +01:00
GUI : : StaticTextWidget * text1 = new GUI : : StaticTextWidget ( this , " LoomTownsDifficultyDialog.Description1 " , _ ( " Select a Proficiency Level. " ) ) ;
text1 - > setAlign ( Graphics : : kTextAlignCenter ) ;
GUI : : StaticTextWidget * text2 = new GUI : : StaticTextWidget ( this , " LoomTownsDifficultyDialog.Description2 " , _ ( " Refer to your Loom(TM) manual for help. " ) ) ;
text2 - > setAlign ( Graphics : : kTextAlignCenter ) ;
2020-11-15 18:15:58 +00:00
new GUI : : ButtonWidget ( this , " LoomTownsDifficultyDialog.Standard " , _ ( " Standard " ) , Common : : U32String ( ) , kStandardCmd ) ;
new GUI : : ButtonWidget ( this , " LoomTownsDifficultyDialog.Practice " , _ ( " Practice " ) , Common : : U32String ( ) , kPracticeCmd ) ;
new GUI : : ButtonWidget ( this , " LoomTownsDifficultyDialog.Expert " , _ ( " Expert " ) , Common : : U32String ( ) , kExpertCmd ) ;
2011-12-24 21:09:46 +01:00
}
void LoomTownsDifficultyDialog : : handleCommand ( GUI : : CommandSender * sender , uint32 cmd , uint32 data ) {
switch ( cmd ) {
case kStandardCmd :
_difficulty = 1 ;
close ( ) ;
break ;
case kPracticeCmd :
_difficulty = 0 ;
close ( ) ;
break ;
case kExpertCmd :
_difficulty = 2 ;
close ( ) ;
break ;
default :
GUI : : Dialog : : handleCommand ( sender , cmd , data ) ;
}
}
2022-03-08 18:21:04 +01:00
LoomEgaOptionsWidget : : LoomEgaOptionsWidget ( GuiObject * boss , const Common : : String & name , const Common : : String & domain ) :
OptionsContainerWidget ( boss , name , " LoomEgaOptionsDialog " , false , domain ) {
GUI : : StaticTextWidget * text = new GUI : : StaticTextWidget ( widgetsBoss ( ) , " LoomEgaOptionsDialog.OvertureTicksHeader " , _ ( " Overture Timing: " ) ) ;
2022-02-03 16:36:00 +01:00
2022-02-12 12:02:55 +01:00
text - > setAlign ( Graphics : : TextAlign : : kTextAlignEnd ) ;
2022-02-03 16:36:00 +01:00
2022-03-08 18:21:04 +01:00
_overtureTicksSlider = new GUI : : SliderWidget ( widgetsBoss ( ) , " LoomEgaOptionsDialog.OvertureTicks " , _ ( " When using replacement music, this adjusts the time when the Overture changes to the scene with the Lucasfilm and Loom logotypes. " ) , kOvertureTicksChanged ) ;
2022-02-12 12:02:55 +01:00
2022-03-01 14:53:06 +01:00
// In the Ozawa recording, the transition happens at about 1:56. At is
// turns out, this is a fairly fast version of the tune. After checking
// a number of different recordings, I've settled on an interval of
// 1:40 - 2:50. This is larger than I had hoped, but I guess it's
// really necessary.
//
// Hopefully that still means you can set the slider back to its default
// value at most reasonable screen resolutions.
_overtureTicksSlider - > setMinValue ( - 160 ) ;
_overtureTicksSlider - > setMaxValue ( 540 ) ;
2022-02-03 16:36:00 +01:00
2022-03-08 18:21:04 +01:00
_overtureTicksLabel = new GUI : : StaticTextWidget ( widgetsBoss ( ) , " LoomEgaOptionsDialog.OvertureTicksLabel " , Common : : U32String ( ) ) ;
2022-02-03 16:36:00 +01:00
_overtureTicksLabel - > setFlags ( GUI : : WIDGET_CLEARBG ) ;
}
2022-03-08 18:21:04 +01:00
void LoomEgaOptionsWidget : : load ( ) {
2022-02-03 19:40:22 +01:00
int loomOvertureTicks = 0 ;
2022-02-03 16:36:00 +01:00
if ( ConfMan . hasKey ( " loom_overture_ticks " , _domain ) )
loomOvertureTicks = ConfMan . getInt ( " loom_overture_ticks " , _domain ) ;
_overtureTicksSlider - > setValue ( loomOvertureTicks ) ;
updateOvertureTicksLabel ( ) ;
}
2022-03-08 18:21:04 +01:00
bool LoomEgaOptionsWidget : : save ( ) {
2022-02-03 16:36:00 +01:00
ConfMan . setInt ( " loom_overture_ticks " , _overtureTicksSlider - > getValue ( ) , _domain ) ;
return true ;
}
2022-03-08 18:21:04 +01:00
void LoomEgaOptionsWidget : : defineLayout ( GUI : : ThemeEval & layouts , const Common : : String & layoutName , const Common : : String & overlayedLayout ) const {
2022-02-03 16:36:00 +01:00
layouts . addDialog ( layoutName , overlayedLayout )
2022-02-15 15:35:35 +01:00
. addLayout ( GUI : : ThemeLayout : : kLayoutHorizontal , 12 )
2022-02-12 12:02:55 +01:00
. addPadding ( 0 , 0 , 16 , 0 )
2022-02-03 16:36:00 +01:00
. addWidget ( " OvertureTicksHeader " , " OptionsLabel " )
. addWidget ( " OvertureTicks " , " WideSlider " )
2022-02-12 12:02:55 +01:00
. addWidget ( " OvertureTicksLabel " , " ShortOptionsLabel " )
2022-02-03 16:36:00 +01:00
. closeLayout ( )
. closeDialog ( ) ;
}
2022-03-08 18:21:04 +01:00
void LoomEgaOptionsWidget : : handleCommand ( GUI : : CommandSender * sender , uint32 cmd , uint32 data ) {
2022-02-03 16:36:00 +01:00
switch ( cmd ) {
case kOvertureTicksChanged :
updateOvertureTicksLabel ( ) ;
break ;
default :
GUI : : OptionsContainerWidget : : handleCommand ( sender , cmd , data ) ;
break ;
}
}
2022-03-08 18:21:04 +01:00
void LoomEgaOptionsWidget : : updateOvertureTicksLabel ( ) {
2022-02-12 12:02:55 +01:00
int ticks = DEFAULT_LOOM_OVERTURE_TRANSITION + _overtureTicksSlider - > getValue ( ) ;
_overtureTicksLabel - > setLabel ( Common : : String : : format ( " %d:%02d.%d " , ticks / 600 , ( ticks % 600 ) / 10 , ticks % 10 ) ) ;
2022-02-03 16:36:00 +01:00
}
2003-10-09 14:17:06 +00:00
} // End of namespace Scumm