mirror of https://github.com/ClassiCube/ClassiCube
Gamecube: Show network details on startup
This commit is contained in:
parent
0f542d8517
commit
68572b545e
|
|
@ -6,17 +6,18 @@
|
|||
#include "Window.h"
|
||||
#include "SystemFonts.h"
|
||||
|
||||
static cc_bool dlg_close;
|
||||
static cc_bool vd_close;
|
||||
static short vd_lineSpace;
|
||||
|
||||
/* Prevent normal input handling from seeing next button press */
|
||||
static cc_bool VirtualDialog_InputHook(int key, struct InputDevice* device) { return true; }
|
||||
|
||||
static void VirtualDialog_OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* device) {
|
||||
dlg_close = true;
|
||||
vd_close = true;
|
||||
}
|
||||
|
||||
struct LogPosition { struct Bitmap* bmp; int x, y; };
|
||||
#define VD_BEG_X 10
|
||||
#define VD_LINE_SPACE 20
|
||||
|
||||
static void PlotOnscreen(int x, int y, void* ctx) {
|
||||
struct LogPosition* pos = ctx;
|
||||
|
|
@ -34,15 +35,17 @@ static int DrawText(const char* msg, struct Bitmap* bmp, int y) {
|
|||
pos.x = VD_BEG_X;
|
||||
pos.y = y;
|
||||
|
||||
int scale = max(1, 2 * DisplayInfo.ScaleY);
|
||||
|
||||
while (*msg)
|
||||
{
|
||||
char c = *msg;
|
||||
if (pos.x + 20 >= bmp->width || c == '\n') {
|
||||
pos.x = VD_BEG_X;
|
||||
pos.y += VD_LINE_SPACE;
|
||||
pos.y += vd_lineSpace;
|
||||
}
|
||||
|
||||
if (c != '\n') { pos.x += FallbackFont_Plot((cc_uint8)c, PlotOnscreen, 1, &pos); }
|
||||
if (c != '\n') { pos.x += FallbackFont_Plot((cc_uint8)c, PlotOnscreen, scale, &pos); }
|
||||
msg++;
|
||||
}
|
||||
return pos.y;
|
||||
|
|
@ -64,16 +67,18 @@ static void VirtualDialog_Show(const char* title, const char* msg) {
|
|||
|
||||
struct Context2D ctx;
|
||||
Context2D_Wrap(&ctx, &bmp);
|
||||
Context2D_Clear(&ctx, BitmapCol_Make(50, 50, 50, 255),
|
||||
Context2D_Clear(&ctx, BitmapCol_Make(30, 30, 30, 255),
|
||||
0, 0, bmp.width, bmp.height);
|
||||
|
||||
const char* ipt_msg = "Press any button to continue (or wait 5 seconds)";
|
||||
dlg_close = false;
|
||||
vd_close = false;
|
||||
|
||||
vd_lineSpace = 20 * DisplayInfo.ScaleY;
|
||||
int y = max(30, bmp.height / 2 - 50);
|
||||
|
||||
y = DrawText(title, &bmp, y);
|
||||
y = DrawText(msg, &bmp, y + 20);
|
||||
DrawText(ipt_msg, &bmp, bmp.height - 30);
|
||||
y = DrawText(msg, &bmp, y + vd_lineSpace);
|
||||
DrawText(ipt_msg, &bmp, bmp.height - vd_lineSpace * 2);
|
||||
|
||||
Input_DownHook old_hook = Input.DownHook;
|
||||
Input.DownHook = VirtualDialog_InputHook;
|
||||
|
|
@ -82,7 +87,7 @@ static void VirtualDialog_Show(const char* title, const char* msg) {
|
|||
Rect2D rect = { 0, 0, bmp.width, bmp.height };
|
||||
cc_bool has_window = Window_Main.Exists;
|
||||
|
||||
for (int i = 0; !dlg_close && i < VD_MAX_ITERS; i++)
|
||||
for (int i = 0; !vd_close && i < VD_MAX_ITERS; i++)
|
||||
{
|
||||
Window_ProcessEvents(1.0f / VD_TICK_INTERVAL);
|
||||
Gamepads_Process( 1.0f / VD_TICK_INTERVAL);
|
||||
|
|
@ -94,7 +99,7 @@ static void VirtualDialog_Show(const char* title, const char* msg) {
|
|||
if (has_window && !Window_Main.Exists) break;
|
||||
}
|
||||
|
||||
Context2D_Clear(&ctx, BitmapCol_Make(40, 40, 40, 255),
|
||||
Context2D_Clear(&ctx, BitmapCol_Make(20, 20, 20, 255),
|
||||
0, 0, bmp.width, bmp.height);
|
||||
Window_DrawFramebuffer(rect, &bmp);
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,12 @@ static void InitSockets(void) {
|
|||
|
||||
int ret = if_config(localip, netmask, gateway, TRUE, 20);
|
||||
if (ret >= 0) {
|
||||
Platform_Log3("Network ip: %c, gw: %c, mask %c", localip, gateway, netmask);
|
||||
cc_string str; char buffer[256];
|
||||
String_InitArray_NT(str, buffer);
|
||||
String_Format3(&str, "IP address: %c\nGateway IP: %c\nNetmask %c", localip, gateway, netmask);
|
||||
|
||||
buffer[str.length] = '\0';
|
||||
Window_ShowDialog("Networking details", buffer);
|
||||
} else {
|
||||
Logger_SimpleWarn(ret, "setting up network");
|
||||
net_supported = false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue