Skip to content

Commit

Permalink
fixup earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
Daaaav committed Aug 2, 2024
1 parent b098ca3 commit cf4ae3a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
8 changes: 5 additions & 3 deletions desktop_version/src/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3543,10 +3543,12 @@ void Graphics::render(void)

draw_window_background();

SDL_Rect rect;
get_stretch_info(&rect);
SDL_Rect stretch_info;
get_stretch_info(&stretch_info);

ime_set_rect(&stretch_info);

copy_texture(gameTexture, NULL, &rect, 0, NULL, flipmode ? SDL_FLIP_VERTICAL : SDL_FLIP_NONE);
copy_texture(gameTexture, NULL, &stretch_info, 0, NULL, flipmode ? SDL_FLIP_VERTICAL : SDL_FLIP_NONE);
}

void Graphics::renderwithscreeneffects(void)
Expand Down
25 changes: 23 additions & 2 deletions desktop_version/src/IMERender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#include "KeyPoll.h"
#include "UTF8.h"

static bool render_done = false;
static SDL_Rect imebox;

void ime_render(void)
{
render_done = false;

if (!SDL_IsTextInputActive() || key.imebuffer == "")
{
return;
}

int fontheight = font::height(PR_FONT_LEVEL);
SDL_Rect imebox;
imebox.x = 8;
imebox.y = SCREEN_HEIGHT_PIXELS - 32 - fontheight;
imebox.w = font::len(PR_FONT_LEVEL, key.imebuffer.c_str()) + 1;
Expand Down Expand Up @@ -76,5 +80,22 @@ void ime_render(void)
}

font::print(PR_FONT_LEVEL | PR_CJK_LOW, imebox.x + 1, imebox.y + 1, key.imebuffer, 255, 255, 255);
SDL_SetTextInputRect(&imebox);

render_done = true;
}

void ime_set_rect(SDL_Rect* stretch_info)
{
if (!render_done)
{
return;
}

SDL_Rect imebox_scaled = imebox;
imebox_scaled.x += stretch_info.x;
imebox_scaled.y += stretch_info.y;
imebox_scaled.w *= stretch_info.w / SCREEN_WIDTH_PIXELS;
imebox_scaled.h *= stretch_info.h / SCREEN_HEIGHT_PIXELS;

SDL_SetTextInputRect(&imebox_scaled);
}
1 change: 1 addition & 0 deletions desktop_version/src/IMERender.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define IMERENDER_H

void ime_render(void);
void ime_set_rect(SDL_Rect* stretch_info);

#endif /* IMERENDER_H */

0 comments on commit cf4ae3a

Please sign in to comment.