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
|
||||
OBJOPT = -Wall -c `sdl-config --cflags`
|
||||
SUBDIRS = glgui glmenu
|
||||
SUBDIROBJECTS = glgui/*.o glmenu/*.o
|
||||
VERSION = 0.0.1
|
||||
LIBNAME = libsegl
|
||||
|
||||
seglar: $(OBJECTS) subdirs
|
||||
@echo OBJOPT $(OBJOPT)
|
||||
@echo CC $(CC)
|
||||
rm -f $(LIBNAME).a
|
||||
ar rcs $(LIBNAME).a $(OBJECTS) $(SUBDIROBJECTS)
|
||||
$(AR) rcs $(LIBNAME).a $(OBJECTS) $(SUBDIROBJECTS)
|
||||
# ranlib $(LIBNAME).a
|
||||
|
||||
segllib: $(OBJECTS) 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
|
||||
$(COMPILER) -c `sdl-config --cflags` $<
|
||||
$(CC) $(OBJOPT) $<
|
||||
|
||||
|
||||
glgui/glgui.a:
|
||||
|
@ -28,8 +32,11 @@ glmenu/glmenu.a:
|
|||
testprog: seglar testprog.o
|
||||
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)
|
||||
cd glgui; $(MAKE) clean
|
||||
cd glmenu; $(MAKE) clean
|
||||
# cd glgui; $(MAKE) clean
|
||||
# cd glmenu; $(MAKE) clean
|
||||
@echo Done cleaning...
|
|
@ -19,6 +19,7 @@ void GLColor::set(float _r, float _g, float _b, float _a) {
|
|||
|
||||
SDL_Color GLColor::getSDLColor() {
|
||||
SDL_Color c = {(Uint8)(r*255.0f), (Uint8)(g*255), (Uint8)(b*255), (Uint8)(a*255)};
|
||||
return 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!="") {
|
||||
|
||||
if((strlpos = str.find('\n'))!=std::string::npos) {
|
||||
if( (unsigned int)(strlpos = str.find('\n')) != std::string::npos) {
|
||||
|
||||
rstr = str.substr(0, strlpos);
|
||||
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
|
||||
|
||||
glguilib: $(OBJECTS)
|
||||
|
@ -6,7 +7,7 @@ glguilib: $(OBJECTS)
|
|||
ar crus glgui.a $(OBJECTS)
|
||||
|
||||
%.o: %.cpp %.h
|
||||
$(COMPILER) -c `sdl-config --cflags` $<
|
||||
$(CC) $(OBJOPT) $<
|
||||
|
||||
clean:
|
||||
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
|
||||
|
||||
glguilib: $(OBJECTS)
|
||||
|
@ -6,7 +7,7 @@ glguilib: $(OBJECTS)
|
|||
ar crus glmenu.a $(OBJECTS)
|
||||
|
||||
%.o: %.cpp %.h
|
||||
$(COMPILER) -c `sdl-config --cflags` $<
|
||||
$(CC) $(OBJOPT) $<
|
||||
|
||||
clean:
|
||||
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);
|
||||
|
||||
if(!usevalue) {
|
||||
fontengine.renderLine(caption, pos.x, pos.y, center);
|
||||
fontengine.renderLine(caption, (int)pos.x, (int)pos.y, center);
|
||||
} else {
|
||||
// center und position ggf. überarbeiten..
|
||||
|
||||
Punkt2D tmp = pos;
|
||||
tmp.x = pos.x - (caplen+vallen+valuewidth)/2;
|
||||
|
||||
tmp.x = pos.x - valuewidth/2 - fontengine.getTextWidth(caption)/2;
|
||||
fontengine.renderLine(caption, tmp.x, tmp.y, center);
|
||||
// tmp.x = pos.x - valuewidth/2 - fontengine.getTextWidth(caption)/2;
|
||||
// tmp.x = pos.x - caplen - valuewidth/2;
|
||||
fontengine.renderLine(caption, (int)tmp.x, (int)tmp.y, false);
|
||||
|
||||
tmp.x = pos.x + valuewidth/2;
|
||||
fontengine.renderLine(value, tmp.x, tmp.y, false);
|
||||
// std::cout << "Value: " << value << std::endl;
|
||||
tmp.x += caplen+valuewidth;
|
||||
fontengine.renderLine(value, (int)tmp.x, (int)tmp.y, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void MIToggle::left() {
|
|||
|
||||
void MIToggle::right() {
|
||||
togglepos++;
|
||||
if(togglepos>=toggles.size())
|
||||
if((unsigned int)togglepos>=toggles.size())
|
||||
togglepos = 0;
|
||||
value = getValueString();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int MIToggle::getValueInt() {
|
|||
}
|
||||
|
||||
void MIToggle::setValueInt(int val) {
|
||||
if(val<0||val>=toggles.size())
|
||||
if(val<0||(unsigned int)val>=toggles.size())
|
||||
return;
|
||||
togglepos = val;
|
||||
value = getValueString();
|
||||
|
@ -105,7 +105,7 @@ void MIStringInput::charInput(char c) {
|
|||
value = value.substr(0, value.length()-1);
|
||||
}
|
||||
} else if(c>=32) {
|
||||
if(!maxlen || value.length()<maxlen)
|
||||
if(!maxlen || value.length()<(unsigned int)maxlen)
|
||||
value +=c;
|
||||
// std::cout << maxlen << " && " << value.length() << " < " << maxlen << std::endl;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void MenuMenu::up() {
|
|||
|
||||
void MenuMenu::down() {
|
||||
do {
|
||||
if(itempos==menuitems.size()-1)
|
||||
if((unsigned int)itempos==menuitems.size()-1)
|
||||
itempos = 0;
|
||||
else
|
||||
itempos++;
|
||||
|
@ -78,8 +78,9 @@ void MenuMenu::charInput(char c) {
|
|||
|
||||
void MenuMenu::resetItemPos() {
|
||||
dohighlight = true;
|
||||
for(itempos = 0; itempos<menuitems.size()&&!menuitems[itempos]->isSelectable(); itempos++);
|
||||
if(itempos==menuitems.size()) {
|
||||
for(itempos = 0; (unsigned int)itempos<menuitems.size()&&!menuitems[itempos]->isSelectable(); itempos++);
|
||||
|
||||
if((unsigned int)itempos==menuitems.size()) {
|
||||
itempos = 0;
|
||||
dohighlight = false;
|
||||
}
|
||||
|
@ -87,12 +88,13 @@ void MenuMenu::resetItemPos() {
|
|||
|
||||
void MenuMenu::render() {
|
||||
Punkt2D pos = menupos;
|
||||
pos.y += offset;
|
||||
if(centerScreenX) {
|
||||
SDL_Surface *screen = SDL_GetVideoSurface();
|
||||
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++) {
|
||||
fontengine.setSize(basefontsize+menuitems[i]->getFontSizeAdd());
|
||||
|
||||
|
@ -100,23 +102,41 @@ void MenuMenu::render() {
|
|||
vlen = std::max(vlen, fontengine.getTextWidth(menuitems[i]->getValue()));
|
||||
height += basefontsize + menuitems[i]->getFontSizeAdd() + offset;
|
||||
}
|
||||
fullvalwidth = clen + vlen + valuewidth;
|
||||
|
||||
std::cout << "clen: " << clen << " und " << (int) paintbackground << std::endl;
|
||||
|
||||
if(paintbackground&&false) {
|
||||
if(paintbackground&&true) {
|
||||
// geht noch nicht ganz
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor3f(0.4f, 0.4f, 0.4f);
|
||||
SDL_Rect bgarea = { pos.x-(clen/2)-((vlen>0)?(valuewidth/2+vlen/2):0),
|
||||
pos.y,
|
||||
clen+((vlen>0)?vlen/2+valuewidth/2:0),
|
||||
height };
|
||||
std::cout << bgarea.x << " " << bgarea.y << " " << bgarea.w << " " << bgarea.h << std::endl;
|
||||
glEnable(GL_BLEND);
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
|
||||
SDL_Rect bgarea = { 0, (int)pos.y, 0, height };
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue