diff --git a/src/config_center/config_center.h b/src/config_center/config_center.h index 207c499..ceb9a02 100644 --- a/src/config_center/config_center.h +++ b/src/config_center/config_center.h @@ -26,7 +26,7 @@ class ConfigCenter { private: VIDEO_QUALITY video_quality_ = VIDEO_QUALITY::MEDIUM; - LANGUAGE language_ = LANGUAGE::ENGLISH; + LANGUAGE language_ = LANGUAGE::CHINESE; }; #endif \ No newline at end of file diff --git a/src/localization/localization.h b/src/localization/localization.h index e21f3ad..826e962 100644 --- a/src/localization/localization.h +++ b/src/localization/localization.h @@ -3,24 +3,20 @@ * @Date: 2024-05-29 * Copyright (c) 2024 by DI JUNKUN, All Rights Reserved. */ - #ifndef _LOCALIZATION_H_ #define _LOCALIZATION_H_ #include #include - namespace localization { -std::vector menu = {u8"菜单", "Menu"}; +std::vector menu = {u8"菜单:", "Menu"}; std::vector local_id = {u8"本机ID:", "Local ID:"}; std::vector password = {u8"密码:", "Password:"}; -std::vector max_password_len = {u8"最大6个租房字符", - "Max 6 chars"}; +std::vector max_password_len = {u8"最大6个字符", "Max 6 chars"}; std::vector remote_id = {u8"远端ID:", "Remote ID:"}; std::vector connect = {u8"连接", "Connect"}; std::vector disconnect = {u8"断开连接", "Disconnect"}; -std::vector reset_ratio = {u8"重置窗口", "Reset ratio"}; std::vector fullscreen = {u8"全屏", "Fullscreen"}; std::vector exit_fullscreen = {u8"退出全屏", "Exit fullscreen"}; diff --git a/src/main_window/main_window.cpp b/src/main_window/main_window.cpp index 99f18d2..3283334 100644 --- a/src/main_window/main_window.cpp +++ b/src/main_window/main_window.cpp @@ -291,24 +291,6 @@ int MainWindow::Run() { ImGui::Spacing(); - { - if (ImGui::Button( - localization::reset_ratio[localization_language_index_] - .c_str())) { - SDL_GetWindowSize(main_window_, &main_window_width_, - &main_window_height_); - - if (main_window_height_ != main_window_width_ * 9 / 16) { - main_window_width_ = main_window_height_ * 16 / 9; - } - - SDL_SetWindowSize(main_window_, main_window_width_, - main_window_height_); - } - } - - ImGui::SameLine(); - if (ImGui::Button(fullscreen_button_label_.c_str())) { if (fullscreen_button_label_ == localization::fullscreen[localization_language_index_]) { @@ -332,6 +314,45 @@ int MainWindow::Run() { SDL_RenderSetScale(sdl_renderer_, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); + SDL_Event event; + while (SDL_PollEvent(&event)) { + ImGui_ImplSDL2_ProcessEvent(&event); + if (event.type == SDL_QUIT) { + exit_ = true; + } else if (event.type == SDL_WINDOWEVENT && + event.window.event == SDL_WINDOWEVENT_RESIZED) { + int window_w_last = main_window_width_; + int window_h_last = main_window_height_; + + SDL_GetWindowSize(main_window_, &main_window_width_, + &main_window_height_); + + int w_change_ratio = abs(main_window_width_ - window_w_last) / 16; + int h_change_ratio = abs(main_window_height_ - window_h_last) / 9; + + if (w_change_ratio > h_change_ratio) { + main_window_height_ = main_window_width_ * 9 / 16; + } else { + main_window_width_ = main_window_height_ * 16 / 9; + } + + SDL_SetWindowSize(main_window_, main_window_width_, + main_window_height_); + } else if (event.type == SDL_WINDOWEVENT && + event.window.event == SDL_WINDOWEVENT_CLOSE && + event.window.windowID == SDL_GetWindowID(main_window_)) { + exit_ = true; + } else if (event.type == REFRESH_EVENT) { + sdlRect.x = 0; + sdlRect.y = 0; + sdlRect.w = main_window_width_; + sdlRect.h = main_window_height_; + + // SDL_UpdateTexture(sdl_texture_, NULL, dst_buffer, pixel_w); + } else { + } + } + SDL_RenderClear(sdl_renderer_); SDL_RenderCopy(sdl_renderer_, sdl_texture_, NULL, &sdlRect);