void tray_update(HWND hWnd, struct th_data *data) { struct tray_status *status = &data->status; NOTIFYICONDATA *niData = &data->niData; HICON oldIcon; unsigned int fg, bg, p, d; BOOL ret; DWORD err; if (!data->tray_ok) { tray_add(hWnd, data); if (!data->tray_ok) return; } odprintf("tray[update]: conn=%d msg=\"%s\" temperature_celsius=%f relative_humidity=%f dew_point=%f", status->conn, status->msg, status->temperature_celsius, status->relative_humidity, status->dew_point); fg = icon_syscolour(COLOR_BTNTEXT); bg = icon_syscolour(COLOR_3DFACE); switch (status->conn) { case NOT_CONNECTED: if (not_connected_width < ICON_WIDTH || not_connected_height < ICON_HEIGHT) icon_wipe(bg); icon_blit(0, 0, 0, fg, bg, 0, 0, not_connected_width, not_connected_height, not_connected_bits); if (status->msg[0] != 0) ret = snprintf(niData->szTip, sizeof(niData->szTip), "Not Connected: %s", status->msg); else ret = snprintf(niData->szTip, sizeof(niData->szTip), "Not Connected"); if (ret < 0) niData->szTip[0] = 0; break; case CONNECTING: if (connecting_width < ICON_WIDTH || connecting_height < ICON_HEIGHT) icon_wipe(bg); icon_blit(0, 0, 0, fg, bg, 0, 0, connecting_width, connecting_height, connecting_bits); if (status->msg[0] != 0) ret = snprintf(niData->szTip, sizeof(niData->szTip), "Connecting to %s", status->msg); else ret = snprintf(niData->szTip, sizeof(niData->szTip), "Connecting"); if (ret < 0) niData->szTip[0] = 0; break; case CONNECTED: if (isnan(status->temperature_celsius)) { icon_clear(0, 0, bg, 0, 0, ICON_WIDTH, digits_base_height); p = 0; icon_blit(0, 0, 0, fg, bg, p, 0, digit_dash_width, digit_dash_height, digit_dash_bits); p += digit_dash_width + 1; icon_blit(0, 0, 0, fg, bg, p, 0, digit_dash_width, digit_dash_height, digit_dash_bits); p += digit_dash_width + 1; icon_blit(0, 0, 0, fg, bg, p, 0, digit_dot_width, digit_dot_height, digit_dot_bits); p += digit_dot_width + 1; icon_blit(0, 0, 0, fg, bg, p, 0, digit_dash_width, digit_dash_height, digit_dash_bits); } else { unsigned int h_fg, h_bg, h_end, hue; int tc = lrint(status->temperature_celsius * 100.0); if (tc > 99999) tc = 99999; if (tc < -9999) tc = -9999; hue = tray_range_to_hue(MIN_TEMPC, MIN_TEMPC_WARN, status->temperature_celsius, MAX_TEMPC_WARN, MAX_TEMPC); h_end = tray_hue_to_width(hue); h_fg = tray_hue_to_fg_colour(hue); h_bg = tray_hue_to_bg_colour(hue); icon_clear(h_bg, h_end, bg, 0, 0, ICON_WIDTH, digits_base_height); if (tc >= 9995) { /* _NNN 100 to 999 */ if (tc % 100 >= 50) tc += 100 - (tc % 100); p = digit_dot_width + 1; d = (tc/10000) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; d = (tc/1000) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; d = (tc/100) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); } else if (tc > 999) { /* NN.N 10.0 to 99.9 */ if (tc % 10 >= 5) tc += 10 - (tc % 10); p = 0; d = (tc/1000) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; d = (tc/100) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digit_dot_width, digit_dot_height, digit_dot_bits); p += digit_dot_width + 1; d = (tc/10) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); } else if (tc >= 0) { /* N.NN 0.00 to 9.99 */ p = 0; d = (tc/100) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digit_dot_width, digit_dot_height, digit_dot_bits); p += digit_dot_width + 1; d = (tc/10) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; d = tc % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); } else if (tc > -995) { /* -N.N -0.1 to -9.9 */ if (abs(tc) % 10 >= 5) tc -= 10 - (abs(tc) % 10); p = 0; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digit_dash_width, digit_dash_height, digit_dash_bits); p += digit_dash_width + 1; d = abs(tc/100) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digit_dot_width, digit_dot_height, digit_dot_bits); p += digit_dot_width + 1; d = abs(tc/10) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); } else /* if (tc >= -9999) */ { /* _-NN -10 to -99 */ if (abs(tc) % 100 >= 50) tc -= 100 - (abs(tc) % 100); p = digit_dot_width + 1; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digit_dash_width, digit_dash_height, digit_dash_bits); p += digit_dash_width + 1; d = abs(tc/1000) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; d = abs(tc/100) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, 0, digits_width[d], digits_height[d], digits_bits[d]); } } icon_clear(0, 0, bg, 0, ICON_HEIGHT/2 - (ICON_HEIGHT/2 - digits_base_height), ICON_WIDTH, (ICON_HEIGHT/2 - digits_base_height) * 2); if (isnan(status->relative_humidity)) { icon_clear(0, 0, bg, 0, ICON_HEIGHT - digits_base_height, ICON_WIDTH, digit_dash_height); p = 0; icon_blit(0, 0, 0, fg, bg, p, ICON_HEIGHT - digits_base_height, digit_dash_width, digit_dash_height, digit_dash_bits); p += digit_dash_width + 1; icon_blit(0, 0, 0, fg, bg, p, ICON_HEIGHT - digits_base_height, digit_dash_width, digit_dash_height, digit_dash_bits); p += digit_dash_width + 1; icon_blit(0, 0, 0, fg, bg, p, ICON_HEIGHT - digits_base_height, digit_dot_width, digit_dot_height, digit_dot_bits); p += digit_dot_width + 1; icon_blit(0, 0, 0, fg, bg, p, ICON_HEIGHT - digits_base_height, digit_dash_width, digit_dash_height, digit_dash_bits); } else { unsigned int h_fg, h_bg, h_end, hue; int rh = lrint(status->relative_humidity * 10.0); if (rh > 999) rh = 999; if (rh < 0) rh = 0; hue = tray_range_to_hue(MIN_DEWPC, MIN_DEWPC_WARN, status->dew_point, MAX_DEWPC_WARN, MAX_DEWPC); h_end = tray_hue_to_width(hue); h_fg = tray_hue_to_fg_colour(hue); h_bg = tray_hue_to_bg_colour(hue); icon_clear(h_bg, h_end, bg, 0, ICON_HEIGHT - digits_base_height, ICON_WIDTH, digits_base_height); /* NN.N 00.0 to 99.9 */ p = 0; d = (rh/100) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, ICON_HEIGHT - digits_base_height, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; d = (rh/10) % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, ICON_HEIGHT - digits_base_height, digits_width[d], digits_height[d], digits_bits[d]); p += digits_width[d] + 1; icon_blit(h_fg, h_bg, h_end, fg, bg, p, ICON_HEIGHT - digits_base_height, digit_dot_width, digit_dot_height, digit_dot_bits); p += digit_dot_width + 1; d = rh % 10; icon_blit(h_fg, h_bg, h_end, fg, bg, p, ICON_HEIGHT - digits_base_height, digits_width[d], digits_height[d], digits_bits[d]); } snprintf(niData->szTip, sizeof(niData->szTip), "Temperature: %.2fC, Relative Humidity: %.2f%%, Dew Point: %.2fC", status->temperature_celsius, status->relative_humidity, status->dew_point); break; default: return; } oldIcon = niData->hIcon; niData->uFlags &= ~NIF_ICON; niData->hIcon = icon_create(); if (niData->hIcon != NULL) niData->uFlags |= NIF_ICON; SetLastError(0); ret = Shell_NotifyIcon(NIM_MODIFY, niData); err = GetLastError(); odprintf("Shell_NotifyIcon[MODIFY]: %s (%ld)", ret == TRUE ? "TRUE" : "FALSE", err); if (ret != TRUE) tray_remove(hWnd, data); if (oldIcon != NULL) icon_destroy(niData->hIcon); }
/* * item_create() * Creates a new item */ item_t *item_create(int type) { item_t *item = NULL; switch(type) { case IT_RING: item = collectible_create(); break; case IT_BOUNCINGRING: item = bouncingcollectible_create(); break; case IT_LIFEBOX: item = lifebox_create(); break; case IT_RINGBOX: item = collectiblebox_create(); break; case IT_STARBOX: item = starbox_create(); break; case IT_SPEEDBOX: item = speedbox_create(); break; case IT_GLASSESBOX: item = glassesbox_create(); break; case IT_SHIELDBOX: item = shieldbox_create(); break; case IT_FIRESHIELDBOX: item = fireshieldbox_create(); break; case IT_THUNDERSHIELDBOX: item = thundershieldbox_create(); break; case IT_WATERSHIELDBOX: item = watershieldbox_create(); break; case IT_ACIDSHIELDBOX: item = acidshieldbox_create(); break; case IT_WINDSHIELDBOX: item = windshieldbox_create(); break; case IT_TRAPBOX: item = trapbox_create(); break; case IT_EMPTYBOX: item = emptybox_create(); break; case IT_CRUSHEDBOX: item = crushedbox_create(); break; case IT_ICON: item = icon_create(); break; case IT_EXPLOSION: item = explosion_create(); break; case IT_FLYINGTEXT: item = flyingtext_create(); break; case IT_ANIMAL: item = animal_create(); break; case IT_LOOPRIGHT: item = loopright_create(); break; case IT_LOOPMIDDLE: item = looptop_create(); break; case IT_LOOPLEFT: item = loopleft_create(); break; case IT_LOOPNONE: item = loopnone_create(); break; case IT_LOOPFLOOR: item = loopfloor_create(); break; case IT_LOOPFLOORNONE: item = loopfloornone_create(); break; case IT_LOOPFLOORTOP: item = loopfloortop_create(); break; case IT_YELLOWSPRING: item = yellowspring_create(); break; case IT_BYELLOWSPRING: item = byellowspring_create(); break; case IT_TRYELLOWSPRING: item = tryellowspring_create(); break; case IT_RYELLOWSPRING: item = ryellowspring_create(); break; case IT_BRYELLOWSPRING: item = bryellowspring_create(); break; case IT_BLYELLOWSPRING: item = blyellowspring_create(); break; case IT_LYELLOWSPRING: item = lyellowspring_create(); break; case IT_TLYELLOWSPRING: item = tlyellowspring_create(); break; case IT_REDSPRING: item = redspring_create(); break; case IT_BREDSPRING: item = bredspring_create(); break; case IT_TRREDSPRING: item = trredspring_create(); break; case IT_RREDSPRING: item = rredspring_create(); break; case IT_BRREDSPRING: item = brredspring_create(); break; case IT_BLREDSPRING: item = blredspring_create(); break; case IT_LREDSPRING: item = lredspring_create(); break; case IT_TLREDSPRING: item = tlredspring_create(); break; case IT_BLUESPRING: item = bluespring_create(); break; case IT_BBLUESPRING: item = bbluespring_create(); break; case IT_TRBLUESPRING: item = trbluespring_create(); break; case IT_RBLUESPRING: item = rbluespring_create(); break; case IT_BRBLUESPRING: item = brbluespring_create(); break; case IT_BLBLUESPRING: item = blbluespring_create(); break; case IT_LBLUESPRING: item = lbluespring_create(); break; case IT_TLBLUESPRING: item = tlbluespring_create(); break; case IT_BLUERING: item = supercollectible_create(); break; case IT_SWITCH: item = switch_create(); break; case IT_DOOR: item = door_create(); break; case IT_TELEPORTER: item = teleporter_create(); break; case IT_BIGRING: item = bigring_create(); break; case IT_CHECKPOINT: item = checkpointorb_create(); break; case IT_GOAL: item = goalsign_create(); break; case IT_ENDSIGN: item = endsign_create(); break; case IT_ENDLEVEL: item = animalprison_create(); break; case IT_BUMPER: item = bumper_create(); break; case IT_DANGER: item = horizontaldanger_create(); break; case IT_VDANGER: item = verticaldanger_create(); break; case IT_FIREDANGER: item = horizontalfiredanger_create(); break; case IT_VFIREDANGER: item = verticalfiredanger_create(); break; case IT_SPIKES: item = floorspikes_create(); break; case IT_CEILSPIKES: item = ceilingspikes_create(); break; case IT_LWSPIKES: item = leftwallspikes_create(); break; case IT_RWSPIKES: item = rightwallspikes_create(); break; case IT_PERSPIKES: item = periodic_floorspikes_create(); break; case IT_PERCEILSPIKES: item = periodic_ceilingspikes_create(); break; case IT_PERLWSPIKES: item = periodic_leftwallspikes_create(); break; case IT_PERRWSPIKES: item = periodic_rightwallspikes_create(); break; case IT_DNADOOR: item = surge_dnadoor_create(); break; case IT_DNADOORNEON: item = neon_dnadoor_create(); break; case IT_DNADOORCHARGE: item = charge_dnadoor_create(); break; case IT_HDNADOOR: item = surge_horizontal_dnadoor_create(); break; case IT_HDNADOORNEON: item = neon_horizontal_dnadoor_create(); break; case IT_HDNADOORCHARGE: item = charge_horizontal_dnadoor_create(); break; case IT_LOOPGREEN: item = loopgreen_create(); break; case IT_LOOPYELLOW: item = loopyellow_create(); break; } if(item != NULL) { item->type = type; item->state = IS_IDLE; item->init(item); } return item; }