diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 907471d1..fb09caa1 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -126,7 +126,7 @@ WorldMapTravelMarkers=0 ;TravelMarkerColor=134 ;The length and spacing of the dots in pixels for each type of terrain in worldmap.txt ;Syntax is 'length:spacing', with each pair separated by a comma (valid range: 1..10; default is 2) -;TravelMarkerDots=2:2,2:2,2:2,2:2 +;TravelMarkerStyles=2:2,2:2,2:2,2:2 ;Set to 1 to display terrain types when hovering the cursor over the player's marker on the world map WorldMapTerrainInfo=0 diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 8af61cfa..a6abce18 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -325,6 +325,8 @@ #define string_format(format, a1, a2) sfall_func3("string_format", format, a1, a2) #define tile_by_position(x, y) sfall_func2("tile_by_position", x, y) #define tile_refresh_display sfall_func0("tile_refresh_display") +#define tolower(text) sfall_func1("tolower", text) +#define toupper(text) sfall_func1("toupper", text) #define unjam_lock(obj) sfall_func1("unjam_lock", obj) #define unset_unique_id(obj) sfall_func2("set_unique_id", obj, -1) #define unwield_slot(critter, slot) sfall_func2("unwield_slot", critter, slot) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 76a417b4..6ae70aa6 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -697,6 +697,14 @@ optional argument: - returns the tile number at the x, y position relative to the top-left corner of the screen - if the position is outside of the range of tiles, it will return -1 +> string sfall_func1("tolower", string text) +- converts all uppercase letters in the given string to lowercase +- returns -1 on argument error + +> string sfall_func1("toupper", string text) +- converts all lowercase letters in the given string to uppercase +- returns -1 on argument error + ------------------------ ------ MORE INFO ------- ------------------------ diff --git a/sfall/Modules/Interface.cpp b/sfall/Modules/Interface.cpp index 8a3ea78b..7c746284 100644 --- a/sfall/Modules/Interface.cpp +++ b/sfall/Modules/Interface.cpp @@ -724,7 +724,7 @@ static void WorldMapInterfacePatch() { if (color > 255) color = 255; else if (color < 1) color = 1; colorDot = color; - auto dotList = GetConfigList("Interface", "TravelMarkerDots", "", 512); + auto dotList = GetConfigList("Interface", "TravelMarkerStyles", "", 512); size_t count = dotList.size(); if (count) { optionTerrainSpaceLen = new int[count]; diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index 7ed9ed44..f93744f8 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -136,6 +136,8 @@ static const SfallMetarule metarules[] = { {"string_format", sf_string_format, 2, 5, 0, {ARG_STRING, ARG_ANY, ARG_ANY, ARG_ANY, ARG_ANY}}, {"tile_by_position", sf_tile_by_position, 2, 2, -1, {ARG_INT, ARG_INT}}, {"tile_refresh_display", sf_tile_refresh_display, 0, 0}, + {"tolower", sf_tolower, 1, 1, -1, {ARG_STRING}}, + {"toupper", sf_toupper, 1, 1, -1, {ARG_STRING}}, {"unjam_lock", sf_unjam_lock, 1, 1, -1, {ARG_OBJECT}}, {"unwield_slot", sf_unwield_slot, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, #ifndef NDEBUG diff --git a/sfall/Modules/Scripting/Handlers/Utils.cpp b/sfall/Modules/Scripting/Handlers/Utils.cpp index 87e534b1..4b7604d3 100644 --- a/sfall/Modules/Scripting/Handlers/Utils.cpp +++ b/sfall/Modules/Scripting/Handlers/Utils.cpp @@ -466,5 +466,30 @@ void sf_get_text_width(OpcodeContext& ctx) { ctx.setReturn(fo::GetTextWidth(ctx.arg(0).strValue())); } +static char* cstrdup(const char* str) { + size_t len = strlen(str); + const size_t bufMaxLen = ScriptExtender::TextBufferSize() - 1; + if (len > bufMaxLen) len = bufMaxLen; + + if (len) memcpy(ScriptExtender::gTextBuffer, str, len); + ScriptExtender::gTextBuffer[len] = '\0'; + + return ScriptExtender::gTextBuffer; +} + +void sf_tolower(OpcodeContext& ctx) { + auto str = std::string(ctx.arg(0).strValue()); + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + + ctx.setReturn(cstrdup(str.c_str())); +} + +void sf_toupper(OpcodeContext& ctx) { + auto str = std::string(ctx.arg(0).strValue()); + std::transform(str.begin(), str.end(), str.begin(), ::toupper); + + ctx.setReturn(cstrdup(str.c_str())); +} + } } diff --git a/sfall/Modules/Scripting/Handlers/Utils.h b/sfall/Modules/Scripting/Handlers/Utils.h index 100606b7..a5198a48 100644 --- a/sfall/Modules/Scripting/Handlers/Utils.h +++ b/sfall/Modules/Scripting/Handlers/Utils.h @@ -77,5 +77,9 @@ void sf_get_string_pointer(OpcodeContext&); void sf_get_text_width(OpcodeContext&); +void sf_tolower(OpcodeContext&); + +void sf_toupper(OpcodeContext&); + } }