C client: Show username in window title

This commit is contained in:
UnknownShadow200 2018-09-10 17:45:24 +10:00
parent 5f12a5b869
commit d8ed9b77a2
7 changed files with 16 additions and 17 deletions

View File

@ -722,7 +722,7 @@ void Game_Free(void* obj) {
}
UInt64 game_renderTimer;
void Game_Run(Int32 width, Int32 height, STRING_REF String* title, struct DisplayDevice* device) {
void Game_Run(Int32 width, Int32 height, STRING_PURE String* title, struct DisplayDevice* device) {
Int32 x = device->Bounds.X + (device->Bounds.Width - width) / 2;
Int32 y = device->Bounds.Y + (device->Bounds.Height - height) / 2;
struct GraphicsMode mode = GraphicsMode_MakeDefault();

View File

@ -91,5 +91,5 @@ Int32 Game_CalcRenderType(STRING_PURE String* type);
void Game_SetFpsLimit(FpsLimit method);
Real32 Game_CalcLimitMillis(FpsLimit method);
void Game_Run(Int32 width, Int32 height, STRING_REF String* title, struct DisplayDevice* device);
void Game_Run(Int32 width, Int32 height, STRING_PURE String* title, struct DisplayDevice* device);
#endif

View File

@ -186,7 +186,7 @@ static void Window_RefreshBounds(XEvent* e) {
}
static XVisualInfo GLContext_SelectVisual(struct GraphicsMode* mode);
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF String* title,
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_PURE String* title,
struct GraphicsMode* mode, struct DisplayDevice* device) {
win_display = DisplayDevice_Meta[0];
win_screen = DisplayDevice_Meta[1];

View File

@ -897,11 +897,12 @@ void Http_Init(void) {
static ReturnCode Http_Make(struct AsyncRequest* req, HINTERNET* handle) {
String url = String_FromRawArray(req->URL);
WCHAR urlStr[300]; Platform_ConvertString(urlStr, &url);
char urlStr[STRING_SIZE + 1];
Mem_Copy(urlStr, url.buffer, url.length);
char headersBuffer[STRING_SIZE * 2] = { 0 };
urlStr[url.length] = '\0';
char headersBuffer[STRING_SIZE * 3];
String headers = String_FromArray(headersBuffer);
WCHAR headersStr[STRING_SIZE * 2 + 1];
/* https://stackoverflow.com/questions/25308488/c-wininet-custom-http-headers */
if (req->Etag[0] || req->LastModified) {
@ -917,16 +918,12 @@ static ReturnCode Http_Make(struct AsyncRequest* req, HINTERNET* handle) {
String_AppendString(&headers, &etag);
String_AppendConst(&headers, "\r\n");
}
String_AppendConst(&headers, "\r\n\r\n");
headers.buffer[headers.length] = '\0';
} else { headers.buffer = NULL; }
Int32 i;
for (i = 0; i < headers.length; i++) {
headersStr[i] = headers.buffer[i];
}
headersStr[headers.length] = '\0';
*handle = InternetOpenUrlW(hInternet, urlStr, headersStr, headers.length,
*handle = InternetOpenUrlA(hInternet, urlStr, headers.buffer, headers.length,
INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_UI | INTERNET_FLAG_RELOAD, 0);
return Win_Return(*handle);
}

View File

@ -62,9 +62,7 @@ int main(int argc, char** argv) {
}
String args[PROGRAM_MAX_CMDARGS];
String title = String_FromConst(PROGRAM_APP_NAME);
Int32 argsCount = Platform_GetCommandLineArgs(argc, argv, args);
/* NOTE: Make sure to comment this out before pushing a commit */
// String rawArgs = String_FromConst("UnknownShadow200 fff 127.0.0.1 25565");
// argsCount = 4; String_UNSAFE_Split(&rawArgs, ' ', args, &argsCount);
@ -109,7 +107,11 @@ int main(int argc, char** argv) {
if (device.Bounds.Width < 854) width = 640;
}
char titleBuffer[STRING_SIZE];
String title = String_FromArray(titleBuffer);
String_Format2(&title, "%c (%s)", PROGRAM_APP_NAME, &Game_Username);
Game_Run(width, height, &title, &device);
Platform_Exit(0);
return 0;
}

View File

@ -389,7 +389,7 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
}
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF String* title,
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_PURE String* title,
struct GraphicsMode* mode, struct DisplayDevice* device) {
win_Instance = GetModuleHandleW(NULL);
/* TODO: UngroupFromTaskbar(); */

View File

@ -38,7 +38,7 @@ enum WINDOW_STATE {
WINDOW_STATE_MAXIMISED, WINDOW_STATE_FULLSCREEN,
};
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF String* title,
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_PURE String* title,
struct GraphicsMode* mode, struct DisplayDevice* device);
void Window_GetClipboardText(STRING_TRANSIENT String* value);
void Window_SetClipboardText(STRING_PURE String* value);