Compare commits
9 Commits
dev-2d4729
...
7a2d7336fb
Author | SHA1 | Date | |
---|---|---|---|
7a2d7336fb | |||
fc5023ec1c | |||
95eb0eb26d | |||
d7e658eba6 | |||
04191858de | |||
df449a475c | |||
9a95dba138 | |||
ef79aa8b80 | |||
ba7188cf66 |
2
.github/workflows/cd.yml
vendored
2
.github/workflows/cd.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt update && sudo apt -y install libsodium-dev
|
run: sudo apt update && sudo apt -y install libsodium-dev cmake
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
46
.github/workflows/ci.yml
vendored
46
.github/workflows/ci.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt update && sudo apt -y install libsodium-dev
|
run: sudo apt update && sudo apt -y install libsodium-dev cmake
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
@ -29,6 +29,50 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
|
android:
|
||||||
|
timeout-minutes: 30
|
||||||
|
# contains sections copied from sdl repo
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- uses: nttld/setup-ndk@v1
|
||||||
|
id: setup_ndk
|
||||||
|
with:
|
||||||
|
local-cache: false # https://github.com/nttld/setup-ndk/issues/518
|
||||||
|
ndk-version: r26d
|
||||||
|
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '17'
|
||||||
|
|
||||||
|
- name: update vcpkg
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/microsoft/vcpkg.git
|
||||||
|
|
||||||
|
- name: Install Dependencies (host)
|
||||||
|
run: sudo apt update && sudo apt -y install cmake pkg-config nasm
|
||||||
|
|
||||||
|
- name: Install Dependencies (target)
|
||||||
|
env:
|
||||||
|
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
||||||
|
run: vcpkg install --triplet arm64-android --overlay-ports=vcpkg/ports libsodium opus libvpx libpng libjpeg-turbo
|
||||||
|
|
||||||
|
# vcpkg scripts root /usr/local/share/vcpkg/scripts
|
||||||
|
- name: Configure CMake
|
||||||
|
env:
|
||||||
|
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
|
||||||
|
#run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=23 -DANDROID_ABI=arm64-v8a
|
||||||
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-android -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=arm64-v8a -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDL3IMAGE_JPG_SHARED=OFF -DSDL3IMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON
|
||||||
|
|
||||||
|
- name: Build (tomato)
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
|
||||||
|
option(TOMATO_MAIN_SO "Build tomato as a shared object (for eg android apps)" ANDROID)
|
||||||
option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF)
|
option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF)
|
||||||
|
|
||||||
if (TOMATO_ASAN)
|
if (TOMATO_ASAN)
|
||||||
|
2
external/CMakeLists.txt
vendored
2
external/CMakeLists.txt
vendored
@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
|
|||||||
|
|
||||||
add_subdirectory(./entt)
|
add_subdirectory(./entt)
|
||||||
|
|
||||||
|
add_subdirectory(./json)
|
||||||
|
|
||||||
add_subdirectory(./solanaceae_util)
|
add_subdirectory(./solanaceae_util)
|
||||||
add_subdirectory(./solanaceae_contact)
|
add_subdirectory(./solanaceae_contact)
|
||||||
add_subdirectory(./solanaceae_message3)
|
add_subdirectory(./solanaceae_message3)
|
||||||
|
13
external/json/CMakeLists.txt
vendored
Normal file
13
external/json/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16...3.24 FATAL_ERROR)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
if (NOT TARGET nlohmann_json::nlohmann_json)
|
||||||
|
FetchContent_Declare(json
|
||||||
|
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
|
||||||
|
URL_HASH SHA256=d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(json)
|
||||||
|
endif()
|
||||||
|
|
2
external/solanaceae_plugin
vendored
2
external/solanaceae_plugin
vendored
Submodule external/solanaceae_plugin updated: f7a519754d...ade1b4ea74
@ -1,11 +1,21 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9...3.24 FATAL_ERROR)
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
add_executable(tomato
|
if (TOMATO_MAIN_SO)
|
||||||
|
add_library(tomato MODULE)
|
||||||
|
target_compile_definitions(tomato PUBLIC TOMATO_MAIN_SO)
|
||||||
|
else()
|
||||||
|
add_executable(tomato)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_sources(tomato PUBLIC
|
||||||
./main.cpp
|
./main.cpp
|
||||||
./icon.rc
|
./icon.rc
|
||||||
|
|
||||||
|
./json_to_config.hpp
|
||||||
|
./json_to_config.cpp
|
||||||
|
|
||||||
./screen.hpp
|
./screen.hpp
|
||||||
./start_screen.hpp
|
./start_screen.hpp
|
||||||
./start_screen.cpp
|
./start_screen.cpp
|
||||||
|
@ -151,8 +151,7 @@ void SendImagePopup::sendMemory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy paste data to memory
|
// copy paste data to memory
|
||||||
original_data.clear();
|
original_data = {data, data+data_size};
|
||||||
original_data.insert(original_data.begin(), data, data+data_size);
|
|
||||||
|
|
||||||
if (!load()) {
|
if (!load()) {
|
||||||
std::cerr << "SIP: failed to load image from memory\n";
|
std::cerr << "SIP: failed to load image from memory\n";
|
||||||
|
@ -41,7 +41,7 @@ ImageLoaderQOI::ImageResult ImageLoaderQOI::loadFromMemoryRGBA(const uint8_t* da
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = 0;
|
new_frame.ms = 0;
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), img_data, img_data+(desc.width*desc.height*4));
|
new_frame.data = {img_data, img_data+(desc.width*desc.height*4)};
|
||||||
|
|
||||||
free(img_data);
|
free(img_data);
|
||||||
return res;
|
return res;
|
||||||
|
@ -47,7 +47,7 @@ ImageLoaderSDLBMP::ImageResult ImageLoaderSDLBMP::loadFromMemoryRGBA(const uint8
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = 0;
|
new_frame.ms = 0;
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (surf->w*surf->h*4));
|
new_frame.data = {(const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (surf->w*surf->h*4)};
|
||||||
|
|
||||||
SDL_UnlockSurface(conv_surf);
|
SDL_UnlockSurface(conv_surf);
|
||||||
SDL_DestroySurface(conv_surf);
|
SDL_DestroySurface(conv_surf);
|
||||||
|
@ -99,7 +99,7 @@ ImageLoaderSDLImage::ImageResult ImageLoaderSDLImage::loadFromMemoryRGBA(const u
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = anim->delays[i];
|
new_frame.ms = anim->delays[i];
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4));
|
new_frame.data = {(const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4)};
|
||||||
|
|
||||||
SDL_UnlockSurface(conv_surf);
|
SDL_UnlockSurface(conv_surf);
|
||||||
SDL_DestroySurface(conv_surf);
|
SDL_DestroySurface(conv_surf);
|
||||||
|
@ -41,7 +41,7 @@ ImageLoaderSTB::ImageResult ImageLoaderSTB::loadFromMemoryRGBA(const uint8_t* da
|
|||||||
for (int i = 0; i < z; i++) {
|
for (int i = 0; i < z; i++) {
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = delays[i];
|
new_frame.ms = delays[i];
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), img_data + (i*stride), img_data + ((i+1)*stride));
|
new_frame.data = {img_data + (i*stride), img_data + ((i+1)*stride)};
|
||||||
}
|
}
|
||||||
|
|
||||||
stbi_image_free(delays); // hope this is right
|
stbi_image_free(delays); // hope this is right
|
||||||
@ -62,7 +62,7 @@ ImageLoaderSTB::ImageResult ImageLoaderSTB::loadFromMemoryRGBA(const uint8_t* da
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = 0;
|
new_frame.ms = 0;
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), img_data, img_data+(x*y*4));
|
new_frame.data = {img_data, img_data+(x*y*4)};
|
||||||
|
|
||||||
stbi_image_free(img_data);
|
stbi_image_free(img_data);
|
||||||
return res;
|
return res;
|
||||||
|
@ -78,7 +78,7 @@ ImageLoaderWebP::ImageResult ImageLoaderWebP::loadFromMemoryRGBA(const uint8_t*
|
|||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = timestamp-prev_timestamp;
|
new_frame.ms = timestamp-prev_timestamp;
|
||||||
prev_timestamp = timestamp;
|
prev_timestamp = timestamp;
|
||||||
new_frame.data.insert(new_frame.data.end(), buf, buf+(res.width*res.height*4));
|
new_frame.data = {buf, buf+(res.width*res.height*4)};
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(anim_info.frame_count == res.frames.size());
|
assert(anim_info.frame_count == res.frames.size());
|
||||||
|
67
src/json_to_config.cpp
Normal file
67
src/json_to_config.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#include "./json_to_config.hpp"
|
||||||
|
|
||||||
|
#include <solanaceae/util/simple_config_model.hpp>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
bool load_json_into_config(const nlohmann::ordered_json& config_json, SimpleConfigModel& conf) {
|
||||||
|
if (!config_json.is_object()) {
|
||||||
|
std::cerr << "TOMATO error: config file is not an json object!!!\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (const auto& [mod, cats] : config_json.items()) {
|
||||||
|
for (const auto& [cat, cat_v] : cats.items()) {
|
||||||
|
if (cat_v.is_object()) {
|
||||||
|
if (cat_v.contains("default")) {
|
||||||
|
const auto& value = cat_v["default"];
|
||||||
|
if (value.is_string()) {
|
||||||
|
conf.set(mod, cat, value.get_ref<const std::string&>());
|
||||||
|
} else if (value.is_boolean()) {
|
||||||
|
conf.set(mod, cat, value.get_ref<const bool&>());
|
||||||
|
} else if (value.is_number_float()) {
|
||||||
|
conf.set(mod, cat, value.get_ref<const double&>());
|
||||||
|
} else if (value.is_number_integer()) {
|
||||||
|
conf.set(mod, cat, value.get_ref<const int64_t&>());
|
||||||
|
} else {
|
||||||
|
std::cerr << "JSON error: wrong value type in " << mod << "::" << cat << " = " << value << "\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cat_v.contains("entries")) {
|
||||||
|
for (const auto& [ent, ent_v] : cat_v["entries"].items()) {
|
||||||
|
if (ent_v.is_string()) {
|
||||||
|
conf.set(mod, cat, ent, ent_v.get_ref<const std::string&>());
|
||||||
|
} else if (ent_v.is_boolean()) {
|
||||||
|
conf.set(mod, cat, ent, ent_v.get_ref<const bool&>());
|
||||||
|
} else if (ent_v.is_number_float()) {
|
||||||
|
conf.set(mod, cat, ent, ent_v.get_ref<const double&>());
|
||||||
|
} else if (ent_v.is_number_integer()) {
|
||||||
|
conf.set(mod, cat, ent, ent_v.get_ref<const int64_t&>());
|
||||||
|
} else {
|
||||||
|
std::cerr << "JSON error: wrong value type in " << mod << "::" << cat << "::" << ent << " = " << ent_v << "\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (cat_v.is_string()) {
|
||||||
|
conf.set(mod, cat, cat_v.get_ref<const std::string&>());
|
||||||
|
} else if (cat_v.is_boolean()) {
|
||||||
|
conf.set(mod, cat, cat_v.get_ref<const bool&>());
|
||||||
|
} else if (cat_v.is_number_float()) {
|
||||||
|
conf.set(mod, cat, cat_v.get_ref<const double&>());
|
||||||
|
} else if (cat_v.is_number_integer()) {
|
||||||
|
conf.set(mod, cat, cat_v.get_ref<const int64_t&>());
|
||||||
|
} else {
|
||||||
|
std::cerr << "JSON error: wrong value type in " << mod << "::" << cat << " = " << cat_v << "\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
9
src/json_to_config.hpp
Normal file
9
src/json_to_config.hpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
|
// fwd
|
||||||
|
struct SimpleConfigModel;
|
||||||
|
|
||||||
|
bool load_json_into_config(const nlohmann::ordered_json& config_json, SimpleConfigModel& conf);
|
||||||
|
|
@ -12,10 +12,17 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string_view>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
// better args
|
||||||
|
std::vector<std::string_view> args;
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
args.push_back(argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// setup hints
|
// setup hints
|
||||||
if (SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1") != SDL_TRUE) {
|
if (SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1") != SDL_TRUE) {
|
||||||
std::cerr << "Failed to set '" << SDL_HINT_VIDEO_ALLOW_SCREENSAVER << "' to 1\n";
|
std::cerr << "Failed to set '" << SDL_HINT_VIDEO_ALLOW_SCREENSAVER << "' to 1\n";
|
||||||
@ -91,7 +98,7 @@ int main(int argc, char** argv) {
|
|||||||
ImGui_ImplSDL3_InitForSDLRenderer(window.get(), renderer.get());
|
ImGui_ImplSDL3_InitForSDLRenderer(window.get(), renderer.get());
|
||||||
ImGui_ImplSDLRenderer3_Init(renderer.get());
|
ImGui_ImplSDLRenderer3_Init(renderer.get());
|
||||||
|
|
||||||
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(renderer.get(), theme);
|
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>(args, renderer.get(), theme);
|
||||||
|
|
||||||
|
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
MainScreen::MainScreen(SDL_Renderer* renderer_, Theme& theme_, std::string save_path, std::string save_password, std::string new_username, std::vector<std::string> plugins) :
|
MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme& theme_, std::string save_path, std::string save_password, std::string new_username, std::vector<std::string> plugins) :
|
||||||
renderer(renderer_),
|
renderer(renderer_),
|
||||||
|
conf(std::move(conf_)),
|
||||||
rmm(cr),
|
rmm(cr),
|
||||||
msnj{cr, {}, {}},
|
msnj{cr, {}, {}},
|
||||||
mts(rmm),
|
mts(rmm),
|
||||||
|
@ -91,7 +91,7 @@ struct MainScreen final : public Screen {
|
|||||||
uint64_t _window_hidden_ts {0};
|
uint64_t _window_hidden_ts {0};
|
||||||
float _time_since_event {0.f};
|
float _time_since_event {0.f};
|
||||||
|
|
||||||
MainScreen(SDL_Renderer* renderer_, Theme& theme_, std::string save_path, std::string save_password, std::string new_username, std::vector<std::string> plugins);
|
MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme& theme_, std::string save_path, std::string save_password, std::string new_username, std::vector<std::string> plugins);
|
||||||
~MainScreen(void);
|
~MainScreen(void);
|
||||||
|
|
||||||
bool handleEvent(SDL_Event& e) override;
|
bool handleEvent(SDL_Event& e) override;
|
||||||
|
@ -31,6 +31,11 @@ uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t wi
|
|||||||
// TODO: error reporting
|
// TODO: error reporting
|
||||||
SDL_UpdateTexture(tex, nullptr, surf->pixels, surf->pitch);
|
SDL_UpdateTexture(tex, nullptr, surf->pixels, surf->pitch);
|
||||||
|
|
||||||
|
SDL_BlendMode surf_blend_mode = SDL_BLENDMODE_NONE;
|
||||||
|
if (SDL_GetSurfaceBlendMode(surf, &surf_blend_mode) == 0) {
|
||||||
|
SDL_SetTextureBlendMode(tex, surf_blend_mode);
|
||||||
|
}
|
||||||
|
|
||||||
if (filter == NEAREST) {
|
if (filter == NEAREST) {
|
||||||
SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST);
|
SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST);
|
||||||
} else if (filter == LINEAR) {
|
} else if (filter == LINEAR) {
|
||||||
|
@ -2,14 +2,53 @@
|
|||||||
|
|
||||||
#include "./main_screen.hpp"
|
#include "./main_screen.hpp"
|
||||||
|
|
||||||
|
#include "./json_to_config.hpp"
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
StartScreen::StartScreen(SDL_Renderer* renderer, Theme& theme) : _renderer(renderer), _theme(theme) {
|
StartScreen::StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme) : _renderer(renderer), _theme(theme) {
|
||||||
|
for (size_t ai = 1; ai < args.size(); ai++) {
|
||||||
|
if (args.at(ai) == "--config" || args.at(ai) == "-c") {
|
||||||
|
if (args.size() == ai+1) {
|
||||||
|
std::cerr << "TOMATO error: argument '" << args.at(ai) << "' missing parameter!\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ai++;
|
||||||
|
|
||||||
|
const auto& config_path = args.at(ai);
|
||||||
|
auto config_file = std::ifstream(static_cast<std::string>(config_path));
|
||||||
|
if (!config_file.is_open()) {
|
||||||
|
std::cerr << "TOMATO error: failed to open config file '" << config_path << "'\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto config_json = nlohmann::ordered_json::parse(config_file);
|
||||||
|
if (!load_json_into_config(config_json, _conf)) {
|
||||||
|
std::cerr << "TOMATO error in config json, exiting...\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (args.at(ai) == "--plugin" || args.at(ai) == "-p") {
|
||||||
|
if (args.size() == ai+1) {
|
||||||
|
std::cerr << "TOMATO error: argument '" << args.at(ai) << "' missing parameter!\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ai++;
|
||||||
|
|
||||||
|
const auto& plugin_path = args.at(ai);
|
||||||
|
// TODO: check for dups
|
||||||
|
queued_plugin_paths.push_back(static_cast<std::string>(plugin_path));
|
||||||
|
} else {
|
||||||
|
std::cerr << "TOMATO error: unknown cli arg: '" << args.at(ai) << "'\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Screen* StartScreen::render(float, bool&) {
|
Screen* StartScreen::render(float, bool&) {
|
||||||
@ -143,7 +182,7 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ImGui::Button("load", {60, 25})) {
|
if (ImGui::Button("load", {60, 25})) {
|
||||||
auto new_screen = std::make_unique<MainScreen>(_renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
||||||
return new_screen.release();
|
return new_screen.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "./chat_gui/theme.hpp"
|
#include "./chat_gui/theme.hpp"
|
||||||
#include "./chat_gui/file_selector.hpp"
|
#include "./chat_gui/file_selector.hpp"
|
||||||
|
|
||||||
|
#include <solanaceae/util/simple_config_model.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -16,6 +18,7 @@ extern "C" {
|
|||||||
struct StartScreen final : public Screen {
|
struct StartScreen final : public Screen {
|
||||||
SDL_Renderer* _renderer;
|
SDL_Renderer* _renderer;
|
||||||
Theme& _theme;
|
Theme& _theme;
|
||||||
|
SimpleConfigModel _conf;
|
||||||
FileSelector _fss;
|
FileSelector _fss;
|
||||||
|
|
||||||
bool _new_save {false};
|
bool _new_save {false};
|
||||||
@ -28,7 +31,7 @@ struct StartScreen final : public Screen {
|
|||||||
std::vector<std::string> queued_plugin_paths;
|
std::vector<std::string> queued_plugin_paths;
|
||||||
|
|
||||||
StartScreen(void) = delete;
|
StartScreen(void) = delete;
|
||||||
StartScreen(SDL_Renderer* renderer, Theme& theme);
|
StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme);
|
||||||
~StartScreen(void) = default;
|
~StartScreen(void) = default;
|
||||||
|
|
||||||
// return nullptr if not next
|
// return nullptr if not next
|
||||||
|
Reference in New Issue
Block a user