本文整理汇总了C++中Question::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ Question::Set方法的具体用法?C++ Question::Set怎么用?C++ Question::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChangeReplay
void ReplayMenu::ChangeReplay()
{
const std::string *name = replay_lbox->GetSelectedFile();
selected = NULL;
if (!name) {
ClearReplayInfo();
return;
}
// Get info from Replay:: and fill in here
FILE *in = fopen(name->c_str(), "rb");
if (!in) {
Question question;
std::string err = "Error: file ";
err += *name;
err += " not found";
question.Set(err, true, 0);
question.Ask();
return; /* File deleted meanwhile ? */
}
ReplayInfo *info = ReplayInfo::ReplayInfoFromFile(in);
fclose(in);
if (!info)
return; /* Bad problem */
// Below gets risky to analyze so error out
if (!info->IsValid()) {
const std::string& err = info->GetLastError();
// Clean current state
ClearReplayInfo();
Question question;
fprintf(stderr, "Error: %s\n", err.c_str());
question.Set(err, true, 0);
question.Ask();
delete info;
return;
}
// Version
std::string text = info->GetVersion();
version_lbl->SetText(text);
// Date
time_t t = info->GetDate();
struct tm * timeinfo = localtime(&t);
char buffer[20];
strftime(buffer, sizeof(buffer), "%Y-%m-%d %HH%Mm%S", timeinfo);
date_lbl->SetText(buffer);
// Duration
Uint32 time = (info->GetMillisecondsDuration()+500)/1000;
char temp[32];
snprintf(temp, 32, "%um%us", time/60, time%60);
text = temp;
duration_lbl->SetText(text);
// Comment
text = info->GetComment();
comment_lbl->SetText(text);
// Teams
teams_lbox->Clear();
for (uint i=0; i<info->GetTeams().size(); i++) {
printf("Adding %s\n", info->GetTeams()[i].id.c_str());
teams_lbox->AddWidget(new Label(info->GetTeams()[i].id, 0, Font::FONT_MEDIUM));
}
teams_lbox->Pack();
teams_lbox->NeedRedrawing();
delete info;
selected = name;
}