Skip to content

Commit

Permalink
subtitles: ignore base files in the editor so you can see what's rema…
Browse files Browse the repository at this point in the history
…ining
  • Loading branch information
xTVaser committed Jul 5, 2023
1 parent 21d61c3 commit 055b395
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions common/serialization/subtitles/subtitles.cpp
Expand Up @@ -9,7 +9,8 @@

void open_subtitle_project(const std::string& project_kind,
const std::string& file_path,
std::vector<GameSubtitleDefinitionFile>& subtitle_files) {
std::vector<GameSubtitleDefinitionFile>& subtitle_files,
const bool ignore_base_files) {
goos::Reader reader;
auto& proj = reader.read_from_file({file_path}).as_pair()->cdr.as_pair()->car;
if (!proj.is_pair() || !proj.as_pair()->car.is_symbol() ||
Expand All @@ -36,9 +37,9 @@ void open_subtitle_project(const std::string& project_kind,
new_file.lines_path = args->car.as_string()->data;
} else if (kwarg == ":meta") {
new_file.meta_path = args->car.as_string()->data;
} else if (kwarg == ":lines-base") {
} else if (!ignore_base_files && kwarg == ":lines-base") {
new_file.lines_base_path = args->car.as_string()->data;
} else if (kwarg == ":meta-base") {
} else if (!ignore_base_files && kwarg == ":meta-base") {
new_file.meta_base_path = args->car.as_string()->data;
}
if (args->cdr.is_empty_list()) {
Expand Down
3 changes: 2 additions & 1 deletion common/serialization/subtitles/subtitles.h
Expand Up @@ -17,7 +17,8 @@ struct GameSubtitleDefinitionFile {

void open_subtitle_project(const std::string& project_kind,
const std::string& file_path,
std::vector<GameSubtitleDefinitionFile>& inputs);
std::vector<GameSubtitleDefinitionFile>& inputs,
const bool ignore_base_files);
std::string lookup_locale_code(const GameVersion game_version, const int language_id);
// Languages that have audio tracks are not translated via Crowdin, therefore they must have
// a copy of the scenes from their base english counterpart no matter what (so it can be
Expand Down
5 changes: 3 additions & 2 deletions common/serialization/subtitles/subtitles_v2.cpp
Expand Up @@ -344,7 +344,8 @@ bool GameSubtitleDB::write_subtitle_db_to_files(const GameVersion game_version)
}

GameSubtitleDB load_subtitle_project(const GameSubtitleDB::SubtitleFormat format_version,
const GameVersion game_version) {
const GameVersion game_version,
const bool ignore_base_files) {
// Load the subtitle files
GameSubtitleDB db;
db.m_subtitle_version = format_version;
Expand All @@ -353,7 +354,7 @@ GameSubtitleDB load_subtitle_project(const GameSubtitleDB::SubtitleFormat format
std::string subtitle_project = (file_util::get_jak_project_dir() / "game" / "assets" /
version_to_game_name(game_version) / "game_subtitle.gp")
.string();
open_subtitle_project("subtitle-v2", subtitle_project, files);
open_subtitle_project("subtitle-v2", subtitle_project, files, ignore_base_files);
for (auto& file : files) {
db.init_banks_from_file(file);
}
Expand Down
3 changes: 2 additions & 1 deletion common/serialization/subtitles/subtitles_v2.h
Expand Up @@ -165,4 +165,5 @@ class GameSubtitleDB {
};

GameSubtitleDB load_subtitle_project(const GameSubtitleDB::SubtitleFormat format_version,
GameVersion game_version);
GameVersion game_version,
const bool ignore_base_files = false);
7 changes: 4 additions & 3 deletions game/tools/subtitle_editor/subtitle_editor.cpp
Expand Up @@ -24,7 +24,8 @@ bool SubtitleEditor::is_v1_format() {
}

bool SubtitleEditor::is_scene_in_current_lang(const std::string& scene_name) {
return m_subtitle_db.m_banks.at(m_current_language)->m_scenes.count(scene_name) > 0;
return m_subtitle_db.m_banks.at(m_current_language)->m_scenes.find(scene_name) !=
m_subtitle_db.m_banks.at(m_current_language)->m_scenes.end();
}

void SubtitleEditor::draw_window() {
Expand All @@ -36,7 +37,7 @@ void SubtitleEditor::draw_window() {
subtitle_version = GameSubtitleDB::SubtitleFormat::V1;
m_jak1_editor_db.update();
}
m_subtitle_db = load_subtitle_project(subtitle_version, g_game_version);
m_subtitle_db = load_subtitle_project(subtitle_version, g_game_version, true);
if (m_subtitle_db.m_load_error) {
m_db_failed_to_load = true;
} else {
Expand All @@ -52,7 +53,7 @@ void SubtitleEditor::draw_window() {
subtitle_version = GameSubtitleDB::SubtitleFormat::V1;
m_jak1_editor_db.update();
}
m_subtitle_db = load_subtitle_project(subtitle_version, g_game_version);
m_subtitle_db = load_subtitle_project(subtitle_version, g_game_version, true);
if (m_subtitle_db.m_load_error) {
m_db_failed_to_load = true;
} else {
Expand Down

0 comments on commit 055b395

Please sign in to comment.