Show clock on menu (zoli0726)
This commit is contained in:
parent
dec77bf2f8
commit
fe542ebfcb
3 changed files with 18 additions and 4 deletions
|
|
@ -688,7 +688,7 @@ void GFX_blitRect(int asset, SDL_Surface* dst, SDL_Rect* dst_rect) {
|
||||||
SDL_FillRect(dst, &(SDL_Rect){x+r,y+h-r,w-d,r}, c);
|
SDL_FillRect(dst, &(SDL_Rect){x+r,y+h-r,w-d,r}, c);
|
||||||
GFX_blitAsset(asset, &(SDL_Rect){r,r,r,r}, dst, &(SDL_Rect){x+w-r,y+h-r});
|
GFX_blitAsset(asset, &(SDL_Rect){r,r,r,r}, dst, &(SDL_Rect){x+w-r,y+h-r});
|
||||||
}
|
}
|
||||||
void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect) {
|
void GFX_blitClockAndBattery(SDL_Surface* dst, SDL_Rect* dst_rect) {
|
||||||
// LOG_info("dst: %p\n", dst);
|
// LOG_info("dst: %p\n", dst);
|
||||||
|
|
||||||
if (!dst_rect) dst_rect = &(SDL_Rect){0,0,0,0};
|
if (!dst_rect) dst_rect = &(SDL_Rect){0,0,0,0};
|
||||||
|
|
@ -717,6 +717,19 @@ void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect) {
|
||||||
|
|
||||||
GFX_blitAsset(percent<=20?ASSET_BATTERY_FILL_LOW:ASSET_BATTERY_FILL, &clip, dst, &(SDL_Rect){x+SCALE1(3)+clip.x,y+SCALE1(2)});
|
GFX_blitAsset(percent<=20?ASSET_BATTERY_FILL_LOW:ASSET_BATTERY_FILL, &clip, dst, &(SDL_Rect){x+SCALE1(3)+clip.x,y+SCALE1(2)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the current time
|
||||||
|
time_t currentTime = time(NULL);
|
||||||
|
struct tm* timeinfo = localtime(¤tTime);
|
||||||
|
int hours = timeinfo->tm_hour;
|
||||||
|
int minutes = timeinfo->tm_min;
|
||||||
|
|
||||||
|
// Convert hours and minutes to strings
|
||||||
|
char timeStr[6];
|
||||||
|
snprintf(timeStr, sizeof(timeStr), "%02d:%02d", hours, minutes);
|
||||||
|
SDL_Surface* text = TTF_RenderUTF8_Blended(font.large, timeStr, COLOR_WHITE);
|
||||||
|
SDL_BlitSurface(text, NULL, dst, &(SDL_Rect){dst_rect->x - text->w - 20, dst_rect->y + (SCALE1(PILL_SIZE) - text->h) / 2});
|
||||||
|
SDL_FreeSurface(text);
|
||||||
}
|
}
|
||||||
int GFX_getButtonWidth(char* hint, char* button) {
|
int GFX_getButtonWidth(char* hint, char* button) {
|
||||||
int button_width = 0;
|
int button_width = 0;
|
||||||
|
|
@ -883,7 +896,7 @@ int GFX_blitHardwareGroup(SDL_Surface* dst, int show_setting) {
|
||||||
ow,
|
ow,
|
||||||
SCALE1(PILL_SIZE)
|
SCALE1(PILL_SIZE)
|
||||||
});
|
});
|
||||||
GFX_blitBattery(dst, &(SDL_Rect){ox,oy});
|
GFX_blitClockAndBattery(dst, &(SDL_Rect){ox,oy});
|
||||||
}
|
}
|
||||||
|
|
||||||
return ow;
|
return ow;
|
||||||
|
|
@ -1342,7 +1355,7 @@ static void POW_initOverlay(void) {
|
||||||
SDL_SetAlpha(gfx.assets, 0,0);
|
SDL_SetAlpha(gfx.assets, 0,0);
|
||||||
GFX_blitAsset(ASSET_BLACK_PILL, NULL, pow.overlay, NULL);
|
GFX_blitAsset(ASSET_BLACK_PILL, NULL, pow.overlay, NULL);
|
||||||
SDL_SetAlpha(gfx.assets, SDL_SRCALPHA,0);
|
SDL_SetAlpha(gfx.assets, SDL_SRCALPHA,0);
|
||||||
GFX_blitBattery(pow.overlay, NULL);
|
GFX_blitClockAndBattery(pow.overlay, NULL);
|
||||||
|
|
||||||
// setup overlay
|
// setup overlay
|
||||||
memset(&pow.oargs, 0, sizeof(struct owlfb_overlay_args));
|
memset(&pow.oargs, 0, sizeof(struct owlfb_overlay_args));
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@
|
||||||
#define SETTINGS_SIZE 4
|
#define SETTINGS_SIZE 4
|
||||||
#define SETTINGS_WIDTH 80
|
#define SETTINGS_WIDTH 80
|
||||||
|
|
||||||
|
#define CLOCK_SIZE 100
|
||||||
#define MAIN_ROW_COUNT 6 // SCREEN_HEIGHT / (PILL_SIZE * SCREEN_SCALE) - 2 (floor and subtract 1 if not an integer)
|
#define MAIN_ROW_COUNT 6 // SCREEN_HEIGHT / (PILL_SIZE * SCREEN_SCALE) - 2 (floor and subtract 1 if not an integer)
|
||||||
#define PADDING 10 // PILL_SIZE / 3 (or non-integer part of the previous calculatiom divided by three)
|
#define PADDING 10 // PILL_SIZE / 3 (or non-integer part of the previous calculatiom divided by three)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1537,7 +1537,7 @@ int main (int argc, char *argv[]) {
|
||||||
char* entry_name = entry->name;
|
char* entry_name = entry->name;
|
||||||
char* entry_unique = entry->unique;
|
char* entry_unique = entry->unique;
|
||||||
int available_width = screen->w - SCALE1(PADDING * 2);
|
int available_width = screen->w - SCALE1(PADDING * 2);
|
||||||
if (i==top->start) available_width -= ow;
|
if (i==top->start) available_width -= ow + CLOCK_SIZE;
|
||||||
|
|
||||||
SDL_Color text_color = COLOR_WHITE;
|
SDL_Color text_color = COLOR_WHITE;
|
||||||
if (isFavorite(entry->path)) {
|
if (isFavorite(entry->path)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue