Skip to content

Commit

Permalink
Minor more paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoru committed Feb 11, 2016
1 parent 442f5e5 commit d6999f1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Image* GameState::GetSkinImage(const std::string& Path)
if (Directory(File).GetExtension() == "ojn")
{
size_t read;
const unsigned char* buf = reinterpret_cast<const unsigned char*>(LoadOJNCover(toLoad.u8string(), read));
const unsigned char* buf = reinterpret_cast<const unsigned char*>(LoadOJNCover(toLoad, read));
ImageData data = ImageLoader::GetDataForImageFromMemory(buf, read);
StageImage->SetTextureData(&data, true);
delete[] buf;
Expand All @@ -237,7 +237,7 @@ Image* GameState::GetSkinImage(const std::string& Path)

if (File.length() && std::filesystem::exists(toLoad))
{
StageImage->Assign(toLoad.u8string(), ImageData::SM_DEFAULT, ImageData::WM_DEFAULT, true);
StageImage->Assign(toLoad, ImageData::SM_DEFAULT, ImageData::WM_DEFAULT, true);
return StageImage;
}
else return nullptr;
Expand All @@ -257,7 +257,7 @@ Image* GameState::GetSkinImage(const std::string& Path)

if (SelectedSong->BackgroundFilename.length() && std::filesystem::exists(toLoad))
{
SongBG->Assign(toLoad.u8string(), ImageData::SM_DEFAULT, ImageData::WM_DEFAULT, true);
SongBG->Assign(toLoad, ImageData::SM_DEFAULT, ImageData::WM_DEFAULT, true);
return SongBG;
}
else return nullptr;
Expand Down
15 changes: 12 additions & 3 deletions src/GameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,22 @@ void GameWindow::AssignSize()
if (WindowWidth == 0 || WindowHeight == 0)
{
GLFWmonitor *mon = glfwGetPrimaryMonitor();
const GLFWvidmode *mode = glfwGetVideoMode(mon);

size.x = mode->width;
size.y = mode->height;
if (mon) {
const GLFWvidmode *mode = glfwGetVideoMode(mon);

size.x = mode->width;
size.y = mode->height;
}
else {
WindowWidth = 1024;
WindowHeight = 768;
goto autosize;
}
}
else
{
autosize:
size.x = WindowWidth;
size.y = WindowHeight;
}
Expand Down
2 changes: 1 addition & 1 deletion src/NoteLoader7K.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace NoteLoaderOM
void LoadObjectsFromFile(std::filesystem::path filename, VSRG::Song *Out);
}

const char *LoadOJNCover(std::string filename, size_t &read);
const char *LoadOJNCover(std::filesystem::path filename, size_t &read);
namespace NoteLoaderOJN
{
void LoadObjectsFromFile(std::filesystem::path filename, VSRG::Song *Out);
Expand Down
8 changes: 2 additions & 6 deletions src/NoteLoaderOJN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,9 @@ bool IsValidOJN(std::fstream &filein, OjnHeader *Head)
return true;
}

const char *LoadOJNCover(std::string filename, size_t &read)
const char *LoadOJNCover(std::filesystem::path filename, size_t &read)
{
#if (!defined _WIN32)
std::fstream filein(filename.c_str());
#else
std::fstream filein(Utility::Widen(filename).c_str(), std::ios::binary | std::ios::in);
#endif
std::fstream filein(filename, std::ios::binary | std::ios::in);
OjnHeader Head;
char* out;

Expand Down
7 changes: 2 additions & 5 deletions src/SongList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void SongList::AddNamedDirectory(std::mutex &loadMutex, SongLoader *Loader, std:
Loader->LoadSong7KFromDir(i, Songs7K);

if (DotcurActive)
Loader->LoadSongDCFromDir(i.path().u8string(), SongsDC);
Loader->LoadSongDCFromDir(i.path().string(), SongsDC);

if (!SongsDC.size() && !Songs7K.size()) // No songs, so, time to recursively search.
{
Expand Down Expand Up @@ -121,10 +121,7 @@ void SongList::AddNamedDirectory(std::mutex &loadMutex, SongLoader *Loader, std:

void SongList::AddDirectory(std::mutex &loadMutex, SongLoader *Loader, std::filesystem::path Dir, bool VSRGActive, bool DotcurActive)
{
int idx = Dir.u8string().find_last_of('/') + 1;
std::string path;
path = Dir.filename().u8string();
AddNamedDirectory(loadMutex, Loader, Dir, path, VSRGActive, DotcurActive);
AddNamedDirectory(loadMutex, Loader, Dir, Utility::Narrow(Dir.filename()), VSRGActive, DotcurActive);
}

void SongList::AddVirtualDirectory(std::string NewEntryName, Game::Song* List, int Count)
Expand Down
2 changes: 1 addition & 1 deletion src/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void Sprite::BindTextureVBO()
std::string Sprite::GetImageFilename() const
{
if (mImage)
return mImage->fname.u8string();
return Utility::Narrow(mImage->fname);
else
return std::string();
}

0 comments on commit d6999f1

Please sign in to comment.