use text for bool representations
This commit is contained in:
@@ -550,7 +550,7 @@ void cDialog::handle_events() {
|
||||
dynamic_cast<cTextField&>(getControl(currentFocus)).handleInput(key, true);
|
||||
}else if(replaying && has_next_action("handleTab")){
|
||||
Element& next_action = pop_next_action();
|
||||
handleTab(boost::lexical_cast<bool>(next_action.GetText()));
|
||||
handleTab(str_to_bool(next_action.GetText()));
|
||||
}else if(replaying && has_next_action("field_focus")) {
|
||||
Element& next_action = pop_next_action();
|
||||
setFocus(&(dynamic_cast<cTextField&>(getControl(next_action.GetText()))));
|
||||
@@ -573,7 +573,7 @@ void cDialog::handle_events() {
|
||||
|
||||
void cDialog::handleTab(bool reverse) {
|
||||
if(recording){
|
||||
record_action("handleTab", boost::lexical_cast<std::string>(reverse));
|
||||
record_action("handleTab", bool_to_str(reverse));
|
||||
}
|
||||
if(reverse) {
|
||||
handleTabOrder(currentFocus, tabOrder.rbegin(), tabOrder.rend());
|
||||
|
@@ -253,7 +253,7 @@ void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw,
|
||||
if(record && recording){
|
||||
std::map<std::string,std::string> info;
|
||||
info["which_type"] = boost::lexical_cast<std::string>(which_type);
|
||||
info["spell_forced"] = boost::lexical_cast<std::string>(spell_forced);
|
||||
info["spell_forced"] = bool_to_str(spell_forced);
|
||||
record_action("handle_spellcast", info);
|
||||
}
|
||||
short store_sp[6];
|
||||
@@ -313,7 +313,7 @@ void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw,
|
||||
|
||||
void handle_begin_look(bool right_button, bool& need_redraw) {
|
||||
if(recording){
|
||||
record_action("handle_begin_look", boost::lexical_cast<std::string>(right_button));
|
||||
record_action("handle_begin_look", bool_to_str(right_button));
|
||||
}
|
||||
if(overall_mode == MODE_OUTDOORS) overall_mode = MODE_LOOK_OUTDOORS;
|
||||
if(overall_mode == MODE_TOWN) overall_mode = MODE_LOOK_TOWN;
|
||||
@@ -486,7 +486,7 @@ void handle_look(location destination, bool right_button, eKeyMod mods, bool& ne
|
||||
if(recording){
|
||||
std::map<std::string,std::string> info;
|
||||
info["destination"] = boost::lexical_cast<std::string>(destination);
|
||||
info["right_button"] = boost::lexical_cast<std::string>(right_button);
|
||||
info["right_button"] = bool_to_str(right_button);
|
||||
info["mods"] = boost::lexical_cast<std::string>(mods);
|
||||
record_action("handle_look", info);
|
||||
}
|
||||
|
@@ -390,12 +390,12 @@ static void replay_next_action() {
|
||||
short help1 = short_from_action(next_action);
|
||||
menu_give_help(help1);
|
||||
}else if(t == "handle_begin_look"){
|
||||
bool right_button = boost::lexical_cast<bool>(next_action.GetText());
|
||||
bool right_button = str_to_bool(next_action.GetText());
|
||||
handle_begin_look(right_button, need_redraw);
|
||||
}else if(t == "handle_look"){
|
||||
auto info = info_from_action(next_action);
|
||||
location destination = boost::lexical_cast<location>(info["destination"]);
|
||||
bool right_button = boost::lexical_cast<bool>(info["right_button"]);
|
||||
bool right_button = str_to_bool(info["right_button"]);
|
||||
eKeyMod mods = static_cast<eKeyMod>(std::stoi(info["mods"]));
|
||||
|
||||
handle_look(destination, right_button, mods, need_redraw, need_reprint);
|
||||
@@ -413,7 +413,7 @@ static void replay_next_action() {
|
||||
}else if(t == "handle_spellcast"){
|
||||
auto info = info_from_action(next_action);
|
||||
eSkill which_type = boost::lexical_cast<eSkill>(info["which_type"]);
|
||||
spell_forced = boost::lexical_cast<bool>(info["spell_forced"]);
|
||||
spell_forced = str_to_bool(info["spell_forced"]);
|
||||
|
||||
handle_spellcast(which_type, did_something, need_redraw, need_reprint);
|
||||
}else if(t == "handle_target_space"){
|
||||
|
@@ -9,6 +9,8 @@
|
||||
#ifndef BOE_PCH
|
||||
#define BOE_PCH
|
||||
|
||||
#include <string>
|
||||
|
||||
typedef unsigned short mon_num_t;
|
||||
typedef signed short miss_num_t;
|
||||
typedef unsigned short ter_num_t;
|
||||
@@ -26,4 +28,12 @@ const char* oboeVersionString();
|
||||
namespace boost { namespace filesystem {}}
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
inline bool str_to_bool(std::string str) {
|
||||
return str == "true";
|
||||
}
|
||||
|
||||
inline std::string bool_to_str(bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -97,7 +97,7 @@ void record_action(std::string action_type, std::map<std::string,std::string> in
|
||||
|
||||
void record_field_input(cKey key) {
|
||||
std::map<std::string,std::string> info;
|
||||
info["spec"] = boost::lexical_cast<std::string>(key.spec);
|
||||
info["spec"] = bool_to_str(key.spec);
|
||||
|
||||
if(key.spec){
|
||||
info["k"] = boost::lexical_cast<std::string>(key.k);
|
||||
@@ -190,7 +190,7 @@ cKey key_from_action(Element& action) {
|
||||
cKey key;
|
||||
int enum_v;
|
||||
|
||||
key.spec = boost::lexical_cast<bool>(info["spec"]);
|
||||
key.spec = str_to_bool(info["spec"]);
|
||||
|
||||
if(key.spec){
|
||||
enum_v = boost::lexical_cast<int>(info["k"]);
|
||||
@@ -218,7 +218,7 @@ word_rect_t word_rect_from_action(Element& action) {
|
||||
|
||||
word_rect.node = boost::lexical_cast<int>(info["node"]);
|
||||
|
||||
bool preset = boost::lexical_cast<bool>(info["preset"]);
|
||||
bool preset = str_to_bool(info["preset"]);
|
||||
word_rect.on = preset ? PRESET_WORD_ON : CUSTOM_WORD_ON;
|
||||
word_rect.off = preset ? PRESET_WORD_OFF : CUSTOM_WORD_OFF;
|
||||
return word_rect;
|
||||
@@ -230,7 +230,7 @@ void record_click_talk_rect(word_rect_t word_rect, bool preset) {
|
||||
info["word"] = word_rect.word;
|
||||
info["rect"] = boost::lexical_cast<std::string>(word_rect.rect);
|
||||
info["node"] = boost::lexical_cast<std::string>(word_rect.node);
|
||||
info["preset"] = boost::lexical_cast<std::string>(preset);
|
||||
info["preset"] = bool_to_str(preset);
|
||||
|
||||
record_action("click_talk_rect", info);
|
||||
}
|
Reference in New Issue
Block a user