mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
mc:// urls can be pasted into direct connect screen input fields now
The username/address/mppass input fields will all be automatically set to the corresponding extracted values from the mc:// url
This commit is contained in:
parent
c8cdd41a1b
commit
ed47d1adda
@ -213,7 +213,7 @@ GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipm
|
||||
if (!Math_IsPowOf2(bmp->width) || !Math_IsPowOf2(bmp->height)) {
|
||||
Logger_Abort("Textures must have power of two dimensions");
|
||||
}
|
||||
if (Gfx.LostContext) return NULL;
|
||||
if (Gfx.LostContext) return 0;
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc = { 0 };
|
||||
desc.Width = bmp->width;
|
||||
|
@ -532,6 +532,19 @@ static struct DirectConnectScreen {
|
||||
struct LWidget* _widgets[6];
|
||||
} DirectConnectScreen_Instance;
|
||||
|
||||
static void DirectConnectScreen_UrlFilter(cc_string* str) {
|
||||
static const cc_string prefix = String_FromConst("mc://");
|
||||
cc_string parts[6];
|
||||
if (!String_CaselessStarts(str, &prefix)) return;
|
||||
/* mc://[ip:port]/[username]/[mppass] */
|
||||
if (String_UNSAFE_Split(str, '/', parts, 6) != 5) return;
|
||||
|
||||
LInput_SetString(&DirectConnectScreen_Instance.iptAddress, &parts[2]);
|
||||
LInput_SetString(&DirectConnectScreen_Instance.iptUsername, &parts[3]);
|
||||
LInput_SetString(&DirectConnectScreen_Instance.iptMppass, &parts[4]);
|
||||
str->length = 0;
|
||||
}
|
||||
|
||||
CC_NOINLINE static void DirectConnectScreen_SetStatus(const char* text) {
|
||||
struct LLabel* w = &DirectConnectScreen_Instance.lblStatus;
|
||||
LLabel_SetConst(w, text);
|
||||
@ -617,6 +630,10 @@ static void DirectConnectScreen_Init(struct LScreen* s_) {
|
||||
LButton_Init(s_, &s->btnBack, 80, 35, "Back");
|
||||
LLabel_Init(s_, &s->lblStatus, "");
|
||||
|
||||
s->iptUsername.ClipboardFilter = DirectConnectScreen_UrlFilter;
|
||||
s->iptAddress.ClipboardFilter = DirectConnectScreen_UrlFilter;
|
||||
s->iptMppass.ClipboardFilter = DirectConnectScreen_UrlFilter;
|
||||
|
||||
s->btnConnect.OnClick = DirectConnectScreen_StartClient;
|
||||
s->btnBack.OnClick = SwitchToMain;
|
||||
/* Init input text from options */
|
||||
|
@ -457,6 +457,12 @@ void LInput_Clear(struct LInput* w) {
|
||||
LWidget_Redraw(w);
|
||||
}
|
||||
|
||||
void LInput_SetString(struct LInput* w, const cc_string* str) {
|
||||
LInput_SetText(w, str);
|
||||
if (w->TextChanged) w->TextChanged(w);
|
||||
LWidget_Redraw(w);
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------LabelWidget--------------------------------------------------------*
|
||||
|
@ -96,16 +96,18 @@ CC_NOINLINE void LInput_Init(struct LScreen* s, struct LInput* w, int width, con
|
||||
CC_NOINLINE void LInput_SetText(struct LInput* w, const cc_string* text);
|
||||
CC_NOINLINE void LInput_ClearText(struct LInput* w);
|
||||
|
||||
/* Appends a character to the currently entered text. */
|
||||
/* Appends a character to the currently entered text */
|
||||
CC_NOINLINE void LInput_Append(struct LInput* w, char c);
|
||||
/* Appends a string to the currently entered text. */
|
||||
/* Appends a string to the currently entered text */
|
||||
CC_NOINLINE void LInput_AppendString(struct LInput* w, const cc_string* str);
|
||||
/* Removes the character preceding the caret in the currently entered text. */
|
||||
/* Removes the character preceding the caret in the currently entered text */
|
||||
CC_NOINLINE void LInput_Backspace(struct LInput* w);
|
||||
/* Removes the character at the caret in the currently entered text. */
|
||||
/* Removes the character at the caret in the currently entered text */
|
||||
CC_NOINLINE void LInput_Delete(struct LInput* w);
|
||||
/* Resets the currently entered text to an empty string. */
|
||||
/* Resets the currently entered text to an empty string */
|
||||
CC_NOINLINE void LInput_Clear(struct LInput* w);
|
||||
/* Sets the currently entered text to the given string */
|
||||
CC_NOINLINE void LInput_SetString(struct LInput* w, const cc_string* str);
|
||||
|
||||
/* Represents non-interactable text. */
|
||||
struct LLabel {
|
||||
|
Loading…
x
Reference in New Issue
Block a user