Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Feb 14, 2024
1 parent 2f35d86 commit 73ff5eb
Showing 1 changed file with 40 additions and 7 deletions.
47 changes: 40 additions & 7 deletions Quake/expmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,60 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

extern "C"
{

#include "quakedef.h"
#include "ls_common.h"
}


#ifdef USE_LUA_SCRIPTING

enum LS_ImGuiType
{
IMTYPE_BOOL,
IMTYPE_INT,
IMTYPE_FLOAT,
IMTYPE_DIR,
IMTYPE_VEC2,
IMTYPE_VEC4,
};

struct LS_ImGuiMember
{
size_t offset:24;
size_t type:8;
size_t offset:24;
};

//#define LS_IMGUI_DEFINE_MEMBER(TYPENAME, MEMBERNAME, TYPE) { #MEMBERNAME, { offsetof(TYPENAME, MEMBERNAME) } }
template <typename T>
constexpr LS_ImGuiType LS_GetImGuiType(T value = T());

template <> constexpr LS_ImGuiType LS_GetImGuiType(bool value) { return IMTYPE_BOOL ; }
template <> constexpr LS_ImGuiType LS_GetImGuiType(int value) { return IMTYPE_INT ; }
template <> constexpr LS_ImGuiType LS_GetImGuiType(float value) { return IMTYPE_FLOAT; }
template <> constexpr LS_ImGuiType LS_GetImGuiType(ImVec2 value) { return IMTYPE_VEC2 ; }
template <> constexpr LS_ImGuiType LS_GetImGuiType(ImVec4 value) { return IMTYPE_VEC4 ; }

#define LS_IMGUI_MEMBER(TYPENAME, MEMBERNAME) \
{ #MEMBERNAME, { LS_GetImGuiType<decltype(TYPENAME::MEMBERNAME)>(), offsetof(TYPENAME, MEMBERNAME) } }

constexpr frozen::unordered_map<frozen::string, LS_ImGuiMember, 2> ls_imguistyle_members =
constexpr frozen::unordered_map<frozen::string, LS_ImGuiMember, 8> ls_imguistyle_members =
{
{ "Alpha", { offsetof(ImGuiStyle, Alpha), IMTYPE_FLOAT } },
{ "DisabledAlpha", { offsetof(ImGuiStyle, DisabledAlpha), IMTYPE_FLOAT } },
#define LS_IMGUI_STYLE_MEMBER(NAME) LS_IMGUI_MEMBER(ImGuiStyle, NAME)

LS_IMGUI_STYLE_MEMBER(Alpha),
LS_IMGUI_STYLE_MEMBER(DisabledAlpha),
LS_IMGUI_STYLE_MEMBER(WindowPadding),
LS_IMGUI_STYLE_MEMBER(WindowRounding),
LS_IMGUI_STYLE_MEMBER(WindowBorderSize),
LS_IMGUI_STYLE_MEMBER(WindowMinSize),
LS_IMGUI_STYLE_MEMBER(WindowTitleAlign),
LS_IMGUI_STYLE_MEMBER(WindowMenuButtonPosition),
// TODO: all members

#undef LS_IMGUI_STYLE_MEMBER
};

#undef LS_IMGUI_MEMBER


static bool ls_framescope;

static void LS_EnsureFrameScope(lua_State* state)
Expand Down Expand Up @@ -941,6 +966,9 @@ static void EXP_EnterMode()
#endif // USE_LUA_SCRIPTING
}

extern "C"
{

static void EXP_ExitMode()
{
if (!exp_active)
Expand Down Expand Up @@ -968,6 +996,11 @@ void EXP_Init(SDL_Window* window, SDL_GLContext context)
exp_window = window;
exp_glcontext = context;

// for (const auto& entry : ls_imguistyle_members)
// {
// printf("%s: %i at %i\n", entry.first.data(), entry.second.type, entry.second.offset);
// }

Cmd_AddCommand("expmode", EXP_EnterMode);
}

Expand Down

0 comments on commit 73ff5eb

Please sign in to comment.