Skip to content

Commit

Permalink
More paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoru committed Feb 11, 2016
1 parent eb90972 commit 442f5e5
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 100 deletions.
17 changes: 9 additions & 8 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ void Application::Init()
#endif

Log::Printf(RAINDROP_WINDOWTITLE RAINDROP_VERSIONTEXT " start.\n");
Log::Printf("Working directory: %s\n", std::filesystem::current_path().u8string().c_str());
// Log::Printf("Current Time: %s.\n", t1);
Log::Printf("Working directory: %s\n", Utility::Narrow(std::filesystem::current_path()).c_str());

GameState::GetInstance().Initialize();
Log::Printf("Initializing... \n");
Expand Down Expand Up @@ -278,7 +279,7 @@ bool Application::PollIPC()
}
}

void ExportToBMSUnquantized(VSRG::Song* Source, Directory PathOut);
void ExportToBMSUnquantized(VSRG::Song* Source, std::filesystem::path PathOut);

void Application::Run()
{
Expand All @@ -301,7 +302,7 @@ void Application::Run()
IPC::Message Msg;
Msg.MessageKind = IPC::Message::MSG_STARTFROMMEASURE;
Msg.Param = Measure;
strncpy(Msg.Path, InFile.u8string().c_str(), 256);
strncpy(Msg.Path, Utility::Narrow(InFile).c_str(), 256);

IPC::SendMessageToQueue(&Msg);
RunLoop = false;
Expand All @@ -325,15 +326,15 @@ void Application::Run()
if (Sng && Sng->Difficulties.size())
{
if (ConvertMode == CONVERTMODE::CONV_OM) // for now this is the default
ConvertToOM(Sng.get(), OutFile.u8string(), Author);
ConvertToOM(Sng.get(), OutFile, Author);
else if (ConvertMode == CONVERTMODE::CONV_BMS)
ConvertToBMS(Sng.get(), OutFile.u8string());
ConvertToBMS(Sng.get(), OutFile);
else if (ConvertMode == CONVERTMODE::CONV_UQBMS)
ExportToBMSUnquantized(Sng.get(), OutFile.u8string());
ExportToBMSUnquantized(Sng.get(), OutFile);
else if (ConvertMode == CONVERTMODE::CONV_NPS)
ConvertToNPSGraph(Sng.get(), OutFile.u8string());
ConvertToNPSGraph(Sng.get(), OutFile);
else
ConvertToSMTiming(Sng.get(), OutFile.u8string());
ConvertToSMTiming(Sng.get(), OutFile);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Audiofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ std::unique_ptr<AudioDataSource> SourceFromExt(std::filesystem::path Filename)
Ret = std::make_unique<AudioSourceOGG>();

if (Ret)
Ret->Open(u8fn.c_str());
Ret->Open(Filename);
else
{
Log::Printf("extension %s has no audiosource associated\n", ext.c_str());
Expand Down
10 changes: 5 additions & 5 deletions src/BackgroundAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class BMSBackground : public BackgroundAnimation
EventsLayer2 = Difficulty->Data->BMPEvents->BMPEventsLayer2;

for (auto v : Difficulty->Data->BMPEvents->BMPList)
List.AddToListIndex(v.second, Song->SongDirectory.u8string(), v.first);
List.AddToListIndex(v.second, Song->SongDirectory, v.first);

List.AddToList(Song->BackgroundFilename, Song->SongDirectory.u8string());
List.AddToList(Song->BackgroundFilename, Song->SongDirectory);
List.LoadAll();
}

Expand Down Expand Up @@ -173,7 +173,7 @@ class StaticBackground : public BackgroundAnimation
std::shared_ptr<Sprite> Background;
ImageList List;
public:
StaticBackground(Interruptible* parent, std::string Filename)
StaticBackground(Interruptible* parent, std::filesystem::path Filename)
: BackgroundAnimation(parent), List(this)
{
Log::Printf("Using static background: %s\n", Filename.c_str());
Expand Down Expand Up @@ -215,15 +215,15 @@ std::shared_ptr<BackgroundAnimation> CreateBGAforVSRG(VSRG::Song &input, uint8_t
if (Diff->Data && Diff->Data->BMPEvents)
return std::make_shared<BMSBackground>(context, Diff, &input);
else
return std::make_shared<StaticBackground>(context, GetSongBackground(input).u8string());
return std::make_shared<StaticBackground>(context, GetSongBackground(input));
}

return nullptr;
}

std::shared_ptr<BackgroundAnimation> CreateBGAforDotcur(dotcur::Song &input, uint8_t DifficultyIndex)
{
return std::make_shared<StaticBackground>(nullptr, GetSongBackground(input).u8string());
return std::make_shared<StaticBackground>(nullptr, GetSongBackground(input));
}

BackgroundAnimation::BackgroundAnimation(Interruptible* parent) : Interruptible(parent)
Expand Down
21 changes: 12 additions & 9 deletions src/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int TrackToXPos(int totaltracks, int track)
return (base * (track + 1) - minus);
}

void ConvertToOM(VSRG::Song *Sng, Directory PathOut, std::string Author)
void ConvertToOM(VSRG::Song *Sng, std::filesystem::path PathOut, std::string Author)
{
for (auto Difficulty : Sng->Difficulties)
{
Expand All @@ -30,9 +30,13 @@ void ConvertToOM(VSRG::Song *Sng, Directory PathOut, std::string Author)
Utility::RemoveFilenameIllegalCharacters(DName, true);
Utility::RemoveFilenameIllegalCharacters(Charter, true);

Directory Str = Utility::Format("%s/%s - %s [%s] (%s).osu", PathOut.c_path(), Author.c_str(), Name.c_str(), DName.c_str(), Charter.c_str());
Str.Normalize(true);
std::ofstream out(Str.c_path());
std::filesystem::path Str =
PathOut / Utility::Format("%s - %s [%s] (%s).osu",
Author.c_str(),
Name.c_str(),
DName.c_str(),
Charter.c_str());
std::ofstream out(Str);

if (!out.is_open())
{
Expand Down Expand Up @@ -146,14 +150,13 @@ void ConvertToOM(VSRG::Song *Sng, Directory PathOut, std::string Author)
}
}

void ConvertToSMTiming(VSRG::Song *Sng, Directory PathOut)
void ConvertToSMTiming(VSRG::Song *Sng, std::filesystem::path PathOut)
{
TimingData BPS, VSpeeds, Warps;
VSRG::Difficulty* Diff = Sng->Difficulties[0].get();
Diff->GetPlayableData(nullptr, BPS, VSpeeds, Warps);

std::ofstream out(PathOut.c_path());

std::ofstream out(PathOut);
// Technically, stepmania's #OFFSET is actually #GAP, not #OFFSET.
out << "#OFFSET:" << -Diff->Offset << ";\n";

Expand Down Expand Up @@ -192,8 +195,8 @@ void ConvertToSMTiming(VSRG::Song *Sng, Directory PathOut)
out << ";";
}

void ExportToBMS(VSRG::Song *Sng, Directory PathOut);
void ConvertToBMS(VSRG::Song *Sng, Directory PathOut)
void ExportToBMS(VSRG::Song *Sng, std::filesystem::path PathOut);
void ConvertToBMS(VSRG::Song *Sng, std::filesystem::path PathOut)
{
ExportToBMS(Sng, PathOut);
}
28 changes: 12 additions & 16 deletions src/ConvertToBMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,24 +341,20 @@ class BMSConverter : public VSRG::RowifiedDifficulty {
}
}

void Output(Directory PathOut)
void Output(std::filesystem::path PathOut)
{
Directory Sn = Song->SongName;
Sn.Normalize(true);
std::filesystem::path name = PathOut / Utility::Format("%s (%s) - %s.bms",
Song->SongName.c_str(), Parent->Name.c_str(), Parent->Author.c_str());

std::string name = Utility::Format("%s/%s (%s) - %s.bms",
PathOut.c_path(), Sn.c_path(), Parent->Name.c_str(), Parent->Author.c_str());

#ifndef _WIN32
std::ofstream out(name.c_str());
#else
std::ofstream out(Utility::Widen(name).c_str());
#endif
std::ofstream out(name);

try
{
if (!out.is_open())
throw std::exception((Utility::Format("failed to open file %s", name.c_str()).c_str()));
if (!out.is_open())
{
auto s = Utility::Format("failed to open file %s", Utility::Narrow(name).c_str());
throw std::exception(s.c_str());
}
if (BPS.size() == 0)
throw std::exception("There are no timing points!");
WriteBMSOutput();
Expand All @@ -371,7 +367,7 @@ class BMSConverter : public VSRG::RowifiedDifficulty {
}
};

void ConvertBMSAll(VSRG::Song *Source, Directory PathOut, bool Quantize)
void ConvertBMSAll(VSRG::Song *Source, std::filesystem::path PathOut, bool Quantize)
{
for (auto Diff : Source->Difficulties)
{
Expand All @@ -380,12 +376,12 @@ void ConvertBMSAll(VSRG::Song *Source, Directory PathOut, bool Quantize)
}
}

void ExportToBMS(VSRG::Song* Source, Directory PathOut)
void ExportToBMS(VSRG::Song* Source, std::filesystem::path PathOut)
{
ConvertBMSAll(Source, PathOut, true);
}

void ExportToBMSUnquantized(VSRG::Song* Source, Directory PathOut)
void ExportToBMSUnquantized(VSRG::Song* Source, std::filesystem::path PathOut)
{
ConvertBMSAll(Source, PathOut, false);
}
8 changes: 4 additions & 4 deletions src/Converter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

void ConvertToOM(VSRG::Song *Sng, Directory PathOut, std::string Author);
void ConvertToBMS(VSRG::Song *Sng, Directory PathOut);
void ConvertToSMTiming(VSRG::Song *Sng, Directory PathOut);
void ConvertToNPSGraph(VSRG::Song *Sng, Directory PathOut);
void ConvertToOM(VSRG::Song *Sng, std::filesystem::path PathOut, std::string Author);
void ConvertToBMS(VSRG::Song *Sng, std::filesystem::path PathOut);
void ConvertToSMTiming(VSRG::Song *Sng, std::filesystem::path PathOut);
void ConvertToNPSGraph(VSRG::Song *Sng, std::filesystem::path PathOut);
11 changes: 4 additions & 7 deletions src/NPSGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,16 @@ class NPSGraph
}
};

void ConvertToNPSGraph(VSRG::Song *Sng, Directory PathOut)
void ConvertToNPSGraph(VSRG::Song *Sng, std::filesystem::path PathOut)
{
for (auto i = 0; i < Sng->Difficulties.size(); i++)
{
std::ofstream out;
auto Diff = Sng->GetDifficulty(i);
Directory Sn = Sng->SongName;
Sn.Normalize(true);

std::string name = Utility::Format("%s/ %s (%s) - %s.svg", PathOut.c_path(), Sn.c_path(), Diff->Name, Diff->Author);

out.open(name.c_str());
auto s = Utility::Format("%s (%s) - %s.svg", Sng->SongName.c_str(), Diff->Name, Diff->Author);
std::filesystem::path name = PathOut / s;

std::ofstream out(name);
double interv = CfgValNPS("IntervalTime", 1);
double margin = CfgValNPS("PeakMargin", 1.2f);

Expand Down
11 changes: 5 additions & 6 deletions src/NoteLoaderBMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ namespace NoteLoaderBMS{
double Time = TimeForObj(i->first, ev.Fraction);
NoteData Note;
Note.StartTime = Time;
Note.Sound = ev.Event; // Mine explosion value.
// todo: finish
Note.Sound = ev.Event / 2; // Mine explosion value.
// todo: finish mine mechanics

}, startChannelMines, i);

Expand All @@ -406,6 +406,9 @@ namespace NoteLoaderBMS{
Note.StartTime = Time;
Note.Sound = ev.Event; // Sound.
Note.NoteKind = NK_INVISIBLE;

UsedSounds[ev.Event] = true;
Msr.Notes[Track].push_back(Note);
}, startChannelInvisible, i);
}

Expand Down Expand Up @@ -919,11 +922,7 @@ namespace NoteLoaderBMS{

void LoadObjectsFromFile(std::filesystem::path filename, Song *Out)
{
#if (!defined _WIN32)
std::ifstream filein(filename.c_str());
#else
std::ifstream filein(filename);
#endif

std::shared_ptr<Difficulty> Diff(new Difficulty());
std::shared_ptr<DifficultyLoadInfo> LInfo(new DifficultyLoadInfo());
Expand Down
4 changes: 0 additions & 4 deletions src/NoteLoaderBMSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,7 @@ namespace NoteLoaderBMSON

void LoadObjectsFromFile(std::filesystem::path filename, VSRG::Song* Out)
{
#if (!defined _WIN32)
std::ifstream filein(filename.c_str());
#else
std::ifstream filein(filename);
#endif

BMSONLoader bmson(filein, Out);
bmson.DoLoad();
Expand Down
5 changes: 0 additions & 5 deletions src/NoteLoaderFTB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ void NoteLoaderFTB::LoadObjectsFromFile(std::filesystem::path filename, Song *Ou
{
std::shared_ptr<VSRG::Difficulty> Diff(new Difficulty());
Measure Msr;

#if (!defined _WIN32) || (defined STLP)
std::ifstream filein(filename.c_str());
#else
std::ifstream filein(filename);
#endif

Diff->Filename = filename;

Expand Down
4 changes: 0 additions & 4 deletions src/NoteLoaderOM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,7 @@ void CopyTimingData(OsuLoadInfo* Info)

void NoteLoaderOM::LoadObjectsFromFile(std::filesystem::path filename, Song *Out)
{
#if (!defined _WIN32) || (defined STLP)
std::ifstream filein(filename.c_str());
#else
std::ifstream filein(filename);
#endif
std::regex versionfmt("osu file format v(\\d+)");

if (!filein.is_open())
Expand Down
8 changes: 0 additions & 8 deletions src/NoteLoaderSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,7 @@ SpeedData ParseScrolls(std::string line)

void NoteLoaderSSC::LoadObjectsFromFile(std::filesystem::path filename, Song *Out)
{
#if (!defined _WIN32) || (defined STLP)
std::ifstream filein(filename.c_str());
#else
std::ifstream filein(filename);
#endif

TimingData BPMData;
TimingData StopsData;
Expand Down Expand Up @@ -660,11 +656,7 @@ void WarpifyTiming(Difficulty* Diff)

void NoteLoaderSM::LoadObjectsFromFile(std::filesystem::path filename, Song *Out)
{
#if (!defined _WIN32) || (defined STLP)
std::ifstream filein(filename.c_str());
#else
std::ifstream filein(filename);
#endif

TimingData BPMData;
TimingData StopsData;
Expand Down
2 changes: 1 addition & 1 deletion src/Noteskin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void lua_Render(Sprite *S)
}
}

#ifndef WIN32
#ifndef _WIN32
#define LUACHECK(x) if (NoteskinLua == nullptr) {Log::Logf("%s: Noteskin state is invalid - no lua.\n", __func__); return x;}
#else
#define LUACHECK(x) if (NoteskinLua == nullptr) {Log::DebugPrintf("%s: Noteskin state is invalid - no lua.\n", __FUNCTION__); return x;}
Expand Down
3 changes: 2 additions & 1 deletion src/ScreenGameplay7K_Mechanics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ void ScreenGameplay7K::PlayLaneKeysound(uint32_t Lane)

if (Keysounds.find(TN->GetSound()) != Keysounds.end() && PlayReactiveSounds)
for (auto &&s : Keysounds[TN->GetSound()])
if (s) s->Play();
if (s)
s->Play();
}

void ScreenGameplay7K::PlayKeysound(TrackNote* TN)
Expand Down
Loading

0 comments on commit 442f5e5

Please sign in to comment.