Made paths in script cross-platform friendly
An ending that made me very, VERY teary-eyed, interrupted by an access denied error…argh, code bugs, why! >~< Basically, the path to “My Games” and the name of the journal’s executable are now defined by oneshot.cpp and loaded into the Ruby script, so the ending isn’t interrupted. Now all that’s left is to compile the journal!
This commit is contained in:
parent
38865d1a09
commit
3224d65988
|
|
@ -75,6 +75,8 @@ void oneshotBindingInit()
|
||||||
rb_const_set(module, rb_intern("USER_NAME"), rb_str_new2(shState->oneshot().userName().c_str()));
|
rb_const_set(module, rb_intern("USER_NAME"), rb_str_new2(shState->oneshot().userName().c_str()));
|
||||||
rb_const_set(module, rb_intern("SAVE_PATH"), rb_str_new2(shState->oneshot().savePath().c_str()));
|
rb_const_set(module, rb_intern("SAVE_PATH"), rb_str_new2(shState->oneshot().savePath().c_str()));
|
||||||
rb_const_set(module, rb_intern("DOCS_PATH"), rb_str_new2(shState->oneshot().docsPath().c_str()));
|
rb_const_set(module, rb_intern("DOCS_PATH"), rb_str_new2(shState->oneshot().docsPath().c_str()));
|
||||||
|
rb_const_set(module, rb_intern("GAME_PATH"), rb_str_new2(shState->oneshot().gamePath().c_str()));
|
||||||
|
rb_const_set(module, rb_intern("JOURNAL"), rb_str_new2(shState->oneshot().journal().c_str()));
|
||||||
rb_const_set(module, rb_intern("LANG"), rb_str_new2(shState->oneshot().lang().c_str()));
|
rb_const_set(module, rb_intern("LANG"), rb_str_new2(shState->oneshot().lang().c_str()));
|
||||||
rb_const_set(msg, rb_intern("INFO"), INT2FIX(Oneshot::MSG_INFO));
|
rb_const_set(msg, rb_intern("INFO"), INT2FIX(Oneshot::MSG_INFO));
|
||||||
rb_const_set(msg, rb_intern("YESNO"), INT2FIX(Oneshot::MSG_YESNO));
|
rb_const_set(msg, rb_intern("YESNO"), INT2FIX(Oneshot::MSG_YESNO));
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
SAVE_FILE_NAME = Oneshot::SAVE_PATH + '/save.dat'
|
SAVE_FILE_NAME = Oneshot::SAVE_PATH + '/save.dat'
|
||||||
PERMA_FLAGS_NAME = Oneshot::SAVE_PATH + '/p-settings.dat'
|
PERMA_FLAGS_NAME = Oneshot::SAVE_PATH + '/p-settings.dat'
|
||||||
FAKE_SAVE_NAME = Oneshot::DOCS_PATH + '\\My Games\\Oneshot\\save_progress.oneshot'
|
FAKE_SAVE_NAME = Oneshot::GAME_PATH + '/Oneshot/save_progress.oneshot'
|
||||||
|
|
||||||
|
|
||||||
def erase_game
|
def erase_game
|
||||||
File.delete(SAVE_FILE_NAME)
|
File.delete(SAVE_FILE_NAME)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_save
|
def fake_save
|
||||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games")
|
Dir.mkdir(Oneshot::GAME_PATH) unless File.exists?(Oneshot::GAME_PATH)
|
||||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games\\Oneshot") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games\\Oneshot")
|
Dir.mkdir(Oneshot::GAME_PATH + "/Oneshot") unless File.exists?(Oneshot::GAME_PATH + "/Oneshot")
|
||||||
File.open(FAKE_SAVE_NAME, 'wb') do |file|
|
File.open(FAKE_SAVE_NAME, 'wb') do |file|
|
||||||
# Wrire frame count for measuring play time
|
# Wrire frame count for measuring play time
|
||||||
Marshal.dump(Graphics.frame_count, file)
|
Marshal.dump(Graphics.frame_count, file)
|
||||||
|
|
|
||||||
|
|
@ -277,18 +277,20 @@ module Script
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.copy_journal
|
def self.copy_journal
|
||||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games")
|
Dir.mkdir(Oneshot::GAME_PATH) unless File.exists?(Oneshot::GAME_PATH)
|
||||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games\\Oneshot") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games\\Oneshot")
|
Dir.mkdir(Oneshot::GAME_PATH + "/Oneshot") unless File.exists?(Oneshot::GAME_PATH + "/Oneshot")
|
||||||
File.open("_______.exe", "rb") do |input|
|
if File.exists?(Oneshot::JOURNAL)
|
||||||
File.open(Oneshot::DOCS_PATH + "\\My Games\\Oneshot\\_______.exe","wb") do |output|
|
File.open(Oneshot::JOURNAL, "rb") do |input|
|
||||||
while buff = input.read(4096)
|
File.open(Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL,"wb") do |output|
|
||||||
output.write(buff)
|
while buff = input.read(4096)
|
||||||
|
output.write(buff)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if File.exists?("README.txt")
|
if File.exists?("README.txt")
|
||||||
File.open("README.txt", "rb") do |input|
|
File.open("README.txt", "rb") do |input|
|
||||||
File.open(Oneshot::DOCS_PATH + "\\My Games\\Oneshot\\README.txt","wb") do |output|
|
File.open(Oneshot::GAME_PATH + "/Oneshot/README.txt","wb") do |output|
|
||||||
while buff = input.read(4096)
|
while buff = input.read(4096)
|
||||||
output.write(buff)
|
output.write(buff)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,8 @@ struct OneshotPrivate
|
||||||
std::string userName;
|
std::string userName;
|
||||||
std::string savePath;
|
std::string savePath;
|
||||||
std::string docsPath;
|
std::string docsPath;
|
||||||
|
std::string gamePath;
|
||||||
|
std::string journal;
|
||||||
|
|
||||||
//Dialog text
|
//Dialog text
|
||||||
std::string txtYes;
|
std::string txtYes;
|
||||||
|
|
@ -409,6 +411,8 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
WCHAR path[MAX_PATH];
|
WCHAR path[MAX_PATH];
|
||||||
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path);
|
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path);
|
||||||
p->docsPath = w32_fromWide(path);
|
p->docsPath = w32_fromWide(path);
|
||||||
|
p->gamePath = p->docsPath+"\\My Games";
|
||||||
|
p->journal = "_______.exe";
|
||||||
#else
|
#else
|
||||||
//Get language code
|
//Get language code
|
||||||
const char *lc_all = getenv("LC_ALL");
|
const char *lc_all = getenv("LC_ALL");
|
||||||
|
|
@ -446,6 +450,12 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
//Get documents path
|
//Get documents path
|
||||||
char *path = xdg_user_dir_lookup_with_fallback("DOCUMENTS", getenv("HOME"));
|
char *path = xdg_user_dir_lookup_with_fallback("DOCUMENTS", getenv("HOME"));
|
||||||
p->docsPath = path;
|
p->docsPath = path;
|
||||||
|
p->gamePath = path;
|
||||||
|
#ifdef OS_OSX
|
||||||
|
p->journal = "_______.app";
|
||||||
|
#elif defined OS_LINUX
|
||||||
|
p->journal = "_______";
|
||||||
|
#endif
|
||||||
free(path);
|
free(path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -603,6 +613,16 @@ const std::string &Oneshot::docsPath() const
|
||||||
return p->docsPath;
|
return p->docsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string &Oneshot::gamePath() const
|
||||||
|
{
|
||||||
|
return p->gamePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &Oneshot::journal() const
|
||||||
|
{
|
||||||
|
return p->journal;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<uint8_t> &Oneshot::obscuredMap() const
|
const std::vector<uint8_t> &Oneshot::obscuredMap() const
|
||||||
{
|
{
|
||||||
return p->obscuredMap;
|
return p->obscuredMap;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ public:
|
||||||
const std::string &userName() const;
|
const std::string &userName() const;
|
||||||
const std::string &savePath() const;
|
const std::string &savePath() const;
|
||||||
const std::string &docsPath() const;
|
const std::string &docsPath() const;
|
||||||
|
const std::string &gamePath() const;
|
||||||
|
const std::string &journal() const;
|
||||||
const std::vector<uint8_t> &obscuredMap() const;
|
const std::vector<uint8_t> &obscuredMap() const;
|
||||||
bool obscuredCleared() const;
|
bool obscuredCleared() const;
|
||||||
bool allowExit() const;
|
bool allowExit() const;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue