mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
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
5 changed files with 36 additions and 11 deletions
|
|
@ -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("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("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(msg, rb_intern("INFO"), INT2FIX(Oneshot::MSG_INFO));
|
||||
rb_const_set(msg, rb_intern("YESNO"), INT2FIX(Oneshot::MSG_YESNO));
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
SAVE_FILE_NAME = Oneshot::SAVE_PATH + '/save.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
|
||||
File.delete(SAVE_FILE_NAME)
|
||||
end
|
||||
|
||||
def fake_save
|
||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games")
|
||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games\\Oneshot") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games\\Oneshot")
|
||||
Dir.mkdir(Oneshot::GAME_PATH) unless File.exists?(Oneshot::GAME_PATH)
|
||||
Dir.mkdir(Oneshot::GAME_PATH + "/Oneshot") unless File.exists?(Oneshot::GAME_PATH + "/Oneshot")
|
||||
File.open(FAKE_SAVE_NAME, 'wb') do |file|
|
||||
# Wrire frame count for measuring play time
|
||||
Marshal.dump(Graphics.frame_count, file)
|
||||
|
|
|
|||
|
|
@ -277,18 +277,20 @@ module Script
|
|||
end
|
||||
|
||||
def self.copy_journal
|
||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games")
|
||||
Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games\\Oneshot") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games\\Oneshot")
|
||||
File.open("_______.exe", "rb") do |input|
|
||||
File.open(Oneshot::DOCS_PATH + "\\My Games\\Oneshot\\_______.exe","wb") do |output|
|
||||
while buff = input.read(4096)
|
||||
output.write(buff)
|
||||
Dir.mkdir(Oneshot::GAME_PATH) unless File.exists?(Oneshot::GAME_PATH)
|
||||
Dir.mkdir(Oneshot::GAME_PATH + "/Oneshot") unless File.exists?(Oneshot::GAME_PATH + "/Oneshot")
|
||||
if File.exists?(Oneshot::JOURNAL)
|
||||
File.open(Oneshot::JOURNAL, "rb") do |input|
|
||||
File.open(Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL,"wb") do |output|
|
||||
while buff = input.read(4096)
|
||||
output.write(buff)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if File.exists?("README.txt")
|
||||
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)
|
||||
output.write(buff)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -219,6 +219,8 @@ struct OneshotPrivate
|
|||
std::string userName;
|
||||
std::string savePath;
|
||||
std::string docsPath;
|
||||
std::string gamePath;
|
||||
std::string journal;
|
||||
|
||||
//Dialog text
|
||||
std::string txtYes;
|
||||
|
|
@ -409,6 +411,8 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
|||
WCHAR path[MAX_PATH];
|
||||
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path);
|
||||
p->docsPath = w32_fromWide(path);
|
||||
p->gamePath = p->docsPath+"\\My Games";
|
||||
p->journal = "_______.exe";
|
||||
#else
|
||||
//Get language code
|
||||
const char *lc_all = getenv("LC_ALL");
|
||||
|
|
@ -446,6 +450,12 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
|||
//Get documents path
|
||||
char *path = xdg_user_dir_lookup_with_fallback("DOCUMENTS", getenv("HOME"));
|
||||
p->docsPath = path;
|
||||
p->gamePath = path;
|
||||
#ifdef OS_OSX
|
||||
p->journal = "_______.app";
|
||||
#elif defined OS_LINUX
|
||||
p->journal = "_______";
|
||||
#endif
|
||||
free(path);
|
||||
#endif
|
||||
|
||||
|
|
@ -603,6 +613,16 @@ const std::string &Oneshot::docsPath() const
|
|||
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
|
||||
{
|
||||
return p->obscuredMap;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public:
|
|||
const std::string &userName() const;
|
||||
const std::string &savePath() const;
|
||||
const std::string &docsPath() const;
|
||||
const std::string &gamePath() const;
|
||||
const std::string &journal() const;
|
||||
const std::vector<uint8_t> &obscuredMap() const;
|
||||
bool obscuredCleared() const;
|
||||
bool allowExit() const;
|
||||
|
|
|
|||
Loading…
Reference in a new issue