Use hexadecimal RRGGBB instead of colorkeys, rename getColor to parseColor
parent
18d7bc7fa1
commit
307c57dcc4
|
@ -389,7 +389,7 @@ end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function menubar.refresh()
|
function menubar.refresh()
|
||||||
menubar.formspec = "box[-2,7.625;15.75,1.75;BLK]"
|
menubar.formspec = "box[-2,7.625;15.75,1.75;000000]"
|
||||||
menubar.buttons = {}
|
menubar.buttons = {}
|
||||||
|
|
||||||
local button_base = -1.8
|
local button_base = -1.8
|
||||||
|
|
|
@ -187,9 +187,9 @@ function modstore.getmodlist(list)
|
||||||
" of " .. (list.pagecount +1) .. "]"
|
" of " .. (list.pagecount +1) .. "]"
|
||||||
|
|
||||||
retval = retval .. "button[11.6,-0.1;0.5,0.5;btn_modstore_page_up;^]"
|
retval = retval .. "button[11.6,-0.1;0.5,0.5;btn_modstore_page_up;^]"
|
||||||
retval = retval .. "box[11.6,0.35;0.28,8.6;BLK]"
|
retval = retval .. "box[11.6,0.35;0.28,8.6;000000]"
|
||||||
local scrollbarpos = 0.35 + (8.1/list.pagecount) * list.page
|
local scrollbarpos = 0.35 + (8.1/list.pagecount) * list.page
|
||||||
retval = retval .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;LIM]"
|
retval = retval .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;32CD32]"
|
||||||
retval = retval .. "button[11.6,9.0;0.5,0.5;btn_modstore_page_down;v]"
|
retval = retval .. "button[11.6,9.0;0.5,0.5;btn_modstore_page_down;v]"
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ function modstore.getmodlist(list)
|
||||||
if details ~= nil then
|
if details ~= nil then
|
||||||
local screenshot_ypos = (i-1 - (list.page * modstore.modsperpage))*1.9 +0.2
|
local screenshot_ypos = (i-1 - (list.page * modstore.modsperpage))*1.9 +0.2
|
||||||
|
|
||||||
retval = retval .. "box[0," .. screenshot_ypos .. ";11.4,1.75;WHT]"
|
retval = retval .. "box[0," .. screenshot_ypos .. ";11.4,1.75;FFFFFF]"
|
||||||
|
|
||||||
--screenshot
|
--screenshot
|
||||||
if details.screenshot_url ~= nil and
|
if details.screenshot_url ~= nil and
|
||||||
|
|
|
@ -960,7 +960,7 @@ textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]
|
||||||
^Scrollabel itemlist showing arbitrary text elements
|
^Scrollabel itemlist showing arbitrary text elements
|
||||||
^ x and y position the itemlist relative to the top left of the menu
|
^ x and y position the itemlist relative to the top left of the menu
|
||||||
^ w and h are the size of the itemlist
|
^ w and h are the size of the itemlist
|
||||||
^ listelements can be prepended by #colorkey (see colorkeys),
|
^ listelements can be prepended by #RRGGBB in hexadecimal format
|
||||||
^ if you want a listelement to start with # write ##
|
^ if you want a listelement to start with # write ##
|
||||||
^ name fieldname sent to server on doubleclick value is current selected element
|
^ name fieldname sent to server on doubleclick value is current selected element
|
||||||
|
|
||||||
|
@ -973,24 +973,12 @@ tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>;<current_tab>;<transparent>;<dr
|
||||||
^ transparent (optional) show transparent
|
^ transparent (optional) show transparent
|
||||||
^ draw_border (optional) draw border
|
^ draw_border (optional) draw border
|
||||||
|
|
||||||
box[<X>,<Y>;<W>,<H>;<colorkey>]
|
box[<X>,<Y>;<W>,<H>;<color>]
|
||||||
^ simple colored semitransparent box
|
^ simple colored semitransparent box
|
||||||
^ x and y position the box relative to the top left of the menu
|
^ x and y position the box relative to the top left of the menu
|
||||||
^ w and h are the size of box
|
^ w and h are the size of box
|
||||||
^ colorkey (see colorkeys)
|
^ color in hexadecimal format RRGGBB
|
||||||
|
|
||||||
Available colorkeys:
|
|
||||||
- YLW yellow
|
|
||||||
- GRN green
|
|
||||||
- LIM lime
|
|
||||||
- ORN orange
|
|
||||||
- RED red
|
|
||||||
- BLU blue
|
|
||||||
- CYN cyan
|
|
||||||
- BLK black
|
|
||||||
- BRN brown
|
|
||||||
- WHT white
|
|
||||||
- GRY grey
|
|
||||||
|
|
||||||
Inventory location:
|
Inventory location:
|
||||||
|
|
||||||
|
|
|
@ -663,15 +663,13 @@ void GUIFormSpecMenu::parseTextList(parserData* data,std::string element) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::wstring toadd = narrow_to_wide(items[i].c_str() + 4);
|
std::wstring toadd = narrow_to_wide(items[i].c_str() + 4);
|
||||||
std::string color = items[i].substr(1,3);
|
std::string color = items[i].substr(1,6);
|
||||||
|
|
||||||
e->addItem(toadd.c_str());
|
e->addItem(toadd.c_str());
|
||||||
|
|
||||||
bool valid_color = true;
|
irr::video::SColor toset;
|
||||||
|
|
||||||
irr::video::SColor toset = getColor(color,valid_color);
|
if (parseColor(color,toset))
|
||||||
|
|
||||||
if (valid_color)
|
|
||||||
e->setItemOverrideColor(i,toset);
|
e->setItemOverrideColor(i,toset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1335,11 +1333,9 @@ void GUIFormSpecMenu::parseBox(parserData* data,std::string element) {
|
||||||
geom.X = stof(v_geom[0]) * (float)spacing.X;
|
geom.X = stof(v_geom[0]) * (float)spacing.X;
|
||||||
geom.Y = stof(v_geom[1]) * (float)spacing.Y;
|
geom.Y = stof(v_geom[1]) * (float)spacing.Y;
|
||||||
|
|
||||||
bool valid_color = false;
|
irr::video::SColor color;
|
||||||
|
|
||||||
irr::video::SColor color = getColor(color_str,valid_color);
|
if (parseColor(color_str,color)) {
|
||||||
|
|
||||||
if (valid_color) {
|
|
||||||
BoxDrawSpec spec(pos,geom,color);
|
BoxDrawSpec spec(pos,geom,color);
|
||||||
|
|
||||||
m_boxes.push_back(spec);
|
m_boxes.push_back(spec);
|
||||||
|
@ -2520,65 +2516,22 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
||||||
return Parent ? Parent->OnEvent(event) : false;
|
return Parent ? Parent->OnEvent(event) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
irr::video::SColor GUIFormSpecMenu::getColor(std::string color,bool& valid_color) {
|
bool GUIFormSpecMenu::parseColor(std::string color, irr::video::SColor& outcolor) {
|
||||||
|
outcolor = irr::video::SColor(0,0,0,0);
|
||||||
|
|
||||||
if (color == "YLW") {
|
if(color.size() != 6) return false;
|
||||||
valid_color = true;
|
if(!string_allowed(color, "0123456789abcdefABCDEF")) return false;
|
||||||
return irr::video::SColor(255,255,255,0);
|
|
||||||
}
|
unsigned int r, g, b;
|
||||||
|
std::istringstream iss("");
|
||||||
if (color == "GRN") {
|
iss.str(color.substr(0, 1));
|
||||||
valid_color = true;
|
iss >> std::hex >> r;
|
||||||
return irr::video::SColor(255,34,249,34);
|
iss.str(color.substr(2, 1));
|
||||||
}
|
iss >> std::hex >> g;
|
||||||
|
iss.str(color.substr(4, 1));
|
||||||
if (color == "LIM") {
|
iss >> std::hex >> b;
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,50,205,50);
|
outcolor = irr::video::SColor(255,r,g,b);
|
||||||
}
|
return true;
|
||||||
|
|
||||||
if (color == "RED") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,255,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == "ORN") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,255,140,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == "BLU") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,0,0,255);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == "CYN") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,0,255,255);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == "BLK") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == "BRN") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,139,69,19);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == "WHT") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,255,255,255);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == "GRY") {
|
|
||||||
valid_color = true;
|
|
||||||
return irr::video::SColor(255,205,201,201);
|
|
||||||
}
|
|
||||||
|
|
||||||
valid_color = false;
|
|
||||||
|
|
||||||
return irr::video::SColor(0,0,0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,7 @@ private:
|
||||||
void parseTabHeader(parserData* data,std::string element);
|
void parseTabHeader(parserData* data,std::string element);
|
||||||
void parseBox(parserData* data,std::string element);
|
void parseBox(parserData* data,std::string element);
|
||||||
|
|
||||||
irr::video::SColor getColor(std::string color,bool& valid_color);
|
bool parseColor(std::string color, irr::video::SColor& outcolor);
|
||||||
};
|
};
|
||||||
|
|
||||||
class FormspecFormSource: public IFormSource
|
class FormspecFormSource: public IFormSource
|
||||||
|
|
Loading…
Reference in New Issue