Skip to content

Commit

Permalink
Fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Apr 30, 2024
1 parent 23221a0 commit d4ae67c
Showing 1 changed file with 47 additions and 48 deletions.
95 changes: 47 additions & 48 deletions src/retro_achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ namespace
if (bucket->achievements[j]->tile)
{
atlas_tile_t* tile = bucket->achievements[j]->tile;
uv0 = (ImVec2){tile->x1, tile->y1};
uv1 = (ImVec2){tile->x2, tile->y2};
uv0 = ImVec2{tile->x1, tile->y1};
uv1 = ImVec2{tile->x2, tile->y2};
image.id = tile->atlas_id;
}

Expand Down Expand Up @@ -1134,26 +1134,25 @@ void retro_achievements_update_atlases()

if (atlas->image.id == SG_INVALID_ID)
{
sg_image_desc desc = {
.type = SG_IMAGETYPE_2D,
.render_target = false,
.width = atlas->pixel_stride,
.height = atlas->pixel_stride,
.num_slices = 1,
.num_mipmaps = 1,
.usage = SG_USAGE_DYNAMIC,
.pixel_format = SG_PIXELFORMAT_RGBA8,
.sample_count = 1,
.min_filter = SG_FILTER_LINEAR,
.mag_filter = SG_FILTER_LINEAR,
.wrap_u = SG_WRAP_CLAMP_TO_EDGE,
.wrap_v = SG_WRAP_CLAMP_TO_EDGE,
.wrap_w = SG_WRAP_CLAMP_TO_EDGE,
.border_color = SG_BORDERCOLOR_TRANSPARENT_BLACK,
.max_anisotropy = 1,
.min_lod = 0.0f,
.max_lod = 1e9f,
};
sg_image_desc desc;
desc.type = SG_IMAGETYPE_2D,
desc.render_target = false,
desc.width = atlas->pixel_stride,
desc.height = atlas->pixel_stride,
desc.num_slices = 1,
desc.num_mipmaps = 1,
desc.usage = SG_USAGE_DYNAMIC,
desc.pixel_format = SG_PIXELFORMAT_RGBA8,
desc.sample_count = 1,
desc.min_filter = SG_FILTER_LINEAR,
desc.mag_filter = SG_FILTER_LINEAR,
desc.wrap_u = SG_WRAP_CLAMP_TO_EDGE,
desc.wrap_v = SG_WRAP_CLAMP_TO_EDGE,
desc.wrap_w = SG_WRAP_CLAMP_TO_EDGE,
desc.border_color = SG_BORDERCOLOR_TRANSPARENT_BLACK,
desc.max_anisotropy = 1,
desc.min_lod = 0.0f,
desc.max_lod = 1e9f,

atlas->image = sg_make_image(&desc);

Expand Down Expand Up @@ -1209,7 +1208,7 @@ void retro_achievements_draw_panel(int win_w)
enter |= igInputText("##Password", password, sizeof(password),
ImGuiInputTextFlags_Password | ImGuiInputTextFlags_EnterReturnsTrue,
NULL, NULL);
if (se_button(ICON_FK_SIGN_IN " Login", (ImVec2){0, 0}) || enter)
if (se_button(ICON_FK_SIGN_IN " Login", ImVec2{0, 0}) || enter)
{
retro_achievements_login(username, password);
}
Expand All @@ -1232,8 +1231,8 @@ void retro_achievements_draw_panel(int win_w)
if (game && game_image)
{
image.id = game_image->atlas_id;
offset1 = (ImVec2){game_image->x1, game_image->y1};
offset2 = (ImVec2){game_image->x2, game_image->y2};
offset1 = ImVec2{game_image->x1, game_image->y1};
offset2 = ImVec2{game_image->x2, game_image->y2};
#ifdef DEBUG_RETRO_ACHIEVEMENTS
snprintf(line2, 256, se_localize_and_cache("Playing: %s (%d)"), game->title, image.id);
#else
Expand All @@ -1243,7 +1242,7 @@ void retro_achievements_draw_panel(int win_w)
else
snprintf(line2, 256, "%s", se_localize_and_cache("No Game Loaded"));
se_boxed_image_dual_label(line1, line2, ICON_FK_TROPHY, image, 0, offset1, offset2);
if (se_button(ICON_FK_SIGN_OUT " Logout", (ImVec2){0, 0}))
if (se_button(ICON_FK_SIGN_OUT " Logout", ImVec2{0, 0}))
{
char login_info_path[SB_FILE_PATH_SIZE];
snprintf(login_info_path, SB_FILE_PATH_SIZE, "%sra_token.txt", se_get_pref_path());
Expand Down Expand Up @@ -1346,12 +1345,12 @@ void retro_achievements_draw_notifications(float left, float top)

float placard_height = padding + title_height + padding + submessage_height + padding + submessage2_height + padding;

ImDrawList_AddRectFilled(igGetWindowDrawList(), (ImVec2){x, y},
(ImVec2){x + placard_width, y + placard_height},
ImDrawList_AddRectFilled(igGetWindowDrawList(), ImVec2{x, y},
ImVec2{x + placard_width, y + placard_height},
0x515151 | ALPHA(180), 8.0f, ImDrawCornerFlags_All);

ImDrawList_AddRect(igGetWindowDrawList(), (ImVec2){x + (padding / 2), y + (padding / 2)},
(ImVec2){x + placard_width - (padding / 2), y + placard_height - (padding / 2)},
ImDrawList_AddRect(igGetWindowDrawList(), ImVec2{x + (padding / 2), y + (padding / 2)},
ImVec2{x + placard_width - (padding / 2), y + placard_height - (padding / 2)},
0x000000 | ALPHA(180), 8.0f, ImDrawCornerFlags_All, 2.0f);

if (notification.tile && notification.tile->atlas_id != SG_INVALID_ID)
Expand All @@ -1360,28 +1359,28 @@ void retro_achievements_draw_notifications(float left, float top)
ImVec2 uv1 = {notification.tile->x2, notification.tile->y2};
ImDrawList_AddImageRounded(
igGetWindowDrawList(), (ImTextureID)(intptr_t)notification.tile->atlas_id,
(ImVec2){x + padding, y + padding},
(ImVec2){x + padding + image_width, y + padding + image_height}, uv0, uv1,
ImVec2{x + padding, y + padding},
ImVec2{x + padding + image_width, y + padding + image_height}, uv0, uv1,
0xffffff | ALPHA(255), 8.0f, ImDrawCornerFlags_All);
}
else
{
ImDrawList_AddRectFilled(
igGetWindowDrawList(), (ImVec2){x + 15, y + 15},
(ImVec2){x + padding + image_width, y + padding + image_height},
igGetWindowDrawList(), ImVec2{x + 15, y + 15},
ImVec2{x + padding + image_width, y + padding + image_height},
0x242424 | ALPHA(255), 8.0f, ImDrawCornerFlags_All);
}

ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 22.0f,
(ImVec2){x + image_width + padding * 2, y + padding},
ImVec2{x + image_width + padding * 2, y + padding},
0xffffff | ALPHA(255), notification.title.c_str(), NULL,
wrap_width, NULL);
ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 18.0f,
(ImVec2){x + image_width + padding * 2, y + padding + title_height + padding},
ImVec2{x + image_width + padding * 2, y + padding + title_height + padding},
0x00aaaa | ALPHA(255), notification.submessage.c_str(), NULL,
wrap_width, NULL);
ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 18.0f,
(ImVec2){x + image_width + padding * 2, y + padding + title_height + padding + submessage_height + padding},
ImVec2{x + image_width + padding * 2, y + padding + title_height + padding + submessage_height + padding},
0xaaaa00 | ALPHA(255), notification.submessage2.c_str(), NULL,
wrap_width, NULL);

Expand All @@ -1403,7 +1402,7 @@ void retro_achievements_draw_progress_indicator(float right, float top) {

ra_progress_indicator_wrapper_t& indicator = game_state->progress_indicator;

ImDrawList_AddCircle(igGetWindowDrawList(), (ImVec2){right, top}, 20, 0xff000000, 32, 2.0f);
ImDrawList_AddCircle(igGetWindowDrawList(), ImVec2{right, top}, 20, 0xff000000, 32, 2.0f);

float image_width = 64;
float image_height = 64;
Expand All @@ -1423,12 +1422,12 @@ void retro_achievements_draw_progress_indicator(float right, float top) {

float placard_height = std::max(padding + title_height + padding + progress_height + padding, padding + image_height + padding);

ImDrawList_AddRectFilled(igGetWindowDrawList(), (ImVec2){x, y},
(ImVec2){x + placard_width, y + placard_height},
ImDrawList_AddRectFilled(igGetWindowDrawList(), ImVec2{x, y},
ImVec2{x + placard_width, y + placard_height},
0xff515151, 8.0f, ImDrawCornerFlags_All);

ImDrawList_AddRect(igGetWindowDrawList(), (ImVec2){x + (padding / 2), y + (padding / 2)},
(ImVec2){x + placard_width - (padding / 2), y + placard_height - (padding / 2)},
ImDrawList_AddRect(igGetWindowDrawList(), ImVec2{x + (padding / 2), y + (padding / 2)},
ImVec2{x + placard_width - (padding / 2), y + placard_height - (padding / 2)},
0xff000000, 8.0f, ImDrawCornerFlags_All, 2.0f);

if (indicator.tile && indicator.tile->atlas_id != SG_INVALID_ID)
Expand All @@ -1437,25 +1436,25 @@ void retro_achievements_draw_progress_indicator(float right, float top) {
ImVec2 uv1 = {indicator.tile->x2, indicator.tile->y2};
ImDrawList_AddImageRounded(
igGetWindowDrawList(), (ImTextureID)(intptr_t)indicator.tile->atlas_id,
(ImVec2){x + padding, y + padding},
(ImVec2){x + padding + image_width, y + padding + image_height}, uv0, uv1,
ImVec2{x + padding, y + padding},
ImVec2{x + padding + image_width, y + padding + image_height}, uv0, uv1,
0xffffffff, 8.0f, ImDrawCornerFlags_All);
}
else
{
ImDrawList_AddRectFilled(
igGetWindowDrawList(), (ImVec2){x + 15, y + 15},
(ImVec2){x + padding + image_width, y + padding + image_height},
igGetWindowDrawList(), ImVec2{x + 15, y + 15},
ImVec2{x + padding + image_width, y + padding + image_height},
0xff242424, 8.0f, ImDrawCornerFlags_All);
}

ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 22.0f,
(ImVec2){x + padding + image_width + padding, y + padding},
ImVec2{x + padding + image_width + padding, y + padding},
0xffffffff, indicator.title.c_str(), NULL,
wrap_width, NULL);

ImDrawList_AddTextFontPtr(igGetWindowDrawList(), igGetFont(), 18.0f,
(ImVec2){x + padding + image_width + padding, y + placard_height - padding - progress_height},
ImVec2{x + padding + image_width + padding, y + placard_height - padding - progress_height},
0xff00aaaa, indicator.measured_progress.c_str(), NULL,
wrap_width, NULL);
}

0 comments on commit d4ae67c

Please sign in to comment.