Commit 425af859 authored by fallenstardust's avatar fallenstardust

载入残局介绍文字

--[[message]]
parent 982fadd5
......@@ -479,6 +479,55 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->SetStaticText(mainGame->stReplayInfo, 180 * mainGame->xScale, mainGame->guiFont, (wchar_t*)repinfo.c_str());
break;
}
case LISTBOX_SINGLEPLAY_LIST: {
int sel = mainGame->lstSinglePlayList->getSelected();
if(sel == -1)
break;
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(sel);
wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name);
FILE *fp;
#ifdef _WIN32
fp = _wfopen(fname, L"rb");
#else
char filename[256];
BufferIO::EncodeUTF8(fname, filename);
fp = fopen(filename, "rb");
#endif
if(!fp) {
mainGame->stSinglePlayInfo->setText(L"");
break;
}
char linebuf[1024];
wchar_t wlinebuf[1024];
std::wstring message = L"";
bool in_message = false;
while(fgets(linebuf, 1024, fp)) {
if(!strncmp(linebuf, "--[[message", 11)) {
size_t len = strlen(linebuf);
char* msgend = strrchr(linebuf, ']');
if(len <= 13) {
in_message = true;
continue;
} else if(len > 15 && msgend) {
*(msgend - 1) = '\0';
BufferIO::DecodeUTF8(linebuf + 12, wlinebuf);
message.append(wlinebuf);
break;
}
}
if(!strncmp(linebuf, "]]", 2)) {
in_message = false;
break;
}
if(in_message) {
BufferIO::DecodeUTF8(linebuf, wlinebuf);
message.append(wlinebuf);
}
}
mainGame->SetStaticText(mainGame->stSinglePlayInfo, 200 * mainGame->xScale, mainGame->guiFont, message.c_str());
break;
}
case LISTBOX_BOT_LIST: {
int sel = mainGame->lstBotList->getSelected();
if(sel == -1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment