Merge branch 'pull_1_fixes'
This commit is contained in:
commit
9cd27ce482
6 changed files with 43 additions and 23 deletions
|
@ -260,9 +260,11 @@ void remove_acquaintance(const std::string& nick) {
|
|||
}
|
||||
}
|
||||
|
||||
bool is_friend(const std::string& nick) {
|
||||
bool is_friend(const std::string& nick)
|
||||
{
|
||||
load_acquaintances();
|
||||
std::map<std::string, acquaintance>::iterator it = acquaintances.find(nick);
|
||||
const std::map<std::string, acquaintance
|
||||
>::const_iterator it = acquaintances.find(nick);
|
||||
|
||||
if(it == acquaintances.end()) {
|
||||
return false;
|
||||
|
@ -271,9 +273,11 @@ bool is_friend(const std::string& nick) {
|
|||
}
|
||||
}
|
||||
|
||||
bool is_ignored(const std::string& nick) {
|
||||
bool is_ignored(const std::string& nick)
|
||||
{
|
||||
load_acquaintances();
|
||||
std::map<std::string, acquaintance>::iterator it = acquaintances.find(nick);
|
||||
const std::map<std::string, acquaintance
|
||||
>::const_iterator it = acquaintances.find(nick);
|
||||
|
||||
if(it == acquaintances.end()) {
|
||||
return false;
|
||||
|
|
|
@ -267,7 +267,7 @@ class acquaintance;
|
|||
class acquaintance {
|
||||
public:
|
||||
|
||||
explicit acquaintance()
|
||||
acquaintance()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -276,29 +276,34 @@ public:
|
|||
load_from_config(cfg);
|
||||
}
|
||||
|
||||
explicit acquaintance(const std::string &nick, const std::string status, const std::string notes):
|
||||
nick_(nick), status_(status), notes_(notes)
|
||||
acquaintance(
|
||||
const std::string& nick
|
||||
, const std::string& status
|
||||
, const std::string& notes)
|
||||
: nick_(nick)
|
||||
, status_(status)
|
||||
, notes_(notes)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void load_from_config(const config& cfg);
|
||||
|
||||
const std::string get_nick() const { return nick_; };
|
||||
const std::string get_status() const { return status_; };
|
||||
const std::string get_notes() const { return notes_; };
|
||||
const std::string& get_nick() const { return nick_; };
|
||||
const std::string& get_status() const { return status_; };
|
||||
const std::string& get_notes() const { return notes_; };
|
||||
|
||||
void save(config& cfg);
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
// acquaintance's MP nick
|
||||
/** acquaintance's MP nick */
|
||||
std::string nick_;
|
||||
|
||||
// status (e.g., "friend", "ignore")
|
||||
/**status (e.g., "friend", "ignore") */
|
||||
std::string status_;
|
||||
|
||||
// notes on the acquaintance
|
||||
/** notes on the acquaintance */
|
||||
std::string notes_;
|
||||
|
||||
};
|
||||
|
|
|
@ -953,7 +953,7 @@ void preferences_dialog::process_event()
|
|||
set_selection(MULTIPLAYER_TAB);
|
||||
|
||||
if (friends_add_friend_button_.pressed()) {
|
||||
std::string notes = "";
|
||||
std::string notes;
|
||||
std::string username = friends_input_.text();
|
||||
size_t pos = username.find_first_of(' ');
|
||||
|
||||
|
@ -970,7 +970,7 @@ void preferences_dialog::process_event()
|
|||
}
|
||||
}
|
||||
if (friends_add_ignore_button_.pressed()) {
|
||||
std::string reason = "";
|
||||
std::string reason;
|
||||
std::string username = friends_input_.text();
|
||||
size_t pos = username.find_first_of(' ');
|
||||
|
||||
|
|
|
@ -2290,11 +2290,10 @@ void chat_command_handler::do_ignore()
|
|||
const std::map<std::string, std::string>& tmp = preferences::get_acquaintances_nice("ignore");
|
||||
print(_("ignores list"), tmp.empty() ? _("(empty)") : utils::join_map(tmp, ")\n", " (") + ")");
|
||||
} else {
|
||||
std::string reason = get_data(2);
|
||||
utils::string_map symbols;
|
||||
symbols["nick"] = get_arg(1);
|
||||
|
||||
if (preferences::add_ignore(get_arg(1), reason)) {
|
||||
if (preferences::add_ignore(get_arg(1), get_data(2))) {
|
||||
print(_("ignores list"), VGETTEXT("Added to ignore list: $nick", symbols));
|
||||
chat_handler_.user_relation_changed(get_arg(1));
|
||||
} else {
|
||||
|
@ -2309,11 +2308,10 @@ void chat_command_handler::do_friend()
|
|||
const std::map<std::string, std::string>& tmp = preferences::get_acquaintances_nice("friend");
|
||||
print(_("friends list"), tmp.empty() ? _("(empty)") : utils::join_map(tmp, ")\n", " (") + ")");
|
||||
} else {
|
||||
std::string notes = get_data(2);
|
||||
utils::string_map symbols;
|
||||
symbols["nick"] = get_arg(1);
|
||||
|
||||
if (preferences::add_friend(get_arg(1), notes)) {
|
||||
if (preferences::add_friend(get_arg(1), get_data(2))) {
|
||||
print(_("friends list"), VGETTEXT("Added to friends list: $nick", symbols));
|
||||
chat_handler_.user_relation_changed(get_arg(1));
|
||||
} else {
|
||||
|
|
|
@ -301,7 +301,12 @@ std::vector< std::string > square_parenthetical_split(std::string const &val,
|
|||
return res;
|
||||
}
|
||||
|
||||
std::map< std::string, std::string > map_split(std::string const &val, char major, char minor, int flags, std::string const default_value)
|
||||
std::map< std::string, std::string > map_split(
|
||||
std::string const &val
|
||||
, char major
|
||||
, char minor
|
||||
, int flags
|
||||
, std::string const& default_value)
|
||||
{
|
||||
//first split by major so that we get a vector with the key-value pairs
|
||||
std::vector< std::string > v = split(val, major, flags);
|
||||
|
|
|
@ -64,7 +64,12 @@ std::vector< std::string > split(std::string const &val, const char c = ',', con
|
|||
* c => d
|
||||
* e => f
|
||||
*/
|
||||
std::map< std::string, std::string > map_split(std::string const &val, char major = ',', char minor = ':', int flags = REMOVE_EMPTY | STRIP_SPACES, std::string const default_value = "");
|
||||
std::map< std::string, std::string > map_split(
|
||||
std::string const &val
|
||||
, char major = ','
|
||||
, char minor = ':'
|
||||
, int flags = REMOVE_EMPTY | STRIP_SPACES
|
||||
, std::string const& default_value = "");
|
||||
|
||||
/**
|
||||
* Splits a string based either on a separator where text within parenthesis
|
||||
|
@ -136,7 +141,10 @@ std::string join(T const &v, const std::string& s = ",")
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
std::string join_map(T const &v, std::string major = ",", std::string minor = ":")
|
||||
std::string join_map(
|
||||
const T& v
|
||||
, const std::string& major = ","
|
||||
, const std::string& minor = ":")
|
||||
{
|
||||
std::stringstream str;
|
||||
for(typename T::const_iterator i = v.begin(); i != v.end(); ++i) {
|
||||
|
|
Loading…
Add table
Reference in a new issue