aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCEnnis91 <cennis91@gmail.com>2013-05-02 13:29:53 -0400
committerTom Marshall <tdm@cyngn.com>2015-11-20 15:46:40 -0800
commit9dc02b1f906832f2e741d7a73469e1f874dd52da (patch)
tree6e9cae0aba6e6383345075effa9bc52df6219920
parent27b1a0ff456b7a21923aea866976cdd8b00c8379 (diff)
downloadbootable_recovery-9dc02b1f906832f2e741d7a73469e1f874dd52da.zip
bootable_recovery-9dc02b1f906832f2e741d7a73469e1f874dd52da.tar.gz
bootable_recovery-9dc02b1f906832f2e741d7a73469e1f874dd52da.tar.bz2
OMGRainbows
No longer will we get bad reviews on CWM recovery for its lack of rainbows! Originally design by gweedo767, this patch brings back the wrap count mechanism from v2.0.2.4 to toggle Rainbow Mode for the user. In the original design, every character has a different color, but that method requires modifying graphics.c which will cause breakage in devices with custom graphics.c. This Rainbow Mode has a different color for each line, instead. The wrap_count has been set to 5 instead of the previous 3 so the toggle won't occur as often, if on accident. (port to CM12.1 by cyanogen) Change-Id: Ie9f6f1b6ed94ee69d4d8d9fe27f9a5417cc3f212 improve Rainbow Mode * Require 5 consecutive menu "wraps" in the same direction to help prevent accidental toggling * Align colors into stripes (i.e. columns) a) less prone to induce dizziness in some people when they change b) better resembles a rainbow * Move the stripes to the right when the selection moves up and move the stripes to the left when the selection moves down Change-Id: I3feae173b22f5703c554ca33e634881749ff54cf
-rw-r--r--minui/graphics.cpp32
-rw-r--r--minui/minui.h3
-rw-r--r--screen_ui.cpp40
-rw-r--r--screen_ui.h5
4 files changed, 76 insertions, 4 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index c0eea9e..43c28ce 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -103,6 +103,36 @@ static void text_blend(unsigned char* src_p, int src_row_bytes,
}
}
+static int rainbow_index = 0;
+static int rainbow_enabled = 0;
+static int rainbow_colors[] = { 255, 0, 0, // red
+ 255, 127, 0, // orange
+ 255, 255, 0, // yellow
+ 0, 255, 0, // green
+ 60, 80, 255, // blue
+ 143, 0, 255 }; // violet
+static int num_rb_colors =
+ (sizeof(rainbow_colors)/sizeof(rainbow_colors[0])) / 3;
+
+static void rainbow(int col) {
+ int rainbow_color = ((rainbow_index + col) % num_rb_colors) * 3;
+ gr_color(rainbow_colors[rainbow_color], rainbow_colors[rainbow_color+1],
+ rainbow_colors[rainbow_color+2], 255);
+}
+
+void set_rainbow_mode(int enabled) {
+ rainbow_enabled = enabled;
+}
+
+void move_rainbow(int x) {
+ rainbow_index += x;
+ if (rainbow_index < 0) {
+ rainbow_index = num_rb_colors - 1;
+ } else if (rainbow_index >= num_rb_colors) {
+ rainbow_index = 0;
+ }
+}
+
void gr_text(int x, int y, const char *s, bool bold)
{
GRFont* font = gr_font;
@@ -116,6 +146,8 @@ void gr_text(int x, int y, const char *s, bool bold)
unsigned char ch;
while ((ch = *s++)) {
+ if (rainbow_enabled) rainbow(x / font->cwidth);
+
if (outside(x, y) || outside(x+font->cwidth-1, y+font->cheight-1)) break;
if (ch < ' ' || ch > '~') {
diff --git a/minui/minui.h b/minui/minui.h
index bdde083..d714632 100644
--- a/minui/minui.h
+++ b/minui/minui.h
@@ -120,4 +120,7 @@ int res_create_localized_alpha_surface(const char* name, const char* locale,
// functions.
void res_free_surface(GRSurface* surface);
+void set_rainbow_mode(int enabled);
+void move_rainbow(int x);
+
#endif
diff --git a/screen_ui.cpp b/screen_ui.cpp
index f2fda2f..f23affa 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -76,7 +76,9 @@ ScreenRecoveryUI::ScreenRecoveryUI() :
animation_fps(20),
installing_frames(-1),
stage(-1),
- max_stage(-1) {
+ max_stage(-1),
+ rainbow(false),
+ wrap_count(0) {
for (int i = 0; i < 5; i++) {
backgroundIcon[i] = nullptr;
@@ -321,6 +323,12 @@ void* ScreenRecoveryUI::ProgressThreadStartRoutine(void* data) {
return nullptr;
}
+void ScreenRecoveryUI::OMGRainbows()
+{
+ rainbow = rainbow ? false : true;
+ set_rainbow_mode(rainbow);
+}
+
void ScreenRecoveryUI::ProgressThreadLoop() {
double interval = 1.0 / animation_fps;
while (true) {
@@ -664,16 +672,40 @@ void ScreenRecoveryUI::StartMenu(const char* const * headers, const char* const
}
int ScreenRecoveryUI::SelectMenu(int sel) {
+ int wrapped = 0;
pthread_mutex_lock(&updateMutex);
if (show_menu) {
int old_sel = menu_sel;
menu_sel = sel;
// Wrap at top and bottom.
- if (menu_sel < 0) menu_sel = menu_items - 1;
- if (menu_sel >= menu_items) menu_sel = 0;
-
+ if (rainbow) {
+ if (menu_sel > old_sel) {
+ move_rainbow(1);
+ } else if (menu_sel < old_sel) {
+ move_rainbow(-1);
+ }
+ }
+ if (menu_sel < 0) {
+ wrapped = -1;
+ menu_sel = menu_items - 1;
+ }
+ if (menu_sel >= menu_items) {
+ wrapped = 1;
+ menu_sel = 0;
+ }
sel = menu_sel;
+ if (wrapped != 0) {
+ if (wrap_count / wrapped > 0) {
+ wrap_count += wrapped;
+ } else {
+ wrap_count = wrapped;
+ }
+ if (wrap_count / wrapped >= 5) {
+ wrap_count = 0;
+ OMGRainbows();
+ }
+ }
if (menu_sel != old_sel) update_screen_locked();
}
pthread_mutex_unlock(&updateMutex);
diff --git a/screen_ui.h b/screen_ui.h
index 8e18864..2ec5f5d 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -116,6 +116,9 @@ class ScreenRecoveryUI : public RecoveryUI {
int stage, max_stage;
+ bool rainbow;
+ int wrap_count;
+
void draw_background_locked(Icon icon);
void draw_progress_locked();
void draw_screen_locked();
@@ -137,6 +140,8 @@ class ScreenRecoveryUI : public RecoveryUI {
void LoadBitmap(const char* filename, GRSurface** surface);
void LoadBitmapArray(const char* filename, int* frames, GRSurface*** surface);
void LoadLocalizedBitmap(const char* filename, GRSurface** surface);
+
+ void OMGRainbows();
};
#endif // RECOVERY_UI_H