mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-01-19 16:00:52 +00:00
Adjust imgui_savestyle.cpp for 1.90.8
ImGuiDir now is a proper enum, not just a typedef of int that happens to have a similar name to the actual enum
This commit is contained in:
parent
863dc48ff4
commit
49ed8ec439
1 changed files with 24 additions and 2 deletions
|
@ -95,7 +95,7 @@ namespace DG {
|
||||||
D3_IMATTR_FLOAT( WindowBorderSize ) \
|
D3_IMATTR_FLOAT( WindowBorderSize ) \
|
||||||
D3_IMATTR_VEC2( WindowMinSize ) \
|
D3_IMATTR_VEC2( WindowMinSize ) \
|
||||||
D3_IMATTR_VEC2( WindowTitleAlign ) \
|
D3_IMATTR_VEC2( WindowTitleAlign ) \
|
||||||
D3_IMATTR_INT( WindowMenuButtonPosition ) \
|
D3_IMATTR_DIR( WindowMenuButtonPosition ) \
|
||||||
D3_IMATTR_FLOAT( ChildRounding ) \
|
D3_IMATTR_FLOAT( ChildRounding ) \
|
||||||
D3_IMATTR_FLOAT( ChildBorderSize ) \
|
D3_IMATTR_FLOAT( ChildBorderSize ) \
|
||||||
D3_IMATTR_FLOAT( PopupRounding ) \
|
D3_IMATTR_FLOAT( PopupRounding ) \
|
||||||
|
@ -120,7 +120,7 @@ namespace DG {
|
||||||
D3_IMATTR_FLOAT( TabBarBorderSize ) \
|
D3_IMATTR_FLOAT( TabBarBorderSize ) \
|
||||||
D3_IMATTR_FLOAT( TableAngledHeadersAngle ) \
|
D3_IMATTR_FLOAT( TableAngledHeadersAngle ) \
|
||||||
D3_IMATTR_VEC2( TableAngledHeadersTextAlign ) \
|
D3_IMATTR_VEC2( TableAngledHeadersTextAlign ) \
|
||||||
D3_IMATTR_INT( ColorButtonPosition ) \
|
D3_IMATTR_DIR( ColorButtonPosition ) \
|
||||||
D3_IMATTR_VEC2( ButtonTextAlign ) \
|
D3_IMATTR_VEC2( ButtonTextAlign ) \
|
||||||
D3_IMATTR_VEC2( SelectableTextAlign ) \
|
D3_IMATTR_VEC2( SelectableTextAlign ) \
|
||||||
D3_IMATTR_FLOAT( SeparatorTextBorderSize ) \
|
D3_IMATTR_FLOAT( SeparatorTextBorderSize ) \
|
||||||
|
@ -227,6 +227,12 @@ static inline char* skipWhitespace( const char* s ) {
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define D3_IMATTR_DIR( NAME ) \
|
||||||
|
if ( sscanf( line, #NAME " = %d", &i ) == 1 ) { \
|
||||||
|
s . NAME = (ImGuiDir)i; \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define D3_IMATTR_BOOL( NAME ) \
|
#define D3_IMATTR_BOOL( NAME ) \
|
||||||
if ( sscanf( line, #NAME " = %d", &i ) == 1 ) { \
|
if ( sscanf( line, #NAME " = %d", &i ) == 1 ) { \
|
||||||
s . NAME = ( i != 0 ); \
|
s . NAME = ( i != 0 ); \
|
||||||
|
@ -282,6 +288,7 @@ static void parseBehaviorLine( ImGuiStyle& s, const char* line )
|
||||||
#undef D3_IMATTR_FLOAT
|
#undef D3_IMATTR_FLOAT
|
||||||
#undef D3_IMATTR_VEC2
|
#undef D3_IMATTR_VEC2
|
||||||
#undef D3_IMATTR_INT
|
#undef D3_IMATTR_INT
|
||||||
|
#undef D3_IMATTR_DIR
|
||||||
#undef D3_IMATTR_BOOL
|
#undef D3_IMATTR_BOOL
|
||||||
|
|
||||||
static void parseColorLine( ImGuiStyle& s, const char* line )
|
static void parseColorLine( ImGuiStyle& s, const char* line )
|
||||||
|
@ -377,6 +384,8 @@ bool WriteImGuiStyle( const ImGuiStyle& s, const char* filename ) {
|
||||||
fprintf( f, "%s = %g, %g\n", #NAME, s . NAME . x, s . NAME . y );
|
fprintf( f, "%s = %g, %g\n", #NAME, s . NAME . x, s . NAME . y );
|
||||||
#define D3_IMATTR_INT( NAME ) \
|
#define D3_IMATTR_INT( NAME ) \
|
||||||
fprintf( f, "%s = %d\n", #NAME, s . NAME );
|
fprintf( f, "%s = %d\n", #NAME, s . NAME );
|
||||||
|
#define D3_IMATTR_DIR( NAME ) \
|
||||||
|
fprintf( f, "%s = %d\n", #NAME, s . NAME );
|
||||||
#define D3_IMATTR_BOOL( NAME ) \
|
#define D3_IMATTR_BOOL( NAME ) \
|
||||||
fprintf( f, "%s = %d\n", #NAME, (int)( s . NAME ) );
|
fprintf( f, "%s = %d\n", #NAME, (int)( s . NAME ) );
|
||||||
|
|
||||||
|
@ -396,6 +405,7 @@ bool WriteImGuiStyle( const ImGuiStyle& s, const char* filename ) {
|
||||||
#undef D3_IMATTR_FLOAT
|
#undef D3_IMATTR_FLOAT
|
||||||
#undef D3_IMATTR_VEC2
|
#undef D3_IMATTR_VEC2
|
||||||
#undef D3_IMATTR_INT
|
#undef D3_IMATTR_INT
|
||||||
|
#undef D3_IMATTR_DIR
|
||||||
#undef D3_IMATTR_BOOL
|
#undef D3_IMATTR_BOOL
|
||||||
|
|
||||||
fprintf( f, "\n[colors]\n" );
|
fprintf( f, "\n[colors]\n" );
|
||||||
|
@ -444,6 +454,10 @@ ImGuiTextBuffer WriteImGuiStyleToCode( const ImGuiStyle& s, const ImGuiStyle* re
|
||||||
if ( refStyle == nullptr || s. NAME != refStyle-> NAME ) { \
|
if ( refStyle == nullptr || s. NAME != refStyle-> NAME ) { \
|
||||||
ret.appendf( "style.%s = %d; // TODO: flag\n", #NAME, s. NAME ); \
|
ret.appendf( "style.%s = %d; // TODO: flag\n", #NAME, s. NAME ); \
|
||||||
}
|
}
|
||||||
|
#define D3_IMATTR_DIR( NAME ) \
|
||||||
|
if ( refStyle == nullptr || s. NAME != refStyle-> NAME ) { \
|
||||||
|
ret.appendf( "style.%s = %d;\n", #NAME, s. NAME ); \
|
||||||
|
}
|
||||||
#define D3_IMATTR_BOOL( NAME ) \
|
#define D3_IMATTR_BOOL( NAME ) \
|
||||||
if ( refStyle == nullptr || s. NAME != refStyle-> NAME ) { \
|
if ( refStyle == nullptr || s. NAME != refStyle-> NAME ) { \
|
||||||
ret.appendf( "style.%s %*s= %s;\n", #NAME, numSpaces( #NAME , 27 ), "", s. NAME ? "true" : "false" ); \
|
ret.appendf( "style.%s %*s= %s;\n", #NAME, numSpaces( #NAME , 27 ), "", s. NAME ? "true" : "false" ); \
|
||||||
|
@ -458,6 +472,7 @@ ImGuiTextBuffer WriteImGuiStyleToCode( const ImGuiStyle& s, const ImGuiStyle* re
|
||||||
#undef D3_IMATTR_FLOAT
|
#undef D3_IMATTR_FLOAT
|
||||||
#undef D3_IMATTR_VEC2
|
#undef D3_IMATTR_VEC2
|
||||||
#undef D3_IMATTR_INT
|
#undef D3_IMATTR_INT
|
||||||
|
#undef D3_IMATTR_DIR
|
||||||
#undef D3_IMATTR_BOOL
|
#undef D3_IMATTR_BOOL
|
||||||
|
|
||||||
ret.append( "\nImVec4* colors = style.Colors;\n" );
|
ret.append( "\nImVec4* colors = style.Colors;\n" );
|
||||||
|
@ -500,6 +515,7 @@ struct D3_ImGuiStyle_Check {
|
||||||
#define D3_IMATTR_FLOAT( NAME ) float NAME ;
|
#define D3_IMATTR_FLOAT( NAME ) float NAME ;
|
||||||
#define D3_IMATTR_VEC2( NAME ) ImVec2 NAME ;
|
#define D3_IMATTR_VEC2( NAME ) ImVec2 NAME ;
|
||||||
#define D3_IMATTR_INT( NAME ) int NAME ;
|
#define D3_IMATTR_INT( NAME ) int NAME ;
|
||||||
|
#define D3_IMATTR_DIR( NAME ) ImGuiDir NAME ;
|
||||||
#define D3_IMATTR_BOOL( NAME ) bool NAME ;
|
#define D3_IMATTR_BOOL( NAME ) bool NAME ;
|
||||||
|
|
||||||
// this expands to all the ImGuiStyle members, up to (excluding) Colors
|
// this expands to all the ImGuiStyle members, up to (excluding) Colors
|
||||||
|
@ -514,6 +530,7 @@ struct D3_ImGuiStyle_Check {
|
||||||
#undef D3_IMATTR_FLOAT
|
#undef D3_IMATTR_FLOAT
|
||||||
#undef D3_IMATTR_VEC2
|
#undef D3_IMATTR_VEC2
|
||||||
#undef D3_IMATTR_INT
|
#undef D3_IMATTR_INT
|
||||||
|
#undef D3_IMATTR_DIR
|
||||||
#undef D3_IMATTR_BOOL
|
#undef D3_IMATTR_BOOL
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -543,6 +560,11 @@ struct is_same<T, T> {
|
||||||
"member " #NAME " not at expected offset - is the member before it missing from the list, or moved to another position?" ); \
|
"member " #NAME " not at expected offset - is the member before it missing from the list, or moved to another position?" ); \
|
||||||
static_assert( is_same< decltype( ImGuiStyle :: NAME ), int >::value, "expected member " #NAME " to be an int - adjust the list!" );
|
static_assert( is_same< decltype( ImGuiStyle :: NAME ), int >::value, "expected member " #NAME " to be an int - adjust the list!" );
|
||||||
|
|
||||||
|
#define D3_IMATTR_DIR( NAME ) \
|
||||||
|
static_assert( offsetof( ImGuiStyle, NAME ) == offsetof( D3_ImGuiStyle_Check, NAME ), \
|
||||||
|
"member " #NAME " not at expected offset - is the member before it missing from the list, or moved to another position?" ); \
|
||||||
|
static_assert( is_same< decltype( ImGuiStyle :: NAME ), ImGuiDir >::value, "expected member " #NAME " to be an ImGuiDir - adjust the list!" );
|
||||||
|
|
||||||
#define D3_IMATTR_BOOL( NAME ) \
|
#define D3_IMATTR_BOOL( NAME ) \
|
||||||
static_assert( offsetof( ImGuiStyle, NAME ) == offsetof( D3_ImGuiStyle_Check, NAME ), \
|
static_assert( offsetof( ImGuiStyle, NAME ) == offsetof( D3_ImGuiStyle_Check, NAME ), \
|
||||||
"member " #NAME " not at expected offset - is the member before it missing from the list, or moved to another position?" ); \
|
"member " #NAME " not at expected offset - is the member before it missing from the list, or moved to another position?" ); \
|
||||||
|
|
Loading…
Reference in a new issue