-
Notifications
You must be signed in to change notification settings - Fork 192
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
2 changed files
with
123 additions
and
121 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
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; | ||
}; | ||
} |
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 |
---|---|---|
@@ -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; | ||
}; | ||
} |