mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:27:35 +00:00
Snake: Implement image-based skins
Co-authored-by: HawDevelopment <hawdevelopment@gmail.com>
This commit is contained in:
parent
da7c883dfa
commit
5708a47157
20 changed files with 425 additions and 33 deletions
28
Userland/Games/Snake/Skins/SnakeSkin.cpp
Normal file
28
Userland/Games/Snake/Skins/SnakeSkin.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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 <LibCore/DeprecatedFile.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 (Core::DeprecatedFile::exists(TRY(String::formatted("/res/graphics/snake/skins/{}", skin_name))))
|
||||
return ImageSkin::create(skin_name);
|
||||
|
||||
// Fall-back on classic
|
||||
return try_make<ClassicSkin>(color);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue