Commit b53f355c authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

gui: fix unix warnings

parent b064d7b0
Pipeline #11498 passed with stage
in 1 minute and 9 seconds
......@@ -11,7 +11,9 @@
#include <filesystem>
#include <vector>
#ifdef _WIN32
#include <windows.h>
#endif
namespace irt {
......@@ -45,6 +47,9 @@ struct file_dialog
drives = ret;
}
#else
void fill_drives()
{}
#endif
const char** file_filters;
......@@ -57,7 +62,7 @@ struct file_dialog
const char** filters = file_filters;
while (*filters) {
if (p.string().starts_with(*filters))
if (p.string().find(*filters) == 0)
return true;
++filters;
......@@ -188,9 +193,7 @@ struct file_dialog
file_dialog fd;
bool
load_file_dialog(const char* description,
const char* filters[],
std::filesystem::path& out)
load_file_dialog(std::filesystem::path& out)
{
if (fd.current.empty()) {
fd.fill_drives();
......@@ -212,7 +215,7 @@ load_file_dialog(const char* description,
if (!path_click) {
ImVec2 size = ImGui::GetContentRegionMax();
size.y /= 1.5;
size.y /= 1.5f;
ImGui::BeginChild("##select_files", size);
......@@ -297,9 +300,7 @@ load_file_dialog(const char* description,
}
bool
save_file_dialog(const char* description,
const char* filters[],
std::filesystem::path& out)
save_file_dialog(std::filesystem::path& out)
{
if (fd.current.empty()) {
fd.fill_drives();
......@@ -322,7 +323,7 @@ save_file_dialog(const char* description,
if (!path_click) {
ImVec2 size = ImGui::GetContentRegionMax();
size.y /= 1.5;
size.y /= 1.5f;
ImGui::BeginChild("##select_files", size);
......@@ -414,4 +415,4 @@ save_file_dialog(const char* description,
return res;
}
} // namespace irt
\ No newline at end of file
} // namespace irt
......@@ -40,14 +40,10 @@ struct window_logger
/* Filesytem dialog box */
bool
load_file_dialog(const char* description,
const char* filters[],
std::filesystem::path& out);
load_file_dialog(std::filesystem::path& out);
bool
save_file_dialog(const char* description,
const char* filters[],
std::filesystem::path& out);
save_file_dialog(std::filesystem::path& out);
} // namespace irt
......
......@@ -772,11 +772,10 @@ struct editor
if (show_load_file_dialog) {
static std::string out;
static const char* filters[] = { "irt", nullptr };
ImGui::OpenPopup("Select file path to load");
if (load_file_dialog("Select a file path to load", filters, path)) {
if (load_file_dialog(path)) {
show_load_file_dialog = false;
log_w.log(5, "Load file from %s\n", path.string().c_str());
reader r(std::fopen(path.string().c_str(), "r"));
......@@ -793,7 +792,7 @@ struct editor
ImGui::OpenPopup("Select file path to save");
if (save_file_dialog("Select a file path to save", nullptr, path)) {
if (save_file_dialog(path)) {
show_save_file_dialog = false;
log_w.log(5, "Save file to %s\n", path.string().c_str());
......
......@@ -396,7 +396,6 @@ struct writer
int id = 0;
while (sim.models.next(mdl)) {
const auto mdl_id = sim.models.get_id(mdl);
const auto mdl_index = irt::get_index(mdl_id);
std::fprintf(file, "%d %s ", id, mdl->name.c_str());
map[id] = mdl_id;
......@@ -435,7 +434,7 @@ struct writer
assert(it_in != map.end());
std::fprintf(file,
"%u %d %u %d\n",
"%ld %d %ld %d\n",
std::distance(map.begin(), it_out),
src_index,
std::distance(map.begin(), it_in),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment