From 3db7723aa5c16358f73e3e8d3bb20a959ce43d5d Mon Sep 17 00:00:00 2001 From: yum Date: Sun, 10 Sep 2023 17:29:01 -0700 Subject: Users can now choose custom chatbox texture size in UI --- GUI/GUI/GUI/Config.cpp | 7 +++++-- GUI/GUI/GUI/Config.h | 1 + GUI/GUI/GUI/Frame.cpp | 29 +++++++++++++++++++++++++++-- GUI/GUI/GUI/Frame.h | 1 + GUI/GUI/GUI/PythonWrapper.cpp | 24 ++++++++++++++++++++++-- 5 files changed, 56 insertions(+), 6 deletions(-) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Config.cpp b/GUI/GUI/GUI/Config.cpp index 91fd1e9..53e292c 100644 --- a/GUI/GUI/GUI/Config.cpp +++ b/GUI/GUI/GUI/Config.cpp @@ -92,8 +92,9 @@ AppConfig::AppConfig(wxTextCtrl* out) chars_per_sync(8), bytes_per_char(1), - rows(4), - cols(48), + rows(3), + cols(36), + texture_sz(512), assets_path(), fx_path(), @@ -139,6 +140,7 @@ bool AppConfig::Serialize(const std::filesystem::path& path) { cm.Set("bytes_per_char", bytes_per_char); cm.Set("rows", rows); cm.Set("cols", cols); + cm.Set("texture_sz", texture_sz); cm.Set("assets_path", assets_path); cm.Set("fx_path", fx_path); @@ -197,6 +199,7 @@ bool AppConfig::Deserialize(const std::filesystem::path& path) { cm.Get("bytes_per_char", c.bytes_per_char); cm.Get("rows", c.rows); cm.Get("cols", c.cols); + cm.Get("texture_sz", c.texture_sz); cm.Get("assets_path", c.assets_path); cm.Get("fx_path", c.fx_path); diff --git a/GUI/GUI/GUI/Config.h b/GUI/GUI/GUI/Config.h index 762adc5..bcbc2dc 100644 --- a/GUI/GUI/GUI/Config.h +++ b/GUI/GUI/GUI/Config.h @@ -81,6 +81,7 @@ public: int bytes_per_char; int rows; int cols; + int texture_sz; // Unity-specific settings. std::string assets_path; diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index a61c821..273423e 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -100,6 +100,7 @@ namespace { ID_UNITY_BYTES_PER_CHAR, ID_UNITY_ROWS, ID_UNITY_COLS, + ID_UNITY_TEXTURE_SZ, ID_UNITY_CLEAR_OSC, ID_UNITY_ENABLE_PHONEMES, ID_DEBUG_PANEL, @@ -1228,6 +1229,13 @@ Frame::Frame() "The number of columns on the text box."); unity_cols_ = unity_cols; + auto* unity_texture_sz = new wxTextCtrl(unity_config_panel_pairs, + ID_UNITY_TEXTURE_SZ, std::to_string(app_c_->texture_sz), + wxDefaultPosition, wxDefaultSize, /*style=*/0); + unity_texture_sz->SetToolTip( + "The size of the textures holding text glyphs."); + unity_texture_sz_ = unity_texture_sz; + auto* sizer = new wxFlexGridSizer(/*cols=*/2); unity_config_panel_pairs->SetSizer(sizer); @@ -1282,6 +1290,11 @@ Frame::Frame() wxID_ANY, /*label=*/"Text box columns:")); sizer->Add(unity_cols, /*proportion=*/0, /*flags=*/wxEXPAND); + + sizer->Add(new wxStaticText(unity_config_panel_pairs, + wxID_ANY, /*label=*/"Texture size:")); + sizer->Add(unity_texture_sz, /*proportion=*/0, + /*flags=*/wxEXPAND); } auto* clear_osc = new wxCheckBox(unity_config_panel, @@ -1660,6 +1673,16 @@ void Frame::ApplyConfigToInputFields() auto* unity_cols = static_cast(FindWindowById(ID_UNITY_COLS)); unity_cols->Clear(); unity_cols->AppendText(std::to_string(app_c_->cols)); + + auto* unity_texture_sz = static_cast(FindWindowById(ID_UNITY_TEXTURE_SZ)); + unity_texture_sz->Clear(); + unity_texture_sz->AppendText(std::to_string(app_c_->texture_sz)); + + auto* unity_clear_osc = static_cast(FindWindowById(ID_UNITY_CLEAR_OSC)); + unity_clear_osc->SetValue(app_c_->clear_osc); + + auto* unity_enable_phonemes = static_cast(FindWindowById(ID_UNITY_ENABLE_PHONEMES)); + unity_enable_phonemes->SetValue(app_c_->enable_phonemes); } void Frame::OnExit(wxCloseEvent& event) @@ -1880,8 +1903,9 @@ void Frame::OnGenerateFX(wxCommandEvent& event) bytes_per_char_idx = kBytesDefault; } - ASSIGN_OR_RETURN_BOOL(int, rows, stoiInRange(transcribe_out_, py_app_rows_->GetValue().ToStdString(), "rows", 1, 10)); - ASSIGN_OR_RETURN_BOOL(int, cols, stoiInRange(transcribe_out_, py_app_cols_->GetValue().ToStdString(), "cols", 1, 120)); + ASSIGN_OR_RETURN_BOOL(int, rows, stoiInRange(transcribe_out_, unity_rows_->GetValue().ToStdString(), "rows", 1, 10)); + ASSIGN_OR_RETURN_BOOL(int, cols, stoiInRange(transcribe_out_, unity_cols_->GetValue().ToStdString(), "cols", 1, 120)); + ASSIGN_OR_RETURN_BOOL(int, texture_sz, stoiInRange(transcribe_out_, unity_texture_sz_->GetValue().ToStdString(), "texture_sz", 128, 8192)); ASSIGN_OR_RETURN_BOOL(int, chars_per_sync, stoiInRange(transcribe_out_, kCharsPerSync[chars_per_sync_idx].ToStdString(), "chars_per_sync", 5, 24)); ASSIGN_OR_RETURN_BOOL(int, bytes_per_char, stoiInRange(transcribe_out_, kBytesPerChar[bytes_per_char_idx].ToStdString(), "bytes_per_char", 1, 2)); @@ -1894,6 +1918,7 @@ void Frame::OnGenerateFX(wxCommandEvent& event) app_c_->chars_per_sync = chars_per_sync; app_c_->rows = rows; app_c_->cols = cols; + app_c_->texture_sz = texture_sz; app_c_->clear_osc = unity_clear_osc_->GetValue(); app_c_->enable_phonemes = unity_enable_phonemes_->GetValue(); app_c_->Serialize(AppConfig::kConfigPath); diff --git a/GUI/GUI/GUI/Frame.h b/GUI/GUI/GUI/Frame.h index 21f1220..31ec375 100644 --- a/GUI/GUI/GUI/Frame.h +++ b/GUI/GUI/GUI/Frame.h @@ -46,6 +46,7 @@ private: wxTextCtrl* py_app_commit_fuzz_threshold_; wxTextCtrl* unity_rows_; wxTextCtrl* unity_cols_; + wxTextCtrl* unity_texture_sz_; wxDirPickerCtrl* unity_assets_file_picker_; wxFilePickerCtrl* unity_animator_file_picker_; diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index 29b7d75..4e1de41 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -509,6 +509,7 @@ bool PythonWrapper::GenerateAnimator( wxTextCtrl* out) { // Python script locations std::string remove_audio_srcs_path = "Resources/Scripts/remove_audio_sources.py"; + std::string set_texture_sz_path = "Resources/Scripts/set_texture_sz.py"; std::string libunity_path = "Resources/Scripts/libunity.py"; std::string libtastt_path = "Resources/Scripts/libtastt.py"; std::string generate_emotes_path = "Resources/Scripts/emotes_v2.py"; @@ -648,8 +649,10 @@ bool PythonWrapper::GenerateAnimator( std::string prefab_path = Quote(std::filesystem::path(tastt_assets_path) / "World Constraint.prefab"); Log(out, "Remove audio sources from prefab at {}\n", prefab_path); Log(out, "Removing audio sources from prefab... "); - if (!InvokeWithArgs({ remove_audio_srcs_path, prefab_path }, - "Failed to generate guid.map", out)) { + if (!InvokeWithArgs({ remove_audio_srcs_path, + "--prefab", Quote(prefab_path) + }, + "Failed to remove audio sources", out)) { return false; } Log(out, "succes!\n"); @@ -756,6 +759,23 @@ bool PythonWrapper::GenerateAnimator( return false; } } + { + Log(out, "Setting texture sizes... "); + std::filesystem::path fonts_dir = tastt_fonts_path / "Bitmaps"; + for (const auto& entry : std::filesystem::recursive_directory_iterator(fonts_dir)) { + Log(out, "Entry get {}\n", entry.path().string()); + Log(out, "Setting size to {}\n", config.texture_sz); + if (entry.is_regular_file() && entry.path().extension() == ".meta") { + if (!InvokeWithArgs({ set_texture_sz_path, + "--meta", Quote(entry.path().string()), + "--size", std::to_string(config.texture_sz)}, + "Failed to set texture size", out)) { + return false; + } + } + } + Log(out, "succes!\n"); + } { Log(out, "Generating guid.map... "); if (!InvokeWithArgs({ libunity_path, "guid_map", -- cgit v1.2.3