-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
148 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "Font.h" | ||
|
||
namespace LUS { | ||
Font::Font() : Resource(std::shared_ptr<ResourceInitData>()) { | ||
} | ||
|
||
Font::~Font() { | ||
if (Data != nullptr) { | ||
delete Data; | ||
} | ||
} | ||
|
||
void* Font::GetPointer() { | ||
return Data; | ||
} | ||
|
||
size_t Font::GetPointerSize() { | ||
return DataSize * sizeof(char); | ||
} | ||
} // namespace LUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "resource/Resource.h" | ||
|
||
namespace LUS { | ||
#define RESOURCE_TYPE_FONT 0x464F4E54 // FONT | ||
|
||
class Font : public Resource<void> { | ||
public: | ||
using Resource::Resource; | ||
|
||
Font(); | ||
~Font(); | ||
|
||
void* GetPointer() override; | ||
size_t GetPointerSize() override; | ||
|
||
char* Data = nullptr; | ||
size_t DataSize; | ||
}; | ||
}; // namespace LUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "window/gui/resource/FontFactory.h" | ||
#include "window/gui/resource/Font.h" | ||
#include "spdlog/spdlog.h" | ||
|
||
namespace LUS { | ||
std::shared_ptr<IResource> ResourceFactoryBinaryFontV0::ReadResource(std::shared_ptr<File> file) { | ||
if (!FileHasValidFormatAndReader(file)) { | ||
return nullptr; | ||
} | ||
|
||
auto font = std::make_shared<Font>(file->InitData); | ||
auto reader = std::get<std::shared_ptr<BinaryReader>>(file->Reader); | ||
|
||
font->DataSize = file->Buffer->size(); | ||
|
||
font->Data = new char[font->DataSize]; | ||
reader->Read(font->Data, font->DataSize); | ||
|
||
// for (uint32_t i = 0; i < dataSize; i++) { | ||
// font->Data.push_back(reader->ReadChar()); | ||
// } | ||
|
||
return font; | ||
} | ||
} // namespace LUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include "resource/Resource.h" | ||
#include "resource/ResourceFactoryBinary.h" | ||
|
||
namespace LUS { | ||
class ResourceFactoryBinaryFontV0 : public ResourceFactoryBinary { | ||
public: | ||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) override; | ||
}; | ||
}; // namespace LUS |