Index: apps/bootmenu-ipodclassic/tools.c |
— | — | @@ -26,10 +26,12 @@ |
27 | 27 | #include "tools.h"
|
28 | 28 | #include "util.h"
|
29 | 29 | #include "main.h"
|
| 30 | +#include "confirmchooser.h"
|
30 | 31 |
|
31 | 32 |
|
32 | 33 | void run_clearcfg(void** firmware, void** app, int* size)
|
33 | 34 | {
|
| 35 | + if (!run_confirmchooser("Really clear Rockbox config?")) return;
|
34 | 36 | remove("/.rockbox/config.cfg");
|
35 | 37 | memcpy(framebuf, bg, 320 * 240 * 3);
|
36 | 38 | message(97, "Rockbox configuration", " has been cleared. ");
|
— | — | @@ -37,6 +39,7 @@ |
38 | 40 |
|
39 | 41 | void run_cleardb(void** firmware, void** app, int* size)
|
40 | 42 | {
|
| 43 | + if (!run_confirmchooser("Really clear Rockbox database?")) return;
|
41 | 44 | remove("/.rockbox/database_0.tcd");
|
42 | 45 | remove("/.rockbox/database_1.tcd");
|
43 | 46 | remove("/.rockbox/database_2.tcd");
|
— | — | @@ -68,6 +71,7 @@ |
69 | 72 |
|
70 | 73 | void run_reformat(void** firmware, void** app, int* size)
|
71 | 74 | {
|
| 75 | + if (!run_confirmchooser("Really reformat data partition?")) return;
|
72 | 76 | memcpy(framebuf, bg, 320 * 240 * 3);
|
73 | 77 | rendertext(framebuf, 70, 125, 320, 0xff7fffff, 0, "Reformatting data partition...");
|
74 | 78 | update_display(NULL);
|
Index: apps/bootmenu-ipodclassic/toolchooser.c |
— | — | @@ -250,7 +250,7 @@ |
251 | 251 |
|
252 | 252 | void run_toolchooser(void** firmware, void** app, int* size)
|
253 | 253 | {
|
254 | | - while (true)
|
| 254 | + while (!*firmware && !*app)
|
255 | 255 | {
|
256 | 256 | const struct chooser_item* result = ui->chooser_run(&toolchooser);
|
257 | 257 | if (!result || !result->user) return;
|
— | — | @@ -257,7 +257,6 @@ |
258 | 258 | void (*selected_function)(void** firmware, void** app, int* size);
|
259 | 259 | selected_function = (void(*)(void** firmware, void** app, int* size))(result->user);
|
260 | 260 | selected_function(firmware, app, size);
|
261 | | - if (firmware || app) return;
|
262 | 261 | }
|
263 | 262 | }
|
264 | 263 |
|
Index: apps/bootmenu-ipodclassic/SOURCES |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | mainchooser.c
|
4 | 4 | toolchooser.c
|
5 | 5 | settingchooser.c
|
| 6 | +confirmchooser.c
|
6 | 7 | boot.c
|
7 | 8 | tools.c
|
8 | 9 | util.c
|
Index: apps/bootmenu-ipodclassic/confirmchooser.c |
— | — | @@ -0,0 +1,213 @@ |
| 2 | +//
|
| 3 | +//
|
| 4 | +// Copyright 2011 TheSeven
|
| 5 | +//
|
| 6 | +//
|
| 7 | +// This file is part of emCORE.
|
| 8 | +//
|
| 9 | +// emCORE is free software: you can redistribute it and/or
|
| 10 | +// modify it under the terms of the GNU General Public License as
|
| 11 | +// published by the Free Software Foundation, either version 2 of the
|
| 12 | +// License, or (at your option) any later version.
|
| 13 | +//
|
| 14 | +// emCORE is distributed in the hope that it will be useful,
|
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| 17 | +// See the GNU General Public License for more details.
|
| 18 | +//
|
| 19 | +// You should have received a copy of the GNU General Public License along
|
| 20 | +// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | +//
|
| 22 | +//
|
| 23 | +
|
| 24 | +
|
| 25 | +#include "emcoreapp.h"
|
| 26 | +#include "libui.h"
|
| 27 | +#include "confirmchooser.h"
|
| 28 | +#include "main.h"
|
| 29 | +#include "util.h"
|
| 30 | +
|
| 31 | +
|
| 32 | +static struct chooser_renderer_list_itemdata confirmchooser_rparams_yes =
|
| 33 | +{
|
| 34 | + .size = LIBUI_POINT(260, 10),
|
| 35 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
| 36 | + .fill_color = 0xa0000000,
|
| 37 | + .fill_color_selected = 0xa00000ff,
|
| 38 | + .icon_pos = LIBUI_POINT_NULL,
|
| 39 | + .icon = LIBUI_SURFACE_NULL,
|
| 40 | + .icon_opacity = 0,
|
| 41 | + .icon_selected = LIBUI_SURFACE_NULL,
|
| 42 | + .icon_selected_opacity = 0,
|
| 43 | + .text = "Yes",
|
| 44 | + .text_pos = LIBUI_POINT(1, 1),
|
| 45 | + .text_color = 0xff0000ff,
|
| 46 | + .text_color_selected = 0xff3f7fff,
|
| 47 | + .render = NULL
|
| 48 | +};
|
| 49 | +
|
| 50 | +static struct chooser_renderer_list_itemdata confirmchooser_rparams_no =
|
| 51 | +{
|
| 52 | + .size = LIBUI_POINT(260, 10),
|
| 53 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
| 54 | + .fill_color = 0xa0000000,
|
| 55 | + .fill_color_selected = 0x60ffffff,
|
| 56 | + .icon_pos = LIBUI_POINT_NULL,
|
| 57 | + .icon = LIBUI_SURFACE_NULL,
|
| 58 | + .icon_opacity = 0,
|
| 59 | + .icon_selected = LIBUI_SURFACE_NULL,
|
| 60 | + .icon_selected_opacity = 0,
|
| 61 | + .text = "No",
|
| 62 | + .text_pos = LIBUI_POINT(1, 1),
|
| 63 | + .text_color = 0xffffffff,
|
| 64 | + .text_color_selected = 0xff7fffff,
|
| 65 | + .render = NULL
|
| 66 | +};
|
| 67 | +
|
| 68 | +static struct chooser_renderer_list_params confirmchooser_rparams =
|
| 69 | +{
|
| 70 | + .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
| 71 | + .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
|
| 72 | + .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
|
| 73 | + LIBUI_POINT(320, 240)),
|
| 74 | + .bg_dest = LIBUI_LOCATION_NULL,
|
| 75 | + .bg_src = LIBUI_SURFACE_NULL,
|
| 76 | + .bg_opacity = 0,
|
| 77 | + .fill_dest = LIBUI_SURFACE_NULL,
|
| 78 | + .fill_color = 0,
|
| 79 | + .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(30, 70)),
|
| 80 | + LIBUI_POINT(260, 140)),
|
| 81 | + .blit_dest = LIBUI_POINT(0, 0),
|
| 82 | + .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
|
| 83 | + LIBUI_POINT(320, 240)),
|
| 84 | + .preblit = update_display,
|
| 85 | + .postblit = NULL
|
| 86 | +};
|
| 87 | +
|
| 88 | +static struct chooser_action_handler_wheel_params confirmchooser_aparams =
|
| 89 | +{
|
| 90 | + .version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
|
| 91 | + .stepsperitem = 128,
|
| 92 | + .eventfilter = NULL,
|
| 93 | + .timeout_initial = TIMEOUT_BLOCK,
|
| 94 | + .timeout_idle = TIMEOUT_BLOCK,
|
| 95 | + .timeout_item = 0,
|
| 96 | + .tick_force_redraw = true,
|
| 97 | + .buttoncount = 5,
|
| 98 | + .buttonmap =
|
| 99 | + {
|
| 100 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
| 101 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
| 102 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_CANCEL,
|
| 103 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
|
| 104 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
|
| 105 | + }
|
| 106 | +};
|
| 107 | +
|
| 108 | +static struct chooser_info confirmchooser =
|
| 109 | +{
|
| 110 | + .version = CHOOSER_INFO_VERSION,
|
| 111 | + .actionhandler = NULL,
|
| 112 | + .actionhandlerparams = &confirmchooser_aparams,
|
| 113 | + .renderer = NULL,
|
| 114 | + .rendererparams = &confirmchooser_rparams,
|
| 115 | + .userparams = NULL,
|
| 116 | + .tickinterval = 10000000,
|
| 117 | + .itemcount = 14,
|
| 118 | + .defaultitem = 0,
|
| 119 | + .items =
|
| 120 | + {
|
| 121 | + {
|
| 122 | + .user = NULL,
|
| 123 | + .actionparams = NULL,
|
| 124 | + .renderparams = &confirmchooser_rparams_no
|
| 125 | + },
|
| 126 | + {
|
| 127 | + .user = NULL,
|
| 128 | + .actionparams = NULL,
|
| 129 | + .renderparams = &confirmchooser_rparams_no
|
| 130 | + },
|
| 131 | + {
|
| 132 | + .user = NULL,
|
| 133 | + .actionparams = NULL,
|
| 134 | + .renderparams = &confirmchooser_rparams_no
|
| 135 | + },
|
| 136 | + {
|
| 137 | + .user = NULL,
|
| 138 | + .actionparams = NULL,
|
| 139 | + .renderparams = &confirmchooser_rparams_no
|
| 140 | + },
|
| 141 | + {
|
| 142 | + .user = NULL,
|
| 143 | + .actionparams = NULL,
|
| 144 | + .renderparams = &confirmchooser_rparams_no
|
| 145 | + },
|
| 146 | + {
|
| 147 | + .user = NULL,
|
| 148 | + .actionparams = NULL,
|
| 149 | + .renderparams = &confirmchooser_rparams_no
|
| 150 | + },
|
| 151 | + {
|
| 152 | + .user = NULL,
|
| 153 | + .actionparams = NULL,
|
| 154 | + .renderparams = &confirmchooser_rparams_no
|
| 155 | + },
|
| 156 | + {
|
| 157 | + .user = NULL,
|
| 158 | + .actionparams = NULL,
|
| 159 | + .renderparams = &confirmchooser_rparams_no
|
| 160 | + },
|
| 161 | + {
|
| 162 | + .user = NULL,
|
| 163 | + .actionparams = NULL,
|
| 164 | + .renderparams = &confirmchooser_rparams_no
|
| 165 | + },
|
| 166 | + {
|
| 167 | + .user = (void*)1,
|
| 168 | + .actionparams = NULL,
|
| 169 | + .renderparams = &confirmchooser_rparams_yes
|
| 170 | + },
|
| 171 | + {
|
| 172 | + .user = NULL,
|
| 173 | + .actionparams = NULL,
|
| 174 | + .renderparams = &confirmchooser_rparams_no
|
| 175 | + },
|
| 176 | + {
|
| 177 | + .user = NULL,
|
| 178 | + .actionparams = NULL,
|
| 179 | + .renderparams = &confirmchooser_rparams_no
|
| 180 | + },
|
| 181 | + {
|
| 182 | + .user = NULL,
|
| 183 | + .actionparams = NULL,
|
| 184 | + .renderparams = &confirmchooser_rparams_no
|
| 185 | + },
|
| 186 | + {
|
| 187 | + .user = NULL,
|
| 188 | + .actionparams = NULL,
|
| 189 | + .renderparams = &confirmchooser_rparams_no
|
| 190 | + }
|
| 191 | + }
|
| 192 | +};
|
| 193 | +
|
| 194 | +bool run_confirmchooser(const char* message)
|
| 195 | +{
|
| 196 | + memcpy(framebuf2, bg, 320 * 240 * 3);
|
| 197 | + ui->blendcolor(260, 20, 0xa0000000, framebuf2, 30, 50, 320, framebuf2, 30, 50, 320);
|
| 198 | + rendertext(framebuf2, 31, 51, 320, 0xff3333ff, 0, message);
|
| 199 | + const struct chooser_item* result = ui->chooser_run(&confirmchooser);
|
| 200 | + if (!result || !result->user) return false;
|
| 201 | + return true;
|
| 202 | +}
|
| 203 | +
|
| 204 | +void confirmchooser_init()
|
| 205 | +{
|
| 206 | + confirmchooser.actionhandler = ui->chooser_action_handler_wheel;
|
| 207 | + confirmchooser.renderer = ui->chooser_renderer_list;
|
| 208 | + confirmchooser_rparams.copy_dest.buf.addr = framebuf;
|
| 209 | + confirmchooser_rparams.copy_src.loc.buf.addr = framebuf2;
|
| 210 | + confirmchooser_rparams.viewport.loc.buf.addr = framebuf;
|
| 211 | + confirmchooser_rparams.blit_src.loc.buf.addr = framebuf;
|
| 212 | + confirmchooser_rparams_yes.render = ui->chooser_renderer_list_show_arrow_right;
|
| 213 | + confirmchooser_rparams_no.render = ui->chooser_renderer_list_show_arrow_left;
|
| 214 | +}
|
Index: apps/bootmenu-ipodclassic/main.c |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | struct libboot_api* boot;
|
36 | 36 | struct libui_api* ui;
|
37 | 37 | void* framebuf;
|
| 38 | +void* framebuf2;
|
38 | 39 | void* bg;
|
39 | 40 | void* icons;
|
40 | 41 | void* rbxlogo;
|
— | — | @@ -83,13 +84,17 @@ |
84 | 85 |
|
85 | 86 | framebuf = malloc(320 * 240 * 3);
|
86 | 87 | if (!framebuf) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer!");
|
| 88 | + framebuf2 = malloc(320 * 240 * 3);
|
| 89 | + if (!framebuf2) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer 2!");
|
87 | 90 |
|
88 | 91 | mainchooser_init();
|
89 | 92 | toolchooser_init();
|
90 | 93 | settingchooser_init();
|
| 94 | + confirmchooser_init();
|
91 | 95 |
|
92 | 96 | run_mainchooser(&firmware, &app, &size);
|
93 | 97 |
|
| 98 | + free(framebuf2);
|
94 | 99 | free(framebuf);
|
95 | 100 | free(rbxlogo);
|
96 | 101 | free(icons);
|
Index: apps/bootmenu-ipodclassic/confirmchooser.h |
— | — | @@ -0,0 +1,35 @@ |
| 2 | +//
|
| 3 | +//
|
| 4 | +// Copyright 2011 TheSeven
|
| 5 | +//
|
| 6 | +//
|
| 7 | +// This file is part of emCORE.
|
| 8 | +//
|
| 9 | +// emCORE is free software: you can redistribute it and/or
|
| 10 | +// modify it under the terms of the GNU General Public License as
|
| 11 | +// published by the Free Software Foundation, either version 2 of the
|
| 12 | +// License, or (at your option) any later version.
|
| 13 | +//
|
| 14 | +// emCORE is distributed in the hope that it will be useful,
|
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| 17 | +// See the GNU General Public License for more details.
|
| 18 | +//
|
| 19 | +// You should have received a copy of the GNU General Public License along
|
| 20 | +// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | +//
|
| 22 | +//
|
| 23 | +
|
| 24 | +
|
| 25 | +#ifndef __APP_CONFIRMCHOOSER_H__
|
| 26 | +#define __APP_CONFIRMCHOOSER_H__
|
| 27 | +
|
| 28 | +
|
| 29 | +#include "emcoreapp.h"
|
| 30 | +
|
| 31 | +
|
| 32 | +extern bool run_confirmchooser(const char* message);
|
| 33 | +extern void confirmchooser_init();
|
| 34 | +
|
| 35 | +
|
| 36 | +#endif
|
Index: apps/bootmenu-ipodclassic/main.h |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | extern struct libboot_api* boot;
|
37 | 37 | extern struct libui_api* ui;
|
38 | 38 | extern void* framebuf;
|
| 39 | +extern void* framebuf2;
|
39 | 40 | extern void* bg;
|
40 | 41 | extern void* icons;
|
41 | 42 | extern void* rbxlogo;
|