Compare commits
No commits in common. "00569f2ef1a78fd1e89071b22bc793774eb0f4a3" and "df86dd586c759c52d504f0992993472967669760" have entirely different histories.
00569f2ef1
...
df86dd586c
|
|
@ -35,13 +35,13 @@ void AddDieButton(enum Dice_Die die) {
|
||||||
.sizing = { CLAY_SIZING_FIXED(100), CLAY_SIZING_FIXED(100) },
|
.sizing = { CLAY_SIZING_FIXED(100), CLAY_SIZING_FIXED(100) },
|
||||||
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
||||||
},
|
},
|
||||||
.image = { GetDiceImage(die, Clay_Hovered()) },
|
.image = { GetDiceImage(die) }
|
||||||
}) {
|
}) {
|
||||||
Clay_OnHover(&HandleAddDieButtonInteraction, die);
|
Clay_OnHover(&HandleAddDieButtonInteraction, die);
|
||||||
CLAY_TEXT(Dice_ToString(die), CLAY_TEXT_CONFIG({
|
CLAY_TEXT(Dice_ToString(die), CLAY_TEXT_CONFIG({
|
||||||
.H(2),
|
|
||||||
.textColor = TextColors(0),
|
.textColor = TextColors(0),
|
||||||
.textAlignment = CLAY_TEXT_ALIGN_CENTER,
|
.H(2),
|
||||||
|
.textAlignment = CLAY_TEXT_ALIGN_CENTER
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -49,22 +49,23 @@ void AddDieButton(enum Dice_Die die) {
|
||||||
static inline
|
static inline
|
||||||
void DiceSelectorContainer() {
|
void DiceSelectorContainer() {
|
||||||
CLAY(CLAY_ID("DiceSelector"), {
|
CLAY(CLAY_ID("DiceSelector"), {
|
||||||
|
.PANEL(0),
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = { CLAY_SIZING_FIT(), CLAY_SIZING_GROW() },
|
.sizing = { CLAY_SIZING_FIT(), CLAY_SIZING_GROW() },
|
||||||
|
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
||||||
},
|
},
|
||||||
.PANEL(0),
|
|
||||||
}) {
|
}) {
|
||||||
CLAY_AUTO_ID({
|
CLAY(CLAY_ID("DiceSelectorInner"), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
.childGap = paragraphGap,
|
||||||
.padding = { 2, 2, 5, 5 },
|
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
||||||
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_TOP },
|
.sizing = { CLAY_SIZING_FIT(), CLAY_SIZING_FIT() },
|
||||||
|
.padding = panelPadding,
|
||||||
},
|
},
|
||||||
.clip = {
|
.clip = {
|
||||||
false, true, Clay_GetScrollOffset(),
|
true, true, Clay_GetScrollOffset(),
|
||||||
},
|
},
|
||||||
.LISTCONTAINER(0),
|
|
||||||
}) {
|
}) {
|
||||||
AddDieButton(D4);
|
AddDieButton(D4);
|
||||||
AddDieButton(D6);
|
AddDieButton(D6);
|
||||||
|
|
@ -92,7 +93,7 @@ void RemoveDieButton(enum Dice_Die die, int index) {
|
||||||
.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 = { GetDiceImage(die, Clay_Hovered()) },
|
.image = { GetDiceImage(die) },
|
||||||
}) {
|
}) {
|
||||||
size_t result_length;
|
size_t result_length;
|
||||||
struct Dice_ResultType const *result = Dice_GetLastResult(&result_length);
|
struct Dice_ResultType const *result = Dice_GetLastResult(&result_length);
|
||||||
|
|
@ -114,23 +115,24 @@ static inline
|
||||||
void ActiveDiceContainer() {
|
void ActiveDiceContainer() {
|
||||||
CLAY(CLAY_ID("ActiveDice"), {
|
CLAY(CLAY_ID("ActiveDice"), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
||||||
|
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
||||||
},
|
},
|
||||||
.PANEL(0),
|
.PANEL(0),
|
||||||
}) {
|
}) {
|
||||||
CLAY(CLAY_ID("ActiveDiceInner"), {
|
CLAY(CLAY_ID("ActiveDiceInner"), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = { CLAY_SIZING_FIT(), CLAY_SIZING_GROW() },
|
.sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||||
.childAlignment = { CLAY_ALIGN_X_LEFT, CLAY_ALIGN_Y_CENTER },
|
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
||||||
.childGap = 16,
|
.childGap = 16,
|
||||||
.padding = { 100, 100, 0, 0 },
|
.padding = { 100, 100, 0, 0 },
|
||||||
},
|
},
|
||||||
.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);
|
||||||
|
|
|
||||||
|
|
@ -139,9 +139,9 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_MOUSE_WHEEL:
|
case SDL_EVENT_MOUSE_WHEEL:
|
||||||
if (shiftDown) {
|
if (shiftDown) {
|
||||||
scrollMotion = (Clay_Vector2) { event.wheel.y * 2.f, -event.wheel.x * 5.f };
|
scrollMotion = (Clay_Vector2) { event.wheel.y * 5.f, event.wheel.x * 5.f };
|
||||||
} else {
|
} else {
|
||||||
scrollMotion = (Clay_Vector2) { -event.wheel.x * 2.f, event.wheel.y * 5.f };
|
scrollMotion = (Clay_Vector2) { event.wheel.x * 5.f, event.wheel.y * 5.f };
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_MOUSE_MOTION:
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
|
|
@ -169,7 +169,6 @@ int main(int argc, char *argv[]) {
|
||||||
Clay_RenderCommandArray array = RenderApplication();
|
Clay_RenderCommandArray array = RenderApplication();
|
||||||
SDL_Clay_RenderClayCommands(&backendData, &array);
|
SDL_Clay_RenderClayCommands(&backendData, &array);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
SDL_Delay(10);
|
|
||||||
}
|
}
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
TTF_Font *fonts[FONT_MAX];
|
TTF_Font *fonts[FONT_MAX];
|
||||||
SDL_Texture *diceImages[DICE_IMAGE_MAX];
|
SDL_Texture *diceImages[DICE_IMAGE_MAX];
|
||||||
SDL_Texture *diceImagesSelected[DICE_IMAGE_MAX];
|
|
||||||
TTF_TextEngine *textEngine = nullptr;
|
TTF_TextEngine *textEngine = nullptr;
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
|
@ -33,42 +32,33 @@ void LoadDiceImages() {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
diceImagesSelected[COIN_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d2.svg");
|
|
||||||
if(!(diceImages[D4_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d4.svg"))) {
|
if(!(diceImages[D4_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d4.svg"))) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
diceImagesSelected[D4_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d4.svg");
|
|
||||||
if(!(diceImages[D6_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d6.svg"))) {
|
if(!(diceImages[D6_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d6.svg"))) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
diceImagesSelected[D6_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d6.svg");
|
|
||||||
if(!(diceImages[D8_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d8.svg"))) {
|
if(!(diceImages[D8_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d8.svg"))) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
diceImagesSelected[D8_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d8.svg");
|
|
||||||
if(!(diceImages[D10_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d10.svg"))) {
|
if(!(diceImages[D10_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d10.svg"))) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
diceImagesSelected[D10_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d10.svg");
|
|
||||||
if(!(diceImages[D12_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d12.svg"))) {
|
if(!(diceImages[D12_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d12.svg"))) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
diceImagesSelected[D12_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d12.svg");
|
|
||||||
if(!(diceImages[D20_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d20.svg"))) {
|
if(!(diceImages[D20_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d20.svg"))) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "IMG_LoadTexture Failed to load die texture: %s", SDL_GetError());
|
||||||
exit(7);
|
exit(7);
|
||||||
}
|
}
|
||||||
diceImagesSelected[D20_IMAGE] = IMG_LoadTexture(renderer, "assets/icons/d20.svg");
|
|
||||||
for (size_t i = 0; i < DICE_IMAGE_MAX; ++i) {
|
for (size_t i = 0; i < DICE_IMAGE_MAX; ++i) {
|
||||||
Clay_Color color = dieColors[i];
|
Clay_Color color = dieColors[i];
|
||||||
SDL_SetTextureColorMod(diceImages[i], color.r, color.g, color.b);
|
SDL_SetTextureColorMod(diceImages[i], color.r, color.g, color.b);
|
||||||
color = ToHoveredColor(dieColors[i]);
|
|
||||||
SDL_SetTextureColorMod(diceImagesSelected[i], color.r, color.g, color.b);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,22 +67,23 @@ void LoadResources() {
|
||||||
LoadDiceImages();
|
LoadDiceImages();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Texture *GetDiceImage(enum Dice_Die die, bool selected) {
|
SDL_Texture *GetDiceImage(enum Dice_Die die) {
|
||||||
switch (die) {
|
switch (die) {
|
||||||
case COIN:
|
case COIN:
|
||||||
return selected ? diceImagesSelected[COIN_IMAGE] : diceImages[COIN_IMAGE];
|
return diceImages[COIN_IMAGE];
|
||||||
case D4:
|
case D4:
|
||||||
return selected ? diceImagesSelected[D4_IMAGE] : diceImages[D4_IMAGE];
|
return diceImages[D4_IMAGE];
|
||||||
case D6:
|
case D6:
|
||||||
return selected ? diceImagesSelected[D6_IMAGE] : diceImages[D6_IMAGE];
|
return diceImages[D6_IMAGE];
|
||||||
case D8:
|
case D8:
|
||||||
return selected ? diceImagesSelected[D8_IMAGE] : diceImages[D8_IMAGE];
|
return diceImages[D8_IMAGE];
|
||||||
case D10:
|
case D10:
|
||||||
case D100:
|
return diceImages[D10_IMAGE];
|
||||||
return selected ? diceImagesSelected[D10_IMAGE] : diceImages[D10_IMAGE];
|
|
||||||
case D12:
|
case D12:
|
||||||
return selected ? diceImagesSelected[D12_IMAGE] : diceImages[D12_IMAGE];
|
return diceImages[D12_IMAGE];
|
||||||
case D20:
|
case D20:
|
||||||
return selected ? diceImagesSelected[D20_IMAGE] : diceImages[D20_IMAGE];
|
return diceImages[D20_IMAGE];
|
||||||
|
case D100:
|
||||||
|
return diceImages[D10_IMAGE];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,9 @@ enum DiceImages {
|
||||||
extern TTF_TextEngine *textEngine;
|
extern TTF_TextEngine *textEngine;
|
||||||
extern TTF_Font *fonts[FONT_MAX];
|
extern TTF_Font *fonts[FONT_MAX];
|
||||||
extern SDL_Texture *diceImages[DICE_IMAGE_MAX];
|
extern SDL_Texture *diceImages[DICE_IMAGE_MAX];
|
||||||
extern SDL_Texture *diceImagesSelected[DICE_IMAGE_MAX];
|
|
||||||
|
|
||||||
extern void LoadResources();
|
extern void LoadResources();
|
||||||
|
|
||||||
extern SDL_Texture *GetDiceImage(enum Dice_Die die, bool selected);
|
extern SDL_Texture *GetDiceImage(enum Dice_Die die);
|
||||||
|
|
||||||
#endif // !RESOURCES_H
|
#endif // !RESOURCES_H
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,7 @@ Clay_Color TextColors(size_t idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_Color WindowBackground() {
|
Clay_Color WindowBackground() {
|
||||||
return (Clay_Color) {
|
return (Clay_Color) { 255*windowBackground, 255*windowBackground, 255*windowBackground, 255 };
|
||||||
255*windowBackground,
|
|
||||||
255*windowBackground,
|
|
||||||
255*windowBackground,
|
|
||||||
255
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_ElementDeclaration WindowStyle() {
|
Clay_ElementDeclaration WindowStyle() {
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,9 @@ constexpr Clay_Padding panelPadding = {
|
||||||
24, 24,
|
24, 24,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LISTCONTAINER(depth_)\
|
|
||||||
border = { PanelBorder(depth_), CLAY_BORDER_ALL(2) },\
|
|
||||||
.cornerRadius = defaultRadiusAll
|
|
||||||
|
|
||||||
#define PANEL(depth_)\
|
#define PANEL(depth_)\
|
||||||
backgroundColor = PanelBackground(depth_),\
|
backgroundColor = PanelBackground(depth_),\
|
||||||
.border = { PanelBorder(depth_), CLAY_BORDER_OUTSIDE(2) },\
|
.border = { PanelBackground(depth_), CLAY_BORDER_ALL(2) },\
|
||||||
.cornerRadius = defaultRadiusAll
|
.cornerRadius = defaultRadiusAll
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
@ -115,7 +111,7 @@ constexpr Clay_CornerRadius defaultRadiusAll = {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Clay_Color PanelBackground(size_t idx);
|
extern Clay_Color PanelBackground(size_t idx);
|
||||||
extern Clay_Color PanelBorder(size_t idx);
|
extern Clay_Color PanelBackground(size_t idx);
|
||||||
extern Clay_Color TextColors(size_t idx);
|
extern Clay_Color TextColors(size_t idx);
|
||||||
extern Clay_Color WindowBackground();
|
extern Clay_Color WindowBackground();
|
||||||
extern Clay_ElementDeclaration WindowStyle();
|
extern Clay_ElementDeclaration WindowStyle();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue