Test round 2 fixes (wrong behaviour against the decompile: stats, combat, odds, level generation, visuals, the Lua API and 45 real mods): Blue Womb's last boss room is the start room (0074a500), Font:GetCharacterWidth takes a string and FontRenderSettings' wrap and truncation take a width, the original's callback error names, mod paths under --mods, SetStateFlag with a negative flag, the run timer hidden by default, popup and transformation text keys, room loads premultiply through a lookup table (about 3x faster, traces identical), --screenshot-every for windowed runs
This commit is contained in:
1 parent
7d407d5c19
commit
ee965dad25
19 files changed
+112
-51
No files matched your search
+8
-2
@@ -19,12 +19,18 @@ std::string dataDirectory = "resources/";
|
||||
std::string languageDirectory;
|
||||
|
||||
// A game path lowercased with forward slashes, as the game normalizes every path before a lookup. A path already under
|
||||
// the resources, which mods build from their script's path as the original's absolute ones, stays there.
|
||||
// the resources or the mods folder, which mods build from their script's path as the original's absolute ones, stays
|
||||
// there.
|
||||
static std::string path_normalize(std::string_view path)
|
||||
{
|
||||
std::string_view mods = platform.modsDirectory;
|
||||
bool isModsPath = !mods.empty() && path.starts_with(mods);
|
||||
if (isModsPath) path.remove_prefix(mods.size());
|
||||
|
||||
std::string normalized(path);
|
||||
for (char& letter : normalized) letter = letter == '\\' ? '/' : (char)std::tolower((unsigned char)letter);
|
||||
if (normalized.starts_with(MODS_FROM_RESOURCES)) normalized.erase(0, PARENT_FOLDER.size());
|
||||
if (isModsPath) normalized.insert(0, MODS_FOLDER);
|
||||
else if (normalized.starts_with(MODS_FROM_RESOURCES)) normalized.erase(0, PARENT_FOLDER.size());
|
||||
else if (normalized.starts_with(dataDirectory)) normalized.erase(0, dataDirectory.size());
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "engine/kage_input.h"
|
||||
#include "engine/kage_sound.h"
|
||||
#include "engine/platform.h"
|
||||
#include "engine/screenshot.h"
|
||||
#include "engine/seeds.h"
|
||||
#include "entity/effect/effect.h"
|
||||
#include "entity/familiar/familiar.h"
|
||||
@@ -42,6 +43,7 @@ struct HarnessFlag
|
||||
constexpr HarnessFlag HARNESS_FLAGS[] = {
|
||||
{"--headless", false}, {"--record", true}, {"--replay", true}, {"--frames", true}, {"--trace", true},
|
||||
{"--trace-every", true}, {"--trace-detail", false}, {"--mods", true}, {"--mute", false},
|
||||
{"--screenshot-every", true},
|
||||
};
|
||||
|
||||
Harness harness;
|
||||
@@ -97,6 +99,7 @@ void Harness::arguments_load(int argc, char** argv)
|
||||
else if (argument == "--trace-every") traceEvery = std::max(std::atoi(value), 1);
|
||||
else if (argument == "--trace-detail") traceMode = TRACE_DETAIL;
|
||||
else if (argument == "--mods") modsDirectory = std::string(value) + '/';
|
||||
else if (argument == "--screenshot-every") screenshotEvery = std::max(std::atoi(value), 0);
|
||||
}
|
||||
|
||||
std::vector<std::string> mods;
|
||||
@@ -241,6 +244,18 @@ void Harness::frame_end()
|
||||
if (frameLimit ? frame >= frameLimit : isReplayOver) platform.isQuitRequested = true;
|
||||
}
|
||||
|
||||
// Saves the finished frame as screenshots/harness-<frame>.png under the user folder on every screenshotEvery-th frame,
|
||||
// counted as Isaac.GetFrameCount() counts them so a mod can tell which frames it gets.
|
||||
void Harness::screenshot_save()
|
||||
{
|
||||
uint64_t count = g_manager ? (uint64_t)g_manager->framecount : frame;
|
||||
if (!screenshotEvery || isHeadless || count % screenshotEvery != 0) return;
|
||||
|
||||
std::error_code error;
|
||||
std::filesystem::create_directories(platform.userDataDirectory + SCREENSHOTS_FOLDER, error);
|
||||
save_screenshot(std::string(SCREENSHOTS_FOLDER) + "/harness-" + std::to_string(count));
|
||||
}
|
||||
|
||||
// Closes the recording with the frame it ended on, and the trace.
|
||||
void Harness::shutdown()
|
||||
{
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
size_t replayNext = 0;
|
||||
SDL_MouseButtonFlags mouseButtons = 0;
|
||||
TraceMode traceMode = TRACE_HASH;
|
||||
int screenshotEvery = 0;
|
||||
int traceEvery = 30;
|
||||
int traceRoom = -1;
|
||||
int traceStage = -1;
|
||||
@@ -69,6 +70,7 @@ public:
|
||||
void text_add(uint32_t character);
|
||||
SDL_MouseButtonFlags mouse_get(float* x, float* y);
|
||||
void frame_end();
|
||||
void screenshot_save();
|
||||
void shutdown();
|
||||
|
||||
private:
|
||||
|
||||
@@ -27,6 +27,8 @@ constexpr int RGBA_HEADER_SIZE = 4;
|
||||
constexpr int QUAD_INDICES = 6;
|
||||
constexpr int QUAD_INDEX_ORDER[QUAD_INDICES] = {0, 2, 1, 1, 2, 3};
|
||||
constexpr double SRGB_GAMMA = 2.2;
|
||||
constexpr int PREMULTIPLY_ALPHA_SHIFT = 8;
|
||||
using PremultiplyTable = std::array<uint8_t, 1 << PREMULTIPLY_ALPHA_SHIFT * 2>;
|
||||
// The color draw calls take to mean "the quad's own colors".
|
||||
constexpr float COLOR_UNSET = -1;
|
||||
constexpr GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9;
|
||||
@@ -978,10 +980,11 @@ bool Manager::shader_create(std::string_view shaderName, std::span<const VertexA
|
||||
// Reads a whole file, false when it cannot be opened.
|
||||
static bool file_read(const std::string& path, std::string& text)
|
||||
{
|
||||
std::ifstream file(path, std::ios::binary);
|
||||
std::ifstream file(path, std::ios::binary | std::ios::ate);
|
||||
if (!file) return false;
|
||||
text.assign(std::istreambuf_iterator<char>(file), {});
|
||||
return true;
|
||||
text.resize((size_t)file.tellg());
|
||||
file.seekg(0);
|
||||
return (bool)file.read(text.data(), (std::streamsize)text.size());
|
||||
}
|
||||
|
||||
// 00a147e0 Builds a shader from its two GLSL files, given as the paths in files, and caches it.
|
||||
@@ -1054,22 +1057,42 @@ static int format_bytes(ImageFormat format)
|
||||
return format == IMAGE_RGB ? 3 : format == IMAGE_RGBA ? COLOR_CHANNELS : 1;
|
||||
}
|
||||
|
||||
// 00a663c0 Premultiplies RGBA texels by their alpha through the game's rounding, in gamma 2.2 for sRGB.
|
||||
static void texels_premultiply(std::vector<uint8_t>& texels)
|
||||
// The exe's premultiply tables (00c23640 straight, 00c13640 in gamma 2.2 for sRGB), indexed by alpha << 8 | color.
|
||||
// Built on first use from the formulas every entry of both matches.
|
||||
static const PremultiplyTable& premultiply_table_get()
|
||||
{
|
||||
auto build = [](auto premultiply)
|
||||
{
|
||||
PremultiplyTable table{};
|
||||
for (int alpha = 0; alpha <= UINT8_MAX; alpha++)
|
||||
for (int color = 0; color <= UINT8_MAX; color++)
|
||||
table[alpha << PREMULTIPLY_ALPHA_SHIFT | color] = (uint8_t)premultiply(color, alpha);
|
||||
return table;
|
||||
};
|
||||
|
||||
if (manager.isSrgb)
|
||||
{
|
||||
static PremultiplyTable srgb = build([](int color, int alpha) {
|
||||
double linear = std::pow(color / (double)UINT8_MAX, SRGB_GAMMA) * alpha / UINT8_MAX;
|
||||
return (int)std::floor(UINT8_MAX * std::pow(linear, 1 / SRGB_GAMMA) + 0.5);
|
||||
});
|
||||
return srgb;
|
||||
}
|
||||
static PremultiplyTable straight =
|
||||
build([](int color, int alpha) { return (color * alpha + UINT8_MAX / 2) / UINT8_MAX; });
|
||||
return straight;
|
||||
}
|
||||
|
||||
// 00a663c0 Premultiplies RGBA texels by their alpha through the game's table. A clear texel turns black.
|
||||
static void texels_premultiply(std::span<uint8_t> texels)
|
||||
{
|
||||
const PremultiplyTable& table = premultiply_table_get();
|
||||
for (size_t i = 0; i + COLOR_CHANNELS <= texels.size(); i += COLOR_CHANNELS)
|
||||
{
|
||||
int alpha = texels[i + 3];
|
||||
if (alpha == UINT8_MAX) continue;
|
||||
for (int channel = 0; channel < 3; channel++)
|
||||
{
|
||||
int color = alpha ? texels[i + channel] : 0;
|
||||
double linear = std::pow(color / (double)UINT8_MAX, SRGB_GAMMA) * alpha / UINT8_MAX;
|
||||
double gamma = std::floor(UINT8_MAX * std::pow(linear, 1 / SRGB_GAMMA) + 0.5);
|
||||
int premultiplied = (color * alpha + UINT8_MAX / 2) / UINT8_MAX;
|
||||
texels[i + channel] = (uint8_t)(manager.isSrgb ? (int)gamma : premultiplied);
|
||||
}
|
||||
if (!alpha) texels[i + 3] = 0;
|
||||
texels[i + channel] = alpha ? table[alpha << PREMULTIPLY_ALPHA_SHIFT | texels[i + channel]] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1083,12 +1106,16 @@ static bool image_fill(ImageBase& image, const uint8_t* pixels, int pixelWidth,
|
||||
}
|
||||
|
||||
int bytes = format_bytes(format);
|
||||
size_t rowSize = (size_t)pixelWidth * bytes;
|
||||
bool isPremultiplied = manager.isPremultipliedAlpha && format == IMAGE_RGBA;
|
||||
std::vector<uint8_t> texels((size_t)image.textureWidth * image.textureHeight * bytes);
|
||||
for (int row = 0; row < pixelHeight; row++)
|
||||
std::copy_n(pixels + (size_t)row * pixelWidth * bytes, (size_t)pixelWidth * bytes,
|
||||
texels.begin() + (size_t)row * image.textureWidth * bytes);
|
||||
{
|
||||
uint8_t* destination = texels.data() + (size_t)row * image.textureWidth * bytes;
|
||||
std::copy_n(pixels + row * rowSize, rowSize, destination);
|
||||
if (isPremultiplied) texels_premultiply({destination, rowSize});
|
||||
}
|
||||
image.format = format;
|
||||
if (manager.isPremultipliedAlpha && format == IMAGE_RGBA) texels_premultiply(texels);
|
||||
return image.texels_load(texels);
|
||||
}
|
||||
|
||||
|
||||
@@ -292,9 +292,10 @@ bool Platform::window_open()
|
||||
return true;
|
||||
}
|
||||
|
||||
// Shows the finished frame, as glfwSwapBuffers.
|
||||
// Shows the finished frame, as glfwSwapBuffers, after the harness's screenshot of it.
|
||||
void Platform::window_swap()
|
||||
{
|
||||
harness.screenshot_save();
|
||||
SDL_GL_SwapWindow(window);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
constexpr const char* SCREENSHOTS_FOLDER = "screenshots";
|
||||
|
||||
void save_screenshot(std::string_view name);
|
||||
+1
-1
@@ -95,7 +95,7 @@ void coop_awards_load(std::array<CoopAward, COOP_AWARD_COUNT>& awards)
|
||||
const CoopAwardRule& rule = COOP_AWARD_RULES[i];
|
||||
CoopAward& award = awards[i];
|
||||
|
||||
award.name = g_manager->stringTable.translate(COOP_AWARD_KEYS[i]);
|
||||
award.name = string_table_translate(g_manager->stringTable, COOP_AWARD_KEYS[i]);
|
||||
award.statId = rule.statId;
|
||||
award.isTieShared = rule.isTieShared;
|
||||
award.isMostWins = rule.isMostWins;
|
||||
|
||||
@@ -192,7 +192,6 @@ constexpr int UPDATE_FRAME_PERIOD = 2;
|
||||
constexpr int CURSOR_VISIBLE_FRAMES = 300;
|
||||
constexpr const char* CURSOR_CLICKED_ANIMATION = "Clicked";
|
||||
constexpr int SCREENSHOT_KEY = 298;
|
||||
constexpr const char* SCREENSHOTS_FOLDER = "screenshots";
|
||||
constexpr const char* MANUAL_SCREENSHOT = "screenshots/ManualScreenshot";
|
||||
// The stage bar's icon for a stage not reached.
|
||||
constexpr int STAGE_ICON_EMPTY = 17;
|
||||
|
||||
+4
-4
@@ -3211,9 +3211,9 @@ constexpr std::array<BlueWombRoom, 5> BLUE_WOMB_ROOMS = {{
|
||||
{{6, 4}, ROOMSHAPE_2x2, {6, 5}, DIRECTION_UP, ROOM_BOSS},
|
||||
}};
|
||||
|
||||
// 0074a500 Lays out the Blue Womb by hand from its own rooms, Tainted Keeper's shop when he plays. Then the rooms off
|
||||
// the map, all drawn from the generation RNG: the error room, black market, crawl space, Mega Satan's, the Void's
|
||||
// entrance, the Member Card's shop and the angel shop.
|
||||
// 0074a500 Lays out the Blue Womb by hand from its own rooms, Tainted Keeper's shop when he plays, the start room
|
||||
// counted the last boss room as in Greed. Then the rooms off the map, all drawn from the generation RNG: the error
|
||||
// room, black market, crawl space, Mega Satan's, the Void's entrance, the Member Card's shop and the angel shop.
|
||||
void Level::generate_blue_womb()
|
||||
{
|
||||
RoomConfig& roomConfig = g_game->roomConfig;
|
||||
@@ -3246,7 +3246,7 @@ void Level::generate_blue_womb()
|
||||
nbRooms = 0;
|
||||
for (size_t i = 0; i < BLUE_WOMB_ROOMS.size(); i++)
|
||||
place_room(generator.rooms[i], configs[i], generationRNG.Next(), nullptr);
|
||||
lastBossRoomListIdx = generator.rooms.back().generationIndex;
|
||||
lastBossRoomListIdx = generator.rooms[0].generationIndex;
|
||||
|
||||
RoomQuery voidQuery = room_query(STAGE_ID_BLUE_WOMB, ROOM_DEFAULT, 1);
|
||||
|
||||
|
||||
@@ -832,8 +832,9 @@ Vector Minimap::GetDisplayedSize()
|
||||
return vector_make(map.boundsMax.x - map.boundsMin.x, map.boundsMax.y - map.boundsMin.y);
|
||||
}
|
||||
|
||||
// 0098e4d0 Draws the maps as far as they show through the room transition's HUD fade, then the time and score,
|
||||
// outside the no HUD seed. Home's dungeon shows only the time and score, and only in a daily run.
|
||||
// 0098e4d0 Draws the maps as far as they show through the room transition's HUD fade, then the time and score as far
|
||||
// as the large map shows (at least half shown under the extra HUD), outside the no HUD seed. Home's dungeon shows
|
||||
// only the time and score, and only in a daily run.
|
||||
void Minimap::Render()
|
||||
{
|
||||
Game& game = *g_game;
|
||||
@@ -854,7 +855,7 @@ void Minimap::Render()
|
||||
if (largeAlpha > 0) render_large(largeAlpha, isLost);
|
||||
|
||||
bool isHistoryShown = g_manager->optionsConfig.historyHudMode == HISTORY_HUD_ON;
|
||||
float scoreAlpha = isHistoryShown ? std::max(SCORE_HISTORY_ALPHA, hudAlpha) : hudAlpha;
|
||||
float scoreAlpha = isHistoryShown ? std::max(SCORE_HISTORY_ALPHA, largeAlpha) : largeAlpha;
|
||||
if (scoreAlpha > 0) render_score_time(scoreAlpha);
|
||||
}
|
||||
|
||||
|
||||
@@ -251,8 +251,10 @@ static void game_register(lua_State* state)
|
||||
lua_method(state, "IsPaused", [](Game& game) { return game.IsPaused(); });
|
||||
lua_method(state, "IsGreedMode", [](Game& game) { return game.IsGreedMode(); });
|
||||
lua_method(state, "GetStateFlag", [](Game& game, GameStateFlag flag) { return game.GetStateFlag(flag); });
|
||||
// 004d72b0 A negative flag is flag 0.
|
||||
lua_method(state, "SetStateFlag", [](Game& game, int flag, bool isSet) {
|
||||
game.gameStateFlags = isSet ? game.gameStateFlags | 1ull << flag : game.gameStateFlags & ~(1ull << flag);
|
||||
uint64_t mask = 1ull << std::max(flag, 0);
|
||||
game.gameStateFlags = isSet ? game.gameStateFlags | mask : game.gameStateFlags & ~mask;
|
||||
});
|
||||
lua_method(state, "ShakeScreen", [](Game&, int timeout) { game_shake_screen(timeout); });
|
||||
lua_method(state, "Spawn", [](Game& game, int type, int variant, Vector position, Vector velocity, Entity* spawner,
|
||||
|
||||
+13
-6
@@ -104,12 +104,17 @@ static void font_register(lua_State* state)
|
||||
lua_method(state, "SetMaxCharacters",
|
||||
[](FontSettings& settings, int16_t count) { settings.maxCharacters = count; });
|
||||
lua_method(state, "GetMaxCharacters", [](FontSettings& settings) { return settings.maxCharacters; });
|
||||
lua_method(state, "EnableAutoWrap", [](FontSettings& settings, bool isOn) {
|
||||
settings.wrapMode = isOn ? FONT_WRAP_WORDS : FONT_WRAP_NONE;
|
||||
// 0085e450 Wraps lines at a width, resetting the line height modifier.
|
||||
lua_method(state, "EnableAutoWrap", [](FontSettings& settings, uint16_t width) {
|
||||
settings.wrapMode = FONT_WRAP_WORDS;
|
||||
settings.maxLineWidth = width;
|
||||
settings.lineHeightModifier = 1;
|
||||
});
|
||||
lua_method(state, "IsAutoWrapEnabled", [](FontSettings& settings) { return settings.wrapMode == FONT_WRAP_WORDS; });
|
||||
lua_method(state, "EnableTruncation", [](FontSettings& settings, bool isOn) {
|
||||
settings.wrapMode = isOn ? FONT_WRAP_TRUNCATE : FONT_WRAP_NONE;
|
||||
// 00a1a600 Truncates lines at a width.
|
||||
lua_method(state, "EnableTruncation", [](FontSettings& settings, uint16_t width) {
|
||||
settings.wrapMode = FONT_WRAP_TRUNCATE;
|
||||
settings.maxLineWidth = width;
|
||||
});
|
||||
lua_method(state, "IsTruncationEnabled",
|
||||
[](FontSettings& settings) { return settings.wrapMode == FONT_WRAP_TRUNCATE; });
|
||||
@@ -128,8 +133,10 @@ static void font_register(lua_State* state)
|
||||
lua_method(state, "Load", [](Font& font, std::string_view path) { return font.Load(path); });
|
||||
lua_method(state, "Unload", [](Font& font) { font.Unload(); });
|
||||
lua_method(state, "IsLoaded", [](Font& font) { return font.isLoaded; });
|
||||
lua_method(state, "GetCharacterWidth",
|
||||
[](Font& font, uint32_t character) { return font.GetCharacterWidth(character); });
|
||||
// 008a8e40 GetCharacterWidth takes a string and measures its first byte.
|
||||
lua_method(state, "GetCharacterWidth", [](Font& font, std::string_view text) {
|
||||
return font.GetCharacterWidth(text.empty() ? 0 : (uint8_t)text[0]);
|
||||
});
|
||||
lua_method(state, "GetStringWidth", [](Font& font, std::string_view text) { return font.GetStringWidth(text); });
|
||||
lua_method(state, "GetLineHeight", [](Font& font) { return font.GetLineHeight(); });
|
||||
lua_method(state, "GetBaselineHeight", [](Font& font) { return font.GetBaselineHeight(); });
|
||||
|
||||
@@ -273,7 +273,7 @@ int LuaEngine::PreGetCollectible(const LuaCollectibleDraw& draw)
|
||||
bool LuaEngine::EntityTakeDamage(Entity* entity, float damage, uint64_t damageFlags, const EntityRef& source,
|
||||
int countdown)
|
||||
{
|
||||
CallbackRun run = {"EntityTakeDamage", MC_ENTITY_TAKE_DMG, entity->type};
|
||||
CallbackRun run = {"PreEntityTakeDamage", MC_ENTITY_TAKE_DMG, entity->type};
|
||||
return callback_boolean_run(*this, run, true, entity, damage, damageFlags, &source, countdown);
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ bool LuaEngine::PreEntityDevolve(Entity* entity)
|
||||
// The original throws past its callers on a Lua error. This logs it and spawns the award.
|
||||
bool LuaEngine::PreSpawnCleanAward(const RNG& rng, const Vector& position)
|
||||
{
|
||||
return callback_boolean_run(*this, {"PreSpawnCleanAward", MC_PRE_SPAWN_CLEAN_AWARD}, false, rng, position);
|
||||
return callback_boolean_run(*this, {"PreRoomRewardSpawn", MC_PRE_SPAWN_CLEAN_AWARD}, false, rng, position);
|
||||
}
|
||||
|
||||
// 00863760 Runs MC_PRE_USE_ITEM for an active item, filtered by its type. Whether a mod skips the use.
|
||||
@@ -370,13 +370,13 @@ void LuaEngine::EvaluateItems(Entity_Player* player, int cacheFlag)
|
||||
// 008635a0 Runs MC_FAMILIAR_INIT, filtered by the familiar's variant.
|
||||
void LuaEngine::FamiliarInit(Entity_Familiar* familiar)
|
||||
{
|
||||
callback_notify(*this, {"FamiliarInit", MC_FAMILIAR_INIT, familiar->variant}, familiar);
|
||||
callback_notify(*this, {"PostFamiliarInit", MC_FAMILIAR_INIT, familiar->variant}, familiar);
|
||||
}
|
||||
|
||||
// 00860f00 Runs MC_FAMILIAR_UPDATE, filtered by the familiar's variant.
|
||||
void LuaEngine::FamiliarUpdate(Entity_Familiar* familiar)
|
||||
{
|
||||
callback_notify(*this, {"FamiliarUpdate", MC_FAMILIAR_UPDATE, familiar->variant}, familiar);
|
||||
callback_notify(*this, {"PostFamiliarUpdate", MC_FAMILIAR_UPDATE, familiar->variant}, familiar);
|
||||
}
|
||||
|
||||
// 00860fe0 Runs MC_POST_FAMILIAR_RENDER with the render offset, filtered by the familiar's variant.
|
||||
@@ -561,7 +561,7 @@ void LuaEngine::PostPlayerInit(Entity_Player* player)
|
||||
// 00863be0 Runs MC_POST_PEFFECT_UPDATE, filtered by the player's character.
|
||||
void LuaEngine::PostPEffectUpdate(Entity_Player* player)
|
||||
{
|
||||
callback_notify(*this, {"PostPEffectUpdate", MC_POST_PEFFECT_UPDATE, player->playerType}, player);
|
||||
callback_notify(*this, {"PostPlayerEffectUpdate", MC_POST_PEFFECT_UPDATE, player->playerType}, player);
|
||||
}
|
||||
|
||||
// 00864130 Runs MC_POST_PLAYER_UPDATE, filtered by the player's variant.
|
||||
|
||||
@@ -372,7 +372,7 @@ int form_progress_get(const ItemConfig_PlayerForm& form, const Entity_Player* pl
|
||||
// A transformation's line in a panel: its name and a count of the items it takes.
|
||||
std::string form_line_get(const ItemConfig_PlayerForm& form, int progress)
|
||||
{
|
||||
std::string name(g_manager->stringTable.translate(form.name));
|
||||
std::string name(string_table_translate(g_manager->stringTable, form.name));
|
||||
return name + FORM_SEPARATOR + std::to_string(progress) + "/" + std::to_string(FORM_GOAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ void MenuManager::online_awards_render()
|
||||
if (award > 0 && award % AWARD_ROWS == 0) label = vector_make(label.x + COLUMN_WIDTH, start.y);
|
||||
|
||||
FontSettings labelSettings;
|
||||
font.DrawString(isWon ? g_manager->stringTable.translate(COOP_AWARD_KEYS[award]) : UNKNOWN_TEXT, label, scale,
|
||||
color, labelSettings);
|
||||
std::string_view name = string_table_translate(g_manager->stringTable, COOP_AWARD_KEYS[award]);
|
||||
font.DrawString(isWon ? name : UNKNOWN_TEXT, label, scale, color, labelSettings);
|
||||
FontSettings countSettings(ALIGN_TOP_RIGHT);
|
||||
font.DrawString(std::to_string(count), vector_make(label.x + COUNT_OFFSET_X, label.y), scale, color,
|
||||
countSettings);
|
||||
@@ -116,7 +116,7 @@ void MenuManager::online_awards_render()
|
||||
FontSettings descriptionSettings(ALIGN_TOP_CENTER);
|
||||
descriptionSettings.EnableAutoWrap(DESCRIPTION_WIDTH);
|
||||
std::string key = std::string(COOP_AWARD_KEYS[award]) + DESCRIPTION_SUFFIX;
|
||||
font.DrawString(isWon ? g_manager->stringTable.translate(key) : UNKNOWN_TEXT,
|
||||
font.DrawString(isWon ? string_table_translate(g_manager->stringTable, key) : UNKNOWN_TEXT,
|
||||
vector_add(draw.position, description->pos), scale, TEXT_COLOR, descriptionSettings);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -411,13 +411,13 @@ void Popup::select_move(int step)
|
||||
} while (desc.lines[selectedLine].id == POPUP_LINE_TEXT);
|
||||
}
|
||||
|
||||
// A line's text, looked up in the string tables when it starts with ##GAME## or ##PLATFORM##.
|
||||
// A line's text, the #key after ##GAME## or ##PLATFORM## translated by the matching string table.
|
||||
static std::string_view line_text_translate(std::string_view text)
|
||||
{
|
||||
if (text.starts_with(GAME_STRING_PREFIX))
|
||||
return g_manager->stringTable.translate(text.substr(GAME_STRING_PREFIX.size()));
|
||||
return string_table_translate(g_manager->stringTable, text.substr(GAME_STRING_PREFIX.size()));
|
||||
if (text.starts_with(PLATFORM_STRING_PREFIX))
|
||||
return g_manager->stringTablePc.translate(text.substr(PLATFORM_STRING_PREFIX.size()));
|
||||
return string_table_translate(g_manager->stringTablePc, text.substr(PLATFORM_STRING_PREFIX.size()));
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user