void insertRoom(room_s* r1, room_s* r2, vect3Di_s v, u8 orientation) { if(!r1 || !r2)return; listCell_s *lc=r2->rectangles.first; vect3Di_s o=vect3Di(0,0,0), s=vect3Di(0,0,0); roomOriginSize(r2,&o,&s); switch(orientation) //TODO : do pre-rotation ? { case 0: v.z-=s.x/2; //not a mistake break; case 1: v.z+=s.x/2; //not a mistake break; case 4: case 5: v.x-=s.x/2; break; } v.y-=4; while(lc) { rectangle_s rec=lc->data; rec.position=vsubi(rec.position,o); //rotate rec.position=orientVector(rec.position,orientation); rec.size=orientVector(rec.size,orientation); if(!(orientation%2) || orientation==1)invertRectangle(&rec); rec.position=vaddi(rec.position,v); rectangle_s* recp=addRoomRectangle(r1, rec); if(recp) { // recp->hide=true; //TEMP ? recp->collides=!lc->data.portalable; // recp->lightData.vertex=lc->data.lightData.vertex; } lc=lc->next; } }
void BasicEditboxView::draw() { rectfill(dbuf, 0, 0, host->w, host->h, bgcolor); set_clip_rect(dbuf, area_xstart-host->x, area_ystart-host->y, area_xstart-host->x+area_width-1, area_ystart-host->y+area_height-1); int textheight = text_height(textfont); int y = -view_y; for(list<LineData>::iterator it = model->getLines().begin(); it != model->getLines().end(); it++) { if(y >= area_ystart-host->y-textheight && y <= area_ystart+host->y + area_height) blit((*it).strip, dbuf, 0, 0, area_xstart-host->x-view_x, area_ystart-host->y+y, view_width, textheight); y+=textheight; } set_clip_rect(dbuf, 0,0,host->w,host->h); //draw cursor if(model->getCursor().isVisible()) { CursorPos cp = model->findCursor(); //int textheight = text_height(textfont); int cursory = cp.lineno*text_height(textfont); //GAH, too many damn coordinate offsets :-/ vline(dbuf, area_xstart-host->x+cp.x-view_x-1, area_ystart-host->y+cursory-view_y-1, area_ystart-host->y+cursory-view_y+textheight, fgcolor); } //draw selection set_clip_rect(dbuf, area_xstart-host->x, area_ystart-host->y, area_xstart-host->x+area_width-1, area_ystart-host->y+area_height-1); if(model->getSelection().hasSelection()) { pair<int, int> selection = model->getSelection().getSelection(); CursorPos selstart = model->findIndex(selection.first); CursorPos selend = model->findIndex(selection.second); if(selstart.lineno == selend.lineno) { //invert the selection rectangle int starty = area_ystart-host->y-view_y+selstart.lineno*textheight; int startx = area_xstart-host->x+selstart.x-view_x; int endx = area_xstart-host->x+selend.x-view_x; invertRectangle(startx, starty, endx, starty+textheight); } else { //do the starting line int starty = area_ystart-host->y-view_y + selstart.lineno*textheight; int startx = area_xstart-host->x+selstart.x-view_x; int endx; if(hstyle == HSTYLE_EOLINE) { endx= area_xstart-host->x+area_width-view_x; } else { endx = area_xstart-host->x+selstart.it->strip->w-view_x; } invertRectangle(startx,starty,endx,starty+textheight); //do intermediate lines list<LineData>::iterator it = selstart.it; it++; for(int line = selstart.lineno+1; line < selend.lineno; line++,it++) { int endx2; if(hstyle == HSTYLE_EOLINE) { endx2=area_xstart-host->x+area_width-view_x; } else { endx2 = area_xstart-host->x+it->strip->w-view_x; } invertRectangle(area_xstart-host->x-view_x, area_ystart-host->y-view_y+line*textheight, endx2, area_ystart-host->y-view_y+(line+1)*textheight); } //do the last line endx = area_xstart-host->x+selend.x-view_x; invertRectangle(area_xstart-host->x-view_x,area_ystart-host->y-view_y+selend.lineno*textheight, endx, area_ystart-host->y-view_y+(selend.lineno+1)*textheight); } } set_clip_rect(dbuf, 0,0,host->w,host->h); drawExtraComponents(); vsync(); blit(dbuf, screen, 0, 0, host->x, host->y,host->w, host->h); set_clip_rect(screen, 0, 0,SCREEN_W,SCREEN_H); Backend::graphics->waitTick(); Backend::graphics->showBackBuffer(); }