ALL: Sync with ScummVM - rev a94849abc4

This commit is contained in:
Pawel Kolodziejski
2020-06-25 08:34:00 +02:00
parent 17df02d25d
commit fa277fcb48
23 changed files with 284 additions and 3731 deletions
+2 -2
View File
@@ -44,8 +44,8 @@ $(PATH_BUILD_GRADLE): $(PATH_BUILD_ASSETS) $(PATH_DIST)/build.gradle
@echo "gradle.ext.androidAbi = '$(ABIS)'" >> $@
@echo "include ':ResidualVM'" >> $@
@echo "project(':ResidualVM').projectDir = new File('$(abspath $(PATH_DIST))')" >> $@
@echo "ndk.dir=$(ANDROID_NDK)" > $(PATH_BUILD)/local.properties
@echo "sdk.dir=$(ANDROID_SDK)" >> $(PATH_BUILD)/local.properties
@echo "ndk.dir=$(ANDROID_NDK_ROOT)" > $(PATH_BUILD)/local.properties
@echo "sdk.dir=$(ANDROID_SDK_ROOT)" >> $(PATH_BUILD)/local.properties
$(PATH_BUILD_SETUPAPK): $(PATH_BUILD_ASSETS) $(PATH_BUILD_JNI) $(PATH_BUILD_GRADLE) | $(PATH_BUILD)
+1 -1
View File
@@ -68,7 +68,7 @@ void UnityTaskbarManager::setProgressState(TaskbarProgressState state) {
switch (state) {
default:
warning("[UnityTaskbarManager::setProgressState] Unknown state / Not implemented (%d)", state);
// fallback to noprogress state
// fall through
case kTaskbarNoProgress:
unity_launcher_entry_set_progress_visible(_launcher, FALSE);
@@ -55,31 +55,31 @@ public:
};
SpeechDispatcherManager();
virtual ~SpeechDispatcherManager();
virtual ~SpeechDispatcherManager() override;
virtual bool say(Common::String str, Action action, Common::String charset = "");
virtual bool say(Common::String str, Action action, Common::String charset = "") override;
virtual bool stop();
virtual bool pause();
virtual bool resume();
virtual bool stop() override;
virtual bool pause() override;
virtual bool resume() override;
virtual bool isSpeaking();
virtual bool isPaused();
virtual bool isReady();
virtual bool isSpeaking() override;
virtual bool isPaused() override;
virtual bool isReady() override;
virtual void setVoice(unsigned index);
virtual void setRate(int rate);
virtual void setPitch(int pitch);
virtual void setVolume(unsigned volume);
virtual void setLanguage(Common::String language);
virtual void setVoice(unsigned index) override;
virtual void setRate(int rate) override;
virtual void setPitch(int pitch) override;
virtual void setVolume(unsigned volume) override;
virtual void setLanguage(Common::String language) override;
void updateState(SpeechEvent event);
virtual void freeVoiceData(void *data);
virtual void freeVoiceData(void *data) override;
private:
void init();
virtual void updateVoices();
virtual void updateVoices() override;
void createVoice(int typeNumber, Common::TTSVoice::Gender, Common::TTSVoice::Age, char *description);
Common::String strToUtf8(Common::String str, Common::String charset);
static void *startSpeech(void *p);
@@ -33,34 +33,36 @@
class MacOSXTextToSpeechManager : public Common::TextToSpeechManager {
public:
MacOSXTextToSpeechManager();
virtual ~MacOSXTextToSpeechManager();
virtual ~MacOSXTextToSpeechManager() override;
virtual bool say(Common::String str, Action action, Common::String charset = "");
virtual bool say(Common::String str, Action action, Common::String charset = "") override;
virtual bool stop();
virtual bool pause();
virtual bool resume();
virtual bool stop() override;
virtual bool pause() override;
virtual bool resume() override;
virtual bool isSpeaking();
virtual bool isPaused();
virtual bool isReady();
virtual bool isSpeaking() override;
virtual bool isPaused() override;
virtual bool isReady() override;
virtual void setVoice(unsigned index);
virtual void setVoice(unsigned index) override;
virtual void setRate(int rate);
virtual void setRate(int rate) override;
virtual void setPitch(int pitch);
virtual void setPitch(int pitch) override;
virtual void setVolume(unsigned volume);
virtual void setVolume(unsigned volume) override;
virtual void setLanguage(Common::String language);
virtual void setLanguage(Common::String language) override;
virtual void freeVoiceData(void *data);
virtual int getDefaultVoice() override;
virtual void freeVoiceData(void *data) override;
bool startNextSpeech();
private:
virtual void updateVoices();
virtual void updateVoices() override;
struct SpeechText {
Common::String text;
@@ -33,20 +33,29 @@
@interface MacOSXTextToSpeechManagerDelegate : NSObject<NSSpeechSynthesizerDelegate> {
MacOSXTextToSpeechManager *_ttsManager;
BOOL _ignoreNextFinishedSpeaking;
}
- (id)initWithManager:(MacOSXTextToSpeechManager*)ttsManager;
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedSpeaking;
- (void)ignoreNextFinishedSpeaking:(BOOL)ignore;
@end
@implementation MacOSXTextToSpeechManagerDelegate
- (id)initWithManager:(MacOSXTextToSpeechManager*)ttsManager {
self = [super init];
_ttsManager = ttsManager;
_ignoreNextFinishedSpeaking = NO;
return self;
}
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedSpeaking {
_ttsManager->startNextSpeech();
if (!_ignoreNextFinishedSpeaking)
_ttsManager->startNextSpeech();
_ignoreNextFinishedSpeaking = NO;
}
- (void)ignoreNextFinishedSpeaking:(BOOL)ignore {
_ignoreNextFinishedSpeaking = ignore;
}
@end
@@ -133,9 +142,15 @@ bool MacOSXTextToSpeechManager::startNextSpeech() {
bool MacOSXTextToSpeechManager::stop() {
_messageQueue.clear();
_currentSpeech.clear(); // so that it immediately reports that it is no longer speeking
// Stop as soon as possible
[synthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary];
if (isSpeaking()) {
_currentSpeech.clear(); // so that it immediately reports that it is no longer speeking
// Stop as soon as possible
// Also tell the MacOSXTextToSpeechManagerDelegate to ignore the next finishedSpeaking as
// it has already been handled, but we might have started another speach by the time we
// receive it, and we don't want to stop that one.
[synthesizerDelegate ignoreNextFinishedSpeaking:YES];
[synthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary];
}
return true;
}
@@ -227,6 +242,19 @@ void MacOSXTextToSpeechManager::setLanguage(Common::String language) {
updateVoices();
}
int MacOSXTextToSpeechManager::getDefaultVoice() {
if (_ttsState->_availableVoices.size() < 2)
return 0;
NSString *defaultVoice = [NSSpeechSynthesizer defaultVoice];
if (defaultVoice == nil)
return 0;
for (int i = 0 ; i < _ttsState->_availableVoices.size() ; ++i) {
if ([defaultVoice isEqualToString:(NSString*)(_ttsState->_availableVoices[i].getData())])
return i;
}
return 0;
}
void MacOSXTextToSpeechManager::freeVoiceData(void *data) {
NSString* voiceId = (NSString*)data;
[voiceId release];
@@ -49,33 +49,33 @@ public:
};
WindowsTextToSpeechManager();
virtual ~WindowsTextToSpeechManager();
virtual ~WindowsTextToSpeechManager() override;
virtual bool say(Common::String str, Action action, Common::String charset = "");
virtual bool say(Common::String str, Action action, Common::String charset = "") override;
virtual bool stop();
virtual bool pause();
virtual bool resume();
virtual bool stop() override;
virtual bool pause() override;
virtual bool resume() override;
virtual bool isSpeaking();
virtual bool isPaused();
virtual bool isReady();
virtual bool isSpeaking() override;
virtual bool isPaused() override;
virtual bool isReady() override;
virtual void setVoice(unsigned index);
virtual void setVoice(unsigned index) override;
virtual void setRate(int rate);
virtual void setRate(int rate) override;
virtual void setPitch(int pitch);
virtual void setPitch(int pitch) override;
virtual void setVolume(unsigned volume);
virtual void setVolume(unsigned volume) override;
virtual void setLanguage(Common::String language);
virtual void setLanguage(Common::String language) override;
virtual void freeVoiceData(void *data);
virtual void freeVoiceData(void *data) override;
private:
void init();
virtual void updateVoices();
virtual void updateVoices() override;
void createVoice(void *cpVoiceToken);
Common::String lcidToLocale(Common::String lcid);
SpeechState _speechState;
+16 -1
View File
@@ -62,6 +62,7 @@ void insertPrioQueue(TimerSlot *head, TimerSlot *newSlot) {
DefaultTimerManager::DefaultTimerManager() :
_timerCallbackNext(0),
_head(0) {
_head = new TimerSlot();
@@ -84,6 +85,10 @@ void DefaultTimerManager::handler() {
uint32 curTime = g_system->getMillis(true);
// On slow systems this could still be run after destructor
if (!_head)
return;
// Repeat as long as there is a TimerSlot that is scheduled to fire.
TimerSlot *slot = _head->next;
while (slot && slot->nextFireTime < curTime) {
@@ -110,6 +115,16 @@ void DefaultTimerManager::handler() {
}
}
void DefaultTimerManager::checkTimers(uint32 interval) {
uint32 curTime = g_system->getMillis();
// Timer checking & firing
if (curTime >= _timerCallbackNext) {
handler();
_timerCallbackNext = curTime + interval;
}
}
bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, void *refCon, const Common::String &id) {
assert(interval > 0);
Common::StackLock lock(_mutex);
@@ -163,7 +178,7 @@ void DefaultTimerManager::removeTimerProc(TimerProc callback) {
// callbacks.
//
// Another issues occurs when one plays a game with ALSA as music driver,
// does RTL and starts a different engine game with ALSA as music driver.
// returns to launcher and starts a different engine game with ALSA as music driver.
// In this case the MPU401 code will add different timer procs with the
// same name, resulting in two different callbacks added with the same
// name and causing installTimerProc to error out.
+8
View File
@@ -38,6 +38,8 @@ private:
TimerSlot *_head;
TimerSlotMap _callbacks;
uint32 _timerCallbackNext;
public:
DefaultTimerManager();
virtual ~DefaultTimerManager();
@@ -48,6 +50,12 @@ public:
* Timer callback, to be invoked at regular time intervals by the backend.
*/
void handler();
/*
* Ensure that the callback is called at regular time intervals.
* Should be called from pollEvents() on backends without threads.
*/
void checkTimers(uint32 interval = 10);
};
#endif
+11 -2
View File
@@ -225,7 +225,7 @@ char *Encoding::convertIconv(const char *to, const char *from, const char *strin
char *dst = buffer;
bool error = false;
while (inSize > 0) {
while (true) {
if (iconv(iconvHandle, &src, &inSize, &dst, &outSize) == ((size_t)-1)) {
// from SDL's implementation of SDL_iconv_string (slightly altered)
if (errno == E2BIG) {
@@ -244,9 +244,18 @@ char *Encoding::convertIconv(const char *to, const char *from, const char *strin
error = true;
break;
}
} else {
// we've successfully finished, after the last call with NULLs
if (inSize == 0 && src == NULL) {
break;
}
}
if (inSize == 0) {
// we're at the end - call one last time with NULLs
src = NULL;
}
}
iconv(iconvHandle, NULL, NULL, &dst, &outSize);
// Add a zero character to the end. Hopefuly UTF32 uses the most bytes from
// all possible encodings, so add 4 zero bytes.
buffer = (char *)realloc(buffer, stringSize + 4);
Vendored
+63 -10
View File
@@ -1862,17 +1862,12 @@ esac
#
case $_host_os in
android)
if test -z "$ANDROID_SDK"; then
echo "Please set ANDROID_SDK in your environment. export ANDROID_SDK=<path to Android SDK>"
if test -z "$ANDROID_SDK_ROOT"; then
echo "Please set ANDROID_SDK_ROOT in your environment. export ANDROID_SDK_ROOT=<path to Android SDK>"
exit 1
fi
if test -z "$ANDROID_NDK"; then
echo "Please set ANDROID_NDK in your environment. export ANDROID_NDK=<path to Android NDK>"
exit 1
fi
ndk_version=$(sed -En -e 's/^Pkg.Revision *= *([0-9a-f]+).*/\1/p' "$ANDROID_NDK/source.properties")
if [ -z "$ndk_version" -o "$ndk_version" -lt 18 ]; then
echo "Need Android NDK r18 or later to compile! Found version '$ndk_version'"
if test -z "$ANDROID_NDK_ROOT"; then
echo "Please set ANDROID_NDK_ROOT in your environment. export ANDROID_NDK_ROOT=<path to Android NDK>"
exit 1
fi
;;
@@ -1975,6 +1970,62 @@ webos)
;;
esac
# Toolchain for Android is in NDK and is using different naming convention
if test "$_host_os" = android; then
# Try to use a known to work (on linux) toolchain
_android_toolchain="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64"
if test -n "$ANDROID_TOOLCHAIN"; then
_android_toolchain="$ANDROID_TOOLCHAIN"
fi
case $_host_cpu in
arm | i686)
_android_version=16
;;
aarch64 | x86_64)
# Platform version 21 is needed as earlier versions of platform do not support this architecture.
_android_version=21
;;
esac
# If CXX environment variable is not set, try to set known to work defaults
if test -z "$CXX"; then
case $_host_cpu in
arm)
_android_target="armv7a-linux-androideabi$_android_version"
;;
aarch64)
_android_target="aarch64-linux-android$_android_version"
;;
i686)
_android_target="i686-linux-android$_android_version"
;;
x86_64)
_android_target="x86_64-linux-android$_android_version"
;;
esac
CXX="$_android_toolchain/bin/clang++"
# If CXX is defined don't alter CXXFLAGS and LDFLAGS as the user can do it himself
append_var CXXFLAGS "-target ${_android_target}"
append_var LDFLAGS "-target ${_android_target}"
fi
# These values can get overriden below by environments variables
_ar="$_android_toolchain/bin/$_ar"
_as="$_android_toolchain/bin/$_as"
_ranlib="$_android_toolchain/bin/$_ranlib"
_strip="$_android_toolchain/bin/$_strip"
if test -z "$STRINGS"; then
STRINGS="$_android_toolchain/bin/$_host_alias-strings"
fi
if test -z "$PKG_CONFIG_LIBDIR"; then
export PKG_CONFIG_LIBDIR="$_android_toolchain/sysroot/usr/lib/$_host_alias/$_android_version/pkgconfig"
fi
_libcurlpath="$_android_toolchain/sysroot/usr/bin/$_host_alias/$_android_version:$_libcurlpath"
fi
#
# Determine the C++ compiler
#
@@ -2629,7 +2680,9 @@ case $_host_os in
# Build ID is needed for native debugging in Android Studio
append_var LDFLAGS "-Wl,--build-id=sha1"
add_line_to_config_mk "ANDROID_SDK = $ANDROID_SDK"
add_line_to_config_mk "ANDROID_SDK_ROOT := $ANDROID_SDK_ROOT"
add_line_to_config_mk "ANDROID_NDK_ROOT := $ANDROID_NDK_ROOT"
_seq_midi=no
;;
beos*)
-105
View File
@@ -1,105 +0,0 @@
@echo off
echo.
echo Automatic creation of the MSVC10 project files
echo.
if "%~1"=="/stable" goto stable
if "%~1"=="/STABLE" goto stable
if "%~1"=="/all" goto all
if "%~1"=="/ALL" goto all
if "%~1"=="/tools" goto tools
if "%~1"=="/TOOLS" goto tools
if "%~1"=="/tests" goto tests
if "%~1"=="/TESTS" goto tests
if "%~1"=="/clean" goto clean_check
if "%~1"=="/CLEAN" goto clean_check
if "%~1"=="/help" goto command_help
if "%~1"=="/HELP" goto command_help
if "%~1"=="/?" goto command_help
if "%~1"=="" goto check_tool
echo Invalid command parameter: %~1
echo.
:command_help
echo Valid command parameters are:
echo stable Generated stable engines project files
echo all Generate all engines project files
echo tools Generate project files for the devtools
echo clean Clean generated project files
echo help Show help message
goto done
:check_tool
if not exist create_project.exe goto no_tool
:question
echo.
set batchanswer=S
set /p batchanswer="Enable stable engines only, or all engines? (S/a)"
if "%batchanswer%"=="s" goto stable
if "%batchanswer%"=="S" goto stable
if "%batchanswer%"=="a" goto all
if "%batchanswer%"=="A" goto all
goto question
:no_tool
echo create_project.exe not found in the current folder.
echo You need to build it first and copy it in this
echo folder
goto done
:all
echo.
echo Creating project files with all engines enabled (stable and unstable)
echo.
create_project ..\.. --enable-all-engines --disable-fluidsynth --disable-sdlnet --disable-libcurl --disable-updates --msvc --msvc-version 10 --build-events
goto done
:stable
echo.
echo Creating normal project files, with only the stable engines enabled
echo.
create_project ..\.. --disable-fluidsynth --disable-sdlnet --disable-libcurl --disable-updates --msvc --msvc-version 10
goto done
:tools
echo.
echo Creating tools project files
echo.
create_project ..\.. --tools --msvc --msvc-version 10
goto done
:tests
echo.
echo Creating tests project files
echo.
create_project ..\.. --tests --msvc --msvc-version 10
goto done
:clean_check
echo.
set cleananswer=N
set /p cleananswer="This will remove all project files. Are you sure you want to continue? (N/y)"
if "%cleananswer%"=="n" goto done
if "%cleananswer%"=="N" goto done
if "%cleananswer%"=="y" goto clean
if "%cleananswer%"=="Y" goto clean
goto clean_check
:clean
echo.
echo Removing all project files
del /Q *.vcxproj* > NUL 2>&1
del /Q *.props > NUL 2>&1
del /Q *.sln* > NUL 2>&1
del /Q residualvm* > NUL 2>&1
del /Q devtools* > NUL 2>&1
del /Q test_runner.cpp > NUL 2>&1
goto done
:done
echo.
pause
-6
View File
@@ -1,6 +0,0 @@
The Visual Studio project files can now be created automatically from the GCC
files using the create_project tool inside the /devtools/create_project folder.
To create the default project files, build create_project.exe, copy it inside
this folder and run the create_msvc10.bat file for a default build. You can run
create_project.exe with no parameters to check the possible command-line options
-9
View File
@@ -1,9 +0,0 @@
The Visual Studio project files can now be created automatically from the GCC
files using the create_project tool inside the /devtools/create_project folder.
To create the default project files, build create_project.exe, copy it inside
this folder and run the create_msvc11.bat file for a default build. You can run
create_project.exe with no parameters to check the possible command-line options.
To enable debug visualization for common types, see the comment in
/devtools/create_project/scripts/residualvm.natvis.
-9
View File
@@ -1,9 +0,0 @@
The Visual Studio project files can now be created automatically from the GCC
files using the create_project tool inside the /devtools/create_project folder.
To create the default project files, build create_project.exe, copy it inside
this folder and run the create_msvc12.bat file for a default build. You can run
create_project.exe with no parameters to check the possible command-line options.
To enable debug visualization for common types, see the comment in
/devtools/create_project/scripts/residualvm.natvis.
-105
View File
@@ -1,105 +0,0 @@
@echo off
echo.
echo Automatic creation of the MSVC9 project files
echo.
if "%~1"=="/stable" goto stable
if "%~1"=="/STABLE" goto stable
if "%~1"=="/all" goto all
if "%~1"=="/ALL" goto all
if "%~1"=="/tools" goto tools
if "%~1"=="/TOOLS" goto tools
if "%~1"=="/tests" goto tests
if "%~1"=="/TESTS" goto tests
if "%~1"=="/clean" goto clean_check
if "%~1"=="/CLEAN" goto clean_check
if "%~1"=="/help" goto command_help
if "%~1"=="/HELP" goto command_help
if "%~1"=="/?" goto command_help
if "%~1"=="" goto check_tool
echo Invalid command parameter: %~1
echo.
:command_help
echo Valid command parameters are:
echo stable Generated stable engines project files
echo all Generate all engines project files
echo tools Generate project files for the devtools
echo clean Clean generated project files
echo help Show help message
goto done
:check_tool
if not exist create_project.exe goto no_tool
:question
echo.
set batchanswer=S
set /p batchanswer="Enable stable engines only, or all engines? (S/a)"
if "%batchanswer%"=="s" goto stable
if "%batchanswer%"=="S" goto stable
if "%batchanswer%"=="a" goto all
if "%batchanswer%"=="A" goto all
goto question
:no_tool
echo create_project.exe not found in the current folder.
echo You need to build it first and copy it in this
echo folder
goto done
:all
echo.
echo Creating project files with all engines enabled (stable and unstable)
echo.
create_project ..\.. --enable-all-engines --disable-fluidsynth --disable-sdlnet --disable-libcurl --disable-updates --msvc --msvc-version 9
goto done
:stable
echo.
echo Creating normal project files, with only the stable engines enabled
echo.
create_project ..\.. --disable-fluidsynth --disable-sdlnet --disable-libcurl --disable-updates --msvc --msvc-version 9
goto done
:tools
echo.
echo Creating tools project files
echo.
create_project ..\.. --tools --msvc --msvc-version 9
goto done
:tests
echo.
echo Creating tests project files
echo.
create_project ..\.. --tests --msvc --msvc-version 9
goto done
:clean_check
echo.
set cleananswer=N
set /p cleananswer="This will remove all project files. Are you sure you want to continue? (N/y)"
if "%cleananswer%"=="n" goto done
if "%cleananswer%"=="N" goto done
if "%cleananswer%"=="y" goto clean
if "%cleananswer%"=="Y" goto clean
goto clean_check
:clean
echo.
echo Removing all project files
del /Q *.vcproj* > NUL 2>&1
del /Q *.vsprops > NUL 2>&1
del /Q *.sln* > NUL 2>&1
del /Q residualvm* > NUL 2>&1
del /Q devtools* > NUL 2>&1
del /Q test_runner.cpp
goto done
:done
echo.
pause
-6
View File
@@ -1,6 +0,0 @@
The Visual Studio project files can now be created automatically from the GCC
files using the create_project tool inside the /devtools/create_project folder.
To create the default project files, build create_project.exe, copy it inside
this folder and run the create_msvc9.bat file for a default build. You can run
create_project.exe with no parameters to check the possible command-line options
File diff suppressed because it is too large Load Diff
Binary file not shown.
+26 -15
View File
@@ -47,6 +47,9 @@ void EditableWidget::init() {
_editScrollOffset = 0;
_align = g_gui.useRTL() ? Graphics::kTextAlignRight : Graphics::kTextAlignLeft;
_drawAlign = _align;
_font = ThemeEngine::kFontStyleBold;
_inversion = ThemeEngine::kTextInversionNone;
}
@@ -58,8 +61,12 @@ void EditableWidget::reflowLayout() {
Widget::reflowLayout();
_editScrollOffset = g_gui.getStringWidth(_editString, _font) - getEditRect().width();
if (_editScrollOffset < 0)
if (_editScrollOffset < 0) {
_editScrollOffset = 0;
_drawAlign = _align;
} else {
_drawAlign = Graphics::kTextAlignLeft;
}
}
void EditableWidget::setEditString(const String &str) {
@@ -265,18 +272,8 @@ void EditableWidget::defaultKeyDownHandler(Common::KeyState &state, bool &dirty,
}
int EditableWidget::getCaretOffset() const {
int caretpos = 0;
uint last = 0;
for (int i = 0; i < _caretPos; ++i) {
const uint cur = _editString[i];
caretpos += g_gui.getCharWidth(cur, _font) + g_gui.getKerningOffset(last, cur, _font);
last = cur;
}
caretpos -= _editScrollOffset;
return caretpos;
Common::String substr(_editString.c_str(), _caretPos);
return g_gui.getStringWidth(substr, _font) - _editScrollOffset;
}
void EditableWidget::drawCaret(bool erase) {
@@ -289,13 +286,27 @@ void EditableWidget::drawCaret(bool erase) {
int x = editRect.left;
int y = editRect.top;
if (_align == Graphics::kTextAlignRight) {
int strVisibleWidth = g_gui.getStringWidth(_editString, _font) - _editScrollOffset;
if (strVisibleWidth > editRect.width()) {
_drawAlign = Graphics::kTextAlignLeft;
strVisibleWidth = editRect.width();
} else {
_drawAlign = _align;
}
x = editRect.right - strVisibleWidth;
}
const int caretOffset = getCaretOffset();
x += caretOffset;
if (y < 0 || y + editRect.height() > _h)
return;
x += getAbsX();
if (g_gui.useRTL())
x += g_system->getOverlayWidth() - _w - getAbsX() + g_gui.getOverlayOffset();
else
x += getAbsX();
y += getAbsY();
g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + editRect.height()), erase);
@@ -328,7 +339,7 @@ void EditableWidget::drawCaret(bool erase) {
width = MIN(editRect.width() - caretOffset, width);
if (width > 0) {
g_gui.theme()->drawText(Common::Rect(x, y, x + width, y + editRect.height()), character,
_state, Graphics::kTextAlignLeft, _inversion, 0, false, _font,
_state, _drawAlign, _inversion, 0, false, _font,
ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
}
+3
View File
@@ -55,6 +55,9 @@ protected:
int _editScrollOffset;
Graphics::TextAlign _align;
Graphics::TextAlign _drawAlign;
ThemeEngine::FontStyle _font;
ThemeEngine::TextInversionState _inversion;
+12 -5
View File
@@ -72,21 +72,28 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
if (_caretVisible)
drawCaret(true);
x += _editScrollOffset;
if (g_gui.useRTL()) {
x = _w - x;
}
x += _editScrollOffset;
int width = 0;
if (_drawAlign == Graphics::kTextAlignRight)
width = _editScrollOffset + getEditRect().width() - g_gui.getStringWidth(_editString, _font);
uint i;
uint last = 0;
for (i = 0; i < _editString.size(); ++i) {
const uint cur = _editString[i];
width += g_gui.getCharWidth(cur, _font) + g_gui.getKerningOffset(last, cur, _font);
if (width >= x)
if (width >= x && width > _editScrollOffset + _leftPadding)
break;
last = cur;
}
if (setCaretPos(i))
markAsDirty();
setCaretPos(i);
markAsDirty();
}
void EditTextWidget::drawWidget() {
@@ -101,7 +108,7 @@ void EditTextWidget::drawWidget() {
g_gui.theme()->drawText(
Common::Rect(_x + 2 + _leftPadding, _y + 1, _x + _leftPadding + getEditRect().width() + 2, _y + _h),
_editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone,
_editString, _state, _drawAlign, ThemeEngine::kTextInversionNone,
-_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
+30 -7
View File
@@ -553,12 +553,13 @@ void ListWidget::drawWidget() {
Common::Rect r(getEditRect());
int pad = _leftPadding;
int rtlPad = (_x + r.left + _leftPadding) - (_x + _hlLeftPadding);
// If in numbering mode, we first print a number prefix
if (_numberingMode != kListNumberingOff) {
// If in numbering mode & not in RTL based GUI, we first print a number prefix
if (_numberingMode != kListNumberingOff && g_gui.useRTL() == false) {
buffer = Common::String::format("%2d. ", (pos + _numberingMode));
g_gui.theme()->drawText(Common::Rect(_x + _hlLeftPadding, y, _x + r.left + _leftPadding, y + fontHeight - 2),
buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
buffer, _state, _drawAlign, inverted, _leftPadding, true);
pad = 0;
}
@@ -571,16 +572,38 @@ void ListWidget::drawWidget() {
color = _listColors[_listIndex[pos]];
}
Common::Rect r1(_x + r.left, y, _x + r.right, y + fontHeight - 2);
if (g_gui.useRTL()) {
if (_scrollBar->isVisible()) {
r1.translate(_scrollBarWidth, 0);
}
if (_numberingMode != kListNumberingOff) {
r1.translate(-rtlPad, 0);
}
}
if (_selectedItem == pos && _editMode) {
buffer = _editString;
color = _editColor;
adjustOffset();
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2), buffer, _state,
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
} else {
buffer = _list[pos];
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2), buffer, _state,
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
}
g_gui.theme()->drawText(r1, buffer, _state,
_drawAlign, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
// If in numbering mode & using RTL layout in GUI, we print a number suffix after drawing the text
if (_numberingMode != kListNumberingOff && g_gui.useRTL()) {
buffer = Common::String::format(" .%2d", (pos + _numberingMode));
Common::Rect r2 = r1;
r2.left = r1.right;
r2.right = r1.right + rtlPad;
g_gui.theme()->drawText(r2, buffer, _state, _drawAlign, inverted, _leftPadding, true);
}
}
}
+33 -5
View File
@@ -129,6 +129,10 @@ void PopUpDialog::reflowLayout() {
void PopUpDialog::drawDialog(DrawLayer layerToDraw) {
Dialog::drawDialog(layerToDraw);
if (g_gui.useRTL()) {
_x = g_system->getOverlayWidth() - _x - _w + g_gui.getOverlayOffset();
}
// Draw the menu border
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), ThemeEngine::kWidgetBackgroundPlain);
@@ -200,7 +204,8 @@ void PopUpDialog::read(Common::String str) {
if (ConfMan.hasKey("tts_enabled", "residualvm") &&
ConfMan.getBool("tts_enabled", "residualvm")) {
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
ttsMan->say(str);
if (ttsMan != nullptr)
ttsMan->say(str);
}
#endif
}
@@ -387,14 +392,31 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
Common::String &name(_entries[entry]);
Common::Rect r1(x, y, x + w, y + _lineHeight);
Common::Rect r2(x + 1, y + 2, x + w, y + 2 + _lineHeight);
Graphics::TextAlign alignment = Graphics::kTextAlignLeft;
int pad = _leftPadding;
if (g_gui.useRTL()) {
if (_twoColumns) {
r1.translate(this->getWidth() - w, 0); // Shift the line-separator to the "first" col of RTL popup
}
r2.left = g_system->getOverlayWidth() - r2.left - w + g_gui.getOverlayOffset();
r2.right = r2.left + w;
alignment = Graphics::kTextAlignRight;
pad = _rightPadding;
}
if (name.size() == 0) {
// Draw a separator
g_gui.theme()->drawLineSeparator(Common::Rect(x, y, x + w, y + _lineHeight));
g_gui.theme()->drawLineSeparator(r1);
} else {
g_gui.theme()->drawText(
Common::Rect(x + 1, y + 2, x + w, y + 2 + _lineHeight),
r2,
name, hilite ? ThemeEngine::kStateHighlight : ThemeEngine::kStateEnabled,
Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, _leftPadding
alignment, ThemeEngine::kTextInversionNone, pad
);
}
}
@@ -510,7 +532,13 @@ void PopUpWidget::drawWidget() {
Common::String sel;
if (_selectedItem >= 0)
sel = _entries[_selectedItem].name;
g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, _leftPadding, _state);
int pad = _leftPadding;
if (g_gui.useRTL() && _useRTL)
pad = _rightPadding;
g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, pad, _state, (g_gui.useRTL() && _useRTL));
}
} // End of namespace GUI