mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 17:17:45 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -638,11 +638,11 @@ ErrorOr<void> ChessWidget::export_pgn(Core::File& file) const
|
|||
// Tag Pair Section
|
||||
TRY(file.write_until_depleted("[Event \"Casual Game\"]\n"sv.bytes()));
|
||||
TRY(file.write_until_depleted("[Site \"SerenityOS Chess\"]\n"sv.bytes()));
|
||||
TRY(file.write_formatted("[Date \"{}\"]\n", Core::DateTime::now().to_deprecated_string("%Y.%m.%d"sv)));
|
||||
TRY(file.write_formatted("[Date \"{}\"]\n", Core::DateTime::now().to_byte_string("%Y.%m.%d"sv)));
|
||||
TRY(file.write_until_depleted("[Round \"1\"]\n"sv.bytes()));
|
||||
|
||||
auto current_user = TRY(Core::Account::self(Core::Account::Read::PasswdOnly));
|
||||
auto const username = TRY(String::from_deprecated_string(current_user.username()));
|
||||
auto const username = TRY(String::from_byte_string(current_user.username()));
|
||||
|
||||
auto const player1 = (!username.is_empty() ? username : "?"sv);
|
||||
auto const player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv : "?"sv);
|
||||
|
|
|
@ -147,7 +147,7 @@ void Game::show_score_card(bool game_over)
|
|||
title_builder.append("Score Card"sv);
|
||||
if (game_over)
|
||||
title_builder.append(" - Game Over"sv);
|
||||
score_dialog->set_title(title_builder.to_deprecated_string());
|
||||
score_dialog->set_title(title_builder.to_byte_string());
|
||||
|
||||
RefPtr<Core::Timer> close_timer;
|
||||
if (!m_players[0].is_human) {
|
||||
|
@ -160,7 +160,7 @@ void Game::show_score_card(bool game_over)
|
|||
score_dialog->exec();
|
||||
}
|
||||
|
||||
void Game::setup(DeprecatedString player_name, int hand_number)
|
||||
void Game::setup(ByteString player_name, int hand_number)
|
||||
{
|
||||
m_players[0].name = move(player_name);
|
||||
|
||||
|
@ -619,7 +619,7 @@ void Game::play_card(Player& player, size_t card_index)
|
|||
0);
|
||||
}
|
||||
|
||||
bool Game::is_valid_play(Player& player, Card& card, DeprecatedString* explanation) const
|
||||
bool Game::is_valid_play(Player& player, Card& card, ByteString* explanation) const
|
||||
{
|
||||
// First card must be 2 of Clubs.
|
||||
if (m_trick_number == 0 && m_trick.is_empty()) {
|
||||
|
@ -692,7 +692,7 @@ void Game::card_clicked_during_passing(size_t, Card& card)
|
|||
|
||||
void Game::card_clicked_during_play(size_t card_index, Card& card)
|
||||
{
|
||||
DeprecatedString explanation;
|
||||
ByteString explanation;
|
||||
if (!is_valid_play(m_players[0], card, &explanation)) {
|
||||
if (m_inverted_card)
|
||||
m_inverted_card->set_inverted(false);
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
virtual ~Game() override = default;
|
||||
|
||||
void setup(DeprecatedString player_name, int hand_number = 0);
|
||||
void setup(ByteString player_name, int hand_number = 0);
|
||||
|
||||
Function<void(String const&)> on_status_change;
|
||||
|
||||
|
@ -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, DeprecatedString* explanation = nullptr) const;
|
||||
bool is_valid_play(Player& player, Card& card, ByteString* explanation = nullptr) const;
|
||||
void let_player_play_card();
|
||||
void continue_game_after_delay(int interval_ms = 750);
|
||||
void advance_game();
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
Gfx::IntRect name_position;
|
||||
Gfx::TextAlignment name_alignment;
|
||||
Gfx::IntPoint taken_cards_target;
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
bool is_human { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -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 = DeprecatedString::formatted("{}", player.scores[score_index]);
|
||||
auto score_text = ByteString::formatted("{}", player.scores[score_index]);
|
||||
auto score_text_width = font.width_rounded_up(score_text);
|
||||
if (score_index != (int)player.scores.size() - 1) {
|
||||
painter.draw_line(
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
|
||||
SettingsDialog::SettingsDialog(GUI::Window* parent, DeprecatedString player_name)
|
||||
SettingsDialog::SettingsDialog(GUI::Window* parent, ByteString player_name)
|
||||
: GUI::Dialog(parent)
|
||||
, m_player_name(move(player_name))
|
||||
{
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
class SettingsDialog : public GUI::Dialog {
|
||||
C_OBJECT(SettingsDialog)
|
||||
public:
|
||||
DeprecatedString const& player_name() const { return m_player_name; }
|
||||
ByteString const& player_name() const { return m_player_name; }
|
||||
|
||||
private:
|
||||
SettingsDialog(GUI::Window* parent, DeprecatedString player_name);
|
||||
SettingsDialog(GUI::Window* parent, ByteString player_name);
|
||||
|
||||
DeprecatedString m_player_name { "Gunnar" };
|
||||
ByteString m_player_name { "Gunnar" };
|
||||
};
|
||||
|
|
|
@ -59,7 +59,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);
|
||||
|
||||
DeprecatedString player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv);
|
||||
ByteString player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv);
|
||||
|
||||
game.on_status_change = [&](String const& status) {
|
||||
statusbar.set_override_text(status);
|
||||
|
|
|
@ -40,7 +40,7 @@ void WordGame::reset()
|
|||
if (maybe_word.has_value())
|
||||
m_current_word = maybe_word.value();
|
||||
else {
|
||||
GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not get a random {} letter word. Defaulting to 5.", m_num_letters), "MasterWord"sv);
|
||||
GUI::MessageBox::show(window(), ByteString::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();
|
||||
|
@ -53,7 +53,7 @@ void WordGame::reset()
|
|||
|
||||
void WordGame::pick_font()
|
||||
{
|
||||
DeprecatedString best_font_name;
|
||||
ByteString best_font_name;
|
||||
auto best_font_size = -1;
|
||||
auto& font_database = Gfx::FontDatabase::the();
|
||||
font_database.for_each_font([&](Gfx::Font const& font) {
|
||||
|
@ -61,7 +61,7 @@ void WordGame::pick_font()
|
|||
return;
|
||||
auto size = font.pixel_size_rounded_up();
|
||||
if (size * 2 <= m_letter_height && size > best_font_size) {
|
||||
best_font_name = font.qualified_name().to_deprecated_string();
|
||||
best_font_name = font.qualified_name().to_byte_string();
|
||||
best_font_size = size;
|
||||
}
|
||||
});
|
||||
|
@ -80,7 +80,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 = DeprecatedString::formatted("{}{}", m_current_guess, event.text().to_uppercase());
|
||||
m_current_guess = ByteString::formatted("{}{}", m_current_guess, event.text().to_uppercase());
|
||||
m_last_word_invalid = false;
|
||||
}
|
||||
// If backspace pressed and already have some letters entered
|
||||
|
@ -107,7 +107,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(), DeprecatedString::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"sv);
|
||||
GUI::MessageBox::show(window(), ByteString::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"sv);
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ void WordGame::read_words()
|
|||
}
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> WordGame::random_word(size_t length)
|
||||
Optional<ByteString> WordGame::random_word(size_t length)
|
||||
{
|
||||
auto words_for_length = m_words.get(length);
|
||||
if (words_for_length.has_value()) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
void set_max_guesses(size_t max_guesses);
|
||||
Gfx::IntSize game_size() const;
|
||||
|
||||
Optional<DeprecatedString> random_word(size_t length);
|
||||
Optional<ByteString> random_word(size_t length);
|
||||
size_t shortest_word();
|
||||
size_t longest_word();
|
||||
bool is_checking_guesses() const;
|
||||
|
@ -77,15 +77,15 @@ private:
|
|||
};
|
||||
|
||||
struct Guess {
|
||||
AK::DeprecatedString text;
|
||||
AK::ByteString text;
|
||||
AK::Vector<LetterState> letter_states;
|
||||
};
|
||||
|
||||
AK::Vector<Guess> m_guesses;
|
||||
AK::DeprecatedString m_current_guess;
|
||||
AK::DeprecatedString m_current_word;
|
||||
AK::ByteString m_current_guess;
|
||||
AK::ByteString m_current_word;
|
||||
|
||||
HashMap<size_t, AK::Vector<DeprecatedString>> m_words;
|
||||
HashMap<size_t, AK::Vector<ByteString>> m_words;
|
||||
|
||||
NonnullRefPtr<Core::Timer> m_clear_message_timer;
|
||||
};
|
||||
|
|
|
@ -120,7 +120,7 @@ ErrorOr<NonnullRefPtr<Field>> Field::create(GUI::Label& flag_label, GUI::Label&
|
|||
field->m_good_face_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/graphics/minesweeper/face-good.png"sv));
|
||||
field->m_bad_face_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/graphics/minesweeper/face-bad.png"sv));
|
||||
for (int i = 0; i < 8; ++i)
|
||||
field->m_number_bitmap[i] = TRY(Gfx::Bitmap::load_from_file(DeprecatedString::formatted("/res/graphics/minesweeper/{}.png", i + 1)));
|
||||
field->m_number_bitmap[i] = TRY(Gfx::Bitmap::load_from_file(ByteString::formatted("/res/graphics/minesweeper/{}.png", i + 1)));
|
||||
field->initialize();
|
||||
return field;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ void Field::initialize()
|
|||
m_timer = Core::Timer::create_repeating(
|
||||
1000, [this] {
|
||||
++m_time_elapsed;
|
||||
m_time_label.set_text(String::from_deprecated_string(human_readable_digital_time(m_time_elapsed)).release_value_but_fixme_should_propagate_errors());
|
||||
m_time_label.set_text(String::from_byte_string(human_readable_digital_time(m_time_elapsed)).release_value_but_fixme_should_propagate_errors());
|
||||
},
|
||||
this)
|
||||
.release_value_but_fixme_should_propagate_errors();
|
||||
|
|
|
@ -66,7 +66,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
|
|||
}
|
||||
|
||||
auto color = Color::from_argb(Config::read_u32("Snake"sv, "Snake"sv, "BaseColor"sv, Color(Color::Green).value()));
|
||||
auto skin_name = TRY(String::from_deprecated_string(Config::read_string("Snake"sv, "Snake"sv, "SnakeSkin"sv, "Classic"sv)));
|
||||
auto skin_name = TRY(String::from_byte_string(Config::read_string("Snake"sv, "Snake"sv, "SnakeSkin"sv, "Classic"sv)));
|
||||
auto skin = TRY(SnakeSkin::create(skin_name, color));
|
||||
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) Game(move(food_bitmaps), color, skin_name, move(skin)));
|
||||
|
@ -275,7 +275,7 @@ void Game::game_over()
|
|||
text.append("\nThat's a new high score!"sv);
|
||||
}
|
||||
GUI::MessageBox::show(window(),
|
||||
text.to_deprecated_string(),
|
||||
text.to_byte_string(),
|
||||
"Game Over"sv,
|
||||
GUI::MessageBox::Type::Information);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Snake {
|
|||
|
||||
ErrorOr<NonnullOwnPtr<ImageSkin>> ImageSkin::create(StringView skin_name)
|
||||
{
|
||||
auto skin_directory = TRY(Core::Directory::create(DeprecatedString::formatted("/res/graphics/snake/skins/{}", skin_name), Core::Directory::CreateDirectories::No));
|
||||
auto skin_directory = TRY(Core::Directory::create(ByteString::formatted("/res/graphics/snake/skins/{}", skin_name), Core::Directory::CreateDirectories::No));
|
||||
|
||||
auto head = TRY(Gfx::Bitmap::load_from_file(TRY(skin_directory.open("head.png"sv, Core::File::OpenMode::Read)), "head.png"sv));
|
||||
Vector<NonnullRefPtr<Gfx::Bitmap>> head_bitmaps;
|
||||
|
|
|
@ -92,14 +92,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto const pause_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"sv));
|
||||
static String const continue_text = "&Continue Game"_string;
|
||||
auto const continue_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"sv));
|
||||
game_menu->add_action(GUI::Action::create(pause_text.to_deprecated_string(), { Mod_None, Key_Space }, pause_icon, [&](auto& action) {
|
||||
game_menu->add_action(GUI::Action::create(pause_text.to_byte_string(), { Mod_None, Key_Space }, pause_icon, [&](auto& action) {
|
||||
if (game.has_timer()) {
|
||||
game.pause();
|
||||
action.set_text(continue_text.to_deprecated_string());
|
||||
action.set_text(continue_text.to_byte_string());
|
||||
action.set_icon(continue_icon);
|
||||
} else {
|
||||
game.start();
|
||||
action.set_text(pause_text.to_deprecated_string());
|
||||
action.set_text(pause_text.to_byte_string());
|
||||
action.set_icon(pause_icon);
|
||||
}
|
||||
}));
|
||||
|
@ -129,7 +129,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto add_skin_action = [&](StringView name, bool enable_color) -> ErrorOr<void> {
|
||||
auto action = GUI::Action::create_checkable(name, GUI::Shortcut {}, [&, enable_color](auto& action) {
|
||||
Config::write_string("Snake"sv, "Snake"sv, "SnakeSkin"sv, action.text());
|
||||
game.set_skin_name(String::from_deprecated_string(action.text()).release_value_but_fixme_should_propagate_errors());
|
||||
game.set_skin_name(String::from_byte_string(action.text()).release_value_but_fixme_should_propagate_errors());
|
||||
change_snake_color->set_enabled(enable_color);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue