Display a netstatus icon. Updated/added icons from #79. Closes #79.

This commit is contained in:
yellows8 2019-06-20 17:34:04 -04:00
parent 527ecb6ce3
commit e91758984c
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
22 changed files with 49 additions and 27 deletions

View File

@ -9,7 +9,7 @@ EXTRA_CFLAGS="-D__USE_MINGW_ANSI_STDIO"
EXTRA_LDFLAGS="-lws2_32"
endif
test : pc_main/main.cpp pc_main/pc_launch.c pc_main/pc_power.c \
test : pc_main/main.cpp pc_main/pc_launch.c pc_main/pc_power.c pc_main/pc_netstatus.c \
common/menu.c common/font.c common/language.c common/launch.c common/worker.c \
common/menu-entry.c common/menu-list.c common/message-box.c common/text.c \
common/ui.c common/assets.c common/math.c common/theme.c \

BIN
assets/airplane_icon.bin Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/eth_icon.bin Normal file

Binary file not shown.

BIN
assets/eth_none_icon.bin Normal file

Binary file not shown.

BIN
assets/wifi1_icon.bin Normal file

Binary file not shown.

BIN
assets/wifi2_icon.bin Normal file

Binary file not shown.

BIN
assets/wifi3_icon.bin Normal file

Binary file not shown.

BIN
assets/wifi_none_icon.bin Normal file

Binary file not shown.

View File

@ -20,6 +20,13 @@ assetsDataEntry g_assetsDataList[AssetId_Max] = {
GENASSET("hbmenu_logo_light.bin"),
GENASSET("theme_icon_dark.bin"),
GENASSET("theme_icon_light.bin"),
GENASSET("airplane_icon.bin"),
GENASSET("wifi_none_icon.bin"),
GENASSET("wifi1_icon.bin"),
GENASSET("wifi2_icon.bin"),
GENASSET("wifi3_icon.bin"),
GENASSET("eth_icon.bin"),
GENASSET("eth_none_icon.bin"),
};
static void assetsClearEntry(assetsDataEntry *entry) {

View File

@ -10,6 +10,13 @@ typedef enum {
AssetId_hbmenu_logo_light,
AssetId_theme_icon_dark,
AssetId_theme_icon_light,
AssetId_airplane_icon,
AssetId_wifi_none_icon,
AssetId_wifi1_icon,
AssetId_wifi2_icon,
AssetId_wifi3_icon,
AssetId_eth_icon,
AssetId_eth_none_icon,
AssetId_Max
} AssetId;

View File

@ -64,6 +64,7 @@ typedef union {
#include "message-box.h"
#include "power.h"
#include "netloader.h"
#include "netstatus.h"
void menuStartupPath(void);
void menuStartup(void);

View File

@ -414,7 +414,36 @@ void drawWave(int id, float timer, color_t color, int height, float phase, float
}
}
void drawTime() {
void drawCharge() {
char chargeString[5];
uint32_t batteryCharge;
bool isCharging;
bool validPower;
validPower = powerGetDetails(&batteryCharge, &isCharging);
if (validPower)
{
batteryCharge = (batteryCharge > 100) ? 100 : batteryCharge;
sprintf(chargeString, "%d%%", batteryCharge);
int tmpX = GetTextXCoordinate(interuiregular14, 1180 - 10, chargeString, 'r');
DrawText(interuiregular14, tmpX - 17, 0 + 47 + 10 + 21 + 4, themeCurrent.textColor, chargeString);
drawIcon(1180 - 16 - 8, 0 + 47 + 10 + 6, 24, 24, assetsGetDataBuffer(AssetId_battery_icon), themeCurrent.textColor);
if (isCharging)
drawIcon(tmpX - 32 - 10, 0 + 47 + 10 + 6, 24, 24, assetsGetDataBuffer(AssetId_charging_icon), themeCurrent.textColor);
}
}
void drawNetwork(int tmpX) {
AssetId id;
if (netstatusGetDetails(&id))
drawIcon(tmpX + 5, 0 + 47 + 10 + 3, 24, 24, assetsGetDataBuffer(id), themeCurrent.textColor);
}
void drawStatus() {
char timeString[9];
@ -431,29 +460,8 @@ void drawTime() {
DrawText(interuimedium20, tmpX, 0 + 47 + 10, themeCurrent.textColor, timeString);
}
void drawCharge() {
char chargeString[5];
uint32_t batteryCharge;
bool isCharging;
bool validPower;
validPower = powerGetDetails(&batteryCharge, &isCharging);
if (validPower)
{
batteryCharge = (batteryCharge > 100) ? 100 : batteryCharge;
sprintf(chargeString, "%d%%", batteryCharge);
int tmpX = GetTextXCoordinate(interuiregular14, 1180, chargeString, 'r');
DrawText(interuiregular14, tmpX - 15, 0 + 47 + 10 + 21, themeCurrent.textColor, chargeString);
drawIcon(1180 - 11, 0 + 47 + 10 + 6, 10, 15, assetsGetDataBuffer(AssetId_battery_icon), themeCurrent.textColor);
if (isCharging)
drawIcon(tmpX - 32, 0 + 47 + 10 + 6, 9, 15, assetsGetDataBuffer(AssetId_charging_icon), themeCurrent.textColor);
}
drawCharge();
drawNetwork(tmpX);
}
void drawButtons(menu_s* menu, bool emptyDir, int *x_image_out) {
@ -553,8 +561,7 @@ void menuLoop(void) {
DrawText(interuiregular14, 180 + 256, 46 + 16 + 18, themeCurrent.textColor, tmpstr);
#endif
drawTime();
drawCharge();
drawStatus();
memset(&netloader_state, 0, sizeof(netloader_state));
netloaderGetState(&netloader_state);

BIN
resources/airplane_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 B

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
resources/eth_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

BIN
resources/wifi1_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
resources/wifi2_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
resources/wifi3_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB