Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLUDGE: Remove UTF8 code #2592

Merged
merged 1 commit into from Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions engines/sludge/builtin.cpp
Expand Up @@ -51,7 +51,6 @@
#include "sludge/sprites.h"
#include "sludge/statusba.h"
#include "sludge/sludge.h"
#include "sludge/utf8.h"
#include "sludge/zbuffer.h"

namespace Sludge {
Expand Down Expand Up @@ -471,9 +470,7 @@ builtIn(substring) {
wholeString = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);

UTF8Converter convert;
convert.setUTF8String(wholeString);
Common::U32String str32 = convert.getU32String();
Common::U32String str32 = wholeString.decode(Common::kUtf8);

if ((int)str32.size() < start + length) {
length = str32.size() - start;
Expand All @@ -485,10 +482,7 @@ builtIn(substring) {
length = 0;
}

int startoffset = convert.getOriginOffset(start);
int endoffset = convert.getOriginOffset(start + length);

Common::String newString(wholeString.begin() + startoffset, wholeString.begin() + endoffset);
Common::String newString = str32.substr(start, length).encode(Common::kUtf8);

fun->reg.makeTextVar(newString);
return BR_CONTINUE;
Expand Down
20 changes: 10 additions & 10 deletions engines/sludge/fonttext.cpp
Expand Up @@ -63,7 +63,7 @@ bool TextManager::isInFont(const Common::String &theText) {
if (theText.empty())
return 0;

Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);
Common::U32String str32 = theText.decode(Common::kUtf8);

// We don't want to compare strings. Only single characters allowed!
if (str32.size() > 1)
Expand All @@ -72,11 +72,11 @@ bool TextManager::isInFont(const Common::String &theText) {
uint32 c = str32[0];

// check if font order contains the utf8 char
return _fontOrder.getU32String().contains(c);
return _fontOrder.contains(c);
}

int TextManager::stringLength(const Common::String &theText) {
Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);
Common::U32String str32 = theText.decode(Common::kUtf8);
return str32.size();
}

Expand All @@ -86,7 +86,7 @@ int TextManager::stringWidth(const Common::String &theText) {
if (_fontTable.empty())
return 0;

Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);
Common::U32String str32 = theText.decode(Common::kUtf8);

for (uint i = 0; i < str32.size(); ++i) {
uint32 c = str32[i];
Expand All @@ -102,7 +102,7 @@ void TextManager::pasteString(const Common::String &theText, int xOff, int y, Sp

xOff += (int)((float)(_fontSpace >> 1) / g_sludge->_gfxMan->getCamZoom());

Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);
Common::U32String str32 = theText.decode(Common::kUtf8);

for (uint32 i = 0; i < str32.size(); ++i) {
uint32 c = str32[i];
Expand All @@ -116,7 +116,7 @@ void TextManager::pasteStringToBackdrop(const Common::String &theText, int xOff,
if (_fontTable.empty())
return;

Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);
Common::U32String str32 = theText.decode(Common::kUtf8);

xOff += _fontSpace >> 1;
for (uint32 i = 0; i < str32.size(); ++i) {
Expand All @@ -131,7 +131,7 @@ void TextManager::burnStringToBackdrop(const Common::String &theText, int xOff,
if (_fontTable.empty())
return;

Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);
Common::U32String str32 = theText.decode(Common::kUtf8);

xOff += _fontSpace >> 1;
for (uint i = 0; i < str32.size(); ++i) {
Expand All @@ -143,14 +143,14 @@ void TextManager::burnStringToBackdrop(const Common::String &theText, int xOff,
}

bool TextManager::loadFont(int filenum, const Common::String &charOrder, int h) {
_fontOrder.setUTF8String(charOrder);
_fontOrder = charOrder.decode(Common::kUtf8);

g_sludge->_gfxMan->forgetSpriteBank(_theFont);

_loadedFontNum = filenum;

// get max value among all utf8 chars
Common::U32String fontOrderString = _fontOrder.getU32String();
Common::U32String fontOrderString = _fontOrder;

// create an index table from utf8 char to the index
if (!_fontTable.empty()) {
Expand Down Expand Up @@ -178,7 +178,7 @@ void TextManager::saveFont(Common::WriteStream *stream) {
if (!_fontTable.empty()) {
stream->writeUint16BE(_loadedFontNum);
stream->writeUint16BE(_fontHeight);
writeString(_fontOrder.getUTF8String(), stream);
writeString(_fontOrder.encode(Common::kUtf8), stream);
}
stream->writeSint16LE(_fontSpace);
}
Expand Down
3 changes: 1 addition & 2 deletions engines/sludge/fonttext.h
Expand Up @@ -26,7 +26,6 @@
#include "common/ustr.h"

#include "sludge/sprites.h"
#include "sludge/utf8.h"

namespace Sludge {

Expand Down Expand Up @@ -62,7 +61,7 @@ class TextManager {
private:
SpriteBank _theFont;
int _fontHeight, _numFontColours, _loadedFontNum;
UTF8Converter _fontOrder;
Common::U32String _fontOrder;
int16 _fontSpace;
SpritePalette _pastePalette;

Expand Down
1 change: 0 additions & 1 deletion engines/sludge/loadsave.cpp
Expand Up @@ -45,7 +45,6 @@
#include "sludge/sprites.h"
#include "sludge/statusba.h"
#include "sludge/speech.h"
#include "sludge/utf8.h"
#include "sludge/variable.h"
#include "sludge/version.h"
#include "sludge/zbuffer.h"
Expand Down
1 change: 0 additions & 1 deletion engines/sludge/module.mk
Expand Up @@ -36,7 +36,6 @@ MODULE_OBJS := \
thumbnail.o \
timing.o \
transition.o \
utf8.o \
variable.o \
zbuffer.o \

Expand Down
103 changes: 0 additions & 103 deletions engines/sludge/utf8.cpp

This file was deleted.

87 changes: 0 additions & 87 deletions engines/sludge/utf8.h

This file was deleted.