| src/gmenu2x.cpp |
| 171 | 171 | skinConfInt.set_deleted_key(""); |
| 172 | 172 | skinConfStr.set_empty_key(" "); |
| 173 | 173 | skinConfStr.set_deleted_key(""); |
| 174 | | skinConfColors.set_empty_key(" "); |
| 175 | | skinConfColors.set_deleted_key(""); |
| 176 | 174 | |
| 177 | 175 | //open2x |
| 178 | 176 | savedVolumeMode = 0; |
| ... | ... | |
| 213 | 211 | path = ""; |
| 214 | 212 | getExePath(); |
| 215 | 213 | |
| 216 | | #ifdef TARGET_GP2X |
| 217 | | gp2x_mem = 0; |
| 218 | | cx25874 = 0; |
| 219 | 214 | batteryHandle = 0; |
| 220 | 215 | backlightHandle = 0; |
| 221 | 216 | usbHandle = 0; |
| 222 | 217 | acHandle = 0; |
| 223 | 218 | |
| 219 | |
| 220 | #ifdef TARGET_GP2X |
| 221 | gp2x_mem = 0; |
| 222 | cx25874 = 0; |
| 224 | 223 | gp2x_init(); |
| 225 | 224 | |
| 226 | 225 | //Fix tv-out |
| ... | ... | |
| 621 | 620 | for(ConfIntHash::iterator curr = skinConfInt.begin(); curr != endI; curr++) |
| 622 | 621 | inf << curr->first << "=" << curr->second << endl; |
| 623 | 622 | |
| 624 | | ConfRGBAHash::iterator endC = skinConfColors.end(); |
| 625 | | for(ConfRGBAHash::iterator curr = skinConfColors.begin(); curr != endC; curr++) |
| 626 | | inf << curr->first << "=#" << hex << curr->second.r << hex << curr->second.g << hex << curr->second.b << hex << curr->second.a << endl; |
| 623 | int i; |
| 624 | for (i = 0; i < NUM_COLORS; ++i) { |
| 625 | inf << colorToString((enum color)i) << "=#" << hex << skinConfColors[i].r << hex |
| 626 | << skinConfColors[i].g << hex << skinConfColors[i].b << hex |
| 627 | << skinConfColors[i].a << endl; |
| 628 | } |
| 627 | 629 | |
| 628 | 630 | inf.close(); |
| 629 | 631 | sync(); |
| ... | ... | |
| 812 | 814 | string sectionIcon = "skin:sections/"+menu->sections[i]+".png"; |
| 813 | 815 | x = (i-menu->firstDispSection())*skinConfInt["linkWidth"]+sectionsCoordX; |
| 814 | 816 | if (menu->selSectionIndex()==(int)i) |
| 815 | | s->box(x, 0, skinConfInt["linkWidth"], skinConfInt["topBarHeight"], skinConfColors["selectionBg"]); |
| 817 | s->box(x, 0, skinConfInt["linkWidth"], |
| 818 | skinConfInt["topBarHeight"], skinConfColors[COLOR_SELECTION_BG]); |
| 816 | 819 | x += skinConfInt["linkWidth"]/2; |
| 817 | 820 | if (sc.exists(sectionIcon)) |
| 818 | 821 | sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32); |
| ... | ... | |
| 879 | 882 | helpDisplayed = ! helpDisplayed; |
| 880 | 883 | |
| 881 | 884 | if (helpDisplayed) { |
| 882 | | s->box(10,50,300,143, skinConfColors["messageBoxBg"]); |
| 883 | | s->rectangle( 12,52,296,helpBoxHeight, skinConfColors["messageBoxBorder"] ); |
| 885 | s->box(10,50,300,143, skinConfColors[COLOR_MESSAGE_BOX_BG]); |
| 886 | s->rectangle( 12,52,296,helpBoxHeight, |
| 887 | skinConfColors[COLOR_MESSAGE_BOX_BORDER] ); |
| 884 | 888 | s->write( font, tr["CONTROLS"], 20, 60 ); |
| 885 | 889 | s->write( font, tr["B, Stick press: Launch link / Confirm action"], 20, 80 ); |
| 886 | 890 | s->write( font, tr["L, R: Change section"], 20, 95 ); |
| ... | ... | |
| 1096 | 1100 | |
| 1097 | 1101 | SettingsDialog sd(this,tr["Skin"]); |
| 1098 | 1102 | sd.addSetting(new MenuSettingMultiString(this,tr["Skin"],tr["Set the skin used by GMenu2X"],&confStr["skin"],&fl_sk.directories)); |
| 1099 | | sd.addSetting(new MenuSettingRGBA(this,tr["Top Bar Color"],tr["Color of the top bar"],&skinConfColors["topBarBg"])); |
| 1100 | | sd.addSetting(new MenuSettingRGBA(this,tr["Bottom Bar Color"],tr["Color of the bottom bar"],&skinConfColors["bottomBarBg"])); |
| 1101 | | sd.addSetting(new MenuSettingRGBA(this,tr["Selection Color"],tr["Color of the selection and other interface details"],&skinConfColors["selectionBg"])); |
| 1102 | | sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Color"],tr["Background color of the message box"],&skinConfColors["messageBoxBg"])); |
| 1103 | | sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Border Color"],tr["Border color of the message box"],&skinConfColors["messageBoxBorder"])); |
| 1104 | | sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Selection Color"],tr["Color of the selection of the message box"],&skinConfColors["messageBoxSelection"])); |
| 1103 | sd.addSetting(new MenuSettingRGBA(this,tr["Top Bar Color"],tr["Color of the top bar"],&skinConfColors[COLOR_TOP_BAR_BG])); |
| 1104 | sd.addSetting(new MenuSettingRGBA(this,tr["Bottom Bar Color"],tr["Color of the bottom bar"],&skinConfColors[COLOR_BOTTOM_BAR_BG])); |
| 1105 | sd.addSetting(new MenuSettingRGBA(this,tr["Selection Color"],tr["Color of the selection and other interface details"],&skinConfColors[COLOR_SELECTION_BG])); |
| 1106 | sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Color"],tr["Background color of the message box"],&skinConfColors[COLOR_MESSAGE_BOX_BG])); |
| 1107 | sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Border Color"],tr["Border color of the message box"],&skinConfColors[COLOR_MESSAGE_BOX_BORDER])); |
| 1108 | sd.addSetting(new MenuSettingRGBA(this,tr["Message Box Selection Color"],tr["Color of the selection of the message box"],&skinConfColors[COLOR_MESSAGE_BOX_SELECTION])); |
| 1105 | 1109 | |
| 1106 | 1110 | if (sd.exec() && sd.edited()) { |
| 1107 | 1111 | if (curSkin != confStr["skin"]) { |
| ... | ... | |
| 1113 | 1117 | } |
| 1114 | 1118 | } |
| 1115 | 1119 | |
| 1120 | enum color GMenu2X::stringToColor(const string &name) |
| 1121 | { |
| 1122 | if (name == "topBarBg") |
| 1123 | return COLOR_TOP_BAR_BG; |
| 1124 | else if (name == "bottomBarBg") |
| 1125 | return COLOR_BOTTOM_BAR_BG; |
| 1126 | else if (name == "messageBoxBg") |
| 1127 | return COLOR_MESSAGE_BOX_BG; |
| 1128 | else if (name == "messageBoxBorder") |
| 1129 | return COLOR_MESSAGE_BOX_BORDER; |
| 1130 | else if (name == "messageBoxSelection") |
| 1131 | return COLOR_MESSAGE_BOX_SELECTION; |
| 1132 | else |
| 1133 | return (enum color)-1; |
| 1134 | } |
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | const string &GMenu2X::colorToString(enum color c) |
| 1139 | { |
| 1140 | static const std::string colorNames[NUM_COLORS + 1] = { |
| 1141 | "topBarBg", |
| 1142 | "bottomBarBg", |
| 1143 | "messageBoxBg", |
| 1144 | "messageBoxBorder", |
| 1145 | "messageBoxSelection", |
| 1146 | "unkown", |
| 1147 | }; |
| 1148 | |
| 1149 | if (c < NUM_COLORS) |
| 1150 | return colorNames[c]; |
| 1151 | else |
| 1152 | return colorNames[NUM_COLORS]; |
| 1153 | } |
| 1154 | |
| 1155 | |
| 1116 | 1156 | void GMenu2X::toggleTvOut() { |
| 1117 | 1157 | #ifdef TARGET_GP2X |
| 1118 | 1158 | /* if (cx25874!=0) |
| ... | ... | |
| 1126 | 1166 | confStr["skin"] = skin; |
| 1127 | 1167 | |
| 1128 | 1168 | //Clear previous skin settings |
| 1129 | | skinConfColors.clear(); |
| 1130 | 1169 | skinConfStr.clear(); |
| 1131 | 1170 | skinConfInt.clear(); |
| 1132 | 1171 | |
| ... | ... | |
| 1135 | 1174 | sc.setSkin(skin); |
| 1136 | 1175 | |
| 1137 | 1176 | //reset colors to the default values |
| 1138 | | skinConfColors["topBarBg"] = (RGBAColor){255,255,255,130}; |
| 1139 | | skinConfColors["bottomBarBg"] = (RGBAColor){255,255,255,130}; |
| 1140 | | skinConfColors["selectionBg"] = (RGBAColor){255,255,255,130}; |
| 1141 | | skinConfColors["messageBoxBg"] = (RGBAColor){255,255,255,255}; |
| 1142 | | skinConfColors["messageBoxBorder"] = (RGBAColor){80,80,80,255}; |
| 1143 | | skinConfColors["messageBoxSelection"] = (RGBAColor){160,160,160,255}; |
| 1177 | skinConfColors[COLOR_TOP_BAR_BG] = (RGBAColor){255,255,255,130}; |
| 1178 | skinConfColors[COLOR_BOTTOM_BAR_BG] = (RGBAColor){255,255,255,130}; |
| 1179 | skinConfColors[COLOR_SELECTION_BG] = (RGBAColor){255,255,255,130}; |
| 1180 | skinConfColors[COLOR_MESSAGE_BOX_BG] = (RGBAColor){255,255,255,255}; |
| 1181 | skinConfColors[COLOR_MESSAGE_BOX_BORDER] = (RGBAColor){80,80,80,255}; |
| 1182 | skinConfColors[COLOR_MESSAGE_BOX_SELECTION] = (RGBAColor){160,160,160,255}; |
| 1144 | 1183 | |
| 1145 | 1184 | //load skin settings |
| 1146 | 1185 | string skinconfname = "skins/"+skin+"/skin.conf"; |
| ... | ... | |
| 1159 | 1198 | if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"') |
| 1160 | 1199 | skinConfStr[name] = value.substr(1,value.length()-2); |
| 1161 | 1200 | else if (value.at(0) == '#') |
| 1162 | | skinConfColors[name] = strtorgba( value.substr(1,value.length()) ); |
| 1201 | skinConfColors[stringToColor(name)] = strtorgba( value.substr(1,value.length()) ); |
| 1163 | 1202 | else |
| 1164 | 1203 | skinConfInt[name] = atoi(value.c_str()); |
| 1165 | 1204 | } |
| ... | ... | |
| 1290 | 1329 | |
| 1291 | 1330 | if (fadeAlpha<200) fadeAlpha = intTransition(0,200,tickStart,500,tickNow); |
| 1292 | 1331 | s->box(0, 0, resX, resY, 0,0,0,fadeAlpha); |
| 1293 | | s->box(box.x, box.y, box.w, box.h, skinConfColors["messageBoxBg"]); |
| 1294 | | s->rectangle( box.x+2, box.y+2, box.w-4, box.h-4, skinConfColors["messageBoxBorder"] ); |
| 1332 | s->box(box.x, box.y, box.w, box.h, skinConfColors[COLOR_MESSAGE_BOX_BG]); |
| 1333 | s->rectangle( box.x+2, box.y+2, box.w-4, box.h-4, skinConfColors[COLOR_MESSAGE_BOX_BORDER] ); |
| 1295 | 1334 | |
| 1296 | 1335 | |
| 1297 | 1336 | //draw selection rect |
| 1298 | | s->box( selbox.x, selbox.y, selbox.w, selbox.h, skinConfColors["messageBoxSelection"] ); |
| 1337 | s->box( selbox.x, selbox.y, selbox.w, selbox.h, skinConfColors[COLOR_MESSAGE_BOX_SELECTION] ); |
| 1299 | 1338 | for (i=0; i<voices.size(); i++) |
| 1300 | 1339 | s->write( font, voices[i].text, box.x+12, box.y+h2+5+(h+2)*i, SFontHAlignLeft, SFontVAlignMiddle ); |
| 1301 | 1340 | s->flip(); |
| ... | ... | |
| 1909 | 1948 | void GMenu2X::drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height) { |
| 1910 | 1949 | if (totalsize<=pagesize) return; |
| 1911 | 1950 | |
| 1912 | | s->rectangle(resX-8, top, 7, height, skinConfColors["selectionBg"]); |
| 1951 | s->rectangle(resX-8, top, 7, height, skinConfColors[COLOR_SELECTION_BG]); |
| 1913 | 1952 | |
| 1914 | 1953 | //internal bar total height = height-2 |
| 1915 | 1954 | //bar size |
| ... | ... | |
| 1920 | 1959 | if (by+bs>top+height-2) by = top+height-2-bs; |
| 1921 | 1960 | |
| 1922 | 1961 | |
| 1923 | | s->box(resX-6, by, 3, bs, skinConfColors["selectionBg"]); |
| 1962 | s->box(resX-6, by, 3, bs, skinConfColors[COLOR_SELECTION_BG]); |
| 1924 | 1963 | } |
| 1925 | 1964 | |
| 1926 | 1965 | void GMenu2X::drawTitleIcon(const string &icon, bool skinRes, Surface *s) { |
| ... | ... | |
| 1957 | 1996 | if (bar != NULL) |
| 1958 | 1997 | bar->blit(s, 0, 0); |
| 1959 | 1998 | else |
| 1960 | | s->box(0, 0, resX, skinConfInt["topBarHeight"], skinConfColors["topBarBg"]); |
| 1999 | s->box(0, 0, resX, skinConfInt["topBarHeight"], |
| 2000 | skinConfColors[COLOR_TOP_BAR_BG]); |
| 1961 | 2001 | } |
| 1962 | 2002 | |
| 1963 | 2003 | void GMenu2X::drawBottomBar(Surface *s) { |
| ... | ... | |
| 1967 | 2007 | if (bar != NULL) |
| 1968 | 2008 | bar->blit(s, 0, resY-bar->raw->h); |
| 1969 | 2009 | else |
| 1970 | | s->box(0, resY-20, resX, 20, skinConfColors["bottomBarBg"]); |
| 2010 | s->box(0, resY-20, resX, 20, skinConfColors[COLOR_BOTTOM_BAR_BG]); |
| 1971 | 2011 | } |
| src/inputdialog.cpp |
| 141 | 141 | |
| 142 | 142 | box.w = gmenu2x->font->getTextWidth(input)+18; |
| 143 | 143 | box.x = 160-box.w/2; |
| 144 | | gmenu2x->s->box(box.x, box.y, box.w, box.h, gmenu2x->skinConfColors["selectionBg"]); |
| 145 | | gmenu2x->s->rectangle(box.x, box.y, box.w, box.h, gmenu2x->skinConfColors["selectionBg"]); |
| 144 | gmenu2x->s->box(box.x, box.y, box.w, box.h, |
| 145 | gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 146 | gmenu2x->s->rectangle(box.x, box.y, box.w, box.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 146 | 147 | |
| 147 | 148 | gmenu2x->s->write(gmenu2x->font, input, box.x+5, box.y+box.h-2, SFontHAlignLeft, SFontVAlignBottom); |
| 148 | 149 | |
| ... | ... | |
| 152 | 153 | caretTick = curTick; |
| 153 | 154 | } |
| 154 | 155 | |
| 155 | | if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors["selectionBg"]); |
| 156 | if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 156 | 157 | |
| 157 | 158 | if (gmenu2x->f200) gmenu2x->ts.poll(); |
| 158 | 159 | action = drawVirtualKeyboard(); |
| ... | ... | |
| 235 | 236 | int action = ID_NO_ACTION; |
| 236 | 237 | |
| 237 | 238 | //keyboard border |
| 238 | | gmenu2x->s->rectangle(kbRect, gmenu2x->skinConfColors["selectionBg"]); |
| 239 | gmenu2x->s->rectangle(kbRect, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 239 | 240 | |
| 240 | 241 | if (selCol<0) selCol = selRow==(int)kb->size() ? 1 : kbLength-1; |
| 241 | 242 | if (selCol>=(int)kbLength) selCol = 0; |
| ... | ... | |
| 244 | 245 | |
| 245 | 246 | //selection |
| 246 | 247 | if (selRow<(int)kb->size()) |
| 247 | | gmenu2x->s->box(kbLeft+selCol*KEY_WIDTH-1, KB_TOP+selRow*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2, gmenu2x->skinConfColors["selectionBg"]); |
| 248 | gmenu2x->s->box(kbLeft+selCol*KEY_WIDTH-1, KB_TOP+selRow*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 248 | 249 | else { |
| 249 | 250 | if (selCol>1) selCol = 0; |
| 250 | 251 | if (selCol<0) selCol = 1; |
| 251 | | gmenu2x->s->box(kbLeft+selCol*kbLength*KEY_WIDTH/2-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1, gmenu2x->skinConfColors["selectionBg"]); |
| 252 | gmenu2x->s->box(kbLeft+selCol*kbLength*KEY_WIDTH/2-1, |
| 253 | KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 252 | 254 | } |
| 253 | 255 | |
| 254 | 256 | //keys |
| ... | ... | |
| 271 | 273 | selRow = l; |
| 272 | 274 | } |
| 273 | 275 | |
| 274 | | gmenu2x->s->rectangle(re, gmenu2x->skinConfColors["selectionBg"]); |
| 276 | gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 275 | 277 | gmenu2x->s->write(gmenu2x->font, charX, kbLeft+xc*KEY_WIDTH+KEY_WIDTH/2-1, KB_TOP+l*KEY_HEIGHT+KEY_HEIGHT/2, SFontHAlignCenter, SFontVAlignMiddle); |
| 276 | 278 | xc++; |
| 277 | 279 | } |
| ... | ... | |
| 279 | 281 | |
| 280 | 282 | //Ok/Cancel |
| 281 | 283 | SDL_Rect re = {kbLeft-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1}; |
| 282 | | gmenu2x->s->rectangle(re, gmenu2x->skinConfColors["selectionBg"]); |
| 284 | gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 283 | 285 | if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(re)) { |
| 284 | 286 | selCol = 0; |
| 285 | 287 | selRow = kb->size(); |
| ... | ... | |
| 287 | 289 | gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"], (int)(160-kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, SFontHAlignCenter, SFontVAlignMiddle); |
| 288 | 290 | |
| 289 | 291 | re.x = kbLeft+kbLength*KEY_WIDTH/2-1; |
| 290 | | gmenu2x->s->rectangle(re, gmenu2x->skinConfColors["selectionBg"]); |
| 292 | gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
| 291 | 293 | if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(re)) { |
| 292 | 294 | selCol = 1; |
| 293 | 295 | selRow = kb->size(); |