Moves internal_font functionality into the data_manager

core_refactor
Joey Pollack 4 years ago
parent b42b0c69a0
commit 25efe7411d

@ -74,7 +74,6 @@ set(LUNARIUM_SRC
"src/graphics/opengl/glGraphics.cpp"
"src/graphics/opengl/glText.cpp"
"src/graphics/opengl/glShader.cpp"
"src/internal_data/internal_font.cpp"
"src/internal_data/data_manager.cpp"
"src/input/keyboard.cpp"
"src/input/input_manager.cpp"

@ -26,6 +26,8 @@ Core:
✔ Read the window size and position on shutdown and write these to the state file @done (2/8/2022, 4:39:37 PM)
Graphics:
☐ Move the openGL reference out of the Image class (OpenGL ID) and make the ID more generic
☐ Add layer to interface API for setting the Images ID in a generic way
☐ Implement batch rendering
✔ Decide on a font/text rendering system @done (9/7/2021, 1:39:53 PM)
✔ Add FreeType to the project @done (9/7/2021, 2:23:13 PM)
@ -108,14 +110,14 @@ Utils:
Assets:
✔ Internal Asset Manager @high @done (1/25/2022, 3:58:20 PM)
☐ Document Index.Dat and the AssetIndex class
☐ Move the GenerateFont method from internal_font.h into data_manager.h
Types:
- Classes that represent each resource Types
✔ Image class @done (9/16/2021, 2:46:34 PM)
✔ Decouple Image class from OGLRenderer @high @done (10/27/2021, 7:41:50 PM)
✔ Decouple Image class from OGLRenderer @high @done (10/27/2021, 7:41:50 PM)
☐ Font class
☐ Sound class
✔ Script class @done (1/25/2022, 3:58:28 PM)

@ -28,7 +28,11 @@ Game:
To support larger region sizes without needing single images that are like 1048576x1048576 or some nonsense.]
Game Object:
☐ List of components
✘ List of components @cancelled(22-05-16 20:01)
Enitity:
☐ Single UUID
☐ Functionality for adding/working with components (through EnTT)
Components:
☐ Transform

@ -10,14 +10,19 @@
#include "data_manager.h"
#include <core/core.h>
#include <utils/logger.h>
#include <graphics/graphics.h>
#include <assets/types/image.h>
// ASSETS
#include "data_headers/open_font.h"
#include "data_headers/roboto_font.h"
#include "data_headers/folder16.h"
#include "data_headers/new_dir_icon.h"
#include "data_headers/up_arrow_icon.h"
#include <fstream>
namespace lunarium
{
// Init asset pointers
@ -77,4 +82,33 @@ namespace lunarium
delete mNewFolderIcon;
delete mFolderIcon;
}
bool DataManager::GenerateFontFileAt(Font font, const char * filename)
{
std::ofstream ofs(filename, std::ios_base::binary);
if (!ofs.is_open())
{
Logger::Warn(LogCategory::GRAPHICS, "Could not generate the default font file at: %s", filename);
return false;
}
switch (font)
{
case Font::F_OPEN:
ofs.write((const char*)OpenFontData, OpenDataSize);
break;
case Font::F_ROBOTO:
ofs.write((const char*)RobotoFontData, RobotoDataSize);
break;
}
ofs.close();
ofs.clear();
return true;
}
}

@ -13,6 +13,12 @@
namespace lunarium
{
enum Font
{
F_OPEN,
F_ROBOTO,
};
class Image;
class DataManager
{
@ -22,6 +28,8 @@ namespace lunarium
static void Shutdown();
static bool GenerateFontFileAt(Font font, const char* filename);
// DATA wrapped in asset types
static Image* mFolderIcon;
static Image* mNewFolderIcon;

@ -1,47 +0,0 @@
/******************************************************************************
* File - Internal_font.h
* Author - Joey Pollack
* Date - 2020/01/08 (y/m/d)
* Mod Date - 2021/09/07 (y/m/d)
* Description - Generates a font file (from OpenSans-Regular.ttf)
*
******************************************************************************/
#include "internal_font.h"
#include "data_headers/open_font.h"
#include "data_headers/roboto_font.h"
#include <utils/logger.h>
#include <fstream>
namespace lunarium
{
bool GenerateFontFileAt(Font font, const char * filename)
{
std::ofstream ofs(filename, std::ios_base::binary);
if (!ofs.is_open())
{
Logger::Warn(LogCategory::GRAPHICS, "Could not generate the default font file at: %s", filename);
return false;
}
switch (font)
{
case Font::F_OPEN:
ofs.write((const char*)OpenFontData, OpenDataSize);
break;
case Font::F_ROBOTO:
ofs.write((const char*)RobotoFontData, RobotoDataSize);
break;
}
ofs.close();
ofs.clear();
return true;
}
}

@ -1,23 +0,0 @@
/******************************************************************************
* File - internal_font.h
* Author - Joey Pollack
* Date - 2020/01/08 (y/m/d)
* Mod Date - 2020/01/08 (y/m/d)
* Description - Generates a font file (from OpenSans-Regular.ttf)
*
******************************************************************************/
#ifndef INTERNAL_FONT_H_
#define INTERNAL_FONT_H_
namespace lunarium
{
enum Font
{
F_OPEN,
F_ROBOTO,
};
bool GenerateFontFileAt(Font font, const char* filename);
}
#endif // INTERNAL_FONT_H_

@ -9,6 +9,7 @@
#include "image.h"
#include <cstring>
#include <utils/logger.h>
namespace lunarium
{
@ -120,6 +121,7 @@ namespace lunarium
void Image::SetGLTextureID(unsigned int id)
{
Logger::Debug(LogCategory::GRAPHICS, "GLTexture ID set for Image");
mGLTextureID = id;
}

@ -14,7 +14,7 @@
#include "dearimgui/imgui.h"
#include "dearimgui/imgui_impl_glfw.h"
#include "dearimgui/imgui_impl_opengl3.h"
#include <internal_data/internal_font.h>
#include <internal_data/data_manager.h>
namespace lunarium
{
@ -57,7 +57,7 @@ namespace lunarium
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// NOTE: Generating a font file for now. Late might look into loading directly from memory
GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf");
DataManager::GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf");
//io.Fonts->AddFontFromFileTTF("open.ttf", 16.0f);
io.Fonts->AddFontFromFileTTF("robo.ttf", 18.0f);
//io.Fonts->AddFontFromFileTTF("Karla-Regular.ttf", 16.0f);

Loading…
Cancel
Save