win32 fixes
use imgui id to allow multiple contents with same name
This commit is contained in:
parent
492e771272
commit
b1bb89909e
|
@ -337,6 +337,12 @@ error:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HOST_OS == OS_WINDOWS
|
||||||
|
#define CloseFile(f) CloseHandle(f)
|
||||||
|
#else
|
||||||
|
#define CloseFile(f) close(f)
|
||||||
|
#endif
|
||||||
|
|
||||||
bool naomi_cart_LoadRom(char* file)
|
bool naomi_cart_LoadRom(char* file)
|
||||||
{
|
{
|
||||||
printf("\nnullDC-Naomi rom loader v1.2\n");
|
printf("\nnullDC-Naomi rom loader v1.2\n");
|
||||||
|
@ -463,7 +469,7 @@ bool naomi_cart_LoadRom(char* file)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < RomCacheMapCount; i++)
|
for (int i = 0; i < RomCacheMapCount; i++)
|
||||||
if (RomCacheMap[i] != INVALID_FD)
|
if (RomCacheMap[i] != INVALID_FD)
|
||||||
close(RomCacheMap[i]);
|
CloseFile(RomCacheMap[i]);
|
||||||
RomCacheMapCount = 0;
|
RomCacheMapCount = 0;
|
||||||
delete[] RomCacheMap;
|
delete[] RomCacheMap;
|
||||||
}
|
}
|
||||||
|
@ -546,11 +552,7 @@ bool naomi_cart_LoadRom(char* file)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < files.size(); i++)
|
for (size_t i = 0; i < files.size(); i++)
|
||||||
if (RomCacheMap[i] != INVALID_FD)
|
if (RomCacheMap[i] != INVALID_FD)
|
||||||
#if HOST_OS == OS_WINDOWS
|
CloseFile(RomCacheMap[i]);
|
||||||
CloseHandle(RomCacheMap[i]);
|
|
||||||
#else
|
|
||||||
close(RomCacheMap[i]);
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,10 @@ static bool init_done;
|
||||||
|
|
||||||
int reicast_init(int argc, char* argv[])
|
int reicast_init(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
setbuf(stdout, 0);
|
||||||
|
setbuf(stderr, 0);
|
||||||
|
#endif
|
||||||
if (!_vmem_reserve())
|
if (!_vmem_reserve())
|
||||||
{
|
{
|
||||||
printf("Failed to alloc mem\n");
|
printf("Failed to alloc mem\n");
|
||||||
|
|
|
@ -1013,15 +1013,20 @@ static void add_game_directory(const std::string& path, std::vector<GameMedia>&
|
||||||
if (name == "." || name == "..")
|
if (name == "." || name == "..")
|
||||||
continue;
|
continue;
|
||||||
std::string child_path = path + "/" + name;
|
std::string child_path = path + "/" + name;
|
||||||
if (entry->d_type == DT_UNKNOWN)
|
bool is_dir = false;
|
||||||
|
#ifndef _WIN32
|
||||||
|
if (entry->d_type == DT_DIR)
|
||||||
|
is_dir = true;
|
||||||
|
if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(child_path.c_str(), &st) != 0)
|
if (stat(child_path.c_str(), &st) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (S_ISDIR(st.st_mode))
|
if (S_ISDIR(st.st_mode))
|
||||||
entry->d_type = DT_DIR;
|
is_dir = true;
|
||||||
}
|
}
|
||||||
if (entry->d_type == DT_DIR)
|
if (is_dir)
|
||||||
{
|
{
|
||||||
add_game_directory(child_path, game_list);
|
add_game_directory(child_path, game_list);
|
||||||
}
|
}
|
||||||
|
@ -1116,11 +1121,13 @@ static void gui_display_content()
|
||||||
for (auto game : game_list)
|
for (auto game : game_list)
|
||||||
if (filter.PassFilter(game.name.c_str()))
|
if (filter.PassFilter(game.name.c_str()))
|
||||||
{
|
{
|
||||||
|
ImGui::PushID(game.path.c_str());
|
||||||
if (ImGui::Selectable(game.name.c_str()))
|
if (ImGui::Selectable(game.name.c_str()))
|
||||||
{
|
{
|
||||||
gui_start_game(game.path);
|
gui_start_game(game.path);
|
||||||
gui_state = ClosedNoResume;
|
gui_state = ClosedNoResume;
|
||||||
}
|
}
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ static bool subfolders_read;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static const std::string separators = "/\\";
|
static const std::string separators = "/\\";
|
||||||
static const std::string native_separator = "\\";
|
static const std::string native_separator = "\\";
|
||||||
|
#define WIN32_PSEUDO_ROOT ":"
|
||||||
#else
|
#else
|
||||||
static const std::string separators = "/";
|
static const std::string separators = "/";
|
||||||
static const std::string native_separator = "/";
|
static const std::string native_separator = "/";
|
||||||
|
@ -56,8 +57,15 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
|
||||||
select_current_directory = home;
|
select_current_directory = home;
|
||||||
#elif HOST_OS == OS_WINDOWS
|
#elif HOST_OS == OS_WINDOWS
|
||||||
const char *home = getenv("HOMEPATH");
|
const char *home = getenv("HOMEPATH");
|
||||||
|
const char *home_drive = getenv("HOMEDRIVE");
|
||||||
if (home != NULL)
|
if (home != NULL)
|
||||||
select_current_directory = home;
|
{
|
||||||
|
if (home_drive != NULL)
|
||||||
|
select_current_directory = home_drive;
|
||||||
|
else
|
||||||
|
select_current_directory.clear();
|
||||||
|
select_current_directory += home;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (select_current_directory.empty())
|
if (select_current_directory.empty())
|
||||||
{
|
{
|
||||||
|
@ -85,13 +93,14 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
|
||||||
select_subfolders.clear();
|
select_subfolders.clear();
|
||||||
error_message.clear();
|
error_message.clear();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (select_current_directory.empty())
|
if (select_current_directory == WIN32_PSEUDO_ROOT)
|
||||||
{
|
{
|
||||||
|
error_message = "Drives";
|
||||||
// List all the drives
|
// List all the drives
|
||||||
u32 drives = GetLogicalDrives();
|
u32 drives = GetLogicalDrives();
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
if ((drives & (1 << i)) != 0)
|
if ((drives & (1 << i)) != 0)
|
||||||
select_subfolders.push_back(std::string(1, (char)('A' + i) + ":\\");
|
select_subfolders.push_back(std::string(1, (char)('A' + i)) + ":\\");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -116,15 +125,20 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
|
||||||
if (name == "..")
|
if (name == "..")
|
||||||
dotdot_seen = true;
|
dotdot_seen = true;
|
||||||
std::string child_path = path + "/" + name;
|
std::string child_path = path + "/" + name;
|
||||||
|
bool is_dir = false;
|
||||||
|
#ifndef _WIN32
|
||||||
|
if (entry->d_type == DT_DIR)
|
||||||
|
is_dir = true;
|
||||||
if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK)
|
if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(child_path.c_str(), &st) != 0)
|
if (stat(child_path.c_str(), &st) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (S_ISDIR(st.st_mode))
|
if (S_ISDIR(st.st_mode))
|
||||||
entry->d_type = DT_DIR;
|
is_dir = true;
|
||||||
}
|
}
|
||||||
if (entry->d_type == DT_DIR && access(child_path.c_str(), R_OK) == 0)
|
if (is_dir && access(child_path.c_str(), R_OK) == 0)
|
||||||
select_subfolders.push_back(name);
|
select_subfolders.push_back(name);
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
@ -158,7 +172,7 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
|
||||||
continue;
|
continue;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (path.size() == 2 && path[1] == ':')
|
if (path.size() == 2 && path[1] == ':')
|
||||||
child_path = "";
|
child_path = WIN32_PSEUDO_ROOT;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (path == ".")
|
if (path == ".")
|
||||||
|
@ -173,17 +187,22 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
|
||||||
else if (path.size() >= 2 && path.substr(path.size() - 2) == "..")
|
else if (path.size() >= 2 && path.substr(path.size() - 2) == "..")
|
||||||
child_path = path + native_separator + "..";
|
child_path = path + native_separator + "..";
|
||||||
else
|
else
|
||||||
|
{
|
||||||
child_path = path.substr(0, last_sep);
|
child_path = path.substr(0, last_sep);
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (child_path.size() == 2 && child_path[1] == ':') // C: -> C:/
|
||||||
|
child_path += native_separator;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!path.empty())
|
#ifdef _WIN32
|
||||||
{
|
if (path == WIN32_PSEUDO_ROOT)
|
||||||
std::string::size_type last_sep = path.find_last_of(separators);
|
child_path = name;
|
||||||
if (last_sep == path.size() - 1)
|
else
|
||||||
path.pop_back();
|
#endif
|
||||||
}
|
child_path = path + native_separator + name;
|
||||||
child_path = path + native_separator + name;
|
|
||||||
}
|
}
|
||||||
if (ImGui::Selectable(name.c_str()))
|
if (ImGui::Selectable(name.c_str()))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue