Last active
December 11, 2015 06:27
-
-
Save ChunChunMorning/fe242b489f6405df3045 to your computer and use it in GitHub Desktop.
Siv3Dでセーブデータ的なサムシングを作る No4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <Siv3D.hpp> | |
# include <shlobj.h> | |
void Main() | |
{ | |
wchar_t appdataPath[MAX_PATH]; | |
FilePath savedataPath; | |
if (SHGetSpecialFolderPath(NULL, appdataPath, CSIDL_APPDATA, true)) | |
{ | |
savedataPath = Format(appdataPath, L"/Asablo/Savedata.csv"); | |
} | |
else | |
{ | |
Println(L"ファイルパスの取得に失敗"); | |
} | |
CSVReader reader(savedataPath); | |
if (!reader) | |
{ | |
CSVWriter writer(savedataPath); | |
writer.writeRow(Vec2::Zero, 100, 100); | |
writer.writeRow(L"はじまりの町"); | |
writer.writeRow(Palette::Green); | |
writer.close(); | |
reader.open(savedataPath); | |
} | |
Println(reader.get<Vec2>(0, 0), L" ", reader.get<int>(0, 1), L" ", reader.get<int>(0, 2)); | |
Println(reader.get<String>(1, 0)); | |
Println(reader.get<Color>(2, 0)); | |
WaitKey(); | |
reader.close(); | |
FileSystem::Remove(FileSystem::ParentPath(savedataPath)); | |
Println(FileSystem::ParentPath(savedataPath), L"を消去"); | |
WaitKey(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment