Compare commits
3 commits
f1dbccdd17
...
dadbbb7697
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dadbbb7697 | ||
|
|
c341f034fa | ||
|
|
59fec07d69 |
204
.clang-format
Normal file
204
.clang-format
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
---
|
||||||
|
BasedOnStyle: Microsoft
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments: None
|
||||||
|
AlignConsecutiveBitFields: None
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignConsecutiveMacros: None
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: DontAlign
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BreakAfterAttributes: Never
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakArrays: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: false
|
||||||
|
SplitEmptyRecord: false
|
||||||
|
SplitEmptyNamespace: false
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 0
|
||||||
|
CommentPragmas: "^ IWYU pragma:"
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: ^"(llvm|llvm-c|clang|clang-c)/
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: ^(<|"(gtest|gmock|isl|json)/)
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: .*
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: (Test)?$
|
||||||
|
IncludeIsMainSourceRegex: ""
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequiresClause: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertBraces: true
|
||||||
|
InsertNewlineAtEOF: true
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
Language: Cpp
|
||||||
|
LineEnding: DeriveLF
|
||||||
|
MacroBlockBegin: ""
|
||||||
|
MacroBlockEnd: ""
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PPIndentWidth: -1
|
||||||
|
PackConstructorInitializers: BinPack
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||||
|
PointerAlignment: Right
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: Never
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: true
|
||||||
|
AfterFunctionDeclarationName: false
|
||||||
|
AfterFunctionDefinitionName: false
|
||||||
|
AfterIfMacros: false
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Latest
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Always
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
|
UseCRLF: false
|
||||||
|
|
@ -4,39 +4,10 @@
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <clay/clay.h>
|
#include <clay/clay.h>
|
||||||
|
|
||||||
static inline
|
|
||||||
void DiceLogContainer() {
|
|
||||||
CLAY(CLAY_ID("LogContainer"), PanelContainer(0, (Clay_ElementDeclaration) {
|
|
||||||
.layout = {
|
|
||||||
.sizing = layoutExpand,
|
|
||||||
.padding = CLAY_PADDING_ALL(16),
|
|
||||||
},
|
|
||||||
})) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
|
||||||
void InitiativeListContainer() {
|
|
||||||
CLAY(CLAY_ID("InitiativeListContainer"), PanelContainer(0, (Clay_ElementDeclaration) {
|
|
||||||
.layout = {
|
|
||||||
.sizing = layoutExpand,
|
|
||||||
.padding = CLAY_PADDING_ALL(16),
|
|
||||||
},
|
|
||||||
})) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Clay_RenderCommandArray RenderApplication() {
|
Clay_RenderCommandArray RenderApplication() {
|
||||||
Clay_BeginLayout();
|
Clay_BeginLayout();
|
||||||
CLAY(CLAY_ID("OuterContainer"), WindowStyle()) {
|
CLAY(CLAY_ID("OuterContainer"), WindowStyle()) {
|
||||||
DiceContainer();
|
DiceContainer();
|
||||||
CLAY(CLAY_ID("LowerSplitContainer"), {
|
|
||||||
.layout = {
|
|
||||||
.sizing = layoutExpand,
|
|
||||||
.childGap = containerGap
|
|
||||||
},
|
|
||||||
}) {
|
|
||||||
DiceLogContainer();
|
|
||||||
InitiativeListContainer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Clay_EndLayout();
|
return Clay_EndLayout();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,38 @@
|
||||||
#include "dice_container.h"
|
#include "dice_container.h"
|
||||||
|
#include "dice.h"
|
||||||
|
#include "elements.h"
|
||||||
|
#include "style.h"
|
||||||
|
#include "ui_data.h"
|
||||||
#include <SDL3/SDL_mouse.h>
|
#include <SDL3/SDL_mouse.h>
|
||||||
#include <SDL3_image/SDL_image.h>
|
#include <SDL3_image/SDL_image.h>
|
||||||
#include <clay/clay.h>
|
#include <clay/clay.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "elements.h"
|
|
||||||
#include "style.h"
|
|
||||||
#include "dice.h"
|
|
||||||
#include "ui_data.h"
|
|
||||||
|
|
||||||
static
|
static void HandleRollSetButtonInteraction(Clay_ElementId element,
|
||||||
void HandleRollSetButtonInteraction(Clay_ElementId element, Clay_PointerData pointer, intptr_t data) {
|
Clay_PointerData pointer,
|
||||||
|
intptr_t data) {
|
||||||
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
||||||
Dice_RollActiveSet();
|
Dice_RollActiveSet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void HandleClearSetButtonInteraction(Clay_ElementId element,
|
||||||
void HandleClearSetButtonInteraction(Clay_ElementId element, Clay_PointerData pointer, intptr_t data) {
|
Clay_PointerData pointer,
|
||||||
|
intptr_t data) {
|
||||||
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
||||||
Dice_ClearActiveSet();
|
Dice_ClearActiveSet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void HandleAddDieButtonInteraction(Clay_ElementId element,
|
||||||
void HandleAddDieButtonInteraction(Clay_ElementId element, Clay_PointerData pointer, intptr_t die) {
|
Clay_PointerData pointer,
|
||||||
|
intptr_t die) {
|
||||||
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
||||||
Dice_AddToActiveSet((enum Dice_Die)die);
|
Dice_AddToActiveSet((enum Dice_Die)die);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline void AddDieButton(enum Dice_Die die) {
|
||||||
void AddDieButton(enum Dice_Die die) {
|
|
||||||
CLAY(CLAY_IDI("AddDieButton", die), {
|
CLAY(CLAY_IDI("AddDieButton", die), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {CLAY_SIZING_FIXED(100), CLAY_SIZING_FIXED(100)},
|
.sizing = {CLAY_SIZING_FIXED(100), CLAY_SIZING_FIXED(100)},
|
||||||
|
|
@ -39,21 +41,16 @@ void AddDieButton(enum Dice_Die die) {
|
||||||
.image = {GetDiceImage(die, Clay_Hovered())},
|
.image = {GetDiceImage(die, Clay_Hovered())},
|
||||||
}) {
|
}) {
|
||||||
Clay_OnHover(&HandleAddDieButtonInteraction, die);
|
Clay_OnHover(&HandleAddDieButtonInteraction, die);
|
||||||
CLAY_TEXT(Dice_ToString(die), CLAY_TEXT_CONFIG(Header(2, {
|
CLAY_TEXT(Dice_ToString(die), CLAY_TEXT_CONFIG(Header(2, {.textColor = TextColors(0), .textAlignment = CLAY_TEXT_ALIGN_CENTER})));
|
||||||
.textColor = TextColors(0),
|
|
||||||
.textAlignment = CLAY_TEXT_ALIGN_CENTER,
|
|
||||||
})));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline void DiceSelectorContainer() {
|
||||||
void DiceSelectorContainer() {
|
|
||||||
CLAY(CLAY_ID("DiceSelector"),
|
CLAY(CLAY_ID("DiceSelector"),
|
||||||
PanelContainer(0, (Clay_ElementDeclaration){
|
PanelContainer(0, (Clay_ElementDeclaration){
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = { CLAY_SIZING_FIT(), CLAY_SIZING_GROW() },
|
.sizing = {CLAY_SIZING_FIT(), CLAY_SIZING_GROW()}
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
)) {
|
)) {
|
||||||
CLAY_AUTO_ID(ListContainer(0, {
|
CLAY_AUTO_ID(ListContainer(0, {
|
||||||
.layout = {
|
.layout = {
|
||||||
|
|
@ -63,7 +60,9 @@ void DiceSelectorContainer() {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
},
|
},
|
||||||
.clip = {
|
.clip = {
|
||||||
false, true, Clay_GetScrollOffset(),
|
false,
|
||||||
|
true,
|
||||||
|
Clay_GetScrollOffset(),
|
||||||
},
|
},
|
||||||
})) {
|
})) {
|
||||||
AddDieButton(D4);
|
AddDieButton(D4);
|
||||||
|
|
@ -78,23 +77,21 @@ void DiceSelectorContainer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void HandleRemoveDieButtonInteraction(Clay_ElementId element,
|
||||||
void HandleRemoveDieButtonInteraction(Clay_ElementId element, Clay_PointerData pointer, intptr_t index) {
|
Clay_PointerData pointer,
|
||||||
|
intptr_t index) {
|
||||||
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
if(pointer.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
||||||
Dice_RemoveFromActiveSet((size_t)index);
|
Dice_RemoveFromActiveSet((size_t)index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline void RemoveDieButton(enum Dice_Die die, size_t index) {
|
||||||
void RemoveDieButton(enum Dice_Die die, size_t index) {
|
|
||||||
CLAY(CLAY_IDI("RemoveDieButton", index), {
|
CLAY(CLAY_IDI("RemoveDieButton", index), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {CLAY_SIZING_FIXED(200), CLAY_SIZING_FIXED(200)},
|
.sizing = {CLAY_SIZING_FIXED(200), CLAY_SIZING_FIXED(200)},
|
||||||
.childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER},
|
.childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER},
|
||||||
},
|
},
|
||||||
.image = {
|
.image = {GetDiceImage(die, Clay_Hovered())},
|
||||||
GetDiceImage(die, Clay_Hovered())
|
|
||||||
},
|
|
||||||
}) {
|
}) {
|
||||||
Clay_OnHover(&HandleRemoveDieButtonInteraction, (intptr_t)index);
|
Clay_OnHover(&HandleRemoveDieButtonInteraction, (intptr_t)index);
|
||||||
size_t result_length;
|
size_t result_length;
|
||||||
|
|
@ -104,14 +101,11 @@ void RemoveDieButton(enum Dice_Die die, size_t index) {
|
||||||
CLAY_TEXT_CONFIG(Header(1, {
|
CLAY_TEXT_CONFIG(Header(1, {
|
||||||
.textColor = TextColors(0),
|
.textColor = TextColors(0),
|
||||||
.textAlignment = CLAY_TEXT_ALIGN_CENTER,
|
.textAlignment = CLAY_TEXT_ALIGN_CENTER,
|
||||||
}
|
})));
|
||||||
))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline void ActiveDiceContainer() {
|
||||||
void ActiveDiceContainer() {
|
|
||||||
CLAY(CLAY_ID("ActiveDice"), PanelContainer(0, {
|
CLAY(CLAY_ID("ActiveDice"), PanelContainer(0, {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {CLAY_SIZING_GROW(), CLAY_SIZING_GROW()},
|
.sizing = {CLAY_SIZING_GROW(), CLAY_SIZING_GROW()},
|
||||||
|
|
@ -127,10 +121,8 @@ void ActiveDiceContainer() {
|
||||||
.childAlignment = {CLAY_ALIGN_X_LEFT, CLAY_ALIGN_Y_CENTER},
|
.childAlignment = {CLAY_ALIGN_X_LEFT, CLAY_ALIGN_Y_CENTER},
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||||
},
|
},
|
||||||
.clip = {
|
.clip = { true, true, {Clay_GetScrollOffset().x, 0}}}
|
||||||
true, true, { Clay_GetScrollOffset().x, 0 }
|
) {
|
||||||
}
|
|
||||||
}) {
|
|
||||||
size_t dice_count = 0;
|
size_t dice_count = 0;
|
||||||
enum Dice_Die const *dice = Dice_GetActiveSet(&dice_count);
|
enum Dice_Die const *dice = Dice_GetActiveSet(&dice_count);
|
||||||
for(size_t i = 0; i < dice_count; ++i) {
|
for(size_t i = 0; i < dice_count; ++i) {
|
||||||
|
|
@ -147,11 +139,9 @@ void ActiveDiceContainer() {
|
||||||
}) {
|
}) {
|
||||||
TextButton(CLAY_STRING("Roll"), proceedButton, &HandleRollSetButtonInteraction, 0);
|
TextButton(CLAY_STRING("Roll"), proceedButton, &HandleRollSetButtonInteraction, 0);
|
||||||
int result = Dice_GetLastResultTotal();
|
int result = Dice_GetLastResultTotal();
|
||||||
CLAY_TEXT(UiData_StoreClayStr(Dice_ResultToString({ result, NONE })),
|
CLAY_TEXT(UiData_StoreClayStr(Dice_ResultToString({result, NONE})), CLAY_TEXT_CONFIG(Header(1, {
|
||||||
CLAY_TEXT_CONFIG(Header(1, {
|
.textColor = TextColors(0)
|
||||||
.textColor = TextColors(0),
|
})));
|
||||||
}))
|
|
||||||
);
|
|
||||||
TextButton(CLAY_STRING("Clear"), warningButton, &HandleClearSetButtonInteraction, 0);
|
TextButton(CLAY_STRING("Clear"), warningButton, &HandleClearSetButtonInteraction, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -160,10 +150,10 @@ void ActiveDiceContainer() {
|
||||||
void DiceContainer() {
|
void DiceContainer() {
|
||||||
CLAY(CLAY_ID("DiceContainer"), {
|
CLAY(CLAY_ID("DiceContainer"), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_PERCENT(0.4) },
|
.sizing = {CLAY_SIZING_GROW(), CLAY_SIZING_GROW()},
|
||||||
.childGap = containerGap,
|
.childGap = containerGap,
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||||
},
|
}
|
||||||
}) {
|
}) {
|
||||||
DiceSelectorContainer();
|
DiceSelectorContainer();
|
||||||
ActiveDiceContainer();
|
ActiveDiceContainer();
|
||||||
|
|
|
||||||
43
src/main.cpp
43
src/main.cpp
|
|
@ -1,14 +1,13 @@
|
||||||
|
#include "renderer/clay_renderer_SDL3.h"
|
||||||
#include <SDL3/SDL_hints.h>
|
#include <SDL3/SDL_hints.h>
|
||||||
#include <SDL3/SDL_keycode.h>
|
#include <SDL3/SDL_keycode.h>
|
||||||
#include <SDL3/SDL_oldnames.h>
|
#include <SDL3/SDL_oldnames.h>
|
||||||
#include <clay/clay.h>
|
#include <clay/clay.h>
|
||||||
#include "renderer/clay_renderer_SDL3.h"
|
|
||||||
|
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "style.h"
|
|
||||||
#include "ui_data.h"
|
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
#include "ui_data.h"
|
||||||
|
|
||||||
#define SDL_MAIN_HANDLED
|
#define SDL_MAIN_HANDLED
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
@ -21,34 +20,29 @@
|
||||||
#include <SDL3/SDL_video.h>
|
#include <SDL3/SDL_video.h>
|
||||||
#include <SDL3_ttf/SDL_ttf.h>
|
#include <SDL3_ttf/SDL_ttf.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
constexpr SDL_InitFlags sdlInitFlags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
constexpr SDL_InitFlags sdlInitFlags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
|
|
||||||
SDL_Window *window = nullptr;
|
SDL_Window *window = nullptr;
|
||||||
SDL_Renderer *renderer = nullptr;
|
SDL_Renderer *renderer = nullptr;
|
||||||
int screenWidth = 1920, screenHeight = 1080;
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
uint64_t clayMemorySize = 0;
|
uint64_t clayMemorySize = 0;
|
||||||
|
|
||||||
Clay_Arena clayPrimaryArena;
|
Clay_Arena clayPrimaryArena;
|
||||||
|
|
||||||
Clay_SDL3RendererData backendData = {
|
Clay_SDL3RendererData backendData = {nullptr, nullptr, nullptr};
|
||||||
nullptr, nullptr, nullptr
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline
|
static inline void LogOutputResolution() {
|
||||||
void LogOutputResolution() {
|
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
|
SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
|
||||||
SDL_Log("output size: %i, %d", w, h);
|
SDL_Log("output size: %i, %d", w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static Clay_Dimensions MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData) {
|
||||||
Clay_Dimensions MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData) {
|
|
||||||
TTF_Font **fonts = (TTF_Font **)userData;
|
TTF_Font **fonts = (TTF_Font **)userData;
|
||||||
TTF_Font *font = fonts[config->fontId];
|
TTF_Font *font = fonts[config->fontId];
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
@ -59,18 +53,22 @@ Clay_Dimensions MeasureText(Clay_StringSlice text, Clay_TextElementConfig *confi
|
||||||
return (Clay_Dimensions){(float)width, (float)height};
|
return (Clay_Dimensions){(float)width, (float)height};
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void HandleClayErrors(Clay_ErrorData data) {
|
||||||
void HandleClayErrors(Clay_ErrorData data) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", data.errorText.chars);
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", data.errorText.chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline void InitSDL() {
|
||||||
void InitSDL() {
|
|
||||||
SDL_SetHint(SDL_HINT_RENDER_LINE_METHOD, "3");
|
SDL_SetHint(SDL_HINT_RENDER_LINE_METHOD, "3");
|
||||||
if(!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS)) {
|
if(!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS)) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "SDL_Init failed: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "SDL_Init failed: %s", SDL_GetError());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
int screenWidth{1920}, screenHeight{1080};
|
||||||
|
if(SDL_DisplayMode const *mode{SDL_GetDesktopDisplayMode(0)}) {
|
||||||
|
screenWidth = mode->w;
|
||||||
|
screenHeight = mode->h;
|
||||||
|
}
|
||||||
|
|
||||||
if((window = SDL_CreateWindow("Window", screenWidth, screenHeight, sdlInitFlags)) == nullptr) {
|
if((window = SDL_CreateWindow("Window", screenWidth, screenHeight, sdlInitFlags)) == nullptr) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "SDL_CreateWindow failed: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "SDL_CreateWindow failed: %s", SDL_GetError());
|
||||||
exit(2);
|
exit(2);
|
||||||
|
|
@ -89,10 +87,11 @@ void InitSDL() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void InitClay() {
|
||||||
void InitClay() {
|
|
||||||
clayMemorySize = Clay_MinMemorySize();
|
clayMemorySize = Clay_MinMemorySize();
|
||||||
clayPrimaryArena = Clay_CreateArenaWithCapacityAndMemory(clayMemorySize, SDL_malloc(clayMemorySize));
|
clayPrimaryArena = Clay_CreateArenaWithCapacityAndMemory(clayMemorySize, SDL_malloc(clayMemorySize));
|
||||||
|
int screenWidth{}, screenHeight{};
|
||||||
|
SDL_GetCurrentRenderOutputSize(renderer, &screenWidth, &screenHeight);
|
||||||
Clay_Initialize(clayPrimaryArena, {(float)screenWidth, (float)screenHeight}, {HandleClayErrors});
|
Clay_Initialize(clayPrimaryArena, {(float)screenWidth, (float)screenHeight}, {HandleClayErrors});
|
||||||
Clay_SetMeasureTextFunction(MeasureText, fonts);
|
Clay_SetMeasureTextFunction(MeasureText, fonts);
|
||||||
Clay_SetLayoutDimensions({(float)screenWidth, (float)screenHeight});
|
Clay_SetLayoutDimensions({(float)screenWidth, (float)screenHeight});
|
||||||
|
|
@ -127,10 +126,7 @@ int main(int argc, char *argv[]) {
|
||||||
running = false;
|
running = false;
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_WINDOW_RESIZED:
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
Clay_SetLayoutDimensions({
|
Clay_SetLayoutDimensions({(float)event.window.data1, (float)event.window.data2});
|
||||||
(float)event.window.data1,
|
|
||||||
(float)event.window.data2
|
|
||||||
});
|
|
||||||
LogOutputResolution();
|
LogOutputResolution();
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_MOUSE_WHEEL:
|
case SDL_EVENT_MOUSE_WHEEL:
|
||||||
|
|
@ -156,7 +152,8 @@ int main(int argc, char *argv[]) {
|
||||||
shiftDown = event.key.down;
|
shiftDown = event.key.down;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Clay_UpdateScrollContainers(true, scrollMotion, deltaTime);
|
Clay_UpdateScrollContainers(true, scrollMotion, deltaTime);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue