1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:47:34 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -45,7 +45,7 @@ void BoardView::set_board(Game::Board const* board)
void BoardView::pick_font()
{
String best_font_name;
DeprecatedString best_font_name;
int best_font_size = -1;
auto& font_database = Gfx::FontDatabase::the();
font_database.for_each_font([&](Gfx::Font const& font) {
@ -234,7 +234,7 @@ void BoardView::paint_event(GUI::PaintEvent& event)
auto rect = Gfx::IntRect::centered_on(center, tile_size);
painter.fill_rect(rect, background_color_for_cell(sliding_tile.value_from));
painter.draw_text(rect, String::number(sliding_tile.value_from), font(), Gfx::TextAlignment::Center, text_color_for_cell(sliding_tile.value_from));
painter.draw_text(rect, DeprecatedString::number(sliding_tile.value_from), font(), Gfx::TextAlignment::Center, text_color_for_cell(sliding_tile.value_from));
}
} else {
for (size_t column = 0; column < columns(); ++column) {
@ -249,7 +249,7 @@ void BoardView::paint_event(GUI::PaintEvent& event)
auto entry = tiles[row][column];
painter.fill_rect(rect, background_color_for_cell(entry));
if (entry > 0)
painter.draw_text(rect, String::number(entry), font(), Gfx::TextAlignment::Center, text_color_for_cell(entry));
painter.draw_text(rect, DeprecatedString::number(entry), font(), Gfx::TextAlignment::Center, text_color_for_cell(entry));
}
}
}

View file

@ -6,9 +6,9 @@
#include "Game.h"
#include <AK/Array.h>
#include <AK/DeprecatedString.h>
#include <AK/NumericLimits.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <stdlib.h>
Game::Game(size_t grid_size, size_t target_tile, bool evil_ai)

View file

@ -33,7 +33,7 @@ GameSizeDialog::GameSizeDialog(GUI::Window* parent, size_t board_size, size_t ta
board_size_spinbox->set_value(m_board_size);
auto tile_value_label = main_widget.find_descendant_of_type_named<GUI::Label>("tile_value_label");
tile_value_label->set_text(String::number(target_tile()));
tile_value_label->set_text(DeprecatedString::number(target_tile()));
auto target_spinbox = main_widget.find_descendant_of_type_named<GUI::SpinBox>("target_spinbox");
target_spinbox->set_max(Game::max_power_for_board(m_board_size));
target_spinbox->set_value(m_target_tile_power);
@ -45,7 +45,7 @@ GameSizeDialog::GameSizeDialog(GUI::Window* parent, size_t board_size, size_t ta
target_spinbox->on_change = [this, tile_value_label](auto value) {
m_target_tile_power = value;
tile_value_label->set_text(String::number(target_tile()));
tile_value_label->set_text(DeprecatedString::number(target_tile()));
};
auto evil_ai_checkbox = main_widget.find_descendant_of_type_named<GUI::CheckBox>("evil_ai_checkbox");

View file

@ -90,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto update = [&]() {
board_view->set_board(&game.board());
board_view->update();
statusbar->set_text(String::formatted("Score: {}", game.score()));
statusbar->set_text(DeprecatedString::formatted("Score: {}", game.score()));
};
update();
@ -149,7 +149,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
case Game::MoveOutcome::Won: {
update();
auto want_to_continue = GUI::MessageBox::show(window,
String::formatted("You won the game in {} turns with a score of {}. Would you like to continue?", game.turns(), game.score()),
DeprecatedString::formatted("You won the game in {} turns with a score of {}. Would you like to continue?", game.turns(), game.score()),
"Congratulations!"sv,
GUI::MessageBox::Type::Question,
GUI::MessageBox::InputType::YesNo);
@ -162,7 +162,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
case Game::MoveOutcome::GameOver:
update();
GUI::MessageBox::show(window,
String::formatted("You reached {} in {} turns with a score of {}", game.largest_tile(), game.turns(), game.score()),
DeprecatedString::formatted("You reached {} in {} turns with a score of {}", game.largest_tile(), game.turns(), game.score()),
"You lost!"sv,
GUI::MessageBox::Type::Information);
start_a_new_game();

View file

@ -496,7 +496,7 @@ void BrickGame::paint_cell(GUI::Painter& painter, Gfx::IntRect rect, bool is_on)
painter.fill_rect(rect, is_on ? m_front_color : m_shadow_color);
}
void BrickGame::paint_text(GUI::Painter& painter, int row, String const& text)
void BrickGame::paint_text(GUI::Painter& painter, int row, DeprecatedString const& text)
{
auto const text_width { font().width(text) };
auto const entire_area_rect { frame_inner_rect() };
@ -541,9 +541,9 @@ void BrickGame::paint_game(GUI::Painter& painter, Gfx::IntRect const& rect)
paint_cell(painter, cell_rect(position), (*m_brick_game)[board_position]);
}
paint_text(painter, 0, String::formatted("Score: {}", m_brick_game->score()));
paint_text(painter, 1, String::formatted("Level: {}", m_brick_game->level()));
paint_text(painter, 4, String::formatted("Hi-Score: {}", m_high_score));
paint_text(painter, 0, DeprecatedString::formatted("Score: {}", m_brick_game->score()));
paint_text(painter, 1, DeprecatedString::formatted("Level: {}", m_brick_game->level()));
paint_text(painter, 4, DeprecatedString::formatted("Hi-Score: {}", m_high_score));
paint_text(painter, 12, "Next:");
auto const hint_rect = Gfx::IntRect {

View file

@ -25,7 +25,7 @@ private:
virtual void keydown_event(GUI::KeyEvent&) override;
virtual void timer_event(Core::TimerEvent&) override;
void paint_text(GUI::Painter&, int row, String const&);
void paint_text(GUI::Painter&, int row, DeprecatedString const&);
void paint_cell(GUI::Painter&, Gfx::IntRect, bool);
void paint_game(GUI::Painter&, Gfx::IntRect const&);
void game_over();

View file

@ -6,8 +6,8 @@
#include "ChessWidget.h"
#include "PromotionDialog.h"
#include <AK/DeprecatedString.h>
#include <AK/Random.h>
#include <AK/String.h>
#include <LibCore/DateTime.h>
#include <LibCore/File.h>
#include <LibGUI/MessageBox.h>
@ -370,7 +370,7 @@ void ChessWidget::keydown_event(GUI::KeyEvent& event)
update();
}
static String set_path = String("/res/icons/chess/sets/");
static DeprecatedString set_path = DeprecatedString("/res/icons/chess/sets/");
static RefPtr<Gfx::Bitmap> get_piece(StringView set, StringView image)
{
@ -521,7 +521,7 @@ void ChessWidget::playback_move(PlaybackDirection direction)
update();
}
String ChessWidget::get_fen() const
DeprecatedString ChessWidget::get_fen() const
{
return m_playback ? m_board_playback.to_fen() : m_board.to_fen();
}
@ -547,10 +547,10 @@ void ChessWidget::import_pgn(Core::File& file)
bool recursive_annotation = false;
bool future_expansion = false;
Chess::Color turn = Chess::Color::White;
String movetext;
DeprecatedString movetext;
for (size_t j = i; j < lines.size(); j++)
movetext = String::formatted("{}{}", movetext, lines.at(i).to_string());
movetext = DeprecatedString::formatted("{}{}", movetext, lines.at(i).to_string());
for (auto token : movetext.split(' ')) {
token = token.trim_whitespace();
@ -626,16 +626,16 @@ void ChessWidget::export_pgn(Core::File& file) const
// Tag Pair Section
file.write("[Event \"Casual Game\"]\n"sv);
file.write("[Site \"SerenityOS Chess\"]\n"sv);
file.write(String::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_string("%Y.%m.%d"sv)));
file.write(DeprecatedString::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_string("%Y.%m.%d"sv)));
file.write("[Round \"1\"]\n"sv);
String username(getlogin());
const String player1 = (!username.is_empty() ? username.view() : "?"sv);
const String player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv : "?"sv);
file.write(String::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2));
file.write(String::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2));
DeprecatedString username(getlogin());
const DeprecatedString player1 = (!username.is_empty() ? username.view() : "?"sv);
const DeprecatedString player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv : "?"sv);
file.write(DeprecatedString::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2));
file.write(DeprecatedString::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2));
file.write(String::formatted("[Result \"{}\"]\n", Chess::Board::result_to_points(m_board.game_result(), m_board.turn())));
file.write(DeprecatedString::formatted("[Result \"{}\"]\n", Chess::Board::result_to_points(m_board.game_result(), m_board.turn())));
file.write("[WhiteElo \"?\"]\n"sv);
file.write("[BlackElo \"?\"]\n"sv);
file.write("[Variant \"Standard\"]\n"sv);
@ -645,13 +645,13 @@ void ChessWidget::export_pgn(Core::File& file) const
// Movetext Section
for (size_t i = 0, move_no = 1; i < m_board.moves().size(); i += 2, move_no++) {
const String white = m_board.moves().at(i).to_algebraic();
const DeprecatedString white = m_board.moves().at(i).to_algebraic();
if (i + 1 < m_board.moves().size()) {
const String black = m_board.moves().at(i + 1).to_algebraic();
file.write(String::formatted("{}. {} {} ", move_no, white, black));
const DeprecatedString black = m_board.moves().at(i + 1).to_algebraic();
file.write(DeprecatedString::formatted("{}. {} {} ", move_no, white, black));
} else {
file.write(String::formatted("{}. {} ", move_no, white));
file.write(DeprecatedString::formatted("{}. {} ", move_no, white));
}
}
@ -688,7 +688,7 @@ int ChessWidget::resign()
set_drag_enabled(false);
update();
const String msg = Chess::Board::result_to_string(m_board.game_result(), m_board.turn());
const DeprecatedString msg = Chess::Board::result_to_string(m_board.game_result(), m_board.turn());
GUI::MessageBox::show(window(), msg, "Game Over"sv, GUI::MessageBox::Type::Information);
return 0;

View file

@ -36,7 +36,7 @@ public:
void set_side(Chess::Color side) { m_side = side; };
void set_piece_set(StringView set);
String const& piece_set() const { return m_piece_set; };
DeprecatedString const& piece_set() const { return m_piece_set; };
Chess::Square mouse_to_square(GUI::MouseEvent& event) const;
@ -47,7 +47,7 @@ public:
bool show_available_moves() const { return m_show_available_moves; }
void set_show_available_moves(bool e) { m_show_available_moves = e; }
String get_fen() const;
DeprecatedString get_fen() const;
void import_pgn(Core::File&);
void export_pgn(Core::File&) const;
@ -56,7 +56,7 @@ public:
void reset();
struct BoardTheme {
String name;
DeprecatedString name;
Color dark_square_color;
Color light_square_color;
};
@ -120,7 +120,7 @@ private:
Color m_marking_secondary_color { Color::from_argb(0x6655dd55) };
Chess::Color m_side { Chess::Color::White };
HashMap<Chess::Piece, RefPtr<Gfx::Bitmap>> m_pieces;
String m_piece_set;
DeprecatedString m_piece_set;
Chess::Square m_moving_square { 50, 50 };
Gfx::IntPoint m_drag_point;
bool m_dragging_piece { false };

View file

@ -36,7 +36,7 @@ Engine::Engine(StringView command)
posix_spawn_file_actions_adddup2(&file_actions, wpipefds[0], STDIN_FILENO);
posix_spawn_file_actions_adddup2(&file_actions, rpipefds[1], STDOUT_FILENO);
String cstr(command);
DeprecatedString cstr(command);
char const* argv[] = { cstr.characters(), nullptr };
if (posix_spawnp(&m_pid, cstr.characters(), &file_actions, nullptr, const_cast<char**>(argv), environ) < 0) {
perror("posix_spawnp");

View file

@ -169,7 +169,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
});
engines_action_group.add_action(*action);
if (engine == String("Human"))
if (engine == DeprecatedString("Human"))
action->set_checked(true);
TRY(engine_submenu->try_add_action(*action));

View file

@ -71,9 +71,9 @@ void Game::paint_event(GUI::PaintEvent& event)
painter.draw_scaled_bitmap(enclosing_int_rect(m_bug.rect()), *m_bug.current_bitmap(), m_bug.flapping_bitmap->rect());
if (m_active) {
painter.draw_text(m_score_rect, String::formatted("{:.0}", m_difficulty), Gfx::TextAlignment::TopLeft, Color::White);
painter.draw_text(m_score_rect, DeprecatedString::formatted("{:.0}", m_difficulty), Gfx::TextAlignment::TopLeft, Color::White);
} else if (m_high_score.has_value()) {
auto message = String::formatted("Your score: {:.0}\nHigh score: {:.0}\n\n{}", m_last_score, m_high_score.value(), m_restart_cooldown < 0 ? "Press any key to play again" : " ");
auto message = DeprecatedString::formatted("Your score: {:.0}\nHigh score: {:.0}\n\n{}", m_last_score, m_high_score.value(), m_restart_cooldown < 0 ? "Press any key to play again" : " ");
painter.draw_text(m_text_rect, message, Gfx::TextAlignment::Center, Color::White);
} else {
painter.draw_text(m_text_rect, "Press any key to start"sv, Gfx::TextAlignment::Center, Color::White);

View file

@ -46,7 +46,7 @@ SettingsDialog::SettingsDialog(GUI::Window* parent, size_t board_rows, size_t bo
m_board_columns = value;
};
static Vector<String> color_scheme_names;
static Vector<DeprecatedString> color_scheme_names;
color_scheme_names.clear();
Core::DirIterator iterator("/res/terminal-colors", Core::DirIterator::SkipParentAndBaseDir);
while (iterator.has_next()) {
@ -57,7 +57,7 @@ SettingsDialog::SettingsDialog(GUI::Window* parent, size_t board_rows, size_t bo
auto color_scheme_combo = main_widget.find_descendant_of_type_named<GUI::ComboBox>("color_scheme_combo");
color_scheme_combo->set_only_allow_values_from_model(true);
color_scheme_combo->set_model(*GUI::ItemListModel<String>::create(color_scheme_names));
color_scheme_combo->set_model(*GUI::ItemListModel<DeprecatedString>::create(color_scheme_names));
color_scheme_combo->set_selected_index(color_scheme_names.find_first_index(m_color_scheme).value());
color_scheme_combo->set_enabled(color_scheme_names.size() > 1);
color_scheme_combo->on_change = [&](auto&, const GUI::ModelIndex& index) {

View file

@ -21,5 +21,5 @@ private:
size_t m_board_rows;
size_t m_board_columns;
String m_color_scheme;
DeprecatedString m_color_scheme;
};

View file

@ -42,10 +42,10 @@ static ErrorOr<Vector<Color>> get_color_scheme_from_string(StringView name)
"White"sv
};
auto const path = String::formatted("/res/terminal-colors/{}.ini", name);
auto const path = DeprecatedString::formatted("/res/terminal-colors/{}.ini", name);
auto color_config_or_error = Core::ConfigFile::open(path);
if (color_config_or_error.is_error()) {
return Error::from_string_view(String::formatted("Unable to read color scheme file '{}': {}", path, color_config_or_error.error()));
return Error::from_string_view(DeprecatedString::formatted("Unable to read color scheme file '{}': {}", path, color_config_or_error.error()));
}
auto const color_config = color_config_or_error.release_value();
Vector<Color> colors;
@ -118,7 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
size_t board_rows = Config::read_i32("Flood"sv, ""sv, "board_rows"sv, 16);
size_t board_columns = Config::read_i32("Flood"sv, ""sv, "board_columns"sv, 16);
String color_scheme = Config::read_string("Flood"sv, ""sv, "color_scheme"sv, "Default"sv);
DeprecatedString color_scheme = Config::read_string("Flood"sv, ""sv, "color_scheme"sv, "Default"sv);
Config::write_i32("Flood"sv, ""sv, "board_rows"sv, board_rows);
Config::write_i32("Flood"sv, ""sv, "board_columns"sv, board_columns);
@ -155,7 +155,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto update = [&]() {
board_widget->update();
statusbar->set_text(String::formatted("Moves remaining: {}", ai_moves - moves_made));
statusbar->set_text(DeprecatedString::formatted("Moves remaining: {}", ai_moves - moves_made));
};
update();
@ -198,12 +198,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
board_widget->board()->update_values();
update();
if (board_widget->board()->is_flooded()) {
String dialog_text("You have tied with the AI."sv);
DeprecatedString dialog_text("You have tied with the AI."sv);
auto dialog_title("Congratulations!"sv);
if (ai_moves - moves_made == 1)
dialog_text = "You defeated the AI by 1 move."sv;
else if (ai_moves - moves_made > 1)
dialog_text = String::formatted("You defeated the AI by {} moves.", ai_moves - moves_made);
dialog_text = DeprecatedString::formatted("You defeated the AI by {} moves.", ai_moves - moves_made);
else
dialog_title = "Game over!"sv;
GUI::MessageBox::show(window,

View file

@ -255,7 +255,7 @@ void BoardWidget::place_pattern(size_t row, size_t column)
void BoardWidget::setup_patterns()
{
auto add_pattern = [&](String name, NonnullOwnPtr<Pattern> pattern) {
auto add_pattern = [&](DeprecatedString name, NonnullOwnPtr<Pattern> pattern) {
auto action = GUI::Action::create(move(name), [this, pattern = pattern.ptr()](const GUI::Action&) {
on_pattern_selection(pattern);
});
@ -263,29 +263,29 @@ void BoardWidget::setup_patterns()
m_patterns.append(move(pattern));
};
Vector<String> blinker = {
Vector<DeprecatedString> blinker = {
"OOO"
};
Vector<String> toad = {
Vector<DeprecatedString> toad = {
".OOO",
"OOO."
};
Vector<String> glider = {
Vector<DeprecatedString> glider = {
".O.",
"..O",
"OOO",
};
Vector<String> lightweight_spaceship = {
Vector<DeprecatedString> lightweight_spaceship = {
".OO..",
"OOOO.",
"OO.OO",
"..OO."
};
Vector<String> middleweight_spaceship = {
Vector<DeprecatedString> middleweight_spaceship = {
".OOOOO",
"O....O",
".....O",
@ -293,7 +293,7 @@ void BoardWidget::setup_patterns()
"..O..."
};
Vector<String> heavyweight_spaceship = {
Vector<DeprecatedString> heavyweight_spaceship = {
"..OO...",
"O....O.",
"......O",
@ -301,9 +301,9 @@ void BoardWidget::setup_patterns()
".OOOOOO"
};
Vector<String> infinite_1 = { "OOOOOOOO.OOOOO...OOO......OOOOOOO.OOOOO" };
Vector<DeprecatedString> infinite_1 = { "OOOOOOOO.OOOOO...OOO......OOOOOOO.OOOOO" };
Vector<String> infinite_2 = {
Vector<DeprecatedString> infinite_2 = {
"......O.",
"....O.OO",
"....O.O.",
@ -312,7 +312,7 @@ void BoardWidget::setup_patterns()
"O.O....."
};
Vector<String> infinite_3 = {
Vector<DeprecatedString> infinite_3 = {
"OOO.O",
"O....",
"...OO",
@ -320,7 +320,7 @@ void BoardWidget::setup_patterns()
"O.O.O"
};
Vector<String> simkin_glider_gun = {
Vector<DeprecatedString> simkin_glider_gun = {
"OO.....OO........................",
"OO.....OO........................",
".................................",
@ -343,7 +343,7 @@ void BoardWidget::setup_patterns()
".....................OOO.........",
".......................O........."
};
Vector<String> gosper_glider_gun = {
Vector<DeprecatedString> gosper_glider_gun = {
"........................O...........",
"......................O.O...........",
"............OO......OO............OO",
@ -355,19 +355,19 @@ void BoardWidget::setup_patterns()
"............OO......................"
};
Vector<String> r_pentomino = {
Vector<DeprecatedString> r_pentomino = {
".OO",
"OO.",
".O."
};
Vector<String> diehard = {
Vector<DeprecatedString> diehard = {
"......O.",
"OO......",
".O...OOO"
};
Vector<String> acorn = {
Vector<DeprecatedString> acorn = {
".O.....",
"...O...",
"OO..OOO"

View file

@ -6,13 +6,13 @@
*/
#include "Pattern.h"
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibGUI/Action.h>
#include <stdio.h>
Pattern::Pattern(Vector<String> pattern)
Pattern::Pattern(Vector<DeprecatedString> pattern)
{
m_pattern = move(pattern);
}
@ -24,7 +24,7 @@ void Pattern::set_action(GUI::Action* action)
void Pattern::rotate_clockwise()
{
Vector<String> rotated;
Vector<DeprecatedString> rotated;
for (size_t i = 0; i < m_pattern.first().length(); i++) {
StringBuilder builder;
for (int j = m_pattern.size() - 1; j >= 0; j--) {

View file

@ -14,13 +14,13 @@
class Pattern final {
public:
Pattern(Vector<String>);
Vector<String> pattern() { return m_pattern; };
Pattern(Vector<DeprecatedString>);
Vector<DeprecatedString> pattern() { return m_pattern; };
GUI::Action* action() { return m_action; }
void set_action(GUI::Action*);
void rotate_clockwise();
private:
RefPtr<GUI::Action> m_action;
Vector<String> m_pattern;
Vector<DeprecatedString> m_pattern;
};

View file

@ -162,7 +162,7 @@ void Game::show_score_card(bool game_over)
score_dialog->exec();
}
void Game::setup(String player_name, int hand_number)
void Game::setup(DeprecatedString player_name, int hand_number)
{
m_players[0].name = move(player_name);
@ -409,7 +409,7 @@ void Game::let_player_play_card()
if (&player == &m_players[0])
on_status_change("Select a card to play.");
else
on_status_change(String::formatted("Waiting for {} to play a card...", player));
on_status_change(DeprecatedString::formatted("Waiting for {} to play a card...", player));
if (player.is_human) {
m_human_can_play = true;
@ -618,7 +618,7 @@ void Game::play_card(Player& player, size_t card_index)
0);
}
bool Game::is_valid_play(Player& player, Card& card, String* explanation) const
bool Game::is_valid_play(Player& player, Card& card, DeprecatedString* explanation) const
{
// First card must be 2 of Clubs.
if (m_trick_number == 0 && m_trick.is_empty()) {
@ -691,14 +691,14 @@ void Game::card_clicked_during_passing(size_t, Card& card)
void Game::card_clicked_during_play(size_t card_index, Card& card)
{
String explanation;
DeprecatedString explanation;
if (!is_valid_play(m_players[0], card, &explanation)) {
if (m_inverted_card)
m_inverted_card->set_inverted(false);
card.set_inverted(true);
update(card.rect());
m_inverted_card = card;
on_status_change(String::formatted("You can't play this card: {}", explanation));
on_status_change(DeprecatedString::formatted("You can't play this card: {}", explanation));
continue_game_after_delay();
return;
}

View file

@ -26,9 +26,9 @@ public:
virtual ~Game() override = default;
void setup(String player_name, int hand_number = 0);
void setup(DeprecatedString player_name, int hand_number = 0);
Function<void(String const&)> on_status_change;
Function<void(DeprecatedString const&)> on_status_change;
private:
Game();
@ -41,7 +41,7 @@ private:
void play_card(Player& player, size_t card_index);
bool are_hearts_broken() const;
bool is_valid_play(Player& player, Card& card, String* explanation = nullptr) const;
bool is_valid_play(Player& player, Card& card, DeprecatedString* explanation = nullptr) const;
void let_player_play_card();
void continue_game_after_delay(int interval_ms = 750);
void advance_game();

View file

@ -55,7 +55,7 @@ public:
Gfx::IntRect name_position;
Gfx::TextAlignment name_alignment;
Gfx::IntPoint taken_cards_target;
String name;
DeprecatedString name;
bool is_human { false };
};

View file

@ -70,7 +70,7 @@ void ScoreCard::paint_event(GUI::PaintEvent& event)
text_color);
for (int score_index = 0; score_index < (int)player.scores.size(); score_index++) {
auto text_rect = cell_rect(player_index, 1 + score_index);
auto score_text = String::formatted("{}", player.scores[score_index]);
auto score_text = DeprecatedString::formatted("{}", player.scores[score_index]);
auto score_text_width = font.width(score_text);
if (score_index != (int)player.scores.size() - 1) {
painter.draw_line(

View file

@ -10,7 +10,7 @@
#include <LibGUI/Label.h>
#include <LibGUI/TextBox.h>
SettingsDialog::SettingsDialog(GUI::Window* parent, String player_name)
SettingsDialog::SettingsDialog(GUI::Window* parent, DeprecatedString player_name)
: GUI::Dialog(parent)
, m_player_name(move(player_name))
{

View file

@ -12,10 +12,10 @@
class SettingsDialog : public GUI::Dialog {
C_OBJECT(SettingsDialog)
public:
String const& player_name() const { return m_player_name; }
DeprecatedString const& player_name() const { return m_player_name; }
private:
SettingsDialog(GUI::Window* parent, String player_name);
SettingsDialog(GUI::Window* parent, DeprecatedString player_name);
String m_player_name { "Gunnar" };
DeprecatedString m_player_name { "Gunnar" };
};

View file

@ -58,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& statusbar = *widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
statusbar.set_text(0, "Score: 0");
String player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv);
DeprecatedString player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv);
game.on_status_change = [&](const AK::StringView& status) {
statusbar.set_override_text(status);

View file

@ -36,7 +36,7 @@ void WordGame::reset()
if (maybe_word.has_value())
m_current_word = maybe_word.value();
else {
GUI::MessageBox::show(window(), String::formatted("Could not get a random {} letter word. Defaulting to 5.", m_num_letters), "MasterWord"sv);
GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not get a random {} letter word. Defaulting to 5.", m_num_letters), "MasterWord"sv);
if (m_num_letters != 5) {
m_num_letters = 5;
reset();
@ -47,7 +47,7 @@ void WordGame::reset()
void WordGame::pick_font()
{
String best_font_name;
DeprecatedString best_font_name;
auto best_font_size = -1;
auto& font_database = Gfx::FontDatabase::the();
font_database.for_each_font([&](Gfx::Font const& font) {
@ -74,7 +74,7 @@ void WordGame::keydown_event(GUI::KeyEvent& event)
{
// If we can still add a letter and the key was alpha
if (m_current_guess.length() < m_num_letters && is_ascii_alpha(event.code_point())) {
m_current_guess = String::formatted("{}{}", m_current_guess, event.text().to_uppercase());
m_current_guess = DeprecatedString::formatted("{}{}", m_current_guess, event.text().to_uppercase());
m_last_word_not_in_dictionary = false;
}
// If backspace pressed and already have some letters entered
@ -93,7 +93,7 @@ void WordGame::keydown_event(GUI::KeyEvent& event)
GUI::MessageBox::show(window(), "You win!"sv, "MasterWord"sv);
reset();
} else if (m_guesses.size() == m_max_guesses) {
GUI::MessageBox::show(window(), String::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"sv);
GUI::MessageBox::show(window(), DeprecatedString::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"sv);
reset();
}
} else {
@ -180,7 +180,7 @@ void WordGame::read_words()
}
}
Optional<String> WordGame::random_word(size_t length)
Optional<DeprecatedString> WordGame::random_word(size_t length)
{
auto words_for_length = m_words.get(length);
if (words_for_length.has_value()) {

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
#include <LibGUI/Frame.h>
#include <LibGfx/Rect.h>
@ -24,7 +24,7 @@ public:
void set_max_guesses(size_t max_guesses);
Gfx::IntSize game_size() const;
Optional<String> random_word(size_t length);
Optional<DeprecatedString> random_word(size_t length);
size_t shortest_word();
size_t longest_word();
bool is_checking_guesses() const;
@ -67,13 +67,13 @@ private:
};
struct Guess {
AK::String text;
AK::DeprecatedString text;
AK::Vector<LetterState> letter_states;
};
AK::Vector<Guess> m_guesses;
AK::String m_current_guess;
AK::String m_current_word;
AK::DeprecatedString m_current_guess;
AK::DeprecatedString m_current_word;
HashMap<size_t, AK::Vector<String>> m_words;
HashMap<size_t, AK::Vector<DeprecatedString>> m_words;
};

View file

@ -69,11 +69,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(settings_menu->try_add_action(GUI::Action::create("Set &Word Length", [&](auto&) {
auto word_length = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5);
auto word_length_string = String::number(word_length);
auto word_length_string = DeprecatedString::number(word_length);
if (GUI::InputBox::show(window, word_length_string, "Word length:"sv, "MasterWord"sv) == GUI::InputBox::ExecResult::OK && !word_length_string.is_empty()) {
auto maybe_word_length = word_length_string.template to_uint();
if (!maybe_word_length.has_value() || maybe_word_length.value() < shortest_word || maybe_word_length.value() > longest_word) {
GUI::MessageBox::show(window, String::formatted("Please enter a number between {} and {}.", shortest_word, longest_word), "MasterWord"sv);
GUI::MessageBox::show(window, DeprecatedString::formatted("Please enter a number between {} and {}.", shortest_word, longest_word), "MasterWord"sv);
return;
}
@ -85,7 +85,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
})));
TRY(settings_menu->try_add_action(GUI::Action::create("Set &Number Of Guesses", [&](auto&) {
auto max_guesses = Config::read_i32("MasterWord"sv, ""sv, "max_guesses"sv, 5);
auto max_guesses_string = String::number(max_guesses);
auto max_guesses_string = DeprecatedString::number(max_guesses);
if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:"sv, "MasterWord"sv) == GUI::InputBox::ExecResult::OK && !max_guesses_string.is_empty()) {
auto maybe_max_guesses = max_guesses_string.template to_uint();
if (!maybe_max_guesses.has_value() || maybe_max_guesses.value() < 1 || maybe_max_guesses.value() > 20) {

View file

@ -127,7 +127,7 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b
m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png"sv).release_value_but_fixme_should_propagate_errors();
m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png"sv).release_value_but_fixme_should_propagate_errors();
for (int i = 0; i < 8; ++i)
m_number_bitmap[i] = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)).release_value_but_fixme_should_propagate_errors();
m_number_bitmap[i] = Gfx::Bitmap::try_load_from_file(DeprecatedString::formatted("/res/icons/minesweeper/{}.png", i + 1)).release_value_but_fixme_should_propagate_errors();
// Square with mine will be filled with background color later, i.e. red
m_mine_palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040));
@ -202,7 +202,7 @@ void Field::reset()
m_time_elapsed = 0;
m_time_label.set_text("00:00");
m_flags_left = m_mine_count;
m_flag_label.set_text(String::number(m_flags_left));
m_flag_label.set_text(DeprecatedString::number(m_flags_left));
m_timer->stop();
set_greedy_for_hits(false);
set_face(Face::Default);
@ -415,7 +415,7 @@ void Field::set_flag(Square& square, bool flag)
}
square.has_flag = flag;
m_flag_label.set_text(String::number(m_flags_left));
m_flag_label.set_text(DeprecatedString::number(m_flags_left));
square.button->set_icon(square.has_flag ? m_flag_bitmap : nullptr);
square.button->update();
}
@ -427,7 +427,7 @@ void Field::on_square_middle_clicked(Square& square)
if (square.has_flag) {
++m_flags_left;
square.has_flag = false;
m_flag_label.set_text(String::number(m_flags_left));
m_flag_label.set_text(DeprecatedString::number(m_flags_left));
}
square.is_considering = !square.is_considering;
square.button->set_icon(square.is_considering ? m_consider_bitmap : nullptr);

View file

@ -50,7 +50,7 @@ SnakeGame::SnakeGame()
reset();
m_high_score = Config::read_i32("Snake"sv, "Snake"sv, "HighScore"sv, 0);
m_high_score_text = String::formatted("Best: {}", m_high_score);
m_high_score_text = DeprecatedString::formatted("Best: {}", m_high_score);
}
void SnakeGame::reset()
@ -148,11 +148,11 @@ void SnakeGame::timer_event(Core::TimerEvent&)
if (m_head == m_fruit) {
++m_length;
++m_score;
m_score_text = String::formatted("Score: {}", m_score);
m_score_text = DeprecatedString::formatted("Score: {}", m_score);
if (m_score > m_high_score) {
m_is_new_high_score = true;
m_high_score = m_score;
m_high_score_text = String::formatted("Best: {}", m_high_score);
m_high_score_text = DeprecatedString::formatted("Best: {}", m_high_score);
update(high_score_rect());
Config::write_i32("Snake"sv, "Snake"sv, "HighScore"sv, m_high_score);
}

View file

@ -65,9 +65,9 @@ private:
size_t m_length { 0 };
unsigned m_score { 0 };
String m_score_text;
DeprecatedString m_score_text;
unsigned m_high_score { 0 };
String m_high_score_text;
DeprecatedString m_high_score_text;
bool m_is_new_high_score { false };
NonnullRefPtrVector<Gfx::Bitmap> m_food_bitmaps;

View file

@ -83,7 +83,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& statusbar = *widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
statusbar.set_text(0, "Score: 0");
statusbar.set_text(1, String::formatted("High Score: {}", high_score()));
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
statusbar.set_text(2, "Time: 00:00:00");
app->on_action_enter = [&](GUI::Action& action) {
@ -98,7 +98,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
game.on_score_update = [&](uint32_t score) {
statusbar.set_text(0, String::formatted("Score: {}", score));
statusbar.set_text(0, DeprecatedString::formatted("Score: {}", score));
};
uint64_t seconds_elapsed = 0;
@ -110,7 +110,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
uint64_t minutes = (seconds_elapsed / 60) % 60;
uint64_t seconds = seconds_elapsed % 60;
statusbar.set_text(2, String::formatted("Time: {:02}:{:02}:{:02}", hours, minutes, seconds));
statusbar.set_text(2, DeprecatedString::formatted("Time: {:02}:{:02}:{:02}", hours, minutes, seconds));
});
game.on_game_start = [&]() {
@ -125,13 +125,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (reason == Solitaire::GameOverReason::Victory) {
if (seconds_elapsed >= 30) {
uint32_t bonus = (20'000 / seconds_elapsed) * 35;
statusbar.set_text(0, String::formatted("Score: {} (Bonus: {})", score, bonus));
statusbar.set_text(0, DeprecatedString::formatted("Score: {} (Bonus: {})", score, bonus));
score += bonus;
}
if (score > high_score()) {
update_high_score(score);
statusbar.set_text(1, String::formatted("High Score: {}", score));
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", score));
}
}
statusbar.set_text(2, "Timer starts after your first move");
@ -160,7 +160,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto single_card_draw_action = GUI::Action::create_checkable("&Single Card Draw", [&](auto&) {
update_mode(Solitaire::Mode::SingleCardDraw);
statusbar.set_text(1, String::formatted("High Score: {}", high_score()));
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
game.setup(mode);
});
single_card_draw_action->set_checked(mode == Solitaire::Mode::SingleCardDraw);
@ -169,7 +169,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto three_card_draw_action = GUI::Action::create_checkable("&Three Card Draw", [&](auto&) {
update_mode(Solitaire::Mode::ThreeCardDraw);
statusbar.set_text(1, String::formatted("High Score: {}", high_score()));
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
game.setup(mode);
});
three_card_draw_action->set_checked(mode == Solitaire::Mode::ThreeCardDraw);

View file

@ -29,13 +29,13 @@ enum class StatisticDisplay : u8 {
__Count
};
static String format_seconds(uint64_t seconds_elapsed)
static DeprecatedString format_seconds(uint64_t seconds_elapsed)
{
uint64_t hours = seconds_elapsed / 3600;
uint64_t minutes = (seconds_elapsed / 60) % 60;
uint64_t seconds = seconds_elapsed % 60;
return String::formatted("{:02}:{:02}:{:02}", hours, minutes, seconds);
return DeprecatedString::formatted("{:02}:{:02}:{:02}", hours, minutes, seconds);
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -126,10 +126,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto reset_statistic_status = [&]() {
switch (statistic_display) {
case StatisticDisplay::HighScore:
statusbar.set_text(1, String::formatted("High Score: {}", high_score()));
statusbar.set_text(1, DeprecatedString::formatted("High Score: {}", high_score()));
break;
case StatisticDisplay::BestTime:
statusbar.set_text(1, String::formatted("Best Time: {}", format_seconds(best_time())));
statusbar.set_text(1, DeprecatedString::formatted("Best Time: {}", format_seconds(best_time())));
break;
default:
VERIFY_NOT_REACHED();
@ -152,7 +152,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
game.on_score_update = [&](uint32_t score) {
statusbar.set_text(0, String::formatted("Score: {}", score));
statusbar.set_text(0, DeprecatedString::formatted("Score: {}", score));
};
uint64_t seconds_elapsed = 0;
@ -160,7 +160,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto timer = Core::Timer::create_repeating(1000, [&]() {
++seconds_elapsed;
statusbar.set_text(2, String::formatted("Time: {}", format_seconds(seconds_elapsed)));
statusbar.set_text(2, DeprecatedString::formatted("Time: {}", format_seconds(seconds_elapsed)));
});
game.on_game_start = [&]() {