aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-11-05 15:46:10 +0100
committerdec05eba <dec05eba@protonmail.com>2023-11-05 15:46:10 +0100
commit7b2cd582f1f69f57c8f826ae8e0a7eadd6e33627 (patch)
treeb53898b9b33d875bfcc049aca54b98e50c3af656
parent5071a2428a35c4b2fed16c7f977e7448b02e3def (diff)
Add config option to set movement speed and icon spinning speed
-rw-r--r--example-config.json4
-rw-r--r--include/Config.hpp6
-rw-r--r--src/Body.cpp7
-rw-r--r--src/Config.cpp6
-rw-r--r--src/QuickMedia.cpp10
5 files changed, 25 insertions, 8 deletions
diff --git a/example-config.json b/example-config.json
index a802dfa..35f2702 100644
--- a/example-config.json
+++ b/example-config.json
@@ -19,6 +19,10 @@
"input": {
"font_size": 16
},
+ "animation": {
+ "move_speed": 30.0,
+ "loading_icon_speed": 400.0
+ },
"video": {
// Plugins that support max height will select a video source that is not taller than this
"max_height": 0
diff --git a/include/Config.hpp b/include/Config.hpp
index 7b77577..1d4675f 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -28,6 +28,11 @@ namespace QuickMedia {
int font_size = 16;
};
+ struct AnimationConfig {
+ float move_speed = 30.0f;
+ float loading_icon_speed = 400.0;
+ };
+
struct VideoConfig {
int max_height = 0;
};
@@ -103,6 +108,7 @@ namespace QuickMedia {
TabConfig tab;
BodyConfig body;
InputConfig input;
+ AnimationConfig animation;
VideoConfig video;
LocalMangaConfig local_manga;
LocalAnimeConfig local_anime;
diff --git a/src/Body.cpp b/src/Body.cpp
index 54a3b5f..e5a23b8 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -680,6 +680,7 @@ namespace QuickMedia {
return 0.0f;
}
+ // TODO: Remove this crap
if(is_touch_enabled()) {
const mgl::vec2f mouse_pos_diff(mouse_pos_raw.x - mouse_pos.x, mouse_pos_raw.y - mouse_pos.y);
const float move_speed = 35.0f;
@@ -769,7 +770,7 @@ namespace QuickMedia {
instant_move = true;
}
- const float speed = 30.0f;
+ const float speed = get_config().animation.move_speed;
const mgl::vec2f item_background_size_diff = mgl::vec2f(item_background_target_size.x, item_background_target_height) - item_background_prev_size;
const float item_background_size_speed = instant_move ? 1000.0f : speed;
@@ -1463,7 +1464,7 @@ namespace QuickMedia {
auto new_loading_icon_size = clamp_to_size(loading_icon_size, content_size);
loading_icon.set_position(item_pos + mgl::vec2f(body_spacing[body_theme].image_padding_x, padding_y) + (content_size * 0.5f));
loading_icon.set_scale(get_ratio(loading_icon_size, new_loading_icon_size));
- loading_icon.set_rotation(elapsed_time_sec * 400.0);
+ loading_icon.set_rotation(elapsed_time_sec * (double)get_config().animation.loading_icon_speed);
window.draw(loading_icon);
}
text_offset_x += body_spacing[body_theme].image_padding_x + item->loaded_image_size.x;
@@ -1601,7 +1602,7 @@ namespace QuickMedia {
auto new_loading_icon_size = clamp_to_size(loading_icon_size, content_size);
loading_icon.set_position(pos + pos_offset + mgl::vec2f(card_padding_x, card_padding_y) + mgl::vec2f(card_max_image_size.x, content_size.y) * 0.5f);
loading_icon.set_scale(get_ratio(loading_icon_size, new_loading_icon_size));
- loading_icon.set_rotation(elapsed_time_sec * 400.0);
+ loading_icon.set_rotation(elapsed_time_sec * (double)get_config().animation.loading_icon_speed);
window.draw(loading_icon);
}
diff --git a/src/Config.cpp b/src/Config.cpp
index 54aa21e..a17e883 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -193,6 +193,12 @@ namespace QuickMedia {
if(input_json.isObject())
get_json_value(input_json, "font_size", config->input.font_size);
+ const Json::Value &animation_json = json_root["animation"];
+ if(animation_json.isObject()) {
+ get_json_value(animation_json, "move_speed", config->animation.move_speed);
+ get_json_value(animation_json, "loading_icon_speed", config->animation.loading_icon_speed);
+ }
+
const Json::Value &video_json = json_root["video"];
if(video_json.isObject())
get_json_value(video_json, "max_height", config->video.max_height);
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 1717df4..d145dda 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2063,7 +2063,7 @@ namespace QuickMedia {
if(matrix && !matrix->is_initial_sync_finished()) {
// if(is_login_sync) {
load_sprite.set_position(mgl::vec2f(body_pos.x + body_size.x * 0.5f, body_pos.y + body_size.y * 0.5f));
- load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * 400.0);
+ load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * (double)get_config().animation.loading_icon_speed);
window.draw(load_sprite);
// }
std::string err_msg;
@@ -3011,7 +3011,7 @@ namespace QuickMedia {
window.clear(get_theme().background_color);
load_sprite.set_position(mgl::vec2f(window_size.x * 0.5f, window_size.y * 0.5f));
- load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * 400.0);
+ load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * (double)get_config().animation.loading_icon_speed);
window.draw(load_sprite);
window.display();
}
@@ -3848,7 +3848,7 @@ namespace QuickMedia {
if(!video_loaded) {
window.clear(get_theme().background_color);
load_sprite.set_position(mgl::vec2f(window_size.x * 0.5f, window_size.y * 0.5f));
- load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * 400.0);
+ load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * (double)get_config().animation.loading_icon_speed);
window.draw(load_sprite);
window.display();
@@ -4129,7 +4129,7 @@ namespace QuickMedia {
window.clear(get_theme().background_color);
load_sprite.set_position(mgl::vec2f(window_size.x * 0.5f, window_size.y * 0.5f));
- load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * 400.0);
+ load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * (double)get_config().animation.loading_icon_speed);
window.draw(load_sprite);
AsyncImageLoader::get_instance().update();
window.display();
@@ -5209,7 +5209,7 @@ namespace QuickMedia {
window.draw(rect);
load_sprite.set_position(mgl::vec2f(window_size.x * 0.5f, window_size.y * 0.5f));
- load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * 400.0);
+ load_sprite.set_rotation(load_sprite_timer.get_elapsed_time_seconds() * (double)get_config().animation.loading_icon_speed);
window.draw(load_sprite);
}
} else if(navigation_stage == NavigationStage::REPLYING) {