Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2013 bigbiff/Dees_Troy TeamWin |
| 3 | This file is part of TWRP/TeamWin Recovery Project. |
| 4 | |
| 5 | TWRP is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | TWRP is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with TWRP. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
Dees Troy | 3be70a8 | 2013-10-22 14:25:12 +0000 | [diff] [blame] | 18 | |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 19 | // pages.cpp - Source to manage GUI base objects |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 20 | |
| 21 | #include <stdarg.h> |
| 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <string.h> |
| 25 | #include <fcntl.h> |
| 26 | #include <sys/reboot.h> |
| 27 | #include <sys/stat.h> |
| 28 | #include <sys/time.h> |
| 29 | #include <sys/mman.h> |
| 30 | #include <sys/types.h> |
| 31 | #include <sys/ioctl.h> |
| 32 | #include <time.h> |
| 33 | #include <unistd.h> |
| 34 | #include <stdlib.h> |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 35 | #include "../twrp-functions.hpp" |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 36 | #include "../partitions.hpp" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 37 | |
| 38 | #include <string> |
| 39 | |
| 40 | extern "C" { |
Dees_Troy | 2673cec | 2013-04-02 20:22:16 +0000 | [diff] [blame] | 41 | #include "../twcommon.h" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 42 | #include "../minuitwrp/minui.h" |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 43 | #include "../minzip/SysUtil.h" |
| 44 | #include "../minzip/Zip.h" |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 45 | #include "gui.h" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | #include "rapidxml.hpp" |
| 49 | #include "objects.hpp" |
gordon1337 | 0d9133d | 2013-06-08 14:17:07 +0200 | [diff] [blame] | 50 | #include "blanktimer.hpp" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 51 | |
| 52 | extern int gGuiRunning; |
| 53 | |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 54 | // From ../twrp.cpp |
| 55 | extern bool datamedia; |
| 56 | |
| 57 | // From console.cpp |
| 58 | extern size_t last_message_count; |
| 59 | extern std::vector<std::string> gConsole; |
| 60 | extern std::vector<std::string> gConsoleColor; |
| 61 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 62 | std::map<std::string, PageSet*> PageManager::mPageSets; |
| 63 | PageSet* PageManager::mCurrentSet; |
| 64 | PageSet* PageManager::mBaseSet = NULL; |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 65 | MouseCursor *PageManager::mMouseCursor = NULL; |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 66 | HardwareKeyboard *PageManager::mHardwareKeyboard = NULL; |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 67 | bool PageManager::mReloadTheme = false; |
| 68 | std::string PageManager::mStartPage = "main"; |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 69 | std::vector<language_struct> Language_List; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 70 | |
Ethan Yonker | 751a85e | 2014-12-12 16:59:10 -0600 | [diff] [blame] | 71 | int tw_x_offset = 0; |
| 72 | int tw_y_offset = 0; |
| 73 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 74 | // Helper routine to convert a string to a color declaration |
| 75 | int ConvertStrToColor(std::string str, COLOR* color) |
| 76 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 77 | // Set the default, solid black |
| 78 | memset(color, 0, sizeof(COLOR)); |
| 79 | color->alpha = 255; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 80 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 81 | // Translate variables |
| 82 | DataManager::GetValue(str, str); |
Matt Mower | fb1c4ff | 2014-04-16 13:43:36 -0500 | [diff] [blame] | 83 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 84 | // Look for some defaults |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 85 | if (str == "black") return 0; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 86 | else if (str == "white") { color->red = color->green = color->blue = 255; return 0; } |
| 87 | else if (str == "red") { color->red = 255; return 0; } |
| 88 | else if (str == "green") { color->green = 255; return 0; } |
| 89 | else if (str == "blue") { color->blue = 255; return 0; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 90 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 91 | // At this point, we require an RGB(A) color |
| 92 | if (str[0] != '#') |
| 93 | return -1; |
| 94 | |
| 95 | str.erase(0, 1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 96 | |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 97 | int result; |
| 98 | if (str.size() >= 8) { |
| 99 | // We have alpha channel |
| 100 | string alpha = str.substr(6, 2); |
| 101 | result = strtol(alpha.c_str(), NULL, 16); |
| 102 | color->alpha = result & 0x000000FF; |
| 103 | str.resize(6); |
| 104 | result = strtol(str.c_str(), NULL, 16); |
| 105 | color->red = (result >> 16) & 0x000000FF; |
| 106 | color->green = (result >> 8) & 0x000000FF; |
| 107 | color->blue = result & 0x000000FF; |
| 108 | } else { |
| 109 | result = strtol(str.c_str(), NULL, 16); |
| 110 | color->red = (result >> 16) & 0x000000FF; |
| 111 | color->green = (result >> 8) & 0x000000FF; |
| 112 | color->blue = result & 0x000000FF; |
| 113 | } |
| 114 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | // Helper APIs |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 118 | xml_node<>* FindNode(xml_node<>* parent, const char* nodename, int depth /* = 0 */) |
| 119 | { |
that | 8d46c09 | 2015-02-26 01:30:04 +0100 | [diff] [blame] | 120 | if (!parent) |
| 121 | return NULL; |
| 122 | |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 123 | xml_node<>* child = parent->first_node(nodename); |
| 124 | if (child) |
| 125 | return child; |
| 126 | |
| 127 | if (depth == 10) { |
| 128 | LOGERR("Too many style loops detected.\n"); |
| 129 | return NULL; |
| 130 | } |
| 131 | |
| 132 | xml_node<>* style = parent->first_node("style"); |
| 133 | if (style) { |
| 134 | while (style) { |
| 135 | if (!style->first_attribute("name")) { |
| 136 | LOGERR("No name given for style.\n"); |
| 137 | continue; |
| 138 | } else { |
| 139 | std::string name = style->first_attribute("name")->value(); |
| 140 | xml_node<>* node = PageManager::FindStyle(name); |
| 141 | |
| 142 | if (node) { |
| 143 | // We found the style that was named |
| 144 | xml_node<>* stylenode = FindNode(node, nodename, depth + 1); |
| 145 | if (stylenode) |
| 146 | return stylenode; |
| 147 | } |
| 148 | } |
| 149 | style = style->next_sibling("style"); |
| 150 | } |
| 151 | } else { |
that | 54e9c83 | 2015-11-04 21:46:01 +0100 | [diff] [blame] | 152 | // Search for stylename in the parent node <object type="foo" style="foo2"> |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 153 | xml_attribute<>* attr = parent->first_attribute("style"); |
| 154 | // If no style is found anywhere else and the node wasn't found in the object itself |
| 155 | // as a special case we will search for a style that uses the same style name as the |
| 156 | // object type, so <object type="button"> would search for a style named "button" |
| 157 | if (!attr) |
| 158 | attr = parent->first_attribute("type"); |
that | 54e9c83 | 2015-11-04 21:46:01 +0100 | [diff] [blame] | 159 | // if there's no attribute type, the object type must be the element name |
| 160 | std::string stylename = attr ? attr->value() : parent->name(); |
| 161 | xml_node<>* node = PageManager::FindStyle(stylename); |
| 162 | if (node) { |
| 163 | xml_node<>* stylenode = FindNode(node, nodename, depth + 1); |
| 164 | if (stylenode) |
| 165 | return stylenode; |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | return NULL; |
| 169 | } |
| 170 | |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 171 | std::string LoadAttrString(xml_node<>* element, const char* attrname, const char* defaultvalue) |
| 172 | { |
| 173 | if (!element) |
| 174 | return defaultvalue; |
| 175 | |
| 176 | xml_attribute<>* attr = element->first_attribute(attrname); |
| 177 | return attr ? attr->value() : defaultvalue; |
| 178 | } |
| 179 | |
| 180 | int LoadAttrInt(xml_node<>* element, const char* attrname, int defaultvalue) |
| 181 | { |
| 182 | string value = LoadAttrString(element, attrname); |
| 183 | // resolve variables |
| 184 | DataManager::GetValue(value, value); |
| 185 | return value.empty() ? defaultvalue : atoi(value.c_str()); |
| 186 | } |
| 187 | |
| 188 | int LoadAttrIntScaleX(xml_node<>* element, const char* attrname, int defaultvalue) |
| 189 | { |
| 190 | return scale_theme_x(LoadAttrInt(element, attrname, defaultvalue)); |
| 191 | } |
| 192 | |
| 193 | int LoadAttrIntScaleY(xml_node<>* element, const char* attrname, int defaultvalue) |
| 194 | { |
| 195 | return scale_theme_y(LoadAttrInt(element, attrname, defaultvalue)); |
| 196 | } |
| 197 | |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 198 | COLOR LoadAttrColor(xml_node<>* element, const char* attrname, bool* found_color, COLOR defaultvalue) |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 199 | { |
| 200 | string value = LoadAttrString(element, attrname); |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 201 | *found_color = !value.empty(); |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 202 | // resolve variables |
| 203 | DataManager::GetValue(value, value); |
| 204 | COLOR ret = defaultvalue; |
| 205 | if (ConvertStrToColor(value, &ret) == 0) |
| 206 | return ret; |
| 207 | else |
| 208 | return defaultvalue; |
| 209 | } |
| 210 | |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 211 | COLOR LoadAttrColor(xml_node<>* element, const char* attrname, COLOR defaultvalue) |
| 212 | { |
| 213 | bool found_color = false; |
| 214 | return LoadAttrColor(element, attrname, &found_color, defaultvalue); |
| 215 | } |
| 216 | |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 217 | FontResource* LoadAttrFont(xml_node<>* element, const char* attrname) |
| 218 | { |
| 219 | std::string name = LoadAttrString(element, attrname, ""); |
| 220 | if (name.empty()) |
| 221 | return NULL; |
| 222 | else |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 223 | return PageManager::GetResources()->FindFont(name); |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | ImageResource* LoadAttrImage(xml_node<>* element, const char* attrname) |
| 227 | { |
| 228 | std::string name = LoadAttrString(element, attrname, ""); |
| 229 | if (name.empty()) |
| 230 | return NULL; |
| 231 | else |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 232 | return PageManager::GetResources()->FindImage(name); |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | AnimationResource* LoadAttrAnimation(xml_node<>* element, const char* attrname) |
| 236 | { |
| 237 | std::string name = LoadAttrString(element, attrname, ""); |
| 238 | if (name.empty()) |
| 239 | return NULL; |
| 240 | else |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 241 | return PageManager::GetResources()->FindAnimation(name); |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 242 | } |
| 243 | |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 244 | bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w /* = NULL */, int* h /* = NULL */, Placement* placement /* = NULL */) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 245 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 246 | if (!node) |
| 247 | return false; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 248 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 249 | if (node->first_attribute("x")) |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 250 | *x = LoadAttrIntScaleX(node, "x") + tw_x_offset; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 251 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 252 | if (node->first_attribute("y")) |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 253 | *y = LoadAttrIntScaleY(node, "y") + tw_y_offset; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 254 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 255 | if (w && node->first_attribute("w")) |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 256 | *w = LoadAttrIntScaleX(node, "w"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 257 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 258 | if (h && node->first_attribute("h")) |
that | f6ed8fc | 2015-02-14 20:23:16 +0100 | [diff] [blame] | 259 | *h = LoadAttrIntScaleY(node, "h"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 260 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 261 | if (placement && node->first_attribute("placement")) |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 262 | *placement = (Placement) LoadAttrInt(node, "placement"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 263 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 264 | return true; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | int ActionObject::SetActionPos(int x, int y, int w, int h) |
| 268 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 269 | if (x < 0 || y < 0) |
| 270 | return -1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 271 | |
Matt Mower | fb1c4ff | 2014-04-16 13:43:36 -0500 | [diff] [blame] | 272 | mActionX = x; |
| 273 | mActionY = y; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 274 | if (w || h) |
| 275 | { |
| 276 | mActionW = w; |
| 277 | mActionH = h; |
| 278 | } |
| 279 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 280 | } |
| 281 | |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 282 | Page::Page(xml_node<>* page, std::vector<xml_node<>*> *templates) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 283 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 284 | mTouchStart = NULL; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 285 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 286 | // We can memset the whole structure, because the alpha channel is ignored |
| 287 | memset(&mBackground, 0, sizeof(COLOR)); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 288 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 289 | // With NULL, we make a console-only display |
| 290 | if (!page) |
| 291 | { |
| 292 | mName = "console"; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 293 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 294 | GUIConsole* element = new GUIConsole(NULL); |
| 295 | mRenders.push_back(element); |
| 296 | mActions.push_back(element); |
| 297 | return; |
| 298 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 299 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 300 | if (page->first_attribute("name")) |
| 301 | mName = page->first_attribute("name")->value(); |
| 302 | else |
| 303 | { |
| 304 | LOGERR("No page name attribute found!\n"); |
| 305 | return; |
| 306 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 307 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 308 | LOGINFO("Loading page %s\n", mName.c_str()); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 309 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 310 | // This is a recursive routine for template handling |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 311 | ProcessNode(page, templates, 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 312 | } |
| 313 | |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 314 | Page::~Page() |
| 315 | { |
| 316 | for (std::vector<GUIObject*>::iterator itr = mObjects.begin(); itr != mObjects.end(); ++itr) |
| 317 | delete *itr; |
| 318 | } |
| 319 | |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 320 | bool Page::ProcessNode(xml_node<>* page, std::vector<xml_node<>*> *templates, int depth) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 321 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 322 | if (depth == 10) |
| 323 | { |
| 324 | LOGERR("Page processing depth has exceeded 10. Failing out. This is likely a recursive template.\n"); |
| 325 | return false; |
| 326 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 327 | |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 328 | for (xml_node<>* child = page->first_node(); child; child = child->next_sibling()) |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 329 | { |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 330 | std::string type = child->name(); |
| 331 | |
| 332 | if (type == "background") { |
| 333 | mBackground = LoadAttrColor(child, "color", COLOR(0,0,0,0)); |
| 334 | continue; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 335 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 336 | |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 337 | if (type == "object") { |
| 338 | // legacy format : <object type="..."> |
| 339 | xml_attribute<>* attr = child->first_attribute("type"); |
| 340 | type = attr ? attr->value() : "*unspecified*"; |
| 341 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 342 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 343 | if (type == "text") |
| 344 | { |
| 345 | GUIText* element = new GUIText(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 346 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 347 | mRenders.push_back(element); |
| 348 | mActions.push_back(element); |
| 349 | } |
| 350 | else if (type == "image") |
| 351 | { |
| 352 | GUIImage* element = new GUIImage(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 353 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 354 | mRenders.push_back(element); |
| 355 | } |
| 356 | else if (type == "fill") |
| 357 | { |
| 358 | GUIFill* element = new GUIFill(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 359 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 360 | mRenders.push_back(element); |
| 361 | } |
| 362 | else if (type == "action") |
| 363 | { |
| 364 | GUIAction* element = new GUIAction(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 365 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 366 | mActions.push_back(element); |
| 367 | } |
| 368 | else if (type == "console") |
| 369 | { |
| 370 | GUIConsole* element = new GUIConsole(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 371 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 372 | mRenders.push_back(element); |
| 373 | mActions.push_back(element); |
| 374 | } |
| 375 | else if (type == "button") |
| 376 | { |
| 377 | GUIButton* element = new GUIButton(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 378 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 379 | mRenders.push_back(element); |
| 380 | mActions.push_back(element); |
| 381 | } |
| 382 | else if (type == "checkbox") |
| 383 | { |
| 384 | GUICheckbox* element = new GUICheckbox(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 385 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 386 | mRenders.push_back(element); |
| 387 | mActions.push_back(element); |
| 388 | } |
| 389 | else if (type == "fileselector") |
| 390 | { |
| 391 | GUIFileSelector* element = new GUIFileSelector(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 392 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 393 | mRenders.push_back(element); |
| 394 | mActions.push_back(element); |
| 395 | } |
| 396 | else if (type == "animation") |
| 397 | { |
| 398 | GUIAnimation* element = new GUIAnimation(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 399 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 400 | mRenders.push_back(element); |
| 401 | } |
| 402 | else if (type == "progressbar") |
| 403 | { |
| 404 | GUIProgressBar* element = new GUIProgressBar(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 405 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 406 | mRenders.push_back(element); |
| 407 | mActions.push_back(element); |
| 408 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 409 | else if (type == "slider") |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 410 | { |
| 411 | GUISlider* element = new GUISlider(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 412 | mObjects.push_back(element); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 413 | mRenders.push_back(element); |
| 414 | mActions.push_back(element); |
| 415 | } |
Vojtech Bocek | 8593234 | 2013-04-01 22:11:33 +0200 | [diff] [blame] | 416 | else if (type == "slidervalue") |
| 417 | { |
| 418 | GUISliderValue *element = new GUISliderValue(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 419 | mObjects.push_back(element); |
Vojtech Bocek | 8593234 | 2013-04-01 22:11:33 +0200 | [diff] [blame] | 420 | mRenders.push_back(element); |
| 421 | mActions.push_back(element); |
| 422 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 423 | else if (type == "listbox") |
| 424 | { |
| 425 | GUIListBox* element = new GUIListBox(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 426 | mObjects.push_back(element); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 427 | mRenders.push_back(element); |
| 428 | mActions.push_back(element); |
| 429 | } |
| 430 | else if (type == "keyboard") |
| 431 | { |
| 432 | GUIKeyboard* element = new GUIKeyboard(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 433 | mObjects.push_back(element); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 434 | mRenders.push_back(element); |
| 435 | mActions.push_back(element); |
| 436 | } |
| 437 | else if (type == "input") |
| 438 | { |
| 439 | GUIInput* element = new GUIInput(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 440 | mObjects.push_back(element); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 441 | mRenders.push_back(element); |
| 442 | mActions.push_back(element); |
| 443 | mInputs.push_back(element); |
| 444 | } |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 445 | else if (type == "partitionlist") |
| 446 | { |
| 447 | GUIPartitionList* element = new GUIPartitionList(child); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 448 | mObjects.push_back(element); |
Dees_Troy | a13d74f | 2013-03-24 08:54:55 -0500 | [diff] [blame] | 449 | mRenders.push_back(element); |
| 450 | mActions.push_back(element); |
| 451 | } |
Vojtech Bocek | 7e11ac5 | 2015-03-05 23:21:49 +0100 | [diff] [blame] | 452 | else if (type == "patternpassword") |
| 453 | { |
| 454 | GUIPatternPassword* element = new GUIPatternPassword(child); |
| 455 | mObjects.push_back(element); |
| 456 | mRenders.push_back(element); |
| 457 | mActions.push_back(element); |
| 458 | } |
Ethan Yonker | 44925ad | 2015-07-22 12:33:59 -0500 | [diff] [blame] | 459 | else if (type == "textbox") |
| 460 | { |
| 461 | GUITextBox* element = new GUITextBox(child); |
| 462 | mObjects.push_back(element); |
| 463 | mRenders.push_back(element); |
| 464 | mActions.push_back(element); |
| 465 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 466 | else if (type == "template") |
| 467 | { |
| 468 | if (!templates || !child->first_attribute("name")) |
| 469 | { |
| 470 | LOGERR("Invalid template request.\n"); |
| 471 | } |
| 472 | else |
| 473 | { |
| 474 | std::string name = child->first_attribute("name")->value(); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 475 | xml_node<>* node; |
| 476 | bool node_found = false; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 477 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 478 | // We need to find the correct template |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 479 | for (std::vector<xml_node<>*>::iterator itr = templates->begin(); itr != templates->end(); itr++) { |
| 480 | node = (*itr)->first_node("template"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 481 | |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 482 | while (node) |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 483 | { |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 484 | if (!node->first_attribute("name")) |
| 485 | continue; |
| 486 | |
| 487 | if (name == node->first_attribute("name")->value()) |
| 488 | { |
| 489 | if (!ProcessNode(node, templates, depth + 1)) |
| 490 | return false; |
| 491 | else { |
| 492 | node_found = true; |
| 493 | break; |
| 494 | } |
| 495 | } |
| 496 | if (node_found) |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 497 | break; |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 498 | node = node->next_sibling("template"); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 499 | } |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 500 | // [check] why is there no if (node_found) here too? |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 501 | } |
| 502 | } |
| 503 | } |
| 504 | else |
| 505 | { |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 506 | LOGERR("Unknown object type: %s.\n", type.c_str()); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 507 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 508 | } |
| 509 | return true; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | int Page::Render(void) |
| 513 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 514 | // Render background |
| 515 | gr_color(mBackground.red, mBackground.green, mBackground.blue, mBackground.alpha); |
| 516 | gr_fill(0, 0, gr_fb_width(), gr_fb_height()); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 517 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 518 | // Render remaining objects |
| 519 | std::vector<RenderObject*>::iterator iter; |
| 520 | for (iter = mRenders.begin(); iter != mRenders.end(); iter++) |
| 521 | { |
| 522 | if ((*iter)->Render()) |
| 523 | LOGERR("A render request has failed.\n"); |
| 524 | } |
| 525 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | int Page::Update(void) |
| 529 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 530 | int retCode = 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 531 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 532 | std::vector<RenderObject*>::iterator iter; |
| 533 | for (iter = mRenders.begin(); iter != mRenders.end(); iter++) |
| 534 | { |
| 535 | int ret = (*iter)->Update(); |
| 536 | if (ret < 0) |
| 537 | LOGERR("An update request has failed.\n"); |
| 538 | else if (ret > retCode) |
| 539 | retCode = ret; |
| 540 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 541 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 542 | return retCode; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | int Page::NotifyTouch(TOUCH_STATE state, int x, int y) |
| 546 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 547 | // By default, return 1 to ignore further touches if nobody is listening |
| 548 | int ret = 1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 549 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 550 | // Don't try to handle a lack of handlers |
| 551 | if (mActions.size() == 0) |
| 552 | return ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 553 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 554 | // We record mTouchStart so we can pass all the touch stream to the same handler |
| 555 | if (state == TOUCH_START) |
| 556 | { |
| 557 | std::vector<ActionObject*>::reverse_iterator iter; |
| 558 | // We work backwards, from top-most element to bottom-most element |
| 559 | for (iter = mActions.rbegin(); iter != mActions.rend(); iter++) |
| 560 | { |
| 561 | if ((*iter)->IsInRegion(x, y)) |
| 562 | { |
| 563 | mTouchStart = (*iter); |
| 564 | ret = mTouchStart->NotifyTouch(state, x, y); |
| 565 | if (ret >= 0) |
| 566 | break; |
| 567 | mTouchStart = NULL; |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | else if (state == TOUCH_RELEASE && mTouchStart != NULL) |
| 572 | { |
| 573 | ret = mTouchStart->NotifyTouch(state, x, y); |
| 574 | mTouchStart = NULL; |
| 575 | } |
| 576 | else if ((state == TOUCH_DRAG || state == TOUCH_HOLD || state == TOUCH_REPEAT) && mTouchStart != NULL) |
| 577 | { |
| 578 | ret = mTouchStart->NotifyTouch(state, x, y); |
| 579 | } |
| 580 | return ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 581 | } |
| 582 | |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 583 | int Page::NotifyKey(int key, bool down) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 584 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 585 | std::vector<ActionObject*>::reverse_iterator iter; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 586 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 587 | // Don't try to handle a lack of handlers |
| 588 | if (mActions.size() == 0) |
| 589 | return 1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 590 | |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 591 | int ret = 1; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 592 | // We work backwards, from top-most element to bottom-most element |
| 593 | for (iter = mActions.rbegin(); iter != mActions.rend(); iter++) |
| 594 | { |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 595 | ret = (*iter)->NotifyKey(key, down); |
| 596 | if (ret < 0) { |
| 597 | LOGERR("An action handler has returned an error\n"); |
| 598 | ret = 1; |
| 599 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 600 | } |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 601 | return ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | int Page::NotifyKeyboard(int key) |
| 605 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 606 | std::vector<InputObject*>::reverse_iterator iter; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 607 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 608 | // Don't try to handle a lack of handlers |
| 609 | if (mInputs.size() == 0) |
| 610 | return 1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 611 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 612 | // We work backwards, from top-most element to bottom-most element |
| 613 | for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++) |
| 614 | { |
| 615 | int ret = (*iter)->NotifyKeyboard(key); |
| 616 | if (ret == 0) |
| 617 | return 0; |
| 618 | else if (ret < 0) |
| 619 | LOGERR("A keyboard handler has returned an error"); |
| 620 | } |
| 621 | return 1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | int Page::SetKeyBoardFocus(int inFocus) |
| 625 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 626 | std::vector<InputObject*>::reverse_iterator iter; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 627 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 628 | // Don't try to handle a lack of handlers |
| 629 | if (mInputs.size() == 0) |
| 630 | return 1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 631 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 632 | // We work backwards, from top-most element to bottom-most element |
| 633 | for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++) |
| 634 | { |
| 635 | int ret = (*iter)->SetInputFocus(inFocus); |
| 636 | if (ret == 0) |
| 637 | return 0; |
| 638 | else if (ret < 0) |
| 639 | LOGERR("An input focus handler has returned an error"); |
| 640 | } |
| 641 | return 1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | void Page::SetPageFocus(int inFocus) |
| 645 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 646 | // Render remaining objects |
| 647 | std::vector<RenderObject*>::iterator iter; |
| 648 | for (iter = mRenders.begin(); iter != mRenders.end(); iter++) |
| 649 | (*iter)->SetPageFocus(inFocus); |
| 650 | |
| 651 | return; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | int Page::NotifyVarChange(std::string varName, std::string value) |
| 655 | { |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 656 | std::vector<GUIObject*>::iterator iter; |
| 657 | for (iter = mObjects.begin(); iter != mObjects.end(); ++iter) |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 658 | { |
| 659 | if ((*iter)->NotifyVarChange(varName, value)) |
| 660 | LOGERR("An action handler errored on NotifyVarChange.\n"); |
| 661 | } |
| 662 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 663 | } |
| 664 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 665 | PageSet::PageSet(const char* xmlFile) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 666 | { |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 667 | mResources = new ResourceManager; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 668 | mCurrentPage = NULL; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 669 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 670 | if (!xmlFile) |
that | b63e2f9 | 2015-06-27 21:35:11 +0200 | [diff] [blame] | 671 | mCurrentPage = new Page(NULL, NULL); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | PageSet::~PageSet() |
| 675 | { |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 676 | mOverlays.clear(); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 677 | for (std::vector<Page*>::iterator itr = mPages.begin(); itr != mPages.end(); ++itr) |
| 678 | delete *itr; |
| 679 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 680 | delete mResources; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 681 | } |
| 682 | |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 683 | int PageSet::LoadLanguage(char* languageFile, ZipArchive* package) |
| 684 | { |
| 685 | xml_document<> lang; |
| 686 | xml_node<>* parent; |
| 687 | xml_node<>* child; |
| 688 | std::string resource_source; |
| 689 | |
| 690 | if (languageFile) { |
| 691 | printf("parsing languageFile\n"); |
| 692 | lang.parse<0>(languageFile); |
| 693 | printf("parsing languageFile done\n"); |
| 694 | } else { |
| 695 | return -1; |
| 696 | } |
| 697 | |
| 698 | parent = lang.first_node("language"); |
| 699 | if (!parent) { |
| 700 | LOGERR("Unable to locate language node in language file.\n"); |
| 701 | lang.clear(); |
| 702 | return -1; |
| 703 | } |
| 704 | |
| 705 | child = parent->first_node("display"); |
| 706 | if (child) { |
| 707 | DataManager::SetValue("tw_language_display", child->value()); |
| 708 | resource_source = child->value(); |
| 709 | } else { |
| 710 | LOGERR("language file does not have a display value set\n"); |
| 711 | DataManager::SetValue("tw_language_display", "Not Set"); |
| 712 | resource_source = languageFile; |
| 713 | } |
| 714 | |
| 715 | child = parent->first_node("resources"); |
| 716 | if (child) |
| 717 | mResources->LoadResources(child, package, resource_source); |
| 718 | else |
| 719 | return -1; |
| 720 | lang.clear(); |
| 721 | return 0; |
| 722 | } |
| 723 | |
| 724 | int PageSet::Load(ZipArchive* package, char* xmlFile, char* languageFile) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 725 | { |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 726 | xml_document<> mDoc; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 727 | xml_node<>* parent; |
| 728 | xml_node<>* child; |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 729 | xml_node<>* xmltemplate; |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 730 | xml_node<>* xmlstyle; |
Matt Mower | fb1c4ff | 2014-04-16 13:43:36 -0500 | [diff] [blame] | 731 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 732 | mDoc.parse<0>(xmlFile); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 733 | parent = mDoc.first_node("recovery"); |
| 734 | if (!parent) |
| 735 | parent = mDoc.first_node("install"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 736 | |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 737 | set_scale_values(1, 1); // Reset any previous scaling values |
| 738 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 739 | // Now, let's parse the XML |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 740 | LOGINFO("Checking resolution...\n"); |
| 741 | child = parent->first_node("details"); |
| 742 | if (child) { |
| 743 | xml_node<>* resolution = child->first_node("resolution"); |
| 744 | if (resolution) { |
| 745 | xml_attribute<>* width_attr = resolution->first_attribute("width"); |
| 746 | xml_attribute<>* height_attr = resolution->first_attribute("height"); |
| 747 | xml_attribute<>* noscale_attr = resolution->first_attribute("noscaling"); |
| 748 | if (width_attr && height_attr && !noscale_attr) { |
| 749 | int width = atoi(width_attr->value()); |
| 750 | int height = atoi(height_attr->value()); |
| 751 | int offx = 0, offy = 0; |
| 752 | #ifdef TW_ROUND_SCREEN |
| 753 | xml_node<>* roundscreen = child->first_node("roundscreen"); |
| 754 | if (roundscreen) { |
| 755 | LOGINFO("TW_ROUND_SCREEN := true, using round screen XML settings.\n"); |
| 756 | xml_attribute<>* offx_attr = roundscreen->first_attribute("offset_x"); |
| 757 | xml_attribute<>* offy_attr = roundscreen->first_attribute("offset_y"); |
| 758 | if (offx_attr) { |
| 759 | offx = atoi(offx_attr->value()); |
| 760 | } |
| 761 | if (offy_attr) { |
| 762 | offy = atoi(offy_attr->value()); |
| 763 | } |
| 764 | } |
| 765 | #endif |
| 766 | if (width != 0 && height != 0) { |
| 767 | float scale_w = ((float)gr_fb_width() - ((float)offx * 2.0)) / (float)width; |
| 768 | float scale_h = ((float)gr_fb_height() - ((float)offy * 2.0)) / (float)height; |
| 769 | #ifdef TW_ROUND_SCREEN |
| 770 | float scale_off_w = (float)gr_fb_width() / (float)width; |
| 771 | float scale_off_h = (float)gr_fb_height() / (float)height; |
| 772 | tw_x_offset = offx * scale_off_w; |
| 773 | tw_y_offset = offy * scale_off_h; |
| 774 | #endif |
| 775 | if (scale_w != 1 || scale_h != 1) { |
| 776 | LOGINFO("Scaling theme width %fx and height %fx, offsets x: %i y: %i\n", scale_w, scale_h, tw_x_offset, tw_y_offset); |
| 777 | set_scale_values(scale_w, scale_h); |
| 778 | } |
| 779 | } |
| 780 | } else { |
| 781 | LOGINFO("XML does not contain width and height, no scaling will be applied\n"); |
| 782 | } |
| 783 | } else { |
| 784 | LOGINFO("XML contains no resolution tag, no scaling will be applied.\n"); |
| 785 | } |
| 786 | } else { |
| 787 | LOGINFO("XML contains no details tag, no scaling will be applied.\n"); |
| 788 | } |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 789 | |
| 790 | if (languageFile) |
| 791 | LoadLanguage(languageFile, package); |
| 792 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 793 | LOGINFO("Loading resources...\n"); |
| 794 | child = parent->first_node("resources"); |
| 795 | if (child) |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 796 | mResources->LoadResources(child, package, "theme"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 797 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 798 | LOGINFO("Loading variables...\n"); |
| 799 | child = parent->first_node("variables"); |
| 800 | if (child) |
| 801 | LoadVariables(child); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 802 | |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 803 | LOGINFO("Loading mouse cursor...\n"); |
| 804 | child = parent->first_node("mousecursor"); |
| 805 | if(child) |
| 806 | PageManager::LoadCursorData(child); |
| 807 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 808 | LOGINFO("Loading pages...\n"); |
| 809 | // This may be NULL if no templates are present |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 810 | xmltemplate = parent->first_node("templates"); |
| 811 | if (xmltemplate) |
| 812 | templates.push_back(xmltemplate); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 813 | |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 814 | // Load styles if present |
| 815 | xmlstyle = parent->first_node("styles"); |
| 816 | if (xmlstyle) |
| 817 | styles.push_back(xmlstyle); |
| 818 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 819 | child = parent->first_node("pages"); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 820 | if (child) { |
| 821 | if (LoadPages(child)) { |
| 822 | LOGERR("PageSet::Load returning -1\n"); |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 823 | mDoc.clear(); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 824 | return -1; |
| 825 | } |
| 826 | } |
Vojtech Bocek | e979abd | 2015-01-12 18:29:12 +0100 | [diff] [blame] | 827 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 828 | int ret = CheckInclude(package, &mDoc); |
| 829 | mDoc.clear(); |
| 830 | templates.clear(); |
| 831 | return ret; |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 832 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 833 | |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 834 | int PageSet::CheckInclude(ZipArchive* package, xml_document<> *parentDoc) |
| 835 | { |
| 836 | xml_node<>* par; |
| 837 | xml_node<>* par2; |
| 838 | xml_node<>* chld; |
| 839 | xml_node<>* parent; |
| 840 | xml_node<>* child; |
| 841 | xml_node<>* xmltemplate; |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 842 | xml_node<>* xmlstyle; |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 843 | long len; |
| 844 | char* xmlFile = NULL; |
| 845 | string filename; |
Vojtech Bocek | e979abd | 2015-01-12 18:29:12 +0100 | [diff] [blame] | 846 | xml_document<> *doc = NULL; |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 847 | |
| 848 | par = parentDoc->first_node("recovery"); |
| 849 | if (!par) { |
| 850 | par = parentDoc->first_node("install"); |
| 851 | } |
| 852 | if (!par) { |
| 853 | return 0; |
| 854 | } |
| 855 | |
| 856 | par2 = par->first_node("include"); |
| 857 | if (!par2) |
| 858 | return 0; |
| 859 | chld = par2->first_node("xmlfile"); |
| 860 | while (chld != NULL) { |
| 861 | xml_attribute<>* attr = chld->first_attribute("name"); |
| 862 | if (!attr) |
| 863 | break; |
| 864 | |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 865 | if (!package) { |
| 866 | // We can try to load the XML directly... |
Dees Troy | 3454ade | 2015-01-20 19:21:04 +0000 | [diff] [blame] | 867 | filename = TWRES; |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 868 | filename += attr->value(); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 869 | } else { |
| 870 | filename += attr->value(); |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 871 | } |
| 872 | xmlFile = PageManager::LoadFileToBuffer(filename, package); |
| 873 | if (xmlFile == NULL) { |
| 874 | LOGERR("PageSet::CheckInclude unable to load '%s'\n", filename.c_str()); |
| 875 | return -1; |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 876 | } |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 877 | |
Vojtech Bocek | e979abd | 2015-01-12 18:29:12 +0100 | [diff] [blame] | 878 | doc = new xml_document<>(); |
| 879 | doc->parse<0>(xmlFile); |
| 880 | |
| 881 | parent = doc->first_node("recovery"); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 882 | if (!parent) |
Vojtech Bocek | e979abd | 2015-01-12 18:29:12 +0100 | [diff] [blame] | 883 | parent = doc->first_node("install"); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 884 | |
| 885 | // Now, let's parse the XML |
| 886 | LOGINFO("Loading included resources...\n"); |
| 887 | child = parent->first_node("resources"); |
| 888 | if (child) |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 889 | mResources->LoadResources(child, package, "theme"); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 890 | |
| 891 | LOGINFO("Loading included variables...\n"); |
| 892 | child = parent->first_node("variables"); |
| 893 | if (child) |
| 894 | LoadVariables(child); |
| 895 | |
| 896 | LOGINFO("Loading mouse cursor...\n"); |
| 897 | child = parent->first_node("mousecursor"); |
| 898 | if(child) |
| 899 | PageManager::LoadCursorData(child); |
| 900 | |
| 901 | LOGINFO("Loading included pages...\n"); |
| 902 | // This may be NULL if no templates are present |
| 903 | xmltemplate = parent->first_node("templates"); |
| 904 | if (xmltemplate) |
| 905 | templates.push_back(xmltemplate); |
| 906 | |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 907 | // Load styles if present |
| 908 | xmlstyle = parent->first_node("styles"); |
| 909 | if (xmlstyle) |
| 910 | styles.push_back(xmlstyle); |
| 911 | |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 912 | child = parent->first_node("pages"); |
Vojtech Bocek | e979abd | 2015-01-12 18:29:12 +0100 | [diff] [blame] | 913 | if (child && LoadPages(child)) |
| 914 | { |
| 915 | templates.pop_back(); |
| 916 | doc->clear(); |
| 917 | delete doc; |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 918 | free(xmlFile); |
Vojtech Bocek | e979abd | 2015-01-12 18:29:12 +0100 | [diff] [blame] | 919 | return -1; |
| 920 | } |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 921 | |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 922 | if (CheckInclude(package, doc)) { |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 923 | doc->clear(); |
| 924 | delete doc; |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 925 | free(xmlFile); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 926 | return -1; |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 927 | } |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 928 | doc->clear(); |
| 929 | delete doc; |
| 930 | free(xmlFile); |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 931 | |
| 932 | chld = chld->next_sibling("xmlfile"); |
| 933 | } |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 934 | |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 935 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | int PageSet::SetPage(std::string page) |
| 939 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 940 | Page* tmp = FindPage(page); |
| 941 | if (tmp) |
| 942 | { |
| 943 | if (mCurrentPage) mCurrentPage->SetPageFocus(0); |
| 944 | mCurrentPage = tmp; |
| 945 | mCurrentPage->SetPageFocus(1); |
| 946 | mCurrentPage->NotifyVarChange("", ""); |
| 947 | return 0; |
| 948 | } |
| 949 | else |
| 950 | { |
| 951 | LOGERR("Unable to locate page (%s)\n", page.c_str()); |
| 952 | } |
| 953 | return -1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | int PageSet::SetOverlay(Page* page) |
| 957 | { |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 958 | if (page) { |
| 959 | if (mOverlays.size() >= 10) { |
| 960 | LOGERR("Too many overlays requested, max is 10.\n"); |
| 961 | return -1; |
| 962 | } |
Matt Mower | d411f8d | 2015-04-09 16:04:12 -0500 | [diff] [blame] | 963 | |
| 964 | std::vector<Page*>::iterator iter; |
| 965 | for (iter = mOverlays.begin(); iter != mOverlays.end(); iter++) { |
| 966 | if ((*iter)->GetName() == page->GetName()) { |
| 967 | mOverlays.erase(iter); |
| 968 | // SetOverlay() is (and should stay) the only function which |
| 969 | // adds to mOverlays. Then, each page can appear at most once. |
| 970 | break; |
| 971 | } |
| 972 | } |
| 973 | |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 974 | page->SetPageFocus(1); |
| 975 | page->NotifyVarChange("", ""); |
| 976 | |
| 977 | if (!mOverlays.empty()) |
| 978 | mOverlays.back()->SetPageFocus(0); |
| 979 | |
| 980 | mOverlays.push_back(page); |
| 981 | } else { |
| 982 | if (!mOverlays.empty()) { |
| 983 | mOverlays.back()->SetPageFocus(0); |
| 984 | mOverlays.pop_back(); |
| 985 | if (!mOverlays.empty()) |
| 986 | mOverlays.back()->SetPageFocus(1); |
| 987 | else if (mCurrentPage) |
| 988 | mCurrentPage->SetPageFocus(1); // Just in case somehow the regular page lost focus, we'll set it again |
| 989 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 990 | } |
| 991 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 992 | } |
| 993 | |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 994 | const ResourceManager* PageSet::GetResources() |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 995 | { |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 996 | return mResources; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 997 | } |
| 998 | |
| 999 | Page* PageSet::FindPage(std::string name) |
| 1000 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1001 | std::vector<Page*>::iterator iter; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1002 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1003 | for (iter = mPages.begin(); iter != mPages.end(); iter++) |
| 1004 | { |
| 1005 | if (name == (*iter)->GetName()) |
| 1006 | return (*iter); |
| 1007 | } |
| 1008 | return NULL; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | int PageSet::LoadVariables(xml_node<>* vars) |
| 1012 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1013 | xml_node<>* child; |
Vojtech Bocek | 81c29dc | 2013-12-07 23:02:09 +0100 | [diff] [blame] | 1014 | xml_attribute<> *name, *value, *persist; |
| 1015 | int p; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1016 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1017 | child = vars->first_node("variable"); |
| 1018 | while (child) |
| 1019 | { |
Vojtech Bocek | 81c29dc | 2013-12-07 23:02:09 +0100 | [diff] [blame] | 1020 | name = child->first_attribute("name"); |
| 1021 | value = child->first_attribute("value"); |
| 1022 | persist = child->first_attribute("persist"); |
| 1023 | if(name && value) |
| 1024 | { |
Ethan Yonker | 751a85e | 2014-12-12 16:59:10 -0600 | [diff] [blame] | 1025 | if (strcmp(name->value(), "tw_x_offset") == 0) { |
| 1026 | tw_x_offset = atoi(value->value()); |
| 1027 | child = child->next_sibling("variable"); |
| 1028 | continue; |
| 1029 | } |
| 1030 | if (strcmp(name->value(), "tw_y_offset") == 0) { |
| 1031 | tw_y_offset = atoi(value->value()); |
| 1032 | child = child->next_sibling("variable"); |
| 1033 | continue; |
| 1034 | } |
Vojtech Bocek | 81c29dc | 2013-12-07 23:02:09 +0100 | [diff] [blame] | 1035 | p = persist ? atoi(persist->value()) : 0; |
Ethan Yonker | 96acb3d | 2014-08-05 09:20:30 -0500 | [diff] [blame] | 1036 | string temp = value->value(); |
| 1037 | string valstr = gui_parse_text(temp); |
| 1038 | |
| 1039 | if (valstr.find("+") != string::npos) { |
| 1040 | string val1str = valstr; |
| 1041 | val1str = val1str.substr(0, val1str.find('+')); |
| 1042 | string val2str = valstr; |
| 1043 | val2str = val2str.substr(val2str.find('+') + 1, string::npos); |
| 1044 | int val1 = atoi(val1str.c_str()); |
| 1045 | int val2 = atoi(val2str.c_str()); |
| 1046 | int val = val1 + val2; |
| 1047 | |
| 1048 | DataManager::SetValue(name->value(), val, p); |
| 1049 | } else if (valstr.find("-") != string::npos) { |
| 1050 | string val1str = valstr; |
| 1051 | val1str = val1str.substr(0, val1str.find('-')); |
| 1052 | string val2str = valstr; |
| 1053 | val2str = val2str.substr(val2str.find('-') + 1, string::npos); |
| 1054 | int val1 = atoi(val1str.c_str()); |
| 1055 | int val2 = atoi(val2str.c_str()); |
| 1056 | int val = val1 - val2; |
| 1057 | |
| 1058 | DataManager::SetValue(name->value(), val, p); |
| 1059 | } else { |
| 1060 | DataManager::SetValue(name->value(), valstr, p); |
| 1061 | } |
Vojtech Bocek | 81c29dc | 2013-12-07 23:02:09 +0100 | [diff] [blame] | 1062 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1063 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1064 | child = child->next_sibling("variable"); |
| 1065 | } |
| 1066 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1067 | } |
| 1068 | |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 1069 | int PageSet::LoadPages(xml_node<>* pages) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1070 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1071 | xml_node<>* child; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1072 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1073 | if (!pages) |
| 1074 | return -1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1075 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1076 | child = pages->first_node("page"); |
| 1077 | while (child != NULL) |
| 1078 | { |
Ethan Yonker | 780cd39 | 2014-07-21 15:24:39 -0500 | [diff] [blame] | 1079 | Page* page = new Page(child, &templates); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1080 | if (page->GetName().empty()) |
| 1081 | { |
| 1082 | LOGERR("Unable to process load page\n"); |
| 1083 | delete page; |
| 1084 | } |
| 1085 | else |
| 1086 | { |
| 1087 | mPages.push_back(page); |
| 1088 | } |
| 1089 | child = child->next_sibling("page"); |
| 1090 | } |
| 1091 | if (mPages.size() > 0) |
| 1092 | return 0; |
| 1093 | return -1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | int PageSet::IsCurrentPage(Page* page) |
| 1097 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1098 | return ((mCurrentPage && mCurrentPage == page) ? 1 : 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | int PageSet::Render(void) |
| 1102 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1103 | int ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1104 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1105 | ret = (mCurrentPage ? mCurrentPage->Render() : -1); |
| 1106 | if (ret < 0) |
| 1107 | return ret; |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 1108 | |
| 1109 | std::vector<Page*>::iterator iter; |
| 1110 | |
| 1111 | for (iter = mOverlays.begin(); iter != mOverlays.end(); iter++) { |
| 1112 | ret = ((*iter) ? (*iter)->Render() : -1); |
| 1113 | if (ret < 0) |
| 1114 | return ret; |
| 1115 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1116 | return ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | int PageSet::Update(void) |
| 1120 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1121 | int ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1122 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1123 | ret = (mCurrentPage ? mCurrentPage->Update() : -1); |
| 1124 | if (ret < 0 || ret > 1) |
| 1125 | return ret; |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 1126 | |
| 1127 | std::vector<Page*>::iterator iter; |
| 1128 | |
| 1129 | for (iter = mOverlays.begin(); iter != mOverlays.end(); iter++) { |
| 1130 | ret = ((*iter) ? (*iter)->Update() : -1); |
| 1131 | if (ret < 0) |
| 1132 | return ret; |
| 1133 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1134 | return ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1135 | } |
| 1136 | |
| 1137 | int PageSet::NotifyTouch(TOUCH_STATE state, int x, int y) |
| 1138 | { |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 1139 | if (!mOverlays.empty()) |
| 1140 | return mOverlays.back()->NotifyTouch(state, x, y); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1141 | |
| 1142 | return (mCurrentPage ? mCurrentPage->NotifyTouch(state, x, y) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1143 | } |
| 1144 | |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 1145 | int PageSet::NotifyKey(int key, bool down) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1146 | { |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 1147 | if (!mOverlays.empty()) |
| 1148 | return mOverlays.back()->NotifyKey(key, down); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1149 | |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 1150 | return (mCurrentPage ? mCurrentPage->NotifyKey(key, down) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1151 | } |
| 1152 | |
| 1153 | int PageSet::NotifyKeyboard(int key) |
| 1154 | { |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 1155 | if (!mOverlays.empty()) |
| 1156 | return mOverlays.back()->NotifyKeyboard(key); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1157 | |
| 1158 | return (mCurrentPage ? mCurrentPage->NotifyKeyboard(key) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | int PageSet::SetKeyBoardFocus(int inFocus) |
| 1162 | { |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 1163 | if (!mOverlays.empty()) |
| 1164 | return mOverlays.back()->SetKeyBoardFocus(inFocus); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1165 | |
| 1166 | return (mCurrentPage ? mCurrentPage->SetKeyBoardFocus(inFocus) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1167 | } |
| 1168 | |
| 1169 | int PageSet::NotifyVarChange(std::string varName, std::string value) |
| 1170 | { |
Ethan Yonker | 1c27331 | 2015-03-16 12:18:56 -0500 | [diff] [blame] | 1171 | std::vector<Page*>::iterator iter; |
| 1172 | |
| 1173 | for (iter = mOverlays.begin(); iter != mOverlays.end(); iter++) |
| 1174 | (*iter)->NotifyVarChange(varName, value); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1175 | |
| 1176 | return (mCurrentPage ? mCurrentPage->NotifyVarChange(varName, value) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1177 | } |
| 1178 | |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1179 | void PageSet::AddStringResource(std::string resource_source, std::string resource_name, std::string value) |
| 1180 | { |
| 1181 | mResources->AddStringResource(resource_source, resource_name, value); |
| 1182 | } |
| 1183 | |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 1184 | char* PageManager::LoadFileToBuffer(std::string filename, ZipArchive* package) { |
| 1185 | size_t len; |
| 1186 | char* buffer = NULL; |
| 1187 | |
| 1188 | if (!package) { |
| 1189 | // We can try to load the XML directly... |
| 1190 | LOGINFO("PageManager::LoadFileToBuffer loading filename: '%s' directly\n", filename.c_str()); |
| 1191 | struct stat st; |
| 1192 | if(stat(filename.c_str(),&st) != 0) { |
| 1193 | // This isn't always an error, sometimes we request files that don't exist. |
| 1194 | return NULL; |
| 1195 | } |
| 1196 | |
| 1197 | len = (size_t)st.st_size; |
| 1198 | |
| 1199 | buffer = (char*) malloc(len + 1); |
| 1200 | if (!buffer) { |
| 1201 | LOGERR("PageManager::LoadFileToBuffer failed to malloc\n"); |
| 1202 | return NULL; |
| 1203 | } |
| 1204 | |
| 1205 | int fd = open(filename.c_str(), O_RDONLY); |
| 1206 | if (fd == -1) { |
| 1207 | LOGERR("PageManager::LoadFileToBuffer failed to open '%s' - (%s)\n", filename.c_str(), strerror(errno)); |
| 1208 | free(buffer); |
| 1209 | return NULL; |
| 1210 | } |
| 1211 | |
| 1212 | if (read(fd, buffer, len) < 0) { |
| 1213 | LOGERR("PageManager::LoadFileToBuffer failed to read '%s' - (%s)\n", filename.c_str(), strerror(errno)); |
| 1214 | free(buffer); |
| 1215 | close(fd); |
| 1216 | return NULL; |
| 1217 | } |
| 1218 | close(fd); |
| 1219 | } else { |
| 1220 | LOGINFO("PageManager::LoadFileToBuffer loading filename: '%s' from zip\n", filename.c_str()); |
| 1221 | const ZipEntry* zipentry = mzFindZipEntry(package, filename.c_str()); |
| 1222 | if (zipentry == NULL) { |
| 1223 | LOGERR("Unable to locate '%s' in zip file\n", filename.c_str()); |
| 1224 | return NULL; |
| 1225 | } |
| 1226 | |
| 1227 | // Allocate the buffer for the file |
| 1228 | len = mzGetZipEntryUncompLen(zipentry); |
| 1229 | buffer = (char*) malloc(len + 1); |
| 1230 | if (!buffer) |
| 1231 | return NULL; |
| 1232 | |
| 1233 | if (!mzExtractZipEntryToBuffer(package, zipentry, (unsigned char*) buffer)) { |
| 1234 | LOGERR("Unable to extract '%s'\n", filename.c_str()); |
| 1235 | free(buffer); |
| 1236 | return NULL; |
| 1237 | } |
| 1238 | } |
| 1239 | // NULL-terminate the string |
| 1240 | buffer[len] = 0x00; |
| 1241 | return buffer; |
| 1242 | } |
| 1243 | |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1244 | void PageManager::LoadLanguageListDir(string dir) { |
| 1245 | if (!TWFunc::Path_Exists(dir)) { |
| 1246 | LOGERR("LoadLanguageListDir '%s' path not found\n", dir.c_str()); |
| 1247 | return; |
| 1248 | } |
| 1249 | |
| 1250 | DIR *d = opendir(dir.c_str()); |
| 1251 | struct dirent *p; |
| 1252 | |
| 1253 | if (d == NULL) { |
| 1254 | LOGERR("LoadLanguageListDir error opening dir: '%s', %s\n", dir.c_str(), strerror(errno)); |
| 1255 | return; |
| 1256 | } |
| 1257 | |
| 1258 | while ((p = readdir(d))) { |
| 1259 | if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..") || strlen(p->d_name) < 5) |
| 1260 | continue; |
| 1261 | |
| 1262 | string file = p->d_name; |
| 1263 | if (file.substr(strlen(p->d_name) - 4) != ".xml") |
| 1264 | continue; |
| 1265 | string path = dir + p->d_name; |
| 1266 | string file_no_extn = file.substr(0, strlen(p->d_name) - 4); |
| 1267 | struct language_struct language_entry; |
| 1268 | language_entry.filename = file_no_extn; |
| 1269 | char* xmlFile = PageManager::LoadFileToBuffer(dir + p->d_name, NULL); |
| 1270 | if (xmlFile == NULL) { |
| 1271 | LOGERR("LoadLanguageListDir unable to load '%s'\n", language_entry.filename.c_str()); |
| 1272 | continue; |
| 1273 | } |
| 1274 | xml_document<> *doc = new xml_document<>(); |
| 1275 | doc->parse<0>(xmlFile); |
| 1276 | |
| 1277 | xml_node<>* parent = doc->first_node("language"); |
| 1278 | if (!parent) { |
| 1279 | LOGERR("Invalid language XML file '%s'\n", language_entry.filename.c_str()); |
| 1280 | } else { |
| 1281 | xml_node<>* child = parent->first_node("display"); |
| 1282 | if (child) { |
| 1283 | language_entry.displayvalue = child->value(); |
| 1284 | } else { |
| 1285 | LOGERR("No display value for '%s'\n", language_entry.filename.c_str()); |
| 1286 | language_entry.displayvalue = language_entry.filename; |
| 1287 | } |
| 1288 | Language_List.push_back(language_entry); |
| 1289 | } |
| 1290 | doc->clear(); |
| 1291 | delete doc; |
| 1292 | free(xmlFile); |
| 1293 | } |
| 1294 | closedir(d); |
| 1295 | } |
| 1296 | |
| 1297 | void PageManager::LoadLanguageList(ZipArchive* package) { |
| 1298 | Language_List.clear(); |
| 1299 | if (TWFunc::Path_Exists(TWRES "customlanguages")) |
| 1300 | TWFunc::removeDir(TWRES "customlanguages", true); |
| 1301 | if (package) { |
| 1302 | TWFunc::Recursive_Mkdir(TWRES "customlanguages"); |
| 1303 | struct utimbuf timestamp = { 1217592000, 1217592000 }; // 8/1/2008 default |
| 1304 | mzExtractRecursive(package, "languages", TWRES "customlanguages/", ×tamp, NULL, NULL, NULL); |
| 1305 | LoadLanguageListDir(TWRES "customlanguages/"); |
| 1306 | } else { |
| 1307 | LoadLanguageListDir(TWRES "languages/"); |
| 1308 | } |
| 1309 | } |
| 1310 | |
| 1311 | void PageManager::LoadLanguage(string filename) { |
| 1312 | string actual_filename; |
| 1313 | if (TWFunc::Path_Exists(TWRES "customlanguages/" + filename + ".xml")) |
| 1314 | actual_filename = TWRES "customlanguages/" + filename + ".xml"; |
| 1315 | else |
| 1316 | actual_filename = TWRES "languages/" + filename + ".xml"; |
| 1317 | char* xmlFile = PageManager::LoadFileToBuffer(actual_filename, NULL); |
| 1318 | if (xmlFile == NULL) |
| 1319 | LOGERR("Unable to load '%s'\n", actual_filename.c_str()); |
| 1320 | else { |
| 1321 | mCurrentSet->LoadLanguage(xmlFile, NULL); |
| 1322 | free(xmlFile); |
| 1323 | } |
| 1324 | PartitionManager.Translate_Partition_Display_Names(); |
| 1325 | } |
| 1326 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1327 | int PageManager::LoadPackage(std::string name, std::string package, std::string startpage) |
| 1328 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1329 | int fd; |
| 1330 | ZipArchive zip, *pZip = NULL; |
| 1331 | long len; |
| 1332 | char* xmlFile = NULL; |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1333 | char* languageFile = NULL; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1334 | PageSet* pageSet = NULL; |
| 1335 | int ret; |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1336 | MemMapping map; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1337 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 1338 | mReloadTheme = false; |
| 1339 | mStartPage = startpage; |
| 1340 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1341 | // Open the XML file |
| 1342 | LOGINFO("Loading package: %s (%s)\n", name.c_str(), package.c_str()); |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1343 | if (package.size() > 4 && package.substr(package.size() - 4) != ".zip") |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1344 | { |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1345 | LOGINFO("Load XML directly\n"); |
Ethan Yonker | 751a85e | 2014-12-12 16:59:10 -0600 | [diff] [blame] | 1346 | tw_x_offset = TW_X_OFFSET; |
| 1347 | tw_y_offset = TW_Y_OFFSET; |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1348 | LoadLanguageList(NULL); |
| 1349 | languageFile = LoadFileToBuffer(TWRES "languages/en.xml", NULL); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1350 | } |
| 1351 | else |
| 1352 | { |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1353 | LOGINFO("Loading zip theme\n"); |
Ethan Yonker | 751a85e | 2014-12-12 16:59:10 -0600 | [diff] [blame] | 1354 | tw_x_offset = 0; |
| 1355 | tw_y_offset = 0; |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1356 | if (!TWFunc::Path_Exists(package)) |
| 1357 | return -1; |
| 1358 | if (sysMapFile(package.c_str(), &map) != 0) { |
| 1359 | LOGERR("Failed to map '%s'\n", package.c_str()); |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 1360 | goto error; |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1361 | } |
| 1362 | if (mzOpenZipArchive(map.addr, map.length, &zip)) { |
| 1363 | LOGERR("Unable to open zip archive '%s'\n", package.c_str()); |
| 1364 | sysReleaseMap(&map); |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 1365 | goto error; |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1366 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1367 | pZip = &zip; |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 1368 | package = "ui.xml"; |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1369 | LoadLanguageList(pZip); |
| 1370 | languageFile = LoadFileToBuffer("languages/en.xml", pZip); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1371 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1372 | |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 1373 | xmlFile = LoadFileToBuffer(package, pZip); |
| 1374 | if (xmlFile == NULL) { |
| 1375 | goto error; |
| 1376 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1377 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1378 | // Before loading, mCurrentSet must be the loading package so we can find resources |
| 1379 | pageSet = mCurrentSet; |
| 1380 | mCurrentSet = new PageSet(xmlFile); |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1381 | ret = mCurrentSet->Load(pZip, xmlFile, languageFile); |
| 1382 | if (languageFile) { |
| 1383 | free(languageFile); |
| 1384 | languageFile = NULL; |
| 1385 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1386 | if (ret == 0) |
| 1387 | { |
| 1388 | mCurrentSet->SetPage(startpage); |
| 1389 | mPageSets.insert(std::pair<std::string, PageSet*>(name, mCurrentSet)); |
| 1390 | } |
| 1391 | else |
| 1392 | { |
| 1393 | LOGERR("Package %s failed to load.\n", name.c_str()); |
| 1394 | } |
Matt Mower | fb1c4ff | 2014-04-16 13:43:36 -0500 | [diff] [blame] | 1395 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1396 | // The first successful package we loaded is the base |
| 1397 | if (mBaseSet == NULL) |
| 1398 | mBaseSet = mCurrentSet; |
| 1399 | |
| 1400 | mCurrentSet = pageSet; |
| 1401 | |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1402 | if (pZip) { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1403 | mzCloseZipArchive(pZip); |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1404 | sysReleaseMap(&map); |
| 1405 | } |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 1406 | free(xmlFile); |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1407 | if (languageFile) |
| 1408 | free(languageFile); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1409 | return ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1410 | |
| 1411 | error: |
Ethan Yonker | 561c58d | 2015-10-05 08:48:22 -0500 | [diff] [blame] | 1412 | // Sometimes we get here without a real error |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1413 | if (pZip) { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1414 | mzCloseZipArchive(pZip); |
Ethan Yonker | a2dc2f2 | 2014-11-08 08:13:40 -0600 | [diff] [blame] | 1415 | sysReleaseMap(&map); |
| 1416 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1417 | if (xmlFile) |
| 1418 | free(xmlFile); |
| 1419 | return -1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | PageSet* PageManager::FindPackage(std::string name) |
| 1423 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1424 | std::map<std::string, PageSet*>::iterator iter; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1425 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1426 | iter = mPageSets.find(name); |
| 1427 | if (iter != mPageSets.end()) |
| 1428 | return (*iter).second; |
| 1429 | |
| 1430 | LOGERR("Unable to locate package %s\n", name.c_str()); |
| 1431 | return NULL; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1432 | } |
| 1433 | |
| 1434 | PageSet* PageManager::SelectPackage(std::string name) |
| 1435 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1436 | LOGINFO("Switching packages (%s)\n", name.c_str()); |
| 1437 | PageSet* tmp; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1438 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1439 | tmp = FindPackage(name); |
| 1440 | if (tmp) |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 1441 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1442 | mCurrentSet = tmp; |
Vojtech Bocek | 0722056 | 2014-02-08 02:05:33 +0100 | [diff] [blame] | 1443 | mCurrentSet->NotifyVarChange("", ""); |
| 1444 | } |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1445 | else |
| 1446 | LOGERR("Unable to find package.\n"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1447 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1448 | return mCurrentSet; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1449 | } |
| 1450 | |
| 1451 | int PageManager::ReloadPackage(std::string name, std::string package) |
| 1452 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1453 | std::map<std::string, PageSet*>::iterator iter; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1454 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 1455 | mReloadTheme = false; |
| 1456 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1457 | iter = mPageSets.find(name); |
| 1458 | if (iter == mPageSets.end()) |
| 1459 | return -1; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1460 | |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 1461 | if(mMouseCursor) |
| 1462 | mMouseCursor->ResetData(gr_fb_width(), gr_fb_height()); |
| 1463 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1464 | PageSet* set = (*iter).second; |
| 1465 | mPageSets.erase(iter); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1466 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 1467 | if (LoadPackage(name, package, mStartPage) != 0) |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1468 | { |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1469 | LOGINFO("Failed to load package '%s'.\n", package.c_str()); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1470 | mPageSets.insert(std::pair<std::string, PageSet*>(name, set)); |
| 1471 | return -1; |
| 1472 | } |
| 1473 | if (mCurrentSet == set) |
| 1474 | SelectPackage(name); |
Vojtech Bocek | bfb6334 | 2014-02-08 00:32:31 +0100 | [diff] [blame] | 1475 | if (mBaseSet == set) |
| 1476 | mBaseSet = mCurrentSet; |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1477 | delete set; |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1478 | GUIConsole::Translate_Now(); |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1479 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | void PageManager::ReleasePackage(std::string name) |
| 1483 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1484 | std::map<std::string, PageSet*>::iterator iter; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1485 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1486 | iter = mPageSets.find(name); |
| 1487 | if (iter == mPageSets.end()) |
| 1488 | return; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1489 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1490 | PageSet* set = (*iter).second; |
| 1491 | mPageSets.erase(iter); |
| 1492 | delete set; |
| 1493 | return; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1494 | } |
| 1495 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 1496 | int PageManager::RunReload() { |
| 1497 | int ret_val = 0; |
| 1498 | std::string theme_path; |
| 1499 | |
| 1500 | if (!mReloadTheme) |
| 1501 | return 0; |
| 1502 | |
| 1503 | mReloadTheme = false; |
| 1504 | theme_path = DataManager::GetSettingsStoragePath(); |
| 1505 | if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) { |
| 1506 | LOGERR("Unable to mount %s during gui_reload_theme function.\n", theme_path.c_str()); |
| 1507 | ret_val = 1; |
| 1508 | } |
| 1509 | |
| 1510 | theme_path += "/TWRP/theme/ui.zip"; |
| 1511 | if (ret_val != 0 || ReloadPackage("TWRP", theme_path) != 0) |
| 1512 | { |
| 1513 | // Loading the custom theme failed - try loading the stock theme |
| 1514 | LOGINFO("Attempting to reload stock theme...\n"); |
| 1515 | if (ReloadPackage("TWRP", TWRES "ui.xml")) |
| 1516 | { |
| 1517 | LOGERR("Failed to load base packages.\n"); |
| 1518 | ret_val = 1; |
| 1519 | } |
| 1520 | } |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1521 | if (ret_val == 0) { |
| 1522 | if (DataManager::GetStrValue("tw_language") != "en.xml") { |
| 1523 | LOGINFO("Loading language '%s'\n", DataManager::GetStrValue("tw_language").c_str()); |
| 1524 | LoadLanguage(DataManager::GetStrValue("tw_language")); |
| 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | // This makes the console re-translate |
| 1529 | last_message_count = 0; |
| 1530 | gConsole.clear(); |
| 1531 | gConsoleColor.clear(); |
| 1532 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 1533 | return ret_val; |
| 1534 | } |
| 1535 | |
| 1536 | void PageManager::RequestReload() { |
| 1537 | mReloadTheme = true; |
| 1538 | } |
| 1539 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1540 | int PageManager::ChangePage(std::string name) |
| 1541 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1542 | DataManager::SetValue("tw_operation_state", 0); |
| 1543 | int ret = (mCurrentSet ? mCurrentSet->SetPage(name) : -1); |
| 1544 | return ret; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | int PageManager::ChangeOverlay(std::string name) |
| 1548 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1549 | if (name.empty()) |
| 1550 | return mCurrentSet->SetOverlay(NULL); |
| 1551 | else |
| 1552 | { |
| 1553 | Page* page = mBaseSet ? mBaseSet->FindPage(name) : NULL; |
| 1554 | return mCurrentSet->SetOverlay(page); |
| 1555 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1556 | } |
| 1557 | |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 1558 | const ResourceManager* PageManager::GetResources() |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1559 | { |
that | 74ac606 | 2015-03-04 22:39:34 +0100 | [diff] [blame] | 1560 | return (mCurrentSet ? mCurrentSet->GetResources() : NULL); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1561 | } |
| 1562 | |
| 1563 | int PageManager::SwitchToConsole(void) |
| 1564 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1565 | PageSet* console = new PageSet(NULL); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1566 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1567 | mCurrentSet = console; |
| 1568 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1569 | } |
| 1570 | |
Ethan Yonker | 03a42f6 | 2014-08-08 11:03:51 -0500 | [diff] [blame] | 1571 | int PageManager::EndConsole(void) |
| 1572 | { |
| 1573 | if (mCurrentSet && mBaseSet) { |
| 1574 | delete mCurrentSet; |
| 1575 | mCurrentSet = mBaseSet; |
| 1576 | return 0; |
| 1577 | } |
| 1578 | return -1; |
| 1579 | } |
| 1580 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1581 | int PageManager::IsCurrentPage(Page* page) |
| 1582 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1583 | return (mCurrentSet ? mCurrentSet->IsCurrentPage(page) : 0); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1584 | } |
| 1585 | |
| 1586 | int PageManager::Render(void) |
| 1587 | { |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 1588 | if(blankTimer.isScreenOff()) |
| 1589 | return 0; |
| 1590 | |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 1591 | int res = (mCurrentSet ? mCurrentSet->Render() : -1); |
| 1592 | if(mMouseCursor) |
| 1593 | mMouseCursor->Render(); |
| 1594 | return res; |
| 1595 | } |
| 1596 | |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 1597 | HardwareKeyboard *PageManager::GetHardwareKeyboard() |
| 1598 | { |
| 1599 | if(!mHardwareKeyboard) |
| 1600 | mHardwareKeyboard = new HardwareKeyboard(); |
| 1601 | return mHardwareKeyboard; |
| 1602 | } |
| 1603 | |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 1604 | xml_node<>* PageManager::FindStyle(std::string name) |
| 1605 | { |
| 1606 | for (std::vector<xml_node<>*>::iterator itr = mCurrentSet->styles.begin(); itr != mCurrentSet->styles.end(); itr++) { |
| 1607 | xml_node<>* node = (*itr)->first_node("style"); |
| 1608 | |
| 1609 | while (node) { |
| 1610 | if (!node->first_attribute("name")) |
| 1611 | continue; |
| 1612 | |
| 1613 | if (name == node->first_attribute("name")->value()) |
| 1614 | return node; |
| 1615 | node = node->next_sibling("style"); |
| 1616 | } |
| 1617 | } |
| 1618 | return NULL; |
| 1619 | } |
| 1620 | |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 1621 | MouseCursor *PageManager::GetMouseCursor() |
| 1622 | { |
| 1623 | if(!mMouseCursor) |
| 1624 | mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height()); |
| 1625 | return mMouseCursor; |
| 1626 | } |
| 1627 | |
| 1628 | void PageManager::LoadCursorData(xml_node<>* node) |
| 1629 | { |
| 1630 | if(!mMouseCursor) |
| 1631 | mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height()); |
| 1632 | |
| 1633 | mMouseCursor->LoadData(node); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1634 | } |
| 1635 | |
| 1636 | int PageManager::Update(void) |
| 1637 | { |
that | fb759d4 | 2015-01-11 12:16:53 +0100 | [diff] [blame] | 1638 | if(blankTimer.isScreenOff()) |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1639 | return 0; |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 1640 | |
Ethan Yonker | e0f1f3b | 2015-10-27 09:49:01 -0500 | [diff] [blame] | 1641 | if (RunReload()) |
| 1642 | return -2; |
| 1643 | |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 1644 | int res = (mCurrentSet ? mCurrentSet->Update() : -1); |
| 1645 | |
| 1646 | if(mMouseCursor) |
| 1647 | { |
| 1648 | int c_res = mMouseCursor->Update(); |
| 1649 | if(c_res > res) |
| 1650 | res = c_res; |
| 1651 | } |
| 1652 | return res; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1653 | } |
| 1654 | |
| 1655 | int PageManager::NotifyTouch(TOUCH_STATE state, int x, int y) |
| 1656 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1657 | return (mCurrentSet ? mCurrentSet->NotifyTouch(state, x, y) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1658 | } |
| 1659 | |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 1660 | int PageManager::NotifyKey(int key, bool down) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1661 | { |
Vojtech Bocek | 0b7fe50 | 2014-03-13 17:36:52 +0100 | [diff] [blame] | 1662 | return (mCurrentSet ? mCurrentSet->NotifyKey(key, down) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1663 | } |
| 1664 | |
| 1665 | int PageManager::NotifyKeyboard(int key) |
| 1666 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1667 | return (mCurrentSet ? mCurrentSet->NotifyKeyboard(key) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1668 | } |
| 1669 | |
| 1670 | int PageManager::SetKeyBoardFocus(int inFocus) |
| 1671 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1672 | return (mCurrentSet ? mCurrentSet->SetKeyBoardFocus(inFocus) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1673 | } |
| 1674 | |
| 1675 | int PageManager::NotifyVarChange(std::string varName, std::string value) |
| 1676 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1677 | return (mCurrentSet ? mCurrentSet->NotifyVarChange(varName, value) : -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1678 | } |
| 1679 | |
Ethan Yonker | 74db157 | 2015-10-28 12:44:49 -0500 | [diff] [blame] | 1680 | void PageManager::AddStringResource(std::string resource_source, std::string resource_name, std::string value) |
| 1681 | { |
| 1682 | if (mCurrentSet) |
| 1683 | mCurrentSet->AddStringResource(resource_source, resource_name, value); |
| 1684 | } |
| 1685 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1686 | extern "C" void gui_notifyVarChange(const char *name, const char* value) |
| 1687 | { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1688 | if (!gGuiRunning) |
| 1689 | return; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1690 | |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 1691 | PageManager::NotifyVarChange(name, value); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1692 | } |