void uicb_screen_prev(Uicb cmd) { struct screen *s = SLIST_FIRST(&W->h.screen); (void)cmd; while(SLIST_NEXT(s, next) && SLIST_NEXT(s, next) != s) s = SLIST_NEXT(s, next); screen_select(s); }
void uicb_screen_next(Uicb cmd) { struct screen *s = SLIST_NEXT(W->screen, next); (void)cmd; if(!s) s = SLIST_FIRST(&W->h.screen); screen_select(s); }
static void ui_draw_bottom(ui_view* ui) { u32 bottomScreenBgWidth = 0; u32 bottomScreenBgHeight = 0; screen_get_texture_size(&bottomScreenBgWidth, &bottomScreenBgHeight, TEXTURE_BOTTOM_SCREEN_BG); u32 bottomScreenTopBarWidth = 0; u32 bottomScreenTopBarHeight = 0; screen_get_texture_size(&bottomScreenTopBarWidth, &bottomScreenTopBarHeight, TEXTURE_BOTTOM_SCREEN_TOP_BAR); u32 bottomScreenTopBarShadowWidth = 0; u32 bottomScreenTopBarShadowHeight = 0; screen_get_texture_size(&bottomScreenTopBarShadowWidth, &bottomScreenTopBarShadowHeight, TEXTURE_BOTTOM_SCREEN_TOP_BAR_SHADOW); u32 bottomScreenBottomBarWidth = 0; u32 bottomScreenBottomBarHeight = 0; screen_get_texture_size(&bottomScreenBottomBarWidth, &bottomScreenBottomBarHeight, TEXTURE_BOTTOM_SCREEN_BOTTOM_BAR); u32 bottomScreenBottomBarShadowWidth = 0; u32 bottomScreenBottomBarShadowHeight = 0; screen_get_texture_size(&bottomScreenBottomBarShadowWidth, &bottomScreenBottomBarShadowHeight, TEXTURE_BOTTOM_SCREEN_BOTTOM_BAR_SHADOW); screen_select(GFX_BOTTOM); screen_draw_texture(TEXTURE_BOTTOM_SCREEN_BG, (BOTTOM_SCREEN_WIDTH - bottomScreenBgWidth) / 2, (BOTTOM_SCREEN_HEIGHT - bottomScreenBgHeight) / 2, bottomScreenBgWidth, bottomScreenBgHeight); if(ui->drawBottom != NULL) { ui->drawBottom(ui, ui->data, 0, bottomScreenTopBarHeight, BOTTOM_SCREEN_WIDTH, BOTTOM_SCREEN_HEIGHT - bottomScreenBottomBarHeight); } float bottomScreenTopBarX = (BOTTOM_SCREEN_WIDTH - bottomScreenTopBarWidth) / 2; float bottomScreenTopBarY = 0; screen_draw_texture(TEXTURE_BOTTOM_SCREEN_TOP_BAR, bottomScreenTopBarX, bottomScreenTopBarY, bottomScreenTopBarWidth, bottomScreenTopBarHeight); screen_draw_texture(TEXTURE_BOTTOM_SCREEN_TOP_BAR_SHADOW, bottomScreenTopBarX, bottomScreenTopBarY + bottomScreenTopBarHeight, bottomScreenTopBarShadowWidth, bottomScreenTopBarShadowHeight); float bottomScreenBottomBarX = (BOTTOM_SCREEN_WIDTH - bottomScreenBottomBarWidth) / 2; float bottomScreenBottomBarY = BOTTOM_SCREEN_HEIGHT - bottomScreenBottomBarHeight; screen_draw_texture(TEXTURE_BOTTOM_SCREEN_BOTTOM_BAR, bottomScreenBottomBarX, bottomScreenBottomBarY, bottomScreenBottomBarWidth, bottomScreenBottomBarHeight); screen_draw_texture(TEXTURE_BOTTOM_SCREEN_BOTTOM_BAR_SHADOW, bottomScreenBottomBarX, bottomScreenBottomBarY - bottomScreenBottomBarShadowHeight, bottomScreenBottomBarShadowWidth, bottomScreenBottomBarShadowHeight); if(ui->name != NULL) { float nameWidth; float nameHeight; screen_get_string_size(&nameWidth, &nameHeight, ui->name, 0.5f, 0.5f); screen_draw_string(ui->name, (BOTTOM_SCREEN_WIDTH - nameWidth) / 2, (bottomScreenTopBarHeight - nameHeight) / 2, 0.5f, 0.5f, COLOR_TEXT, false); } if(ui->info != NULL) { float infoWidth; float infoHeight; screen_get_string_size(&infoWidth, &infoHeight, ui->info, 0.5f, 0.5f); screen_draw_string(ui->info, (BOTTOM_SCREEN_WIDTH - infoWidth) / 2, BOTTOM_SCREEN_HEIGHT - (bottomScreenBottomBarHeight + infoHeight) / 2, 0.5f, 0.5f, COLOR_TEXT, false); } }
LOCAL ICACHE_FLASH_ATTR int handleCommandSelect(clientInfo_t *cl) { if (cl->argc!=1) { client_senderror(cl,"INVALIDARGS"); } screen_t *s = screen_find(cl->argv[0]); if (s) { screen_select(s); client_sendOK(cl,"SELECT"); } else { client_senderror(cl,"NOTFOUND"); } return s!=NULL; }
void schedule_event() { screen_t *s; if (!schedule_running) return; #ifdef DEBUG printf("Schedule: current tick %d, delay %d, cptr %p\n", current_tick, current_delay, current); #endif current_tick++; if (current_tick==SCHEDULE_TICKS) { current_tick=0; if (current_delay) { current_delay--; } else { // Handle event. if (current) { #ifdef DEBUG printf("New schedule, type %d\n", current->type); #endif switch (current->type) { case SCHEDULE_SELECT: s = screen_find(current->val.string); if (s) { screen_select(s); } else { #ifdef DEBUG printf("Cannot find screen\n"); abort(); #endif } break; case SCHEDULE_WAIT: current_delay = current->val.intval * 10; break; } current = current->next; if (current==NULL) { current = schedule_root; } } } } }
static void ui_draw_top(ui_view* ui) { u32 topScreenBgWidth = 0; u32 topScreenBgHeight = 0; screen_get_texture_size(&topScreenBgWidth, &topScreenBgHeight, TEXTURE_TOP_SCREEN_BG); u32 topScreenTopBarWidth = 0; u32 topScreenTopBarHeight = 0; screen_get_texture_size(&topScreenTopBarWidth, &topScreenTopBarHeight, TEXTURE_TOP_SCREEN_TOP_BAR); u32 topScreenTopBarShadowWidth = 0; u32 topScreenTopBarShadowHeight = 0; screen_get_texture_size(&topScreenTopBarShadowWidth, &topScreenTopBarShadowHeight, TEXTURE_TOP_SCREEN_TOP_BAR_SHADOW); u32 topScreenBottomBarWidth = 0; u32 topScreenBottomBarHeight = 0; screen_get_texture_size(&topScreenBottomBarWidth, &topScreenBottomBarHeight, TEXTURE_TOP_SCREEN_BOTTOM_BAR); u32 topScreenBottomBarShadowWidth = 0; u32 topScreenBottomBarShadowHeight = 0; screen_get_texture_size(&topScreenBottomBarShadowWidth, &topScreenBottomBarShadowHeight, TEXTURE_TOP_SCREEN_BOTTOM_BAR_SHADOW); screen_select(GFX_TOP); screen_draw_texture(TEXTURE_TOP_SCREEN_BG, (TOP_SCREEN_WIDTH - topScreenBgWidth) / 2, (TOP_SCREEN_HEIGHT - topScreenBgHeight) / 2, topScreenBgWidth, topScreenBgHeight); if(ui->drawTop != NULL) { ui->drawTop(ui, ui->data, 0, topScreenTopBarHeight, TOP_SCREEN_WIDTH, TOP_SCREEN_HEIGHT - topScreenBottomBarHeight); } float topScreenTopBarX = (TOP_SCREEN_WIDTH - topScreenTopBarWidth) / 2; float topScreenTopBarY = 0; screen_draw_texture(TEXTURE_TOP_SCREEN_TOP_BAR, topScreenTopBarX, topScreenTopBarY, topScreenTopBarWidth, topScreenTopBarHeight); screen_draw_texture(TEXTURE_TOP_SCREEN_TOP_BAR_SHADOW, topScreenTopBarX, topScreenTopBarY + topScreenTopBarHeight, topScreenTopBarShadowWidth, topScreenTopBarShadowHeight); float topScreenBottomBarX = (TOP_SCREEN_WIDTH - topScreenBottomBarWidth) / 2; float topScreenBottomBarY = TOP_SCREEN_HEIGHT - topScreenBottomBarHeight; screen_draw_texture(TEXTURE_TOP_SCREEN_BOTTOM_BAR, topScreenBottomBarX, topScreenBottomBarY, topScreenBottomBarWidth, topScreenBottomBarHeight); screen_draw_texture(TEXTURE_TOP_SCREEN_BOTTOM_BAR_SHADOW, topScreenBottomBarX, topScreenBottomBarY - topScreenBottomBarShadowHeight, topScreenBottomBarShadowWidth, topScreenBottomBarShadowHeight); time_t t = time(NULL); char* timeText = ctime(&t); float timeTextWidth; float timeTextHeight; screen_get_string_size(&timeTextWidth, &timeTextHeight, timeText, 0.5f, 0.5f); screen_draw_string(timeText, topScreenTopBarX + (topScreenTopBarWidth - timeTextWidth) / 2, topScreenTopBarY + (topScreenTopBarHeight - timeTextHeight) / 2, 0.5f, 0.5f, COLOR_TEXT, false); u32 batteryIcon = 0; u8 batteryChargeState = 0; u8 batteryLevel = 0; if(R_SUCCEEDED(PTMU_GetBatteryChargeState(&batteryChargeState)) && batteryChargeState) { batteryIcon = TEXTURE_BATTERY_CHARGING; } else if(R_SUCCEEDED(PTMU_GetBatteryLevel(&batteryLevel))) { batteryIcon = TEXTURE_BATTERY_0 + batteryLevel; } else { batteryIcon = TEXTURE_BATTERY_0; } u32 batteryWidth; u32 batteryHeight; screen_get_texture_size(&batteryWidth, &batteryHeight, batteryIcon); float batteryX = topScreenTopBarX + topScreenTopBarWidth - 2 - batteryWidth; float batteryY = topScreenTopBarY + (topScreenTopBarHeight - batteryHeight) / 2; screen_draw_texture(batteryIcon, batteryX, batteryY, batteryWidth, batteryHeight); u32 wifiIcon = 0; u32 wifiStatus = 0; if(R_SUCCEEDED(ACU_GetWifiStatus(&wifiStatus)) && wifiStatus) { wifiIcon = TEXTURE_WIFI_0 + osGetWifiStrength(); } else { wifiIcon = TEXTURE_WIFI_DISCONNECTED; } u32 wifiWidth; u32 wifiHeight; screen_get_texture_size(&wifiWidth, &wifiHeight, wifiIcon); float wifiX = topScreenTopBarX + topScreenTopBarWidth - 2 - batteryWidth - 4 - wifiWidth; float wifiY = topScreenTopBarY + (topScreenTopBarHeight - wifiHeight) / 2; screen_draw_texture(wifiIcon, wifiX, wifiY, wifiWidth, wifiHeight); FS_ArchiveResource sd; FSUSER_GetSdmcArchiveResource(&sd); FS_ArchiveResource nand; FSUSER_GetNandArchiveResource(&nand); char buffer[64]; snprintf(buffer, 64, "SD: %.1f MiB, NAND: %.1f MiB", ((u64) sd.freeClusters * (u64) sd.clusterSize) / 1024.0 / 1024.0, ((u64) nand.freeClusters * (u64) nand.clusterSize) / 1024.0 / 1024.0); float freeSpaceHeight; screen_get_string_size(NULL, &freeSpaceHeight, buffer, 0.5f, 0.5f); screen_draw_string(buffer, topScreenBottomBarX + 2, topScreenBottomBarY + (topScreenBottomBarHeight - freeSpaceHeight) / 2, 0.5f, 0.5f, COLOR_TEXT, false); }