mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 20:45:06 +00:00

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.
28 lines
706 B
C++
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);
|
|
}
|
|
|
|
}
|