Skip to content

Commit

Permalink
Better deprecation message for new DescriptionWML
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Mar 20, 2016
1 parent 37d9b10 commit 2900f1c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/scripting/lua_gui2.cpp
Expand Up @@ -273,13 +273,20 @@ int show_message_dialog(lua_State *L, CVideo & video)
// for the deprecated syntax, this branch should still be retained
// when the deprecated syntax is removed, as a simpler method
// of specifying options when only a single string is needed.
gui2::tlegacy_menu_item item(short_opt);
const std::string& opt_str = short_opt;
gui2::tlegacy_menu_item item(opt_str);
opt["image"] = item.icon();
opt["label"] = item.label();
opt["description"] = item.description();
opt["default"] = item.is_default();
if(!opt["image"].blank() || !opt["description"].blank() || !opt["default"].blank()) {
ERR_LUA << "The &image=col1=col2 syntax is deprecated, use new DescriptionWML instead.\n";
// The exact error message depends on whether & or = was actually present
if(opt_str.find_first_of('=') == std::string::npos) {
// They just used a simple message, so the other error would be misleading
ERR_LUA << "[option]message= is deprecated, use label= instead.\n";
} else {
ERR_LUA << "The &image=col1=col2 syntax is deprecated, use new DescriptionWML instead.\n";
}
}
} else if(!luaW_toconfig(L, -1, opt)) {
std::ostringstream error;
Expand Down

0 comments on commit 2900f1c

Please sign in to comment.