Kaynağa Gözat

Font ported to underscore naming convention

Daniele Bartolini 12 yıl önce
ebeveyn
işleme
1f8251b929
2 değiştirilmiş dosya ile 32 ekleme ve 53 silme
  1. 17 27
      src/Font.cpp
  2. 15 26
      src/Font.h

+ 17 - 27
src/Font.cpp

@@ -23,48 +23,38 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Font.h"
-#include "MathUtils.h"
 #include "Types.h"
-#include "Image.h"
-#include "Log.h"
-#include "Filesystem.h"
+#include "Font.h"
 
 namespace crown
 {
 
-FontResource::FontResource() :
-	mMaxTextHeight(0),
-	mMaxCharacterHeight(0),
-	mMaxCharacterWidth(0)
+//-----------------------------------------------------------------------------
+void* FontResource::load(Allocator& allocator, ResourceArchive& archive, ResourceId id)
 {
+	(void)allocator;
+	(void)archive;
+	(void)id;
+
+	return NULL;
 }
 
-FontResource::~FontResource()
+//-----------------------------------------------------------------------------
+void FontResource::online(void* resource)
 {
+	(void)resource;
 }
 
-Glyph& FontResource::GetGlyph(uint32_t code)
+//-----------------------------------------------------------------------------
+void FontResource::unload(Allocator& allocator, void* resource)
 {
-	if (mCodeGlyphDict.Contains(code))
-	{
-		return mCodeGlyphDict[code];
-	}
-
-	static Glyph nullGlyph;
-	return nullGlyph;
+	(void)allocator;
+	(void)resource;
 }
 
-void FontResource::SetCodeGlyphMetrics(uint32_t code, float left, float right, float bottom, float top, float width, float height, float advance, float baseline)
+//-----------------------------------------------------------------------------
+void FontResource::offline()
 {
-	if (mCodeGlyphDict.Contains(code))
-	{
-		mCodeGlyphDict[code].SetMetrics(left, right, bottom, top, width, height, advance, baseline);
-	}
-	else
-	{
-		mCodeGlyphDict[code] = Glyph(code, left, right, bottom, top, width, height, advance, baseline);
-	}
 }
 
 } // namespace crown

+ 15 - 26
src/Font.h

@@ -26,49 +26,38 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "List.h"
-#include "Dictionary.h"
 #include "Glyph.h"
 #include "Resource.h"
-#include "Image.h"
 
 namespace crown
 {
 
-class Image;
-class Texture;
+class Allocator;
+class ResourceArchive;
 
-/**
-	Font resource for using in text rendering.
-*/
 class FontResource
 {
-
-	typedef Dictionary<uint32_t, Glyph> CodeGlyphDict;
-
 public:
 
-							FontResource();
-							~FontResource();
+	static void*		load(Allocator& allocator, ResourceArchive& archive, ResourceId id);
+	static void			online(void* resource);
+	static void			unload(Allocator& allocator, void* resource);
+	static void			offline();
 
-	Glyph&					GetGlyph(uint32_t code);	//! Returns the glyph for the desired point32_t code
-	void					SetCodeGlyphMetrics(uint32_t code, float left, float right, float bottom, float top, float width, float height, float advance, float baseline);
+public:
 
-	inline uint32_t			_GetMaxTextHeight() { return mMaxTextHeight; }
-	inline uint32_t			_GetMaxCharacterHeight() { return mMaxCharacterHeight; }
-	inline uint32_t			_GetMaxCharacterWidth() { return mMaxCharacterWidth; }
+	/// Returns the glyph for the desired point32_t code
+	Glyph&					glyph(uint32_t code);
 
-	ResourceId				GetTexture() { return mTexture; }
+	inline uint32_t			mat_text_heigth() { return m_max_text_height; }
+	inline uint32_t			max_character_height() { return m_max_character_height; }
+	inline uint32_t			max_character_width() { return m_max_character_width; }
 
 private:
 
-	CodeGlyphDict			mCodeGlyphDict;
-
-	uint32_t				mMaxTextHeight;
-	uint32_t				mMaxCharacterHeight;
-	uint32_t				mMaxCharacterWidth;
-
-	ResourceId				mTexture;
+	uint32_t				m_max_text_height;
+	uint32_t				m_max_character_height;
+	uint32_t				m_max_character_width;
 };
 
 } // namespace crown