paint: add sounds tab
This commit is contained in:
@@ -95,6 +95,26 @@ string_array_t *export_arm_fonts_to_files(char *project_path, slot_font_t_array_
|
||||
return font_files;
|
||||
}
|
||||
|
||||
string_array_t *export_arm_sounds_to_files(char *project_path, slot_sound_t_array_t *sounds) {
|
||||
string_array_t *sound_files = any_array_create_from_raw((void *[]){}, 0);
|
||||
for (i32 i = 0; i < sounds->length; ++i) {
|
||||
slot_sound_t *f = sounds->buffer[i];
|
||||
#ifdef IRON_IOS
|
||||
bool same_drive = false;
|
||||
#else
|
||||
bool same_drive = char_at(project_path, 0) == char_at(f->file, 0);
|
||||
#endif
|
||||
// Convert sound path from absolute to relative
|
||||
if (same_drive) {
|
||||
any_array_push(sound_files, path_to_relative(project_path, f->file));
|
||||
}
|
||||
else {
|
||||
any_array_push(sound_files, f->file);
|
||||
}
|
||||
}
|
||||
return sound_files;
|
||||
}
|
||||
|
||||
void export_arm_run_project() {
|
||||
|
||||
tab_timeline_prepare_save();
|
||||
@@ -172,8 +192,9 @@ void export_arm_run_project() {
|
||||
|
||||
string_array_t *texture_files = export_arm_assets_to_files(g_project->_->filepath, g_project->_->assets);
|
||||
|
||||
string_array_t *font_files = export_arm_fonts_to_files(g_project->_->filepath, g_project->_->fonts);
|
||||
string_array_t *mesh_files = export_arm_meshes_to_files(g_project->_->filepath);
|
||||
string_array_t *font_files = export_arm_fonts_to_files(g_project->_->filepath, g_project->_->fonts);
|
||||
string_array_t *sound_files = export_arm_sounds_to_files(g_project->_->filepath, g_project->_->sounds);
|
||||
string_array_t *mesh_files = export_arm_meshes_to_files(g_project->_->filepath);
|
||||
|
||||
i32 bits_pos = base_bits_handle->i;
|
||||
i32 bpp = bits_pos == TEXTURE_BITS_BITS8 ? 8 : bits_pos == TEXTURE_BITS_BITS16 ? 16 : 32;
|
||||
@@ -288,6 +309,7 @@ void export_arm_run_project() {
|
||||
g_project->brush_nodes = bnodes;
|
||||
g_project->layer_datas = ld;
|
||||
g_project->font_assets = font_files;
|
||||
g_project->sound_assets = sound_files;
|
||||
g_project->mesh_assets = mesh_files;
|
||||
|
||||
tab_timeline_export(g_project);
|
||||
|
||||
@@ -359,6 +359,22 @@ void import_arm_run_project(char *path) {
|
||||
}
|
||||
}
|
||||
|
||||
if (g_project->sound_assets != NULL) {
|
||||
for (i32 i = 0; i < g_project->sound_assets->length; ++i) {
|
||||
char *file = g_project->sound_assets->buffer[i];
|
||||
#ifdef IRON_WINDOWS
|
||||
file = string_copy(string_replace_all(file, "/", "\\"));
|
||||
#else
|
||||
file = string_copy(string_replace_all(file, "\\", "/"));
|
||||
#endif
|
||||
// Convert sound path from relative to absolute
|
||||
char *abs = data_is_abs(file) ? file : string("%s%s", base, file);
|
||||
if (iron_file_exists(abs)) {
|
||||
import_sound_run(abs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mesh_data_t *md = mesh_data_create(g_project->mesh_datas->buffer[0]);
|
||||
|
||||
mesh_object_set_data(g_context->paint_object, md);
|
||||
|
||||
@@ -63,8 +63,8 @@ void import_asset_run(char *path, f32 drop_x, f32 drop_y, bool show_box, bool hd
|
||||
g_context->ddirty = 2;
|
||||
}
|
||||
}
|
||||
else if (path_is_audio(path)) {
|
||||
import_audio_run(path);
|
||||
else if (path_is_sound(path)) {
|
||||
import_sound_run(path);
|
||||
}
|
||||
else if (path_is_lut(path)) {
|
||||
box_preferences_lut_picked(path);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
void import_audio_run(char *path) {
|
||||
|
||||
#ifdef IRON_AUDIO
|
||||
sound_t *s = data_get_sound(path);
|
||||
iron_a1_play_sound(s->sound_, false, 1, false);
|
||||
|
||||
string_array_t *ar = string_split(path, PATH_SEP);
|
||||
char *name = ar->buffer[ar->length - 1];
|
||||
console_info(string("%s %s", tr("Audio imported:"), name));
|
||||
#endif
|
||||
}
|
||||
@@ -172,7 +172,8 @@ project_t *import_arm_from_map_to_arm(any_map_t *old) {
|
||||
}
|
||||
}
|
||||
|
||||
project->font_assets = any_map_get(old, "font_assets");
|
||||
project->font_assets = any_map_get(old, "font_assets");
|
||||
project->sound_assets = any_map_get(old, "sound_assets");
|
||||
|
||||
any_array_t *lds = any_map_get(old, "layer_datas");
|
||||
if (lds != NULL) {
|
||||
@@ -299,6 +300,11 @@ project_t *import_arm_from_map_to_arm(any_map_t *old) {
|
||||
return project;
|
||||
}
|
||||
|
||||
project_t *import_arm_from_version_10(any_map_t *old) {
|
||||
any_map_set(old, "sound_assets", NULL);
|
||||
return import_arm_from_map_to_arm(old);
|
||||
}
|
||||
|
||||
project_t *import_arm_from_version_9(any_map_t *old) {
|
||||
any_array_t *lds = any_map_get(old, "layer_datas");
|
||||
if (lds != NULL) {
|
||||
@@ -307,7 +313,7 @@ project_t *import_arm_from_version_9(any_map_t *old) {
|
||||
any_map_set(ld, "texpaint_sculpt", NULL);
|
||||
}
|
||||
}
|
||||
return import_arm_from_map_to_arm(old);
|
||||
return import_arm_from_version_10(old);
|
||||
}
|
||||
|
||||
project_t *import_arm_from_version_8(any_map_t *old) {
|
||||
@@ -412,8 +418,9 @@ project_t *import_arm_from_version_0(any_map_t *old) {
|
||||
project_t *import_arm_from_old(buffer_t *b) {
|
||||
any_map_t *old = armpack_decode_to_map(b);
|
||||
project_t *(*fns[])(any_map_t *) = {
|
||||
import_arm_from_version_0, import_arm_from_version_1, import_arm_from_version_2, import_arm_from_version_3, import_arm_from_version_4,
|
||||
import_arm_from_version_5, import_arm_from_version_6, import_arm_from_version_7, import_arm_from_version_8, import_arm_from_version_9,
|
||||
import_arm_from_version_0, import_arm_from_version_1, import_arm_from_version_2, import_arm_from_version_3,
|
||||
import_arm_from_version_4, import_arm_from_version_5, import_arm_from_version_6, import_arm_from_version_7,
|
||||
import_arm_from_version_8, import_arm_from_version_9, import_arm_from_version_10,
|
||||
};
|
||||
for (i32 v = sizeof(fns) / sizeof(fns[0]) - 1; v >= 0; --v) {
|
||||
if (import_arm_is_version(b, i32_to_string(v))) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
void import_sound_run(char *path) {
|
||||
for (i32 i = 0; i < g_project->_->sounds->length; ++i) {
|
||||
slot_font_t *f = g_project->_->sounds->buffer[i];
|
||||
if (string_equals(f->file, path)) {
|
||||
console_info(strings_asset_already_imported());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string_array_t *ar = string_split(path, PATH_SEP);
|
||||
char *name = ar->buffer[ar->length - 1];
|
||||
|
||||
sound_t *sound = data_get_sound(path);
|
||||
slot_font_t *s = slot_sound_create(name, sound, path);
|
||||
g_context->sound = s;
|
||||
any_array_push(g_project->_->sounds, s);
|
||||
|
||||
console_info(string("%s %s", tr("Sound imported:"), name));
|
||||
}
|
||||
Reference in New Issue
Block a user