TinWoo/source/main.cpp

59 lines
1.8 KiB
C++
Raw Normal View History

2023-09-05 02:06:35 +01:00
#include <thread>
2023-09-29 03:27:12 +01:00
#include <string>
2023-10-06 02:34:49 +01:00
//#include <sstream>
2023-09-29 03:27:12 +01:00
#include <switch.h>
2023-09-05 02:06:35 +01:00
#include "util/error.hpp"
#include "ui/MainApplication.hpp"
#include "util/util.hpp"
#include "util/config.hpp"
2023-09-29 03:27:12 +01:00
#include "util/theme.hpp"
2023-09-05 02:06:35 +01:00
using namespace pu::ui::render;
int main(int argc, char* argv[])
{
inst::util::initApp();
try {
2023-09-29 03:27:12 +01:00
Theme::Load();
int x = 0;
2023-10-06 02:34:49 +01:00
int langInt = inst::config::languageSetting;
//Don't use custom fonts if Taiwanese or Japanese language is selected.
//but still use custom fonts if the system language is selected.
if (langInt != 2) {
if (langInt != 8) {
2023-10-07 21:49:09 +01:00
if (langInt != 9) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "fonts.default"_theme)) {
x = 1;
}
2023-10-06 02:34:49 +01:00
}
}
2023-09-29 03:27:12 +01:00
}
2023-09-05 02:06:35 +01:00
auto renderer_opts = pu::ui::render::RendererInitOptions(SDL_INIT_EVERYTHING, pu::ui::render::RendererHardwareFlags);
renderer_opts.UseImage(pu::ui::render::IMGAllFlags);
renderer_opts.UseAudio(pu::ui::render::MixerAllFlags);
2023-09-29 03:27:12 +01:00
if (x == 1) {
const auto default_font_path = (inst::config::appDir + "fonts.default"_theme);
renderer_opts.UseTTF(default_font_path);
}
2023-09-05 02:06:35 +01:00
renderer_opts.UseTTF();
2023-09-29 03:27:12 +01:00
if (x == 1) {
std::string size = "fonts.default_size"_theme;
int myint1 = stoi(size);
renderer_opts.SetExtraDefaultFontSize(myint1);
}
2023-09-05 02:06:35 +01:00
renderer_opts.UseRomfs();
auto renderer = pu::ui::render::Renderer::New(renderer_opts);
auto main = inst::ui::MainApplication::New(renderer);
std::thread updateThread;
if (inst::config::autoUpdate && inst::util::getIPAddress() != "1.0.0.127") updateThread = std::thread(inst::util::checkForAppUpdate);
main->Prepare();
main->ShowWithFadeIn();
updateThread.join();
}
catch (std::exception& e) {
LOG_DEBUG("An error occurred:\n%s", e.what());
}
inst::util::deinitApp();
return 0;
}