1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 20:45:06 +00:00
serenity/Userland/Games/Snake/Skins/SnakeSkin.cpp
Cubic Love a7600caea1 Base+Snake: Capitalize snake skin names
In Snake, the menu for choosing a skin looked messy due to
inconsistent capitalization. Two skins names were entirely lowercase.
For the sprite-based skins, the menu takes the name of each skin's
directory, so I have capitalized these.

Capitalizing the original snake skin required more change than simply
renaming a directory.
2023-05-06 22:19:41 +02:00

28 lines
706 B
C++

/*
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "SnakeSkin.h"
#include "ClassicSkin.h"
#include "ImageSkin.h"
#include <AK/String.h>
#include <LibFileSystem/FileSystem.h>
namespace Snake {
ErrorOr<NonnullOwnPtr<SnakeSkin>> SnakeSkin::create(StringView skin_name, Color color)
{
if (skin_name == "Classic"sv)
return try_make<ClassicSkin>(color);
// Try to find an image-based skin matching the name.
if (FileSystem::exists(TRY(String::formatted("/res/graphics/snake/skins/{}", skin_name))))
return ImageSkin::create(skin_name);
// Fall-back on classic
return try_make<ClassicSkin>(color);
}
}