summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GUI/GUI/GUI/Config.cpp7
-rw-r--r--GUI/GUI/GUI/Config.h1
-rw-r--r--GUI/GUI/GUI/Frame.cpp29
-rw-r--r--GUI/GUI/GUI/Frame.h1
-rw-r--r--GUI/GUI/GUI/PythonWrapper.cpp24
-rw-r--r--Scripts/libunity.py11
-rw-r--r--Scripts/remove_audio_sources.py7
-rw-r--r--Scripts/set_texture_sz.py24
8 files changed, 93 insertions, 11 deletions
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<wxTextCtrl*>(FindWindowById(ID_UNITY_COLS));
unity_cols->Clear();
unity_cols->AppendText(std::to_string(app_c_->cols));
+
+ auto* unity_texture_sz = static_cast<wxTextCtrl*>(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<wxCheckBox*>(FindWindowById(ID_UNITY_CLEAR_OSC));
+ unity_clear_osc->SetValue(app_c_->clear_osc);
+
+ auto* unity_enable_phonemes = static_cast<wxCheckBox*>(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");
@@ -757,6 +760,23 @@ bool PythonWrapper::GenerateAnimator(
}
}
{
+ 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",
"--project_root", Quote(config.assets_path),
diff --git a/Scripts/libunity.py b/Scripts/libunity.py
index 39348d4..77eeb95 100644
--- a/Scripts/libunity.py
+++ b/Scripts/libunity.py
@@ -446,7 +446,7 @@ class UnityAnimator():
self.nodes.append(node)
anchor = node.anchor
if anchor == None:
- raise Exception("Node is missing anchor: {}".format(str(node)))
+ anchor = self.allocateId()
if anchor in self.id_to_node:
raise Exception("Duplicate anchor: {}, node 1: {}, node 2: {}".format(anchor, str(node), str(self.id_to_node[anchor])))
self.id_to_node[anchor] = node
@@ -1013,9 +1013,11 @@ def unityYamlToString(nodes):
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
"""[1:][:-1]
- lines.append(preamble)
+ if len(nodes) > 1 or (len(nodes) == 1 and nodes[0].anchor):
+ lines.append(preamble)
for doc in nodes:
- lines.append("--- !u!" + doc.class_id + " &" + doc.anchor)
+ if len(nodes) > 1 or (len(nodes) == 1 and nodes[0].anchor):
+ lines.append("--- !u!" + doc.class_id + " &" + doc.anchor)
lines.append(str(doc))
result = '\n'.join(lines)
@@ -1134,7 +1136,8 @@ class UnityParser:
if self.cur_node == None:
self.cur_node = UnityDocument()
self.cur_node.anchor = event.anchor
- self.cur_node.class_id = anchor_to_class_id[event.anchor]
+ if event.anchor:
+ self.cur_node.class_id = anchor_to_class_id[event.anchor]
else:
self.cur_node = self.cur_node.addChildMapping(self.cur_scalar)
self.pushState(self.MAPPING_START)
diff --git a/Scripts/remove_audio_sources.py b/Scripts/remove_audio_sources.py
index 0b4e566..0486169 100644
--- a/Scripts/remove_audio_sources.py
+++ b/Scripts/remove_audio_sources.py
@@ -1,3 +1,4 @@
+import argparse
import libunity
import sys
@@ -16,5 +17,9 @@ def removeAudioSources(path: str):
f.write(libunity.unityYamlToString(anim.nodes))
if __name__ == "__main__":
- removeAudioSources(sys.argv[1])
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--prefab", type=str, help="Path to .prefab file.")
+ args = parser.parse_args()
+
+ removeAudioSources(args.prefab)
diff --git a/Scripts/set_texture_sz.py b/Scripts/set_texture_sz.py
new file mode 100644
index 0000000..f6fbb45
--- /dev/null
+++ b/Scripts/set_texture_sz.py
@@ -0,0 +1,24 @@
+import argparse
+import libunity
+import sys
+
+def setTextureSize(path: str, size: int):
+ parser = libunity.MulticoreUnityParser()
+ anim = parser.parseFile(path)
+
+ node = anim.nodes[0]
+ node.mapping['TextureImporter'].mapping['maxTextureSize'] = size
+ for plat in node.mapping['TextureImporter'].mapping['platformSettings'].sequence:
+ plat.mapping['maxTextureSize'] = size
+
+ with open(path, "w", encoding="utf-8") as f:
+ f.write(libunity.unityYamlToString(anim.nodes))
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--meta", type=str, help="Path to texture .meta file.")
+ parser.add_argument("--size", type=int, help="Texture size.")
+ args = parser.parse_args()
+
+ setTextureSize(args.meta, args.size)
+