Menuupdates, geordnet
This commit is contained in:
parent
f542e933b2
commit
952d87e707
21
Makefile
21
Makefile
|
@ -1,22 +1,26 @@
|
||||||
COMPILER = g++
|
CC = g++
|
||||||
|
AR = ar
|
||||||
OBJECTS = punkt3d.o punkt2d.o emath.o emath_opengl.o glcolor.o gldrawhelper.o glfontengine.o glrect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o
|
OBJECTS = punkt3d.o punkt2d.o emath.o emath_opengl.o glcolor.o gldrawhelper.o glfontengine.o glrect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o
|
||||||
|
OBJOPT = -Wall -c `sdl-config --cflags`
|
||||||
SUBDIRS = glgui glmenu
|
SUBDIRS = glgui glmenu
|
||||||
SUBDIROBJECTS = glgui/*.o glmenu/*.o
|
SUBDIROBJECTS = glgui/*.o glmenu/*.o
|
||||||
VERSION = 0.0.1
|
VERSION = 0.0.1
|
||||||
LIBNAME = libsegl
|
LIBNAME = libsegl
|
||||||
|
|
||||||
seglar: $(OBJECTS) subdirs
|
seglar: $(OBJECTS) subdirs
|
||||||
|
@echo OBJOPT $(OBJOPT)
|
||||||
|
@echo CC $(CC)
|
||||||
rm -f $(LIBNAME).a
|
rm -f $(LIBNAME).a
|
||||||
ar rcs $(LIBNAME).a $(OBJECTS) $(SUBDIROBJECTS)
|
$(AR) rcs $(LIBNAME).a $(OBJECTS) $(SUBDIROBJECTS)
|
||||||
# ranlib $(LIBNAME).a
|
# ranlib $(LIBNAME).a
|
||||||
|
|
||||||
segllib: $(OBJECTS) subdirs
|
segllib: $(OBJECTS) subdirs
|
||||||
|
|
||||||
subdirs:
|
subdirs:
|
||||||
@for i in $(SUBDIRS); do $(MAKE) -C $$i; done
|
@for i in $(SUBDIRS); do $(MAKE) CC="$(CC)" OBJOPT="$(OBJOPT)" -C $$i; done
|
||||||
|
|
||||||
%.o: %.cpp %.h
|
%.o: %.cpp %.h
|
||||||
$(COMPILER) -c `sdl-config --cflags` $<
|
$(CC) $(OBJOPT) $<
|
||||||
|
|
||||||
|
|
||||||
glgui/glgui.a:
|
glgui/glgui.a:
|
||||||
|
@ -28,8 +32,11 @@ glmenu/glmenu.a:
|
||||||
testprog: seglar testprog.o
|
testprog: seglar testprog.o
|
||||||
g++ `sdl-config --libs` -lSDL_image -lGL -lGLU testprog.o -o testprog $(LIBNAME).a
|
g++ `sdl-config --libs` -lSDL_image -lGL -lGLU testprog.o -o testprog $(LIBNAME).a
|
||||||
|
|
||||||
clean:
|
cleansubdirs:
|
||||||
|
@for i in $(SUBDIRS); do $(MAKE) clean -C $$i; done
|
||||||
|
|
||||||
|
clean: cleansubdirs
|
||||||
rm -f $(OBJECTS)
|
rm -f $(OBJECTS)
|
||||||
cd glgui; $(MAKE) clean
|
# cd glgui; $(MAKE) clean
|
||||||
cd glmenu; $(MAKE) clean
|
# cd glmenu; $(MAKE) clean
|
||||||
@echo Done cleaning...
|
@echo Done cleaning...
|
|
@ -19,6 +19,7 @@ void GLColor::set(float _r, float _g, float _b, float _a) {
|
||||||
|
|
||||||
SDL_Color GLColor::getSDLColor() {
|
SDL_Color GLColor::getSDLColor() {
|
||||||
SDL_Color c = {(Uint8)(r*255.0f), (Uint8)(g*255), (Uint8)(b*255), (Uint8)(a*255)};
|
SDL_Color c = {(Uint8)(r*255.0f), (Uint8)(g*255), (Uint8)(b*255), (Uint8)(a*255)};
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glColorGLC(GLColor c) {
|
void glColorGLC(GLColor c) {
|
||||||
|
|
|
@ -198,7 +198,7 @@ void GLFontEngine::renderLines(std::string str, int x, int y, bool center, SDL_R
|
||||||
|
|
||||||
while(str!="") {
|
while(str!="") {
|
||||||
|
|
||||||
if((strlpos = str.find('\n'))!=std::string::npos) {
|
if( (unsigned int)(strlpos = str.find('\n')) != std::string::npos) {
|
||||||
|
|
||||||
rstr = str.substr(0, strlpos);
|
rstr = str.substr(0, strlpos);
|
||||||
str = str.substr(strlpos+1);
|
str = str.substr(strlpos+1);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
COMPILER = g++
|
CC = g++
|
||||||
|
OBJOPT = -c `sdl-config --cflags` -Wall
|
||||||
OBJECTS = button.o object.o textlabel.o window.o
|
OBJECTS = button.o object.o textlabel.o window.o
|
||||||
|
|
||||||
glguilib: $(OBJECTS)
|
glguilib: $(OBJECTS)
|
||||||
|
@ -6,7 +7,7 @@ glguilib: $(OBJECTS)
|
||||||
ar crus glgui.a $(OBJECTS)
|
ar crus glgui.a $(OBJECTS)
|
||||||
|
|
||||||
%.o: %.cpp %.h
|
%.o: %.cpp %.h
|
||||||
$(COMPILER) -c `sdl-config --cflags` $<
|
$(CC) $(OBJOPT) $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJECTS)
|
rm -f $(OBJECTS)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
COMPILER = g++
|
CC = g++
|
||||||
|
OBJOPT = -c `sdl-config --cflags` -Wall
|
||||||
OBJECTS = menumanager.o menumenu.o menuitem.o menuitems.o
|
OBJECTS = menumanager.o menumenu.o menuitem.o menuitems.o
|
||||||
|
|
||||||
glguilib: $(OBJECTS)
|
glguilib: $(OBJECTS)
|
||||||
|
@ -6,7 +7,7 @@ glguilib: $(OBJECTS)
|
||||||
ar crus glmenu.a $(OBJECTS)
|
ar crus glmenu.a $(OBJECTS)
|
||||||
|
|
||||||
%.o: %.cpp %.h
|
%.o: %.cpp %.h
|
||||||
$(COMPILER) -c `sdl-config --cflags` $<
|
$(CC) $(OBJOPT) $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJECTS)
|
rm -f $(OBJECTS)
|
||||||
|
|
|
@ -34,18 +34,19 @@ void MenuItem::render(Punkt2D pos, bool center, int basefontsize, int maxwidth,
|
||||||
fontengine.setColor(1.0f, 1.0f, 1.0f);
|
fontengine.setColor(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
if(!usevalue) {
|
if(!usevalue) {
|
||||||
fontengine.renderLine(caption, pos.x, pos.y, center);
|
fontengine.renderLine(caption, (int)pos.x, (int)pos.y, center);
|
||||||
} else {
|
} else {
|
||||||
// center und position ggf. überarbeiten..
|
// center und position ggf. überarbeiten..
|
||||||
|
|
||||||
Punkt2D tmp = pos;
|
Punkt2D tmp = pos;
|
||||||
|
tmp.x = pos.x - (caplen+vallen+valuewidth)/2;
|
||||||
|
|
||||||
tmp.x = pos.x - valuewidth/2 - fontengine.getTextWidth(caption)/2;
|
// tmp.x = pos.x - valuewidth/2 - fontengine.getTextWidth(caption)/2;
|
||||||
fontengine.renderLine(caption, tmp.x, tmp.y, center);
|
// tmp.x = pos.x - caplen - valuewidth/2;
|
||||||
|
fontengine.renderLine(caption, (int)tmp.x, (int)tmp.y, false);
|
||||||
|
|
||||||
tmp.x = pos.x + valuewidth/2;
|
tmp.x += caplen+valuewidth;
|
||||||
fontengine.renderLine(value, tmp.x, tmp.y, false);
|
fontengine.renderLine(value, (int)tmp.x, (int)tmp.y, false);
|
||||||
// std::cout << "Value: " << value << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ void MIToggle::left() {
|
||||||
|
|
||||||
void MIToggle::right() {
|
void MIToggle::right() {
|
||||||
togglepos++;
|
togglepos++;
|
||||||
if(togglepos>=toggles.size())
|
if((unsigned int)togglepos>=toggles.size())
|
||||||
togglepos = 0;
|
togglepos = 0;
|
||||||
value = getValueString();
|
value = getValueString();
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ int MIToggle::getValueInt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIToggle::setValueInt(int val) {
|
void MIToggle::setValueInt(int val) {
|
||||||
if(val<0||val>=toggles.size())
|
if(val<0||(unsigned int)val>=toggles.size())
|
||||||
return;
|
return;
|
||||||
togglepos = val;
|
togglepos = val;
|
||||||
value = getValueString();
|
value = getValueString();
|
||||||
|
@ -105,7 +105,7 @@ void MIStringInput::charInput(char c) {
|
||||||
value = value.substr(0, value.length()-1);
|
value = value.substr(0, value.length()-1);
|
||||||
}
|
}
|
||||||
} else if(c>=32) {
|
} else if(c>=32) {
|
||||||
if(!maxlen || value.length()<maxlen)
|
if(!maxlen || value.length()<(unsigned int)maxlen)
|
||||||
value +=c;
|
value +=c;
|
||||||
// std::cout << maxlen << " && " << value.length() << " < " << maxlen << std::endl;
|
// std::cout << maxlen << " && " << value.length() << " < " << maxlen << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ void MenuMenu::up() {
|
||||||
|
|
||||||
void MenuMenu::down() {
|
void MenuMenu::down() {
|
||||||
do {
|
do {
|
||||||
if(itempos==menuitems.size()-1)
|
if((unsigned int)itempos==menuitems.size()-1)
|
||||||
itempos = 0;
|
itempos = 0;
|
||||||
else
|
else
|
||||||
itempos++;
|
itempos++;
|
||||||
|
@ -78,8 +78,9 @@ void MenuMenu::charInput(char c) {
|
||||||
|
|
||||||
void MenuMenu::resetItemPos() {
|
void MenuMenu::resetItemPos() {
|
||||||
dohighlight = true;
|
dohighlight = true;
|
||||||
for(itempos = 0; itempos<menuitems.size()&&!menuitems[itempos]->isSelectable(); itempos++);
|
for(itempos = 0; (unsigned int)itempos<menuitems.size()&&!menuitems[itempos]->isSelectable(); itempos++);
|
||||||
if(itempos==menuitems.size()) {
|
|
||||||
|
if((unsigned int)itempos==menuitems.size()) {
|
||||||
itempos = 0;
|
itempos = 0;
|
||||||
dohighlight = false;
|
dohighlight = false;
|
||||||
}
|
}
|
||||||
|
@ -87,12 +88,13 @@ void MenuMenu::resetItemPos() {
|
||||||
|
|
||||||
void MenuMenu::render() {
|
void MenuMenu::render() {
|
||||||
Punkt2D pos = menupos;
|
Punkt2D pos = menupos;
|
||||||
|
pos.y += offset;
|
||||||
if(centerScreenX) {
|
if(centerScreenX) {
|
||||||
SDL_Surface *screen = SDL_GetVideoSurface();
|
SDL_Surface *screen = SDL_GetVideoSurface();
|
||||||
pos.x = screen->w/2;
|
pos.x = screen->w/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int clen=0, vlen=0, height=0;
|
int clen=0, vlen=0, height=0, fullvalwidth=0;
|
||||||
for(unsigned int i=0; i<menuitems.size(); i++) {
|
for(unsigned int i=0; i<menuitems.size(); i++) {
|
||||||
fontengine.setSize(basefontsize+menuitems[i]->getFontSizeAdd());
|
fontengine.setSize(basefontsize+menuitems[i]->getFontSizeAdd());
|
||||||
|
|
||||||
|
@ -100,23 +102,41 @@ void MenuMenu::render() {
|
||||||
vlen = std::max(vlen, fontengine.getTextWidth(menuitems[i]->getValue()));
|
vlen = std::max(vlen, fontengine.getTextWidth(menuitems[i]->getValue()));
|
||||||
height += basefontsize + menuitems[i]->getFontSizeAdd() + offset;
|
height += basefontsize + menuitems[i]->getFontSizeAdd() + offset;
|
||||||
}
|
}
|
||||||
|
fullvalwidth = clen + vlen + valuewidth;
|
||||||
|
|
||||||
std::cout << "clen: " << clen << " und " << (int) paintbackground << std::endl;
|
if(paintbackground&&true) {
|
||||||
|
|
||||||
if(paintbackground&&false) {
|
|
||||||
// geht noch nicht ganz
|
// geht noch nicht ganz
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glColor3f(0.4f, 0.4f, 0.4f);
|
glEnable(GL_BLEND);
|
||||||
SDL_Rect bgarea = { pos.x-(clen/2)-((vlen>0)?(valuewidth/2+vlen/2):0),
|
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
||||||
pos.y,
|
|
||||||
clen+((vlen>0)?vlen/2+valuewidth/2:0),
|
SDL_Rect bgarea = { 0, (int)pos.y, 0, height };
|
||||||
height };
|
|
||||||
std::cout << bgarea.x << " " << bgarea.y << " " << bgarea.w << " " << bgarea.h << std::endl;
|
if(vlen>0&&fullvalwidth>=clen) {
|
||||||
|
bgarea.x = (int)pos.x-fullvalwidth/2;
|
||||||
|
bgarea.w = fullvalwidth;
|
||||||
|
} else {
|
||||||
|
bgarea.x = (int)pos.x-clen/2;
|
||||||
|
bgarea.w = clen;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "clen: " << clen << " fvw: " << fullvalwidth << std::endl;
|
||||||
|
|
||||||
|
// SDL_Rect bgarea = { pos.x-(clen/2)-((vlen>0)?(valuewidth+vlen):0),
|
||||||
|
// pos.y,
|
||||||
|
// clen+((vlen>0)?vlen+valuewidth:0),
|
||||||
|
// height };
|
||||||
|
// std::cout << bgarea.x << " " << bgarea.y << " " << bgarea.w << " " << bgarea.h << std::endl;
|
||||||
|
bgarea.x -= offset;
|
||||||
|
bgarea.y -= offset;
|
||||||
|
bgarea.w += offset*2;
|
||||||
|
bgarea.h += offset;
|
||||||
|
|
||||||
GLFontEngine::paintSDLRect(bgarea);
|
GLFontEngine::paintSDLRect(bgarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int i=0; i<menuitems.size(); i++) {
|
for(unsigned int i=0; i<menuitems.size(); i++) {
|
||||||
menuitems[i]->render(pos, centermenu, basefontsize, maxwidth, valuewidth, (itempos==i)&&dohighlight, clen, vlen);
|
menuitems[i]->render(pos, centermenu, basefontsize, maxwidth, valuewidth, ((unsigned int)itempos==i)&&dohighlight, clen, vlen);
|
||||||
pos.y += basefontsize + menuitems[i]->getFontSizeAdd() + offset;
|
pos.y += basefontsize + menuitems[i]->getFontSizeAdd() + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue