Skip to content

Commit

Permalink
Add missing headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vieiraa committed Sep 12, 2020
1 parent 921ac20 commit 6885139
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 121 deletions.
113 changes: 57 additions & 56 deletions apps/freeablo/fagui/menu/menuscreen.h
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
#pragma once
#include <functional>
#include <queue>
#include <vector>

struct nk_context;

namespace Engine
{
enum class KeyboardInputAction;
}

namespace FAGui
{
class MenuHandler;
enum class MenuFontColor;

class MenuScreen
{
protected:
enum class [[nodiscard]] DrawFunctionResult{
executeAction,
setActive,
noAction,
};
enum class [[nodiscard]] ActionResult{
stopDrawing,
continueDrawing,
};
class MenuItem
{
public:
std::function<DrawFunctionResult(nk_context* ctx, bool isActive)> drawFunction;
std::function<ActionResult()> action;
};

public:
explicit MenuScreen(MenuHandler& menu);
virtual ~MenuScreen();
virtual void update(nk_context* ctx) = 0;
void notify(Engine::KeyboardInputAction action);

protected:
static void menuText(nk_context* ctx, const char* text, MenuFontColor color, int fontSize, uint32_t textAlignment);
ActionResult drawMenuItems(nk_context* ctx);
ActionResult executeActive();
ActionResult applyInputAction(Engine::KeyboardInputAction action);

protected:
MenuHandler& mMenuHandler;
std::function<ActionResult()> mRejectAction;
std::vector<MenuItem> mMenuItems;
std::queue<Engine::KeyboardInputAction> mInputActions;
int mActiveItemIndex = 0;
};
}
#pragma once
#include <cstdint>
#include <functional>
#include <queue>
#include <vector>

struct nk_context;

namespace Engine
{
enum class KeyboardInputAction;
}

namespace FAGui
{
class MenuHandler;
enum class MenuFontColor;

class MenuScreen
{
protected:
enum class [[nodiscard]] DrawFunctionResult{
executeAction,
setActive,
noAction,
};
enum class [[nodiscard]] ActionResult{
stopDrawing,
continueDrawing,
};
class MenuItem
{
public:
std::function<DrawFunctionResult(nk_context* ctx, bool isActive)> drawFunction;
std::function<ActionResult()> action;
};

public:
explicit MenuScreen(MenuHandler& menu);
virtual ~MenuScreen();
virtual void update(nk_context* ctx) = 0;
void notify(Engine::KeyboardInputAction action);

protected:
static void menuText(nk_context* ctx, const char* text, MenuFontColor color, int fontSize, uint32_t textAlignment);
ActionResult drawMenuItems(nk_context* ctx);
ActionResult executeActive();
ActionResult applyInputAction(Engine::KeyboardInputAction action);

protected:
MenuHandler& mMenuHandler;
std::function<ActionResult()> mRejectAction;
std::vector<MenuItem> mMenuItems;
std::queue<Engine::KeyboardInputAction> mInputActions;
int mActiveItemIndex = 0;
};
}
131 changes: 66 additions & 65 deletions apps/freeablo/farender/fontinfo.h
Original file line number Diff line number Diff line change
@@ -1,65 +1,66 @@
#pragma once
#include "fa_nuklear.h"
#include <array>

namespace DiabloExe
{
class FontData;
}

namespace FARender
{
class CelFontInfo
{
private:
using self = CelFontInfo;

public:
static const int charCount = 256;
nk_user_font nkFont;

private:
std::array<int, charCount> widthPx;
std::array<float, charCount> uvLeft, uvWidth;
int mSpacing;

private:
void initByFontData(const DiabloExe::FontData& fontData, int textureWidthPx, int spacing);
static float getWidth(nk_handle handle, float h, const char* s, int len);
static void queryGlyph(nk_handle handle, float font_height, struct nk_user_font_glyph* glyph, nk_rune codepoint, nk_rune next_codepoint);
friend class Renderer;
};

struct PcxFontInitData
{
int32_t fontSize;
int32_t textureWidth;
int32_t textureHeight;
int32_t spacingX;
int32_t spacingY;
enum class LayoutOrder
{
horizontal,
vertical
} fontDirection;
};

class PcxFontInfo
{
private:
using self = PcxFontInfo;

public:
nk_user_font nkFont;

private:
static const int charCount = 256;
std::array<struct nk_user_font_glyph, charCount> mGlyphs;

private:
void init(const std::string& binPath, const PcxFontInitData& fontInitData);
static float getWidth(nk_handle handle, float h, const char* s, int len);
static void queryGlyph(nk_handle handle, float font_height, struct nk_user_font_glyph* glyph, nk_rune codepoint, nk_rune next_codepoint);
friend class Renderer;
};
}
#pragma once
#include "fa_nuklear.h"
#include <array>
#include <string>

namespace DiabloExe
{
class FontData;
}

namespace FARender
{
class CelFontInfo
{
private:
using self = CelFontInfo;

public:
static const int charCount = 256;
nk_user_font nkFont;

private:
std::array<int, charCount> widthPx;
std::array<float, charCount> uvLeft, uvWidth;
int mSpacing;

private:
void initByFontData(const DiabloExe::FontData& fontData, int textureWidthPx, int spacing);
static float getWidth(nk_handle handle, float h, const char* s, int len);
static void queryGlyph(nk_handle handle, float font_height, struct nk_user_font_glyph* glyph, nk_rune codepoint, nk_rune next_codepoint);
friend class Renderer;
};

struct PcxFontInitData
{
int32_t fontSize;
int32_t textureWidth;
int32_t textureHeight;
int32_t spacingX;
int32_t spacingY;
enum class LayoutOrder
{
horizontal,
vertical
} fontDirection;
};

class PcxFontInfo
{
private:
using self = PcxFontInfo;

public:
nk_user_font nkFont;

private:
static const int charCount = 256;
std::array<struct nk_user_font_glyph, charCount> mGlyphs;

private:
void init(const std::string& binPath, const PcxFontInitData& fontInitData);
static float getWidth(nk_handle handle, float h, const char* s, int len);
static void queryGlyph(nk_handle handle, float font_height, struct nk_user_font_glyph* glyph, nk_rune codepoint, nk_rune next_codepoint);
friend class Renderer;
};
}

0 comments on commit 6885139

Please sign in to comment.