Skip to content

Commit

Permalink
MP Lobby: used specific colors instead of pango presets
Browse files Browse the repository at this point in the history
The Pango presets are usually a little darker than we want, so this makes the colors POP.
  • Loading branch information
Vultraz committed May 4, 2018
1 parent 65a554f commit 3d15813
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/gui/dialogs/multiplayer/lobby.cpp
Expand Up @@ -42,6 +42,7 @@

#include "addon/manager_ui.hpp"
#include "chat_log.hpp"
#include "font/text_formatting.hpp"
#include "formatter.hpp"
#include "formula/string_utils.hpp"
#include "preferences/game.hpp"
Expand Down Expand Up @@ -210,13 +211,9 @@ void modify_grid_with_data(grid* grid, const std::map<std::string, string_map>&
}
}

std::string colorize(const std::string& str, const std::string& color)
std::string colorize(const std::string& str, const color_t& color)
{
if(color.empty()) {
return str;
}

return (formatter() << "<span color=\"" << color << "\">" << str << "</span>").str();
return (formatter() << font::span_color(color) << str << "</span>").str();
}

bool handle_addon_requirements_gui(const std::vector<mp::game_info::required_addon>& reqs, mp::game_info::ADDON_REQ addon_outcome)
Expand Down Expand Up @@ -421,15 +418,15 @@ std::map<std::string, string_map> mp_lobby::make_game_row_data(const mp::game_in

item["use_markup"] = "true";

std::string color_string;
color_t color_string;
if(game.vacant_slots > 0) {
color_string = (game.reloaded || game.started) ? "yellow" : "green";
color_string = (game.reloaded || game.started) ? font::YELLOW_COLOR : font::GOOD_COLOR;
}

item["label"] = game.name;
data.emplace("name", item);

item["label"] = colorize("<i>" + game.scenario + "</i>", font::GRAY_COLOR.to_hex_string());
item["label"] = colorize("<i>" + game.scenario + "</i>", font::GRAY_COLOR);
data.emplace("scenario", item);

item["label"] = colorize(game.status, color_string);
Expand Down Expand Up @@ -601,12 +598,12 @@ void mp_lobby::update_playerlist()
target_list = &player_list_.other_rooms;
break;
case mp::user_info::SEL_GAME:
name = colorize(name, "cyan");
name = colorize(name, {0, 255, 255});
icon_ss << (user.observing ? "-obs" : "-playing");
target_list = &player_list_.active_game;
break;
case mp::user_info::GAME:
name = colorize(name, "red");
name = colorize(name, font::BAD_COLOR);
icon_ss << (user.observing ? "-obs" : "-playing");
target_list = &player_list_.other_games;
break;
Expand Down

0 comments on commit 3d15813

Please sign in to comment.