From 869064c5c76f8627d1f839d25aabfb8a83168466 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 30 Oct 2018 15:21:09 +1100 Subject: [PATCH] Fix wrong sounds option key, fix 'fly on' being two pixels too high --- src/CarbonWindow.c | 18 +++++++++--------- src/NixWindow.c | 10 ++-------- src/Options.h | 2 +- src/Screens.c | 20 ++++++++++++-------- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/CarbonWindow.c b/src/CarbonWindow.c index bcb51abdb..fc235b150 100644 --- a/src/CarbonWindow.c +++ b/src/CarbonWindow.c @@ -523,20 +523,20 @@ void Window_GetClipboardText(String* value) { void Window_SetClipboardText(const String* value) { PasteboardRef pbRef; CFDataRef cfData; + char str[800]; + int len; OSStatus err; - + pbRef = Window_GetPasteboard(); - - err = PasteboardClear(pbRef); + err = PasteboardClear(pbRef); if (err) ErrorHandler_Fail2(err, "Clearing Pasteboard"); PasteboardSynchronize(pbRef); - - IntPtr ptr = Marshal.StringToHGlobalUni(value); - cfData = CFDataCreate(NULL, ptr, (value.Length + 1) * 2); + + len = Platform_ConvertString(str, value); + CFDataCreate(NULL, str, len); if (!cfData) ErrorHandler_Fail("CFDataCreate() returned null pointer"); - - PasteboardPutItemFlavor(pbRef, 1, FMT_UTF16, cfData, 0); - Marshal.FreeHGlobal(ptr); + + PasteboardPutItemFlavor(pbRef, 1, FMT_UTF8, cfData, 0); } /* TODO: IMPLEMENT void Window_SetIcon(Bitmap* bmp); */ diff --git a/src/NixWindow.c b/src/NixWindow.c index f5e553435..f411e10e2 100644 --- a/src/NixWindow.c +++ b/src/NixWindow.c @@ -604,14 +604,8 @@ void Window_ProcessEvents(void) { if (e.xselectionrequest.selection == xa_clipboard && e.xselectionrequest.target == xa_utf8_string && clipboard_copy_text.length) { reply.xselection.property = Window_GetSelectionProperty(&e); - uint8_t data[1024]; - int i, len = 0; - - for (i = 0; i < clipboard_copy_text.length; i++) { - uint8_t* cur = data + len; - Codepoint cp = Convert_CP437ToUnicode(clipboard_copy_text.buffer[i]); - len += Convert_UnicodeToUtf8(cp, cur); - } + char str[800]; + int len = Platform_ConvertString(str, &clipboard_copy_text); XChangeProperty(win_display, reply.xselection.requestor, reply.xselection.property, xa_utf8_string, 8, PropModeReplace, data, len); diff --git a/src/Options.h b/src/Options.h index a277efbb0..432cfd0f0 100644 --- a/src/Options.h +++ b/src/Options.h @@ -13,7 +13,7 @@ extern const char* FpsLimit_Names[FPS_LIMIT_COUNT]; #define OPT_USE_MUSIC "usemusic" #define OPT_USE_SOUND "usesound" #define OPT_MUSIC_VOLUME "musicvolume" -#define OPT_SOUND_VOLUME "soundvolume" +#define OPT_SOUND_VOLUME "soundsvolume" #define OPT_FORCE_OPENAL "forceopenal" #define OPT_FORCE_OLD_OPENGL "force-oldgl" diff --git a/src/Screens.c b/src/Screens.c index eec3ac9ee..38f598cdd 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -362,24 +362,28 @@ static void StatusScreen_ContextLost(void* screen) { Elem_TryFree(&s->HackStates); } -static void StatusScreen_ContextRecreated(void* screen) { +static void StatusScreen_ContextRecreated(void* screen) { + static String chars = String_FromConst("0123456789-, ()"); + static String prefix = String_FromConst("Position: "); struct StatusScreen* s = screen; - String chars = String_FromConst("0123456789-, ()"); - String prefix = String_FromConst("Position: "); struct TextWidget* status = &s->Status; + struct TextWidget* hacks = &s->HackStates; + int y; + + y = 2; TextWidget_Make(status); - Widget_SetLocation(status, ANCHOR_MIN, ANCHOR_MIN, 2, 2); + Widget_SetLocation(status, ANCHOR_MIN, ANCHOR_MIN, 2, y); status->ReducePadding = true; StatusScreen_Update(s, 1.0); - int elemHeight = status->Height + 2; + y += status->Height; TextAtlas_Make(&s->PosAtlas, &chars, &s->Font, &prefix); - s->PosAtlas.Tex.Y = elemHeight; + s->PosAtlas.Tex.Y = y; - struct TextWidget* hacks = &s->HackStates; + y += s->PosAtlas.Tex.Height; TextWidget_Make(hacks); - Widget_SetLocation(hacks, ANCHOR_MIN, ANCHOR_MIN, 2, elemHeight * 2); + Widget_SetLocation(hacks, ANCHOR_MIN, ANCHOR_MIN, 2, y); hacks->ReducePadding = true; StatusScreen_UpdateHackState(s); }