Skip to content

Commit

Permalink
gui/initial setup: Add two gui setting.
Browse files Browse the repository at this point in the history
- Fix size of column of select language.
- Save config any time press on next.
- Small clean code.
- Change bg color.
  • Loading branch information
Zangetsu38 committed Oct 17, 2024
1 parent 9fb28ae commit 019fa62
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
50 changes: 31 additions & 19 deletions vita3k/gui/src/initial_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "private.h"

#include <config/functions.h>
#include <config/state.h>
#include <dialog/state.h>
#include <gui/functions.h>
Expand Down Expand Up @@ -69,7 +70,8 @@ void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) {
const auto SCALE = ImVec2(RES_SCALE.x * emuenv.dpi_scale, RES_SCALE.y * emuenv.dpi_scale);
const auto WINDOW_SIZE = ImVec2(756.f * SCALE.x, 418.f * SCALE.y);
const auto SELECT_SIZE = 72.f * SCALE.y;
const auto BUTTON_SIZE = ImVec2(154.f * SCALE.x, 52.f * SCALE.y);
const auto BUTTON_SIZE = ImVec2(186.f * SCALE.x, 52.f * SCALE.y);
const ImVec2 BUTTON_POS(8.f * SCALE.x, display_size.y - BUTTON_SIZE.y - (6.f * SCALE.y));
const auto BIG_BUTTON_SIZE = ImVec2(324.f * SCALE.x, 48.f * SCALE.y);
const auto BIG_BUTTON_POS = ImVec2((WINDOW_SIZE.x / 2.f) - (BIG_BUTTON_SIZE.x / 2.f), WINDOW_SIZE.y - BIG_BUTTON_SIZE.y - (20.f * SCALE.y));

Expand All @@ -86,34 +88,38 @@ void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) {
ImGui::PushFont(gui.vita_font);
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
ImGui::SetNextWindowSize(display_size, ImGuiCond_Always);
ImGui::Begin("##initial_setup", &emuenv.cfg.initial_setup, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings);
ImGui::GetBackgroundDrawList()->AddRectFilled(ImVec2(0.f, 0), display_size, IM_COL32(112.f, 124.f, 246.f, 255.f), 0.f, ImDrawFlags_RoundCornersAll);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f);
ImGui::Begin("##initial_setup", &emuenv.cfg.initial_setup, ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings);
ImGui::PopStyleVar(2);

ImGui::GetBackgroundDrawList()->AddRectFilled(ImVec2(0.f, 0), display_size, IM_COL32(194.f, 207.f, 241.f, 255.f), 0.f, ImDrawFlags_RoundCornersAll);
ImGui::SetNextWindowPos(ImVec2(98.f * SCALE.x, 30 * SCALE.y), ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.f * SCALE.x);
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 6.f * SCALE.x);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6.f * SCALE.x);
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 2.f * SCALE.x);
ImGui::PushStyleColor(ImGuiCol_Border, GUI_COLOR_TEXT);
ImGui::SetNextWindowBgAlpha(0.0f);

ImGui::BeginChild("##window_box", WINDOW_SIZE, ImGuiChildFlags_Borders, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings);
ImGui::SetWindowFontScale(1.3f * RES_SCALE.x);
ImGui::SetWindowFontScale(1.6f * RES_SCALE.x);
const auto SELECT_COLOR = ImVec4(0.23f, 0.68f, 0.95f, 0.60f);
const auto SELECT_COLOR_HOVERED = ImVec4(0.23f, 0.68f, 0.99f, 0.80f);
const auto SELECT_COLOR_ACTIVE = ImVec4(0.23f, 0.68f, 1.f, 1.f);

ImGui::SetCursorPos(ImVec2((WINDOW_SIZE.x / 2.f) - (ImGui::CalcTextSize(title_str.c_str()).x / 2.f), (47 * SCALE.y) - (ImGui::GetFontSize() / 2.f)));
ImGui::Text("%s", title_str.c_str());
ImGui::SetWindowFontScale(1.4f * RES_SCALE.x);
ImGui::SetCursorPosY(94.f * SCALE.y);
ImGui::Separator();
switch (setup) {
case SELECT_LANGUAGE:
title_str = lang["select_language"];
ImGui::SetNextWindowPos(ImVec2(198.f * SCALE.x, 126.f * SCALE.y), ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.f);
ImGui::BeginChild("##lang_list", ImVec2(WINDOW_SIZE.x - (200.f * SCALE.x), WINDOW_SIZE.y - (108.f * SCALE.y)), ImGuiChildFlags_None, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoSavedSettings);
ImGui::Columns(3, nullptr, false);
ImGui::SetColumnWidth(0, 96.f * SCALE.x);
ImGui::SetColumnWidth(1, 30.f * SCALE.x);
ImGui::SetColumnWidth(0, 90.f * SCALE.x);
ImGui::SetColumnWidth(1, 34.f * SCALE.x);
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.f, 0.5f));
ImGui::PushStyleColor(ImGuiCol_Header, SELECT_COLOR);
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, SELECT_COLOR_HOVERED);
Expand All @@ -137,7 +143,6 @@ void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) {
ImGui::PopStyleColor(3);
ImGui::Columns(1);
ImGui::EndChild();
ImGui::PopStyleVar();
break;
case SELECT_PREF_PATH:
title_str = lang["select_pref_path"];
Expand Down Expand Up @@ -186,15 +191,19 @@ void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) {
if (ImGui::Button(lang["install_firmware_file"].c_str(), BIG_BUTTON_SIZE))
gui.file_menu.firmware_install_dialog = true;
if (gui.file_menu.firmware_install_dialog) {
ImGui::PushFont(gui.vita_font);
ImGui::SetWindowFontScale(RES_SCALE.x);
draw_firmware_install_dialog(gui, emuenv);
ImGui::PopFont();
}
break;
case SELECT_INTERFACE_SETTINGS:
title_str = lang["select_interface_settings"];
ImGui::SetCursorPosY((WINDOW_SIZE.y / 2.f) - ImGui::GetFontSize());
ImGui::Checkbox(gui.lang.settings_dialog.gui["display_info_message"].c_str(), &emuenv.cfg.display_info_message);
SetTooltipEx(gui.lang.settings_dialog.gui["display_info_message_description"].c_str());
ImGui::SameLine();
ImGui::Checkbox(gui.lang.settings_dialog.gui["display_system_apps"].c_str(), &emuenv.cfg.display_system_apps);
SetTooltipEx(gui.lang.settings_dialog.gui["display_system_apps_description"].c_str());
ImGui::Spacing();
ImGui::Checkbox(lang["show_info_bar"].c_str(), &emuenv.cfg.show_info_bar);
SetTooltipEx(lang["info_bar_description"].c_str());
ImGui::SameLine();
Expand All @@ -214,29 +223,32 @@ void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) {
ImGui::SetCursorPos(ImVec2((WINDOW_SIZE.x / 2.f) - (ImGui::CalcTextSize(completed_setup).x / 2.f), (WINDOW_SIZE.y / 2.f) - ImGui::GetFontSize()));
ImGui::Text("%s", completed_setup);
ImGui::SetCursorPos(BIG_BUTTON_POS);
if (ImGui::Button(common["ok"].c_str(), BIG_BUTTON_SIZE) || ImGui::IsKeyPressed(static_cast<ImGuiKey>(emuenv.cfg.keyboard_button_cross)))
if (ImGui::Button(common["ok"].c_str(), BIG_BUTTON_SIZE) || ImGui::IsKeyPressed(static_cast<ImGuiKey>(emuenv.cfg.keyboard_button_cross))) {
emuenv.cfg.initial_setup = true;
config::serialize_config(emuenv.cfg, emuenv.base_path);
}
break;
default: break;
}

ImGui::SetWindowFontScale(1.f);
ImGui::EndChild();
ImGui::PopStyleVar(2);
ImGui::PopStyleColor();
ImGui::SetWindowFontScale(1.5f * RES_SCALE.x);

// Draw Button
ImGui::SetWindowFontScale(1.2f * RES_SCALE.x);
ImGui::SetCursorPos(ImVec2(10.f * SCALE.x, display_size.y - BUTTON_SIZE.y - (14.f * SCALE.y)));
ImGui::SetCursorPos(BUTTON_POS);
if ((setup > SELECT_LANGUAGE) && ImGui::Button(lang["back"].c_str(), BUTTON_SIZE) || (setup > SELECT_LANGUAGE) && ImGui::IsKeyPressed(static_cast<ImGuiKey>(emuenv.cfg.keyboard_button_circle)))
setup = (InitialSetup)(setup - 1);
ImGui::SetCursorPos(ImVec2(display_size.x - BUTTON_SIZE.x - (14.f * SCALE.x), display_size.y - BUTTON_SIZE.y - (14.f * SCALE.y)));
if ((setup < FINISHED) && ImGui::Button(lang["next"].c_str(), BUTTON_SIZE) || ImGui::IsKeyPressed(static_cast<ImGuiKey>(emuenv.cfg.keyboard_button_cross)))
ImGui::SetCursorPos(ImVec2(display_size.x - BUTTON_SIZE.x - BUTTON_POS.x, BUTTON_POS.y));
if ((setup < FINISHED) && ImGui::Button(lang["next"].c_str(), BUTTON_SIZE) || ImGui::IsKeyPressed(static_cast<ImGuiKey>(emuenv.cfg.keyboard_button_cross))) {
setup = (InitialSetup)(setup + 1);
config::serialize_config(emuenv.cfg, emuenv.base_path);
}
ImGui::SetWindowFontScale(1.f);

ImGui::PopStyleVar(3);

ImGui::SetWindowFontScale(1.f);
ImGui::PopStyleVar();
ImGui::End();
ImGui::PopFont();
}
Expand Down
1 change: 0 additions & 1 deletion vita3k/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ int main(int argc, char *argv[]) {
} else
return QuitRequested;
}
config::serialize_config(emuenv.cfg, emuenv.config_path);
run_execv(argv, emuenv);
}
gui::init(gui, emuenv);
Expand Down

0 comments on commit 019fa62

Please sign in to comment.