// master windows // masterwin.cpp // jared bruni (master on lsd) #include "masterwin.h" // ** masterwindow ** // draw to screen void masterwindow::draw() { } // draw window title void masterwindow::drawtitle() { drawrect(x,y,x+w,y+13,titcolor,titcolor); COLORREF prebg; prebg = game->text.bk; game->text.setbkcolor(titcolor); game->text.settextcolor(txtcolor); game->text.printtext(title,x+2,y); drawrect(x+w-15,y,x+w,y+13,titcolor,RGB(48,104,160)); drawrect(x+w-30,y,x+w-15,y+13,titcolor,RGB(48,104,160)); drawrect(x+w-30+2,y+2,x+w-15-2,y+13-2,titcolor,RGB(0,0,255)); drawrect(x+w-30+5,y+5,x+w-15-5,y+13-5,titcolor,RGB(255,255,0)); drawrect(x+w-15+2,y+2,x+w-2,y+13-2,RGB(255,0,0),RGB(0,0,255)); game->text.bk = prebg; } // draw background void masterwindow::drawbg() { if(y+h >= 480-20) { y = 480-h-2-20; } if(y < 0) { y = 1; } if(x+w >= 640) { x= 640-w-1; } if(x < 0) { x = 1; } drawrect(x,y,x+w,y+h,bgcolor,outline); } // drawing controls... void masterwindow::drawcontrols() { // draw images on the background // draw textbox's, edit box's, // last draw labels int i; // graphics drawing for(i = 0; i < MASTER_MAXCHILD; i++) { if(image[Screen][i].on == true) { if(image[Screen][i].visible) { HRESULT ddrval; ddrval = game->mxbltsurf(image[Screen][i].surf,image[Screen][i].x+x+1,image[Screen][i].y+y+13,image[Screen][i].w,image[Screen][i].h,false); if(ddrval != DD_OK) { // reload and restore // image[Screen][i].surf = DDLoadBitmap(game->scr->lpDD, image[Screen][i].filename); image[Screen][i].surf->Restore(); game->scr->lpBack->Restore(); DDReLoadBitmap(image[Screen][i].surf,image[Screen][i].filename); // image[Screen][i].surf->Restore(); /* ddrval = game->mxbltsurf(image[Screen][i].surf,image[Screen][i].x+x+1,image[Screen][i].y+y+13,image[Screen][i].w,image[Screen][i].h,false); if(ddrval != DD_OK) { image[Screen][i].surf = DDLoadBitmap(game->scr->lpDD, image[Screen][i].filename); } */ } } } } // // text drawing for(i = 0; i < MASTER_MAXCHILD; i++) { // drawing display box if(display[Screen][i].on) { if(display[Screen][i].visible) { game->text.setbkcolor(display[Screen][i].bgcolor); HFONT oldfont; oldfont = game->text.font; if(display[Screen][i].font) { game->text.font = display[Screen][i].font; } game->text.settextcolor(display[Screen][i].txtcolor); int mx; int my; int mh; int mw; mx = display[Screen][i].x + x + 1; my = display[Screen][i].y + y + 13; mw = mx + display[Screen][i].w; mh = my + display[Screen][i].h; game->text.printtextrect((char*)display[Screen][i].data,mx,my,mw,mh); // return old font game->text.font = oldfont; } } //drawing labels if(label[Screen][i].on == true) { if(label[Screen][i].visible) { game->text.settextcolor(label[Screen][i].fore); game->text.setbkcolor(label[Screen][i].back); game->text.printtext(label[Screen][i].title,label[Screen][i].x+x+1,label[Screen][i].y+y+13); } } // drawing a master display (created with displaylist ) if(mdisplay[Screen][i].on) { int xz; int yz; int wz; int hz; xz = mdisplay[Screen][i].x + x + 1; yz = mdisplay[Screen][i].y + y + 13; wz = xz + mdisplay[Screen][i].w; hz = yz + mdisplay[Screen][i].h; game->mxdrawrect(xz,yz,wz,hz,mdisplay[Screen][i].back_fill,mdisplay[Screen][i].back_out); // drawing text game->text.setbkcolor(mdisplay[Screen][i].back_fill); COLORREF xfor; xfor = mdisplay[Screen][i].display[i].fore; game->text.settextcolor(xfor); int sx = xz+3; int sy = yz+3; int mi = mdisplay[Screen][i].display_index; for(int b = 0; b < mdisplay[Screen][i].down_len; b++) { if(mi <= mdisplay[Screen][i].array_len) { game->text.printtext(mdisplay[Screen][i].display[mi].data,sx,sy); } mi++; sy = sy + 13; } } // drawing a button if(mbutton[Screen][i].on == true) { // draw button // get size int rzx; int rzy; int rzw; int rzh; rzx = mbutton[Screen][i].x + x + 1; rzy = mbutton[Screen][i].y + y + 13; rzw = rzx + mbutton[Screen][i].w; rzh = rzy + mbutton[Screen][i].h; COLORREF xwhite; COLORREF xblack; xwhite = mbutton[Screen][i].push_white; xblack = mbutton[Screen][i].push_black; if(mbutton[Screen][i].idown) { game->text.setbkcolor(mbutton[Screen][i].down_backcolor); game->mxdrawrect(rzx,rzy,rzw,rzh,mbutton[Screen][i].down_backcolor,mbutton[Screen][i].down_outline); game->mxdrawrect(rzx,rzy+mbutton[Screen][i].h-2,rzw,rzy+mbutton[Screen][i].h,xwhite,xwhite); game->mxdrawrect(rzw-2,rzy,rzw,rzy+mbutton[Screen][i].h,xwhite,xwhite); game->mxdrawrect(rzx,rzy,rzx+1,rzh-3,xblack,xblack); game->mxdrawrect(rzx,rzy,rzw-3,rzy+2,xblack,xblack); } else { game->text.setbkcolor(mbutton[Screen][i].up_backcolor); game->mxdrawrect(rzx,rzy,rzw,rzh,mbutton[Screen][i].up_backcolor,mbutton[Screen][i].up_outline); game->mxdrawrect(rzx,rzy+mbutton[Screen][i].h-2,rzw,rzy+mbutton[Screen][i].h,xblack,xblack); game->mxdrawrect(rzw-2,rzy,rzw,rzy+mbutton[Screen][i].h,xblack,xblack); game->mxdrawrect(rzx,rzy,rzx+1,rzh-3,xwhite,xwhite); game->mxdrawrect(rzx,rzy,rzw-3,rzy+2,xwhite,xwhite); } int mhalf; mhalf = mbutton[Screen][i].h / 2; game->text.settextcolor(mbutton[Screen][i].forecolor); game->text.printtext(mbutton[Screen][i].title,rzx+3,rzy+mhalf-13+5 ); } // drawing links if(link[Screen][i].on == true) { if(link[Screen][i].visible) { game->text.settextcolor(link[Screen][i].txtcolor); game->text.setbkcolor(link[Screen][i].bgcolor); if(link[Screen][i].under) { game->text.setbkcolor(link[Screen][i].bgcolor); game->text.settextcolor(link[Screen][i].seltxtcolor); game->text.printtextunderline(link[Screen][i].title,link[Screen][i].x+x+1,link[Screen][i].y+y+13); } else { game->text.settextcolor(link[Screen][i].txtcolor); game->text.setbkcolor(link[Screen][i].bgcolor); game->text.printtext(link[Screen][i].title,link[Screen][i].x+x+1,link[Screen][i].y+y+13); } } } } // now we draw eDItz for(i = 0; i < MASTER_MAXCHILD; i++) { if(input[Screen][i].on == true) { game->text.setbkcolor(input[Screen][i].back); game->text.settextcolor(input[Screen][i].fore); HFONT cfont; cfont = game->text.font; game->text.font = input[Screen][i].font; char pdata[200]; strcpy(pdata,input[Screen][i].data); if(ecount > 3) { pdata[input[Screen][i].index] = '_'; ecount = 0; } else { pdata[input[Screen][i].index] = ' '; } ecount++; pdata[input[Screen][i].index+1] = 0; game->text.printtext(pdata,input[Screen][i].x+x+1,input[Screen][i].y+y+13); game->text.font = cfont;// restore; } // on if(text[Screen][i].on == true) { if(text[Screen][i].visible == true) { int zx; int zy; int zw; int zh; zx = text[Screen][i].x + x + 1; zy = text[Screen][i].y + y + 13; zw = zx + text[Screen][i].w; zh = zy + text[Screen][i].h; game->mxdrawrect(zx,zy,zw,zh,text[Screen][i].bgcolor,text[Screen][i].outline); game->text.settextcolor(RGB(255,0,0)); game->text.printtext((char*)text[Screen][i].data,zx,zy); } } } } // correct child update time void masterwindow::childupdate() { // now the drawing of your windows flat screen's (*** change with apporpiate link lister) for(int g = 0; g < 20; g++) { if(child[g].on) { child[g].wx = x; child[g].wy = y; child[g].update(); } } } // window is updating masterwinmsg masterwindow::update() { if(prog == false) { if(show == true) { drawbg(); drawtitle(); draw(); drawcontrols(); // a throw is happening if(welthrow) { welcount++; if(welcount < 10) { if(y > 0) { y = y -4; } } if((welcount > 10) && (welcount < 20)) { y = y +4; } if((welcount > 20)) { if(y +h < getbary()-10) { y = y + 8; } if(y+h > getbary()-10) { im_attach = true; welcount = 0; welthrow = false; mxbswitch(false); } } } } rtmsg.lbuff = NULL; rtmsg.msg = 0; rtmsg.rbuff = NULL; } else { // VB APP Proccessing. // first find if it exiits } setvbfocuswin(title); return rtmsg; } masterwindow::masterwindow() { tbar = true; } // init the window's gamex void masterwindow::init(MasterXHWND* zgame) { game = zgame; // load bar graphics } // move window void masterwindow::movewindow(int zx, int zy) { x = zx; y = zy; } // showwindow void masterwindow::showwindow(bool tx) { show = tx; } // printtext void masterwindow::printtext(char* buff, int x, int y, COLORREF r) { game->text.settextcolor(r); game->text.setbkcolor(bgcolor); game->text.printtext(buff,x,y); } // createwindow void masterwindow::createwindow(char* titlex, int zx, int zy, int zw, int zh, MasterXHWND* zgame) { strcpy(title,titlex); x = zx; y = zy; w = zw; h = zh; game = zgame; on = true; titcolor = RGB(150,150,150); } // create a link control int masterwindow::createlink(int scr,char* title, char* id, int ix, int iy) { int n = -1; for(int cur =0; cur < MASTER_MAXCHILD;cur++) { if(link[scr][cur].on == false) { n = cur; } } if(n == -1) { return -1; } link[scr][n].on = true; link[scr][n].visible = true; link[scr][n].x = ix; link[scr][n].y = iy; link[scr][n].seltxtcolor = RGB(0,0,255); link[scr][n].txtcolor = RGB(0,0,255); link[scr][n].bgcolor = RGB(0,0,0); strcpy(link[scr][n].title,title); strcpy(link[scr][n].id,id); return n; } // create a button control int masterwindow::createbutton(int scr,char* title, char* id, int dx, int dy, int dw, int dh) { int n = -1; for(int z = 0; z < MASTER_MAXCHILD;z++) { if(mbutton[scr][z].on == false) { n = z; break; } } // failure if(n == -1) { return -1; } mbutton[scr][z].x = dx; mbutton[scr][z].y = dy; mbutton[scr][z].w = dw; mbutton[scr][z].h = dh; mbutton[scr][z].on = true; mbutton[scr][z].visible = true; strcpy(mbutton[scr][z].title,title); strcpy(mbutton[scr][z].id,id); mbutton[scr][z].down_backcolor = RGB(200,200,200); mbutton[scr][z].down_outline = RGB(200,200,200); mbutton[scr][z].up_backcolor = RGB(200,200,200); mbutton[scr][z].up_outline = RGB(200,200,200); mbutton[scr][z].forecolor = RGB(100,0,0); mbutton[scr][z].push_black = RGB(150,150,150);//RGB(72,72,72); mbutton[scr][z].push_white = RGB(255,255,255); return n; } // master window create a child (*flat* global windowed screen) int masterwindow::createchild(char* titlea, int xa, int ya, int wa, int ha) { int n = -1; for(int z = 0; z < MASTER_MAXCHILD; z++) { if(child[z].on == false) { n = z; break; } } // failure if(n == -1) { return -1; } child[n].on = true; child[n].bar_fill = RGB(0,0,150); child[n].bar_out = RGB(0,0,200); child[n].bg_fill = RGB(0,0,0); child[n].bg_out = RGB(25,25,100); child[n].bg_out2 = RGB(50,50,200); child[n].mouse_over = RGB(100,100,100); child[n].x = xa; child[n].y = ya; child[n].w = wa; child[n].h = ha; strcpy(child[n].title,titlea); child[n].child_index = childdepth; child[n].game = game; child[n].op_close = true; child[n].op_min = true; child[n].show = true; child[n].fore = RGB(200,0,0); child[n].bg_shade1 = RGB(0,0,125); child[n].bg_shade2 = RGB(0,0,175); child[n].loadgraphics(); childdepth++; return n; } // creating a input control int masterwindow::createinput(int scr, int ax, int ay, int alen) { int n = -1; for(int z = 0; z < MASTER_MAXCHILD; z++) { if(input[scr][z].on == false) { n = z; break; } } // failure if(n == -1) { return -1; } input[scr][z].on = true; input[scr][z].index = 0; input[scr][z].x = ax; input[scr][z].y = ay; input[scr][z].len = alen; input[scr][z].fore = RGB(200,0,0);//fore input[scr][z].back = RGB(0,0,0);//back input[scr][z].font = getmxfont();//font strcpy(input[scr][z].data,""); return n; } // create a text display control int masterwindow::createdisplay(int scr,char* txt, int ax, int ay, int aw, int ah) { int n = -1; for(int z = 0; z < MASTER_MAXCHILD; z++) { if(display[scr][z].on == false) { n = z; break; } } // failure if(n == -1) { return -1; } // defaults // init display[scr][n].bgcolor = RGB(0,0,0); display[scr][n].font = game->text.font; display[scr][n].data = new PCHAR[strlen(txt)+1]; strcpy((char*)display[scr][n].data,txt); display[scr][n].x = ax; display[scr][n].y = ay; display[scr][n].w = aw; display[scr][n].h = ah; display[scr][n].on = true; display[scr][n].txtcolor = RGB(0,0,255); display[scr][n].visible = true; return n; } // create a text box , and return its position int masterwindow::createtext(int scr,char* txt, int tx, int ty, int tw, int th) { int n = -1; for(int i = 0; i < MASTER_MAXCHILD; i++) { if(text[scr][i].on == false) { n = i; break; } } text[scr][n].bgcolor = RGB(0,0,0); text[scr][n].data = new PCHAR[strlen(txt)+1]; strcpy((char*)text[scr][n].data,txt); text[scr][n].h = th; text[scr][n].w = tw; text[scr][n].x = tx; text[scr][n].y = ty; text[scr][n].txtcolor = RGB(255,0,0); text[scr][n].outline = RGB(0,255,0); text[scr][n].on = true; text[scr][n].visible = true; return n; } // create a master disp int masterwindow::createmasterdisplay(int scr,displaylist* display,int array_len,int x, int y, int w, int h,int down_len) { int n = -1; for(int z = 0; z < MASTER_MAXCHILD; z++) { if(mdisplay[scr][z].on == false) { n = z; break; } } // failure if(n == -1) { return -1; } mdisplay[scr][n].init(display,array_len,down_len); mdisplay[scr][n].x = x; mdisplay[scr][n].y = y; mdisplay[scr][n].w = w; mdisplay[scr][n].h = h; mdisplay[scr][n].on = true; mdisplay[scr][n].back_fill = RGB(150,150,150); mdisplay[scr][n].back_out = RGB(0,0,0); mdisplay[scr][n].fore = RGB(200,0,0); return n; } // create a label, and return its position int masterwindow::createlabel(int scr,char* title, int ix, int iy, COLORREF bg,COLORREF fore) { int n = -1; for(int cur =0; cur < MASTER_MAXCHILD; cur++) { if(label[scr][cur].on == false) { n = cur; } } if(n == -1) { return -1; } label[scr][n].on = true; strcpy(label[scr][n].title,title); label[scr][n].x = ix; label[scr][n].y = iy; label[scr][n].w = w; label[scr][n].h = h; label[scr][n].back = bg; label[scr][n].fore = fore; label[scr][n].visible = true; return n; } // create the image, return its position int masterwindow::createimage(int scr,char* filename, int ix, int iy) { int pos = -1; for(int i = 0; i < MASTER_MAXCHILD; i++) { if(image[scr][i].on == false) { pos = i; break; } } // failure if(pos == -1) { return -1; } image[scr][pos].on = true; image[scr][pos].key = false; image[scr][pos].visible = true; image[scr][pos].x = ix; image[scr][pos].y = iy; strcpy(image[scr][pos].filename,filename); image[scr][pos].game = game; if(filecheck(filename)) { image[scr][pos].surf = DDLoadBitmap(game->scr->lpDD,filename); HBITMAP hbm; BITMAP bm; hbm = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP,0,0,LR_LOADFROMFILE | LR_CREATEDIBSECTION); if(hbm == NULL) { image[scr][pos].visible = false; image[scr][pos].on = false; } GetObject(hbm, sizeof(bm), &bm); // size DeleteObject(hbm); // Create Surface for this Bitmap int cw = bm.bmWidth; int ch = bm.bmHeight; image[scr][pos].w = cw; image[scr][pos].h = ch; } else { image[scr][pos].visible = false; } return pos; } // killing masterwindow graphics void masterwindow::killgraphics() { for(int i=0;iRelease(); } } } for(i = 0; i < 25; i++) { if(child[i].on) { child[i].destroygraphics(); } } } // draw a rectangle void masterwindow::drawrect(int ix, int iy, int xx, int yy, COLORREF fill, COLORREF outline) { HDC dc; game->scr->lpBack->GetDC(&dc); HBRUSH hNewBrush,hOldBrush;// new Brush to paint with and one thats current (so we can restore) HPEN hNewPen,hOldPen; // New pen to paint with and the current (so we can restore) hNewBrush = (HBRUSH)CreateSolidBrush(fill); // create this brush hOldBrush = (HBRUSH)SelectObject(dc,(HBRUSH)hNewBrush); // set this brush and get the old brush hNewPen = CreatePen(PS_SOLID,2,outline); // create this pen hOldPen= (HPEN__*)SelectObject(dc,(HPEN__*)hNewPen); // set this pen and get the old one Rectangle(dc,ix,iy,xx,yy); // Draw a rectangle // when using shape functions, it outlines the shape with the Pen, and fills it in // with the brush // how shapes work is x,y,xx,yy // x is the top left x cord, y, is the bottom left y cord // xx is the top right x cord, and yy is the bottom right x cord // so you basicly set 4 cords and it fills in that space :) // restore shit SelectObject(dc,hOldPen); SelectObject(dc,hOldBrush); DeleteObject(hNewBrush); // DIE DIE MY PEN ILL BE SEEING YOU AGIAN DeleteObject(hNewPen); // i dont need this sso lets KILL It game->scr->lpBack->ReleaseDC(dc); } // throwing window void masterwindow::windowthrow() { welthrow = true; welcount = 0; mxbswitch(true); masterx_interupt("#mxs_masterfall"); } void masterwindow::winfix() { if(im_attach) { y = getbary()-10-h; } } // recv keyinput void masterwindow::keypress(int key) { for(int i = 0; i < MASTER_MAXCHILD;i++) { if((input[Screen][i].on) && (input[Screen][i].focus)) { switch(key) { case 8: if(input[Screen][i].index > 0) { input[Screen][i].index--; input[Screen][i].data[input[Screen][i].index] = 0; } return; break; case VK_DOWN: case VK_UP: case VK_LEFT: case VK_RIGHT: case 16: case 44: case 17: return; break; case 13: masterwinmsg imsg; imsg.msg = MX_INPUT; imsg.mousex = 0; imsg.mousey = 0; imsg.mousebutton = 0; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = 0; imsg.mx_type = MXT_INPUT; strcpy(imsg.id,input[Screen][i].data); callmessageproc(mx_index,i,imsg); ZeroMemory(input[Screen][i].data,sizeof(input[Screen][i].data)); input[Screen][i].index = 0; strcpy(input[Screen][i].data," "); return; break; case 20: if(caps) { caps = 0; } else { caps = 420; } return; } char cur; cur = fixkeys(key,caps,true); // 20 & 9 if(input[Screen][i].index < input[Screen][i].len) { input[Screen][i].data[input[Screen][i].index] = cur; input[Screen][i].index++; } } } } // recv mouseclick void masterwindow::mouseclick(int ix, int iy) { // turn into msg and proccess wlock = false; masterwinmsg imsg; // check up on links , see if anys underlined if so, send a message for processing for(int z = 0; z < MASTER_MAXCHILD; z++) { if(link[Screen][z].on) { if(link[Screen][z].visible) { if(link[Screen][z].under) { imsg.msg = MX_LINKCLICK; imsg.mousex = 0; imsg.mousey = 0; imsg.mousebutton = 0; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = 0; imsg.mx_type = MXT_LINK; callmessageproc(mx_index,z,imsg); // call message proc } } } } } // recv a mousedown void masterwindow::mousedown(int ix, int iy, int button) { // child looop goes here, unil then temp for(int r = 0; r < 25; r++) { child[r].mousedown(ix,iy,button); } if((ix > x)&&(ix < x+w-30)&&(iy > y)&&(iy < y+15)) { wlock = true; woverx = x-ix; wovery = y-iy; im_attach = false; } // for(int z = 0; z < MASTER_MAXCHILD; z++) { if(mbutton[Screen][z].on) { // check and see if cords are correct int rzx; int rzy; int rzw; int rzh; rzx = mbutton[Screen][z].x + x + 1; rzy = mbutton[Screen][z].y + y + 13; rzw = rzx + mbutton[Screen][z].w; rzh = rzy + mbutton[Screen][z].h; if((ix > rzx) && (ix < rzw) && (iy > rzy) && (iy < rzh)) { mbutton[Screen][z].idown = true; } } } } // recv a mouseup void masterwindow::mouseup(int ix, int iy, int button) { wlock = false; if(y + h + 25 < getbary()) { } else { y = getbary()-10-h; wlock = false; im_attach = true; // masterx_interupt("#mxs_masterfall"); } for(int r = 0; r < 25; r++) { child[r].mouseup(ix,iy,button); } // for(int z = 0; z < MASTER_MAXCHILD; z++) { if(mbutton[Screen][z].on) { if(mbutton[Screen][z].idown == true) { mbutton[Screen][z].idown = false; // process the click // only if we are still within the buttons area int rzx; int rzy; int rzw; int rzh; rzx = mbutton[Screen][z].x + x + 1; rzy = mbutton[Screen][z].y + y + 13; rzw = rzx + mbutton[Screen][z].w; rzh = rzy + mbutton[Screen][z].h; if((ix > rzx) && (ix < rzw) && (iy > rzy) && (iy < rzh)) { masterwinmsg imsg; imsg.msg = MX_BUTTONCLICK; imsg.mousex = 0; imsg.mousey = 0; imsg.mousebutton = 0; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = 0; imsg.mx_type = MXT_BUTTON; strcpy(imsg.id,mbutton[Screen][z].id); callmessageproc(mx_index,z,imsg); } } } } } // recv mousemove void masterwindow::mousemove(int Movex, int Movey, long button) { // check for link underlining shit // -master child loop- // change when u do real loop for(int xor = 0; xor < 25; xor++) { child[xor].mousemove(Movex,Movey,button); } /* int cey; // get current bar y position cey = getbary(); if(y+h>= cey) { return; } */ for(int m = 0; m < MASTER_MAXCHILD;m++) { if(getrunstate()) { link[Screen][m].under = false; } else { if(link[Screen][m].on) { if(Movex < x) { link[Screen][m].under = false; return; } if(Movex > x+w) { link[Screen][m].under = false; return; } int lx; int ly; int width; width = strlen(link[Screen][m].title)*12/2; lx = link[Screen][m].x + x; ly = link[Screen][m].y + y; if((Movex > lx) && (Movex < lx+width) && (Movey > ly) && (Movey < ly+20)) { link[Screen][m].under = true; } else { link[Screen][m].under = false; } } } } if(button) { if(wlock == true) { x = Movex + woverx; if(y + h < getbary()) { y = Movey - wovery; } else { y = getbary()-10-h; wlock = false; im_attach = true; } } } // drawmove(); } // setting and getting current screen void masterwindow::setscreen(int s) { if(s < 25) { Screen = s; } } int masterwindow::getscreen() { return Screen; } // drawing move void masterwindow::drawmove() { if(wlock) { // movex, movey (using width & height) game->mxdrawrect(movex,movey,movex+w,movey+h,RGB(0,255,0),RGB(0,0,255)); } } // recv msg and dispatch void masterwindow::recvmsg(masterwinmsg msg) { rtmsg = msg; } // load graphics for window void masterwindow::loadgraphics() { } void masterwindow::reloadgraphics() { for(int s = 0; s < 25; s++) { for(int i = 0; i < MASTER_MAXCHILD; i++) { if(image[s][i].on) { image[s][i].surf->Restore(); game->scr->lpBack->Restore(); DDReLoadBitmap(image[s][i].surf,image[s][i].filename); } } } } // masterwinhandle // this is the master windows interface handler // init void masterwinhandle::init(MasterXHWND* zgame) { game = zgame; curwin = -1; mode = 1; cpos = 0; disbar = 0; disbar2 = 2; barx = 5; bary = 260; lstat = 0; rstat = 2; bgout = RGB(200,200,200); bgout2 = RGB(50,50,50); loadgraphics(); } // recive a keyinput void masterwinhandle::keyinput(int key) { if(GetAsyncKeyState(16)) { if(key == VK_LEFT) { barleft(); } if(key == VK_RIGHT) { barright(); } if(key == VK_DOWN) { bardown(); } if(key == VK_UP) { barup(); } } win[curwin].keypress(key); // global message proc, key press masterwinmsg imsg; imsg.msg = MX_KEYPRESS; imsg.mousex = 0; imsg.mousey = 0; imsg.mousebutton = 0; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = key; callmessageproc(curwin,MX_CURWINDOW,imsg); } // recive a mouse click input void masterwinhandle::mouseclick(int ix, int iy) { barclick(ix,iy); win[curwin].mouseclick(ix,iy); masterwinmsg imsg; imsg.msg = MX_MOUSECLICK; imsg.mousex = ix; imsg.mousey = iy; imsg.mousebutton = MX_LBUTTON; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = 0; callmessageproc(curwin,MX_CURWINDOW,imsg); } // master win handle (see if they click0red the bar0r) void masterwinhandle::barclick(int ix, int iy) { int dx; int dy; dx = barx+50; dy = bary; int curWin = curwin; int mwIndex; for(int z = curwin; z < curwin+7; z++) { mwIndex = win[curWin].mwindex; // win[0].drawrect(dx,dy,dx+75,bary+20,RGB(164,149,149),outln); if(curWin != -1) { if(win[curWin].on) { // game->text.printtext(win[curWin].title,dx+3,dy+3); // check cordinates if(ix > dx) { if(ix < dx+75) { if(iy > bary) { if(iy < bary+20) { curwin = curWin; masterx_interupt("#mxs_masterwarp "); masterx_insert("masterX- application dimension jump"); char xbuff[100]; strcpy(xbuff,"current demension: "); strcat(xbuff, win[curwin].title); strcat(xbuff, " "); masterx_insert(xbuff); } } } } } } dx = dx+ 75; // curWin++; // <-- Replace with Find Next Index ( SCAN FOR NEXT INDEX ) if(curWin != -1) { curWin = getnextwindow(mwIndex); } } } void masterwinhandle::mousedown(int ix, int iy,int button) { // check for left + right window toggles int cx = win[curwin].x + win[curwin].w - 30 + 1; int cy = win[curwin].y+1; // lcheck if(ix > cx) { if(ix < cx+12) { if(iy > cy) { if(iy < cy+10) { lstat = 1; } } } } cx = win[curwin].x + win[curwin].w - 15 ; cy = win[curwin].y + 1; if(ix > cx) { if(ix < cx+12) { if(iy > cy) { if(iy < cy+10) { rstat = 3; } } } } if(ix > barx+30) { if(ix < barx+30+20) { if(iy >= bary) { if(iy < bary+20) { disbar = 1; barleft(); return; } } } } if(ix > barx+580) { if(ix < barx+580+20) { if(iy >= bary) { if(iy < bary+20) { disbar2 = 3; barright(); return; } } } } win[curwin].mousedown(ix,iy,button); // send the mouse down masterwinmsg imsg; imsg.msg = MX_MOUSEDOWN; imsg.mousex = ix; imsg.mousey = iy; imsg.mousebutton = button; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = 0; callmessageproc(curwin,MX_CURWINDOW,imsg); } void masterwinhandle::mouseup(int ix, int iy, int button) { int cx = win[curwin].x + win[curwin].w - 30 + 1; int cy = win[curwin].y+1; // lcheck lstat =0; rstat =2; if(ix > cx) { if(ix < cx+12) { if(iy > cy) { if(iy < cy+10) { // shell toggle left barleft(); } } } } cx = win[curwin].x + win[curwin].w - 15 ; cy = win[curwin].y + 1; if(ix > cx) { if(ix < cx+12) { if(iy > cy) { if(iy < cy+10) { barright();// toggle right } } } } disbar = 0; disbar2 = 2; win[curwin].mouseup(ix,iy,button); masterwinmsg imsg; imsg.msg = MX_MOUSEUP; imsg.mousex = ix; imsg.mousey = iy; imsg.mousebutton = button; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = 0; callmessageproc(curwin,MX_CURWINDOW,imsg); } // mouse movement void masterwinhandle::mousemove(int ix, int iy, long button) { // calculate were the mouse is : setup shit // check certin positions of the mouse if so, draw the square // around the icon if((ix > 227) && (ix < 227+18) && (iy > 3) && (iy <3+15)) { mxbar1 = true; } else { mxbar1 = false; } if((ix > 615) && (ix < 615+18) && (iy > 3) && (iy < 3+15)) { mxbar2 = true; } else { mxbar2 = false; } int bxy; bxy = getbary(); if((ix > 10) && (ix < 30) && (iy > bxy + 2) && (iy < bxy + 17)) { dshow = true; } else { dshow = false; } win[curwin].mousemove(ix,iy,button); mx_mousex = ix; mx_mousey = iy; // procc mousemove masterwinmsg imsg; imsg.msg = MX_MOUSEMOVE; imsg.mousex = ix; imsg.mousey = iy; imsg.mousebutton = button; imsg.rbuff = 0; imsg.rlen = 0; imsg.lbuff = 0; imsg.llen = 0; imsg.curkey = 0; callmessageproc(curwin,MX_CURWINDOW,imsg); } // find a window masterhandle masterwinhandle::findwindow(char* mtitle) { for(int i = 0; i < mx_max; i++) { if(strstr(win[i].title,mtitle)){ return i; } } return -1; // failure } // find a window child masterhandle masterwinhandle::findwindowex(char* mtitle,char* title) { return 0; } long masterwinhandle::sendmessage(masterhandle mwindow,masterhandle mchild, masterwinmsg msg) { callmessageproc(mwindow,mchild,msg); return 0; } // bar change (for win attach) void masterwinhandle::barchange() { for(int i = 0; i < MASTER_MAXWIN; i++) { if(win[i].im_attach) { win[i].y = getbary()-5-win[i].h; } } } // update void masterwinhandle::update() { if(curwin > -1) { if(curwin != oldcur) { oldcur = curwin; char oldbg[100]; getbackground(oldbg); if(strstr(oldbg,win[curwin].mybackground)) {} else { setbackground(win[curwin].mybackground); } } win[curwin].update(); if(win[curwin].tbar) { HRESULT ddrval; int cx = win[curwin].x + win[curwin].w - 30 + 1; int cy = win[curwin].y+1; // drawrect(x+w-30+5,y+5,x+w-15-5,y+13-5,titcolor,RGB(255,255,0)); // drawrect(x+w-15+2,y+2,x+w-2,y+13-2,RGB(255,0,0),RGB(0,0,255)); if(bswitch == false) { if(iswitch == false) { ddrval = game->mxbltsurf(bar[lstat],cx,cy,12,10,false); } } if(ddrval != DD_OK) { loadbar(); } cx = win[curwin].x + win[curwin].w - 15 ; cy = win[curwin].y + 1; if(bswitch == false) { if(iswitch == false) { ddrval = game->mxbltsurf(bar[rstat],cx,cy,12,10,false); } } if(ddrval != DD_OK) { loadbar(); } // child update here. if(bswitch == false) { if(iswitch == false) { win[curwin].childupdate(); } } progbar(); } } drawbar(); masterwinmsg mx_msg; mx_msg.curkey = NULL; mx_msg.lbuff = NULL; mx_msg.rbuff = NULL; mx_msg.rlen = NULL; mx_msg.llen = NULL; mx_msg.msg = MX_UPDATE; mx_msg.mousex = mx_mousex; mx_msg.mousey = mx_mousey; callmessageproc(curwin,NULL,mx_msg); } // select a window void masterwinhandle::selectwindow(int k) { curwin = k; win[curwin].wlock = false; } // get a off node space for a window handle int masterwinhandle::getoffwin() { for(int i = 0; i < mx_max; i++) { if(win[i].on == false) { return i; } } return -1;// failure } // create a new window int masterwinhandle::masterWindow(char* t, int x, int y,int w,int h, COLORREF bg) { int off; off = getoffwin(); win[off].createwindow(t,x,y,w,h,game); win[off].bgcolor = bg; win[off].txtcolor = RGB(255,0,0); win[off].show = true; win[off].on = true; win[off].mx_index = off; win[off].mwindex = max; win[off].outline = RGB(50,100,100); win[off].tbar = true; win[off].loadgraphics(); win[off].progbar = RGB(0,0,0); win[off].prog_title = RGB(100,100,100); win[off].prog_titleout = RGB(150,150,150); win[off].prog_titleout2 = RGB(75,75,75); win[off].chbarbg = RGB(75,75,75); win[off].chbar2 = RGB(100,100,100); win[off].chbar_out = RGB(200,200,200);// light (200,200,200) win[off].chbar_out2 = RGB(50,50,50);// dark (50,50,50) strcpy(win[off].mybackground,"wallpaper.bmp"); max++; selectwindow(off); return off; } // create a master program (vb/c++ plugin) int masterwinhandle::masterProgram(char* cl, char* title) { if(FindWindow(cl,title)) { int off; off = getoffwin(); strcpy(win[off].title,title); strcpy(win[off].cl,cl); win[off].prog = true; win[off].on = true; win[off].myhwnd = FindWindow(cl,title); win[off].mwindex = max; max++; return off; } else { // failure return -1; } } void masterwinhandle::destroywindow(int index) { // destroying a window by ints index if(index == 0) { return; } if(index <= MASTER_MAXWIN) { if(index == curwin) { if(curwin > 0) { curwin--; } else { curwin++; } } // kill surfaces win[index].killgraphics(); ZeroMemory(&win[index],sizeof(win[index])); win[index].on = false; } } // relay messages to a vb program (if its the current) void masterwinhandle::msgrelay(UINT msg,LPARAM lParam,WPARAM wParam) { if(win[curwin].prog) { if(FindWindow(win[curwin].cl,win[curwin].title)) { SendMessage(win[curwin].myhwnd,msg,wParam,lParam); } else { } } } // move selected window in bar left void masterwinhandle::barleft() { if(curwin > 0) { // curwin--; int chkwin; int mw; mw = win[curwin].mwindex; chkwin = getprevwindow(mw); if(chkwin != -1) { curwin = chkwin; } // game->playsound(IDR_WAVE3); curwin = chkwin; masterx_interupt("#mxs_masterwarp"); masterx_insert("masterX- application dimension warp."); char buff[100]; strcpy(buff,"current Dimension:"); strcat(buff,win[curwin].title); strcat(buff,"."); masterx_insert(buff); } } // move select window in bar right void masterwinhandle::barright() { /* int chk; chk = curwin + 1; if(win[chk].on) { if(curwin < MASTER_MAXWIN) { curwin++; // game->playsound(IDR_WAVE3); } } */ int chkwin; int mw; mw= win[curwin].mwindex; chkwin = getnextwindow(mw); if(chkwin != -1) { curwin = chkwin; masterx_interupt("#mxs_masterwarp"); masterx_insert("masterX- application dimension warp."); char buff[100]; strcpy(buff,"current dimension:"); strcat(buff,win[curwin].title); strcat(buff,"."); masterx_insert(buff); } } // move bar up void masterwinhandle::barup() { mxbarup(); } // move bar down void masterwinhandle::bardown() { mxbardown(); } // load bar graphics void masterwinhandle::loadgraphics() { surf[0] = DDLoadBitmap(game->scr->lpDD,"moveleft.bmp"); surf[1] = DDLoadBitmap(game->scr->lpDD,"moveleft_down.bmp"); surf[2] = DDLoadBitmap(game->scr->lpDD,"moveright.bmp"); surf[3] = DDLoadBitmap(game->scr->lpDD,"moveright_down.bmp"); xbar[0] = DDLoadBitmap(game->scr->lpDD,"mbarl.bmp"); xbar[1] = DDLoadBitmap(game->scr->lpDD,"mbarr.bmp"); loadbar(); } // reload void masterwinhandle::reloadgraphics() { DDReLoadBitmap(surf[0],"moveleft.bmp"); DDReLoadBitmap(surf[1],"moveleft_down.bmp"); DDReLoadBitmap(surf[2],"moveright.bmp"); DDReLoadBitmap(surf[3],"moveright_down.bmp"); DDReLoadBitmap(xbar[0],"mbarl.bmp"); DDReLoadBitmap(xbar[1],"mbarr.bmp"); DDReLoadBitmap(bar[0],"wl_up.bmp"); DDReLoadBitmap(bar[1],"wl_down.bmp"); DDReLoadBitmap(bar[2],"wr_up.bmp"); DDReLoadBitmap(bar[3],"wr_down.bmp"); } // deconstructor masterwinhandle::~masterwinhandle() { /* */ } void masterwinhandle::loadbar() { bar[0] = DDLoadBitmap(game->scr->lpDD,"wl_up.bmp"); bar[1] = DDLoadBitmap(game->scr->lpDD,"wl_down.bmp"); bar[2] = DDLoadBitmap(game->scr->lpDD,"wr_up.bmp"); bar[3] = DDLoadBitmap(game->scr->lpDD,"wr_down.bmp"); } void masterwinhandle::killgraphics() { for(int z = 0; z < 10; z++) { if(surf[z]) { surf[z]->Release(); } if(xbar[z]) { xbar[z]->Release(); } } for(int p=0;p<4;p++) { if(bar[p]) { bar[p]->Release(); } } } // the bar is over void masterwinhandle::barover() { if(dshow == true) { int wx,wy,ww,wh; wx = 30; wy = getbary() + 2; ww = 31; wh = getbary() + 18; COLORREF d1 = RGB(50,50,50); COLORREF d2 = RGB(170,170,170); d1 = RGB(100,100,100); d2 = RGB(200,200,200); game->mxdrawrect(wx,wy,ww,wh,d1,d1); game->mxdrawrect(wx-1,wy,ww-1,wh,d2,d2); wx = 10; ww = 30; wy = getbary() + 16; wh = getbary() + 17; game->mxdrawrect(wx,wy,ww,wh,d2,d2); wx = 7; ww = 8; wy = getbary()+2; wh = getbary()+18; game->mxdrawrect(wx,wy,ww,wh,d1,d1); } } // draw the window selection bar void masterwinhandle::drawbar() { // first drw the rect win[0].drawrect(barx,bary,640-4,bary+20,RGB(164,149,149),RGB(0,0,0)); win[0].drawrect(0,bary,barx,bary+20,RGB(0,0,0),RGB(0,0,0)); win[0].drawrect(637,bary,640,bary+20,RGB(0,0,0),RGB(0,0,0)); win[0].drawrect(0,640,470,480,RGB(0,0,0),RGB(0,0,0)); int dx; int dy; dx = barx+50; dy = bary; COLORREF outln; COLORREF r; r = game->text.bk; int curWin = curwin; int mwIndex; for(int z = curwin; z < curwin+7; z++) { mwIndex = win[curWin].mwindex; if(z == curwin) { outln = RGB(200,20,20); game->text.settextcolor(RGB(20,0,255)); } else { outln = RGB(0,0,0); game->text.settextcolor(outln); } win[0].drawrect(dx,dy,dx+75,bary+20,RGB(164,149,149),outln); win[0].drawrect(dx,dy,dx+75,dy+2,RGB(200,0,0),RGB(200,0,0)); game->text.bk = RGB(164,149,149); if(curWin != -1) { if(win[curWin].on) { game->text.printtext(win[curWin].title,dx+3,dy+3); } } dx = dx+ 75; // curWin++; // <-- Replace with Find Next Index ( SCAN FOR NEXT INDEX ) if(curWin != -1) { curWin = getnextwindow(mwIndex); } } game->text.bk = r; HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,16,16); ddrval = game->scr->lpBack->BltFast(barx+30,bary+1,surf[disbar],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); game->scr->lpBack->Restore(); } ddrval = game->scr->lpBack->BltFast(barx+580-3,bary+1,surf[disbar2],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); game->scr->lpBack->Restore(); } game->mxdrawrect(57,bary+2,128,bary+3,RGB(170,170,170),RGB(170,170,170)); game->mxdrawrect(57,bary+2,58,bary+17,RGB(170,170,170),RGB(170,170,170)); game->mxdrawrect(57,bary+17,128,bary+18,RGB(50,50,50),RGB(100,100,100)); game->mxdrawrect(127,bary+2,128,bary+17,RGB(170,170,170),RGB(170,170,170)); int zx; int zy; int zw; int zh; zx = 132; zy = bary+3; zw = 133; zh = bary+17; game->mxdrawrect(zx,zy,zw,zh,RGB(170,170,170),RGB(170,170,170)); zx = 202; zy = bary+3; zw = 203; zh = bary+17; game->mxdrawrect(zx,zy,zw,zh,RGB(170,170,170),RGB(170,170,170)); zx = 132; zy = bary+3; zw = 202; zh = bary+4; game->mxdrawrect(zx,zy,zw,zh,RGB(50,50,50),RGB(50,50,50)); int farx; farx = 75; for(int c = 0; c < 5; c++) { zx = 132 + farx; zy = bary+3; zw = 133 + farx; zh = bary+17; game->mxdrawrect(zx,zy,zw,zh,RGB(170,170,170),RGB(170,170,170)); zx = 202 + farx; zy = bary+3; zw = 203 + farx; zh = bary+17; game->mxdrawrect(zx,zy,zw,zh,RGB(170,170,170),RGB(170,170,170)); zx = 132 + farx; zy = bary+3; zw = 202 + farx; zh = bary+4; game->mxdrawrect(zx,zy,zw,zh,RGB(50,50,50),RGB(50,50,50)); farx = farx + 75; } // now for icons in bar } // d rawing the masterX window program bars void masterwinhandle::progbar() { game->mxdrawrect(0,0,5,getbary(),win[curwin].progbar,win[curwin].progbar); game->mxdrawrect(635,0,640,getbary(),win[curwin].progbar,win[curwin].progbar); game->mxdrawrect(0,0,640,19,win[curwin].progbar,win[curwin].progbar); // prog title game->mxdrawrect(6,3,224,16,win[curwin].prog_title,win[curwin].prog_title); // print out game->text.setbkcolor(win[curwin].prog_title); game->text.settextcolor(RGB(0,0,200)); game->text.printtext(" Dimension: ",7,3); game->text.settextcolor(RGB(200,0,0)); game->text.printtext(win[curwin].title,65,3); COLORREF out; COLORREF out2; out = win[curwin].prog_titleout; out2 = win[curwin].prog_titleout2; game->mxdrawrect(7,3,224,4,out2,out2); game->mxdrawrect(7,17,224,18,out,out); game->mxdrawrect(6,3,7,18,out2,out2); game->mxdrawrect(223,3,224,18,out,out); // now drawing all the masterX- demension chlidren game->mxdrawrect(227,3,634,18,win[curwin].prog_title,win[curwin].prog_title); HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,17,14); ddrval = game->scr->lpBack->BltFast(227,3,xbar[0],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); game->scr->lpBack->Restore(); } ddrval = game->scr->lpBack->BltFast(615,3,xbar[1],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); game->scr->lpBack->Restore(); } if(mxbar1 == true) { game->mxdrawrect(227,3,227+18,4,out,out); game->mxdrawrect(227+17,3,227+18,3+15,out,out); game->mxdrawrect(227,3,228,3+15,out2,out2); game->mxdrawrect(227,3+14,227+15,3+15,out2,out2); } if(mxbar2 == true) { game->mxdrawrect(615,3,615+18,4,out,out); game->mxdrawrect(615+17,3,615+18,3+15,out,out); game->mxdrawrect(615,3,616,3+15,out2,out2); game->mxdrawrect(615,3+14,615+15,3+15,out2,out2); } // drawing the child screen bar COLORREF cb; cb = win[curwin].chbarbg; game->mxdrawrect(227+19,3,614,3+15,cb,cb); game->text.setbkcolor(cb); game->text.settextcolor(RGB(200,0,0)); char timebuf[9]; _strtime(timebuf); game->text.printtext(timebuf,570,3); COLORREF chbar2; chbar2 = win[curwin].chbar2; game->mxdrawrect(227+20,3,567,3+15,chbar2,chbar2); game->mxdrawrect(567,3,568,3+15,win[curwin].progbar,win[curwin].progbar); game->mxdrawrect(615,3,616,3+15,win[curwin].progbar,win[curwin].progbar); game->mxdrawrect(227+18,3,227+19,3+15,win[curwin].progbar,win[curwin].progbar); int spx = 0; int spy = 3; spx = 227+21; for(int p = 0; p < 3; p++) { game->mxdrawrect(spx,spy+1,spx+99,spy+14,chbar2,chbar2); game->text.setbkcolor(chbar2); game->text.settextcolor(RGB(200,0,0)); game->text.printtext("testXXXXX",spx+3,spy); COLORREF chbar_out; COLORREF chbar_out2; if(p == 0) { chbar_out2 = win[curwin].chbar_out;// light (200,200,200) chbar_out = win[curwin].chbar_out2;// dark (50,50,50) } else { chbar_out = win[curwin].chbar_out;// light (200,200,200) chbar_out2 = win[curwin].chbar_out2;// dark (50,50,50) } game->mxdrawrect(spx+1,spy+1,spx+98,spy+2,chbar_out,chbar_out); game->mxdrawrect(spx+1,spy+13,spx+98,spy+14,chbar_out2,chbar_out2); game->mxdrawrect(spx+1,spy+1,spx+2,spy+13,chbar_out,chbar_out); game->mxdrawrect(spx+97,spy+1,spx+98,spy+13,chbar_out2,chbar_out2); spx = spx + 100; } game->mxdrawrect(0,0,640,1,bgout,bgout); game->mxdrawrect(0,0,1,getbary(),bgout,bgout); game->mxdrawrect(640,0,641,getbary(),bgout,bgout); game->mxdrawrect(6,getbary()-2,634,getbary()+1,bgout,bgout); } // get next child int masterwinhandle::getnextchild(int x) { return x; } // get previous child int masterwinhandle::getprevchild(int x) { return x; } // Master Window Handle :: Get Next Window int masterwinhandle::getnextwindow(int mxIndex) { int mscan = mxIndex + 1; int lcount = 0; while(true) { for(int i = 0; i < MASTER_MAXWIN;i++) { if(win[i].mwindex == mscan) { return i; } } lcount++; mscan++; if(lcount > 100) { return -1; break; } } } // int get previous window by its mw window handle int masterwinhandle::getprevwindow(int mxIndex) { int mscan = mxIndex - 1; int lcount = 0; while(true) { for(int i = 0; i < MASTER_MAXWIN;i++) { if(win[i].mwindex == mscan) { return i; } } lcount++; mscan--; if(lcount > 100) { return -1; break; } } } // creating a socketed connection void masterwinhandle::addimsocket(SOCKET* s, displaylist* disp) { masterx_insert(" socket recvied , creating im "); int nchild; nchild = win[curwin].createchild("Instant Message", rand()%5 + 20,rand()%10 + 20,200,200); win[curwin].child[nchild].aim = true; int dirt; dirt = win[curwin].child[nchild].createmasterdisplay(0,disp,100,5,5,100,100,7); } //***** MASTER X WINDOW *CONTROLS* FUNCTIONS *****************/ // change the graphic current loaded in the image control void masterimage::setgraphic(char* filenamex) { if(filecheck(filenamex)) { on = true; visible = true; strcpy(filename,filenamex); if(surf) // release current { surf->Release(); } surf = DDLoadBitmap(game->scr->lpDD,filename); HBITMAP hbm; BITMAP bm; hbm = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP,0,0,LR_LOADFROMFILE | LR_CREATEDIBSECTION); if(hbm == NULL) { visible = false; } GetObject(hbm, sizeof(bm), &bm); // size DeleteObject(hbm); // Create Surface for this Bitmap int cw = bm.bmWidth; int ch = bm.bmHeight; w = cw; h = ch; } else { visible = false; } } // setting the surfaces quicky for a fast image switch // setting surface void masterimage::setsurf(char* filenamex,LPDIRECTDRAWSURFACE surfx,int wx, int hx) { if(filecheck(filenamex)) { if(surf) { surf->Release(); } surf = surfx; strcpy(filename,filenamex); w = wx; h = hx; } } // setting a master surface (for animations) void masterimage::setmsurf(mastersurf* msurf) { if(surf) { surf->Release(); } if(filecheck(msurf->filename)) { strcpy(filename,msurf->filename); w = msurf->w; h = msurf->h; surf = msurf->surf; } } // masterX surface ( image to pass to image control for animations ) mastersurf::mastersurf() { surf = NULL; } void mastersurf::loadsurface(char* filenamex) { if(game) { if(filecheck(filenamex)) { strcpy(filename,filenamex); if(surf) // release current { surf->Release(); } surf = DDLoadBitmap(game->scr->lpDD,filename); HBITMAP hbm; BITMAP bm; hbm = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP,0,0,LR_LOADFROMFILE | LR_CREATEDIBSECTION); if(hbm == NULL) { } GetObject(hbm, sizeof(bm), &bm); // size DeleteObject(hbm); // Create Surface for this Bitmap int cw = bm.bmWidth; int ch = bm.bmHeight; w = cw; h = ch; } else { } } } // die surface die void mastersurf::destroysurface() { if(surf) { surf->Release(); } w = 0; h = 0; } // master text display control (quick list style text display) void masterdisp::init(displaylist* displayx,int arraylen,int down) { add_index = 0; display_index = 0; array_len = arraylen; down_len = down; display = displayx; } void masterdisp::add(char* data,COLORREF c) { if(add_index <= array_len) { strcpy(display[add_index].data,data); display[add_index].fore = c; add_index++; } } // ** CLEAR ** void masterdisp::clear() { for(int i = 0; i < array_len; i++) { strcpy(display[add_index].data,""); display[add_index].fore = NULL; } add_index = 0; display_index = 0; } // **SCROLL DOWN** void masterdisp::scrolldown() { if(display_index < array_len) { display_index++; } } // **SCROLL UP** void masterdisp::scrollup() { if(display_index > 0) { display_index--; } } // THE FINAL [LINEAR FLAT SCREEN WINDOW DISPLAY] (EXTERNAL DISPLAY) // loading the graphics to the screen void masterchild::loadgraphics() { gsurf[0] = DDLoadBitmap(game->scr->lpDD,"windown.bmp"); gsurf[1] = DDLoadBitmap(game->scr->lpDD,"winclose.bmp"); gsurf[2] = DDLoadBitmap(game->scr->lpDD,"windown_down.bmp"); gsurf[3] = DDLoadBitmap(game->scr->lpDD,"winclose_down.bmp"); wdstate = 0;//2 wcstate = 1;//3 } // reload the surfaces void masterchild::reloadgraphics() { DDReLoadBitmap(gsurf[0],"windown.bmp"); DDReLoadBitmap(gsurf[1],"winclose.bmp"); DDReLoadBitmap(gsurf[2],"windown_down.bmp"); DDReLoadBitmap(gsurf[3],"winclose_down.bmp"); game->scr->lpBack->Restore(); } // destroying graphics off the screen void masterchild::destroygraphics() { for(int z = 0; z < 50; z++) { if(image[z].on) { if(image[z].surf) { image[z].surf->Release(); } } } for(z = 0; z < 5; z++) { if(gsurf[z]) { gsurf[z]->Release(); } } } // draw the background void masterchild::drawbg() { // drawing a masterX external flat screen child. // rectangle clipping. (ability to keyshift window children); if(y+h >= 480) { y = 480-h-2; } if(y < 0) { y = 1; } if(x+w >= 640) { x= 640-w-1; } if(x < 0) { x = 1; } game->mxdrawrect(x,y,x+w,y+h,bg_out,bg_out); game->mxdrawrect(x+1,y+1,x+w-1,y+h-1,bg_fill,bg_out2); game->mxdrawrect(x+2,y+2,x+w-2,y+16, bg_out2,bg_out2); game->text.setbkcolor(bg_out2); game->text.settextcolor(fore); game->text.printtext(title,x+4,y+2); game->mxdrawrect(x+w-16,y+0,x+w-1,y+16,bg_fill,bg_fill); game->mxdrawrect(x+w-32,y+0,x+w-16,y+15,bg_fill,bg_fill); game->mxdrawrect(x,y,x+w,y+1,bg_out,bg_out); game->text.setbkcolor(bg_out2); game->mxdrawrect(x+w-30,y+15,x+w-1,y+16,bg_out,bg_out); game->mxdrawrect(x+2,y+15,x+w-31,y+16,bg_shade1,bg_shade1); game->mxdrawrect(x+w-32,y+2,x+w-31,y+16,bg_shade1,bg_shade1); game->mxdrawrect(x+2,y+2,x+2,y+16,bg_shade2,bg_shade2); game->mxdrawrect(x+2,y+1,x+w-31,y+2,bg_shade2,bg_shade2); game->mxdrawrect(x+2,y+h-3,x+w-2,y+h-2,bg_shade2,bg_shade2); game->mxdrawrect(x+2,y+16,x+w-2,y+16+1,bg_shade1,bg_shade1); game->mxdrawrect(x+2,y+16,x+4,y+h-2,bg_shade1,bg_shade1); game->mxdrawrect(x+w-3,y+16,x+w-2,y+h-2,bg_shade2,bg_shade2); game->mxdrawrect(x+w-3,y+16,x+w-1,y+17,bg_out2,bg_out2); game->mxdrawrect(x+1,y+1,x+2,y+2,bg_out2,bg_out2); game->mxdrawrect(x+1,y+16,x+w-1,y+17,bg_out2,bg_out2); // drawing menu bar COLORREF boxbg = RGB(50,50,50); game->mxdrawrect(x+w-32,y+1,x+w-2,y+15,boxbg,boxbg); COLORREF boxcolor = RGB(100,100,100); game->mxdrawrect(x+w-31,y+2,x+w-1,y+14,boxcolor,boxcolor); HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,16,13); ddrval = game->scr->lpBack->BltFast(x+w-31,y+1,gsurf[wdstate],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); game->scr->lpBack->Restore(); } ddrval = game->scr->lpBack->BltFast(x+w-17,y+1,gsurf[wcstate],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); game->scr->lpBack->Restore(); } // mouse over state game->mxdrawrect(x+31,y+15,x+16,y+16,mouse_over,mouse_over); drawcontrols(); } // drawing the window controls void masterchild::drawcontrols() { // draw images on the background // draw textbox's, edit box's, // last draw labels int i; // graphics drawing for(i = 0; i < 50; i++) { if(image[i].on == true) { if(image[i].visible) { HRESULT ddrval; ddrval = game->mxbltsurf(image[i].surf,image[i].x+x+1,image[i].y+y+13,image[i].w,image[i].h,false); if(ddrval != DD_OK) { // reload and restore // image[i].surf = DDLoadBitmap(game->scr->lpDD, image[i].filename); image[i].surf->Restore(); game->scr->lpBack->Restore(); DDReLoadBitmap(image[i].surf,image[i].filename); // image[i].surf->Restore(); /* ddrval = game->mxbltsurf(image[i].surf,image[i].x+x+1,image[i].y+y+13,image[i].w,image[i].h,false); if(ddrval != DD_OK) { image[i].surf = DDLoadBitmap(game->scr->lpDD, image[i].filename); } */ } } } } // // text drawing for(i = 0; i < 50; i++) { // drawing display box //drawing labels if(label[i].on == true) { if(label[i].visible) { game->text.settextcolor(label[i].fore); game->text.setbkcolor(label[i].back); game->text.printtext(label[i].title,label[i].x+x+1,label[i].y+y+13); } } // drawing a master display (created with displaylist ) if(mdisplay[i].on) { int xz; int yz; int wz; int hz; xz = mdisplay[i].x + x + 1; yz = mdisplay[i].y + y + 13; wz = xz + mdisplay[i].w; hz = yz + mdisplay[i].h; game->mxdrawrect(xz,yz,wz,hz,mdisplay[i].back_fill,mdisplay[i].back_out); // drawing text game->text.setbkcolor(mdisplay[i].back_fill); COLORREF xfor; xfor = mdisplay[i].display[i].fore; game->text.settextcolor(xfor); int sx = xz+3; int sy = yz+3; int mi = mdisplay[i].display_index; for(int b = 0; b < mdisplay[i].down_len; b++) { if(mi <= mdisplay[i].array_len) { game->text.printtext(mdisplay[i].display[mi].data,sx,sy); } mi++; sy = sy + 13; } } // drawing a button if(mbutton[i].on == true) { // draw button // get size int rzx; int rzy; int rzw; int rzh; rzx = mbutton[i].x + x + 1; rzy = mbutton[i].y + y + 13; rzw = rzx + mbutton[i].w; rzh = rzy + mbutton[i].h; COLORREF xwhite; COLORREF xblack; xwhite = mbutton[i].push_white; xblack = mbutton[i].push_black; if(mbutton[i].idown) { game->text.setbkcolor(mbutton[i].down_backcolor); game->mxdrawrect(rzx,rzy,rzw,rzh,mbutton[i].down_backcolor,mbutton[i].down_outline); game->mxdrawrect(rzx,rzy+mbutton[i].h-2,rzw,rzy+mbutton[i].h,xwhite,xwhite); game->mxdrawrect(rzw-2,rzy,rzw,rzy+mbutton[i].h,xwhite,xwhite); game->mxdrawrect(rzx,rzy,rzx+1,rzh-3,xblack,xblack); game->mxdrawrect(rzx,rzy,rzw-3,rzy+2,xblack,xblack); } else { game->text.setbkcolor(mbutton[i].up_backcolor); game->mxdrawrect(rzx,rzy,rzw,rzh,mbutton[i].up_backcolor,mbutton[i].up_outline); game->mxdrawrect(rzx,rzy+mbutton[i].h-2,rzw,rzy+mbutton[i].h,xblack,xblack); game->mxdrawrect(rzw-2,rzy,rzw,rzy+mbutton[i].h,xblack,xblack); game->mxdrawrect(rzx,rzy,rzx+1,rzh-3,xwhite,xwhite); game->mxdrawrect(rzx,rzy,rzw-3,rzy+2,xwhite,xwhite); } int mhalf; mhalf = mbutton[i].h / 2; game->text.settextcolor(mbutton[i].forecolor); game->text.printtext(mbutton[i].title,rzx+3,rzy+mhalf-13+5 ); } // drawing links if(link[i].on == true) { if(link[i].visible) { game->text.settextcolor(link[i].txtcolor); game->text.setbkcolor(link[i].bgcolor); if(link[i].under) { game->text.setbkcolor(link[i].bgcolor); game->text.settextcolor(link[i].seltxtcolor); game->text.printtextunderline(link[i].title,link[i].x+x+1,link[i].y+y+13); } else { game->text.settextcolor(link[i].txtcolor); game->text.setbkcolor(link[i].bgcolor); game->text.printtext(link[i].title,link[i].x+x+1,link[i].y+y+13); } } } } // now we draw eDItz for(i = 0; i < 50; i++) { if(input[i].on == true) { game->text.setbkcolor(input[i].back); game->text.settextcolor(input[i].fore); HFONT cfont; cfont = game->text.font; game->text.font = input[i].font; char pdata[200]; strcpy(pdata,input[i].data); if(ecount > 3) { pdata[input[i].index] = '_'; ecount = 0; } else { pdata[input[i].index] = ' '; } ecount++; pdata[input[i].index+1] = 0; game->text.printtext(pdata,input[i].x+x+1,input[i].y+y+13); game->text.font = cfont;// restore; } } } // control keyinput void masterchild::keypress(int key) { } // master mouse click void masterchild::mouseclick(int mx, int my) { } // master mouse down void masterchild::mousedown(int mx, int my, int button) { if((mx > x) && (mx < x+w-32) && (my > y) && (my < y+15)) { wlock = true; wover = x-mx; wovery = y-my; } } // mouse up void masterchild::mouseup(int mx, int my, int button) { wlock = false; wover = 0; } // mouse move void masterchild::mousemove(int mx, int my, long button) { if((mx > x+w-32)&&(mx < mx+w) && (my > y+1) && (my < y+16)) { wdstate = 2; wcstate = 1; } else { wdstate = 0; } if((mx > x+w-16) &&(mx < x+w) && (my > y+1) && (my < y+16)) { wcstate = 3; wdstate = 0; } else { wcstate = 1; } if(button) { if(wlock == true) { x = mx + wover; y = my - wovery; } } } void masterchild::update() { drawbg(); drawcontrols(); } int masterchild::createmasterdisplay(int screen,displaylist* display,int array_len,int x, int y, int w, int h,int down_len) { int n = -1; for(int z = 0; z < 50; z++) { if(mdisplay[z].on == false) { n = z; break; } } // failure if(n == -1) { return -1; } mdisplay[n].init(display,array_len,down_len); mdisplay[n].x = x; mdisplay[n].y = y; mdisplay[n].w = w; mdisplay[n].h = h; mdisplay[n].on = true; mdisplay[n].back_fill = RGB(150,150,150); mdisplay[n].back_out = RGB(0,0,0); mdisplay[n].fore = RGB(200,0,0); return n; }