Files
jak-project/game/tools/subtitles2/subtitle2_editor.h
T
ManDude 18ddd1613c Jak 2 pc subtitle support (#2672)
Adds support for adding custom subtitles to Jak 2 audio. Comes with a
new editor for the new system and format. Compared to the Jak 1 system,
this is much simpler to make an editor for.

Comes with a few subtitles already made as an example.
Cutscenes are not officially supported but you can technically subtitle
those with editor, so please don't right now.

This new system supports multiple subtitles playing at once (even from a
single source!) and will smartly push the subtitles up if there's a
message already playing:

![image](https://github.com/open-goal/jak-project/assets/7569514/033e6374-a05a-4c31-b029-51868153a932)

![image](https://github.com/open-goal/jak-project/assets/7569514/5298aa6d-a183-446e-bdb6-61c4682df917)

Unlike in Jak 1, it will not hide the bottom HUD when subtitles are
active:

![image](https://github.com/open-goal/jak-project/assets/7569514/d466bfc0-55d0-4689-a6e1-b7784b9fff59)

Sadly this leaves us with not much space for the subtitle region (and
the subtitles are shrunk when the minimap is enabled) but when you have
guards and citizens talking all the time, hiding the HUD every time
anyone spoke would get really frustrating.

The subtitle speaker is also color-coded now, because I thought that
would be fun to do.

TODO:
- [x] proper cutscene support.
- [x] merge mode for cutscenes so we don't have to rewrite the script?

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-06-08 01:04:16 +01:00

76 lines
2.2 KiB
C++

#pragma once
#include <optional>
#include <string_view>
#include "common/repl/nrepl/ReplClient.h"
#include "common/serialization/subtitles2/subtitles2_ser.h"
#include "third-party/imgui/imgui.h"
// TODO Later:
// - Hints, these seem less annoying but there are a lot of them
class Subtitle2Editor {
public:
Subtitle2Editor(GameVersion version);
void draw_window();
private:
void draw_edit_options();
void draw_repl_options();
void draw_speaker_options();
void draw_all_scenes(bool base_cutscenes = false);
void draw_subtitle_options(Subtitle2Scene& scene,
const std::string& name,
bool current_scene = false);
void draw_new_cutscene_line_form();
bool db_loaded = false;
GameSubtitle2DB m_subtitle_db;
Subtitle2Scene* m_current_scene = nullptr;
std::string m_current_scene_name = "";
std::string m_filter;
std::string m_filter_hints;
ReplClient m_repl;
float m_current_scene_frame[2] = {0, 0};
std::string m_current_scene_text = "";
std::string m_current_scene_speaker = "";
bool m_current_scene_offscreen = false;
bool m_current_scene_merge = false;
bool m_add_new_scene_as_current = false;
std::string m_new_scene_name = "";
std::string m_new_scene_id = "0";
std::string m_filter_placeholder = "Filter List...";
std::optional<bool> m_files_saved_successfully = {};
int m_base_language = 0;
int m_current_language = 0;
// bool m_base_show_lines = false;
bool m_base_show_missing_cutscenes = true;
// TODO - let the user customize these colors
ImVec4 m_normal_text_color = ImVec4(1.0f, 0.0f, 1.0f, 1.0f);
int m_selected_text_color = IM_COL32(89, 227, 225, 255);
ImVec4 m_success_text_color = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
ImVec4 m_error_text_color = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
ImVec4 m_disabled_text_color = ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
ImVec4 m_warning_color = ImVec4(0.619f, 0.443f, 0.0f, 1.0f);
int m_offscreen_text_color = IM_COL32(240, 242, 102, 255);
// TODO - cycle speaker colors
const std::vector<std::string> m_speaker_names;
void repl_rebuild_text();
void repl_play_vag(const std::string& name, bool is_scene);
bool is_scene_in_current_lang(const std::string& scene_name);
};