//lost.cpp // main #include "lost.h" mxOptions mx_opz;// pre-initlized options structure, will be imported from options.cpp // the screen void lostsidedead::setscreen(int s) { screen = s; } // user void lostsidedead::getuser(char* buff) { strcpy(buff,themaster.theuser.user); } // set the debug switch (true/false) void lostsidedead::debugswitch(bool sw) { debug = sw; themaster.debugswitch(sw); thespace.debugswitch(sw); } int lostsidedead::getscreen() { return screen; } // loadgraphics void lostsidedead::loadgraphics() { surf[0] = DDLoadBitmap(game->scr->lpDD,"masterdown.bmp"); surf[1] = DDLoadBitmap(game->scr->lpDD,"masterdown_down.bmp"); surf[2] = DDLoadBitmap(game->scr->lpDD,"masterup.bmp"); surf[3] = DDLoadBitmap(game->scr->lpDD,"masterup_down.bmp"); cursors[0] = DDLoadBitmap(game->scr->lpDD,"arrow_cur.bmp"); background = DDLoadBitmap(game->scr->lpDD,backgroundx); for(int i = 0; i < 10; i++) { if(cursors[i]) { DDSetColorKey(cursors[i],RGB(255,0,255)); } } } void lostsidedead::reloadgraphics() { game->scr->lpBack->Restore(); DDReLoadBitmap(surf[0], "masterdown.bmp"); DDReLoadBitmap(surf[1], "masterdown_down.bmp"); DDReLoadBitmap(surf[2], "masterup.bmp"); DDReLoadBitmap(surf[3], "masterup_down.bmp"); DDReLoadBitmap(cursors[0],"arrow_cur.bmp"); DDReLoadBitmap(background,backgroundx); } // draw bg wall paper void lostsidedead::drawbg() { if(bgon) { // draw it // drawicon shit HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,640,480); ddrval = game->scr->lpBack->BltFast(0,0,background,&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); } } } // draw cursor void lostsidedead::drawcursor() { if(MASTER_CURSOR == false) { HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,32,32); // change stuff if(cursorx < 0) { cursorx = 0; } if(cursorx > 640-32) { cursorx = 640-32;} if(cursory > 480-32) { cursory = 480-32+16; } if(cursory < 2) { cursory = 2; } ddrval = game->scr->lpBack->BltFast(cursorx,cursory-16,cursors[current_cur],&rcRect,DDBLTFAST_SRCCOLORKEY); //if(ddrval != DD_OK) { loadgraphics(); game->scr->lpBack->Restore(); } if(ddrval != DD_OK) { reloadgraphics();} } } void lostsidedead::killgraphics() { for(int z = 0; z < 10; z++) { if(surf[z]) { surf[z]->Release(); } if(cursors[z]) { cursors[z]->Release(); } } if(background) { background->Release(); } } // deconstruct lostsidedead::~lostsidedead() { } // mouse goes up void lostsidedead::mouseup(int x, int y, int button) { if(thestate == 0) { curstate = 1; } else { curstate = 3; } } // mouse goes down void lostsidedead::mousedown(int x, int y, int button) { if(runmenu.visible) { } else { if(themasterwin.win[themasterwin.curwin].im_attach == false) { if(y < getbary()) { if(thestate != 1) { curstate = 2; thestate = 1; theswitch = true; masterx_interupt("#mxs_masterfall"); } } } } int bx; int by; bx = themasterwin.barx; by = themasterwin.bary; if(x > bx) { if(x < bx+16) { if(y > by) { if( y < by+20) { if(thestate == 0) { curstate = 0; } else { curstate = 2; } stateswitch(); } } } } } // switch the state void lostsidedead::stateswitch() { pSound[2]->Play(0,0,0); themasterwin.dshow = false; if(thestate == 0) { curstate = 2; thestate = 1; theswitch = true; themaster.master_focus = true; } else { curstate = 0; thestate = 0; theswitch = true; themaster.master_focus = false; } } // draw the switch void lostsidedead::drawswitch() { if(theswitch == true) { themasterwin.dshow = false; if(thestate == 1) { if(themasterwin.bary < 460) { themasterwin.bary = themasterwin.bary + 10; } else { theswitch = false; curstate = 3; } } } if(thestate == 0) { if(themasterwin.bary > 260) { themasterwin.bary = themasterwin.bary - 10; } else { themasterwin.bary = 260; theswitch = false; } } } //draw the run menu void lostsidedead::drawrun() { runmenu.visible = run_visible; runmenu.update(); } // init game void lostsidedead::init(HWND hwndx,HINSTANCE hInstx,MasterXHWND* m) { curstate = 1; hInst = hInstx; hwnd = hwndx; game = m; game->init(hwndx); strcpy(backgroundx,"wallpaper.bmp"); thestate = 0; themaster.init(game,0,280); thespace.init(game); // thechat.init(game); runmenu.init(game); themaster.printtextf("MasterX Online ",255,0,0); themaster.printtextf("system loaded [ Lost Side Dead ] ",255,0,0); themaster.printtextf("site: www.8op.com/lostsidedead/ im me: master on lsd ",255,0,0); themaster.printtextf("launching startup/reading registery.. ",0,0,255); // program init // get user loadgraphics(); pSound[0] = DSLoadSoundBuffer(game->pDS, MAKEINTRESOURCE(IDR_WAVE3)); pSound[1] = DSLoadSoundBuffer(game->pDS, MAKEINTRESOURCE(IDR_WAVE4)); pSound[2] = DSLoadSoundBuffer(game->pDS, MAKEINTRESOURCE(IDR_WAVE5)); pSound[3] = DSLoadSoundBuffer(game->pDS, MAKEINTRESOURCE(IDR_WAVE6)); pSound[4] = DSLoadSoundBuffer(game->pDS, MAKEINTRESOURCE(IDR_WAVE6)); pSound[5] = DSLoadSoundBuffer(game->pDS, MAKEINTRESOURCE(IDR_WAVE7)); ifstream fin("muser.lsd",ios::binary); fin.read((char*)&themaster.theuser,sizeof(themaster.theuser)); fin.close(); themaster.theuser.loaded++; if(themaster.theuser.loaded == 1) { themaster.printtextf("first time load... require user name: ",0,0,255); themaster.inputtext("usersetup"); } else { themaster.printtextf("successfuly started...",0,0,255); themaster.printtextf(" - masterX virtual machine - activated ",0,255,255); char fullbuff[100]; strcpy(fullbuff, " - loaded by user: "); strcat(fullbuff,themaster.theuser.user); strcat(fullbuff, " total load: "); char tload[10]; itoa(themaster.theuser.loaded,tload,10); strcat(fullbuff,tload); strcat(fullbuff, " "); themaster.printtextf(fullbuff,0,255,255); // thechat.newim(INVALID_SOCKET); themaster.printtextf("entercmd =)> ",0,255,255); themaster.inputtext("mastercmd"); ofstream fout("muser.lsd",ios::binary); fout.write((char*)&themaster.theuser,sizeof(themaster.theuser)); fout.close(); } themasterwin.init(game); // create setup stuff wel = themasterwin.masterWindow("Welcome",40,40,357,200,RGB(0,0,0)); sys = themasterwin.masterWindow("System",100,30,210,195 ,RGB(0,0,0)); serv = themasterwin.masterWindow("My Server",100,30,200,200,RGB(0,0,0)); lsd = themasterwin.masterWindow("LostSideDead",40,40,357,200,RGB(0,0,0)); themasterwin.win[wel].setscreen(0); themasterwin.win[sys].setscreen(0); themasterwin.win[serv].setscreen(0); themasterwin.win[lsd].setscreen(0); themasterwin.win[lsd].bgcolor = RGB(0,0,50); themasterwin.win[lsd].titcolor = RGB(0,0,0); themasterwin.win[lsd].outline = RGB(0,0,0); int lo = themasterwin.win[lsd].createimage(0,"lsdlogo.bmp",0,0); themasterwin.win[lsd].createimage(1,"lsdlogo2.bmp",0,0); strcpy(themasterwin.win[sys].mybackground,"wallpaper2.bmp"); strcpy(themasterwin.win[lsd].mybackground,"wallpaper3.bmp"); int welchl; welchl = themasterwin.win[wel].createchild("MasterX Intro",400,40,230,150); themasterwin.win[wel].child[welchl].bar_fill = RGB(100,100,100); themasterwin.win[wel].child[welchl].bar_out = RGB(100,150,100); themasterwin.win[wel].child[welchl].bg_fill = RGB(0,0,0); themasterwin.win[wel].child[welchl].bg_out = RGB(0,0,0); themasterwin.win[wel].child[welchl].bg_out2 = RGB(100,100,100); themasterwin.win[wel].child[welchl].bg_shade1 = RGB(100,100,100); themasterwin.win[wel].child[welchl].bg_shade2 = RGB(100,100,100); /* mastersurf s; s.game = game; s.loadsurface("lsdlogo2.bmp"); themasterwin.win[lsd].image[0][lo].setmsurf((mastersurf*)&s); // NOTE: MASTERSURF MUST BE RELEASED MANUALY!!!!! s.destroysurface(); */ int enterb = themasterwin.win[lsd].createbutton(0," Enter","enterlsd",295,150,50,25); int goback = themasterwin.win[lsd].createbutton(1," Back","gohome",295,150,50,25); themasterwin.win[lsd].mbutton[0][enterb].down_backcolor = RGB(0,0,30); themasterwin.win[lsd].mbutton[0][enterb].up_backcolor = RGB(0,0,75); themasterwin.win[lsd].mbutton[0][enterb].push_black = RGB(0,0,0); themasterwin.win[lsd].mbutton[0][enterb].push_white = RGB(0,0,200); themasterwin.win[lsd].mbutton[0][enterb].down_outline = RGB(100,0,0); // themasterwin.win[lsd].mbutton[1][goback].down_backcolor = RGB(0,0,30); themasterwin.win[lsd].mbutton[1][goback].up_backcolor = RGB(0,0,75); themasterwin.win[lsd].mbutton[1][goback].push_black = RGB(0,0,0); themasterwin.win[lsd].mbutton[1][goback].push_white = RGB(0,0,200); themasterwin.win[lsd].mbutton[1][goback].down_outline = RGB(100,0,0); int intro; intro = themasterwin.win[lsd].createbutton(1," Intro","lsdintro",10,150,50,25); int poem; poem = themasterwin.win[lsd].createbutton(1," Poem","lsdpoem",60,150,50,25); int f; f = themasterwin.win[lsd].createbutton(1," Idea","lsdidea",110,150,50,25); int a; a = themasterwin.win[lsd].createbutton(1," About","lsdabout",160,150,50,25); for(int z = intro; z < a+1;z++) { themasterwin.win[lsd].mbutton[1][z].down_backcolor = RGB(30,0,0); themasterwin.win[lsd].mbutton[1][z].up_backcolor = RGB(75,0,0); themasterwin.win[lsd].mbutton[1][z].push_black = RGB(0,0,0); themasterwin.win[lsd].mbutton[1][z].push_white = RGB(200,0,0); themasterwin.win[lsd].mbutton[1][z].down_outline = RGB(0,0,100); themasterwin.win[lsd].mbutton[1][z].forecolor = RGB(0,0,200); } //themasterwin.win[wel].createlabel("testing",0,0,RGB(0,0,0),RGB(255,0,0)); themasterwin.win[wel].createimage(0,"welcome.bmp",0,0); sitelink = themasterwin.win[wel].createlink(0,"http://www.8op.com/masterx","masterx_site",220,170); //themasterwin.win[wel].createdisplay("welcome user stuff\n\n",3,200,100,100); char line[50]; char sn[25]; getusersn(sn); strcpy(line, "Welcome "); strcat(line,sn); strcat(line, " to MasterX"); themasterwin.win[wel].createlabel(0,line,5,100,RGB(0,0,0),RGB(255,0,0)); themasterwin.win[wel].createlabel(0,"masterx is currently under construction. program completion 75%",5,115,RGB(0,0,0),RGB(255,0,0)); themasterwin.win[wel].createlabel(0,"\"Im Not Insane , Just Devious in my Sanity\"",5,130,RGB(0,0,0),RGB(255,0,0)); //themasterwin.win[wel].createlabel(0,"-master on lsd",5,145,RGB(0,0,0),RGB(255,0,0)); themasterwin.win[wel].createlabel(0,"-master",5,145,RGB(0,0,0),RGB(255,0,0)); /* int dis = themasterwin.win[wel].createmasterdisplay(0,(displaylist*)&dlist,10,10,10,100,100,7); themasterwin.win[wel].mdisplay[0][dis].add("test",RGB(100,0,0)); themasterwin.win[wel].mdisplay[0][dis].add("testX",RGB(100,0,0)); themasterwin.win[wel].mdisplay[0][dis].add("testX2",RGB(100,0,0)); themasterwin.win[wel].mdisplay[0][dis].add("testX3",RGB(100,0,0)); themasterwin.win[wel].mdisplay[0][dis].add("testX4",RGB(100,0,0)); themasterwin.win[wel].mdisplay[0][dis].add("testX5",RGB(100,0,0)); themasterwin.win[wel].mdisplay[0][dis].add("testX6",RGB(100,0,0)); */ themasterwin.win[sys].createbutton(0," X On","acid",10-5,5,50,25 ); themasterwin.win[sys].createbutton(0,"Log On","log",60-5,5,50,25); themasterwin.win[sys].createbutton(0," Site","site",110-5,5,50,25); themasterwin.win[sys].createbutton(0," Kill","kill",160-5,5,50,25); themasterwin.win[sys].createimage(0,"mxsys.bmp",5,35); //themasterwin.win[sys].createtext("testing..\ntesting\nandstuff",10,10,100,100); themasterwin.selectwindow(themasterwin.findwindow("Welcome")); // a pass window command. } // proc a window message void lostsidedead::messageproc(int window, int child, masterwinmsg msg) { // do a switch on window (inside of window doa switch on child) // inside of child do a switch on msg switch(msg.msg) { case MX_UPDATE: // screen update if(window == mxhlp) { int mxscr; mxscr = themasterwin.win[mxhlp].Screen; int idex = themasterwin.win[mxhlp].mdisplay[mxscr][hdisp].display_index; int idlen = themasterwin.win[mxhlp].mdisplay[mxscr][hdisp].array_len; if(idex >= idlen) { themasterwin.win[mxhlp].mdisplay[mxscr][hdisp].display_index = 0; } xcount++; if(xcount > 50) { themasterwin.win[mxhlp].mdisplay[mxscr][hdisp].scrolldown(); xcount = 0; } } break; } if(window == mxhlp) { if(msg.mx_type == MXT_BUTTON) { themasterwin.destroywindow(mxhlp); } } if(window == wel) { switch(msg.mx_type) { case MXT_LINK: switch(msg.msg) { case MX_LINKCLICK: if(child == sitelink) { ShowWindow(FindWindow("LostSideDead",NULL),SW_MINIMIZE); ShellExecute(0,"open","http://www.8op.com/masterx/", NULL,NULL,SW_SHOW); } // then switch the child break; } break; } } if(window == lsd) { int lScreen; lScreen = themasterwin.win[lsd].Screen; switch(msg.mx_type) { case MXT_BUTTON: if(msg.msg == MX_BUTTONCLICK) { if(strstr(msg.id,"enterlsd")) { themasterwin.win[lsd].setscreen(1); } if(strstr(msg.id,"gohome")) { themasterwin.win[lsd].setscreen(0); } } break; } } if(window == sys) { int cScreen; cScreen = themasterwin.win[sys].Screen; switch(msg.mx_type) { case MXT_BUTTON: if(msg.msg == MX_BUTTONCLICK) { if(strstr(msg.id,"kill")) { // masterx_interupt("aol signedon?"); // masterx_insert("testing.."); masterx_interupt3("quit;"); } if(strstr(msg.id,"site")) { // web site } if(strstr(msg.id,"acid")) { // acid char buff[100]; strcpy(buff,themasterwin.win[sys].mbutton[cScreen][child].title); if(strstr(buff,"On")) { strcpy(themasterwin.win[sys].mbutton[cScreen][child].title," X Off"); masterx_interupt("xmode on;"); } else { strcpy(themasterwin.win[sys].mbutton[cScreen][child].title," X On"); masterx_interupt("xmode off;"); } } if(strstr(msg.id,"log")) { char xbuff[100]; strcpy(xbuff,themasterwin.win[sys].mbutton[cScreen][child].title); if(strstr(xbuff,"On")) { strcpy(themasterwin.win[sys].mbutton[cScreen][child].title,"Log Off"); masterx_interupt("master log"); } else { strcpy(themasterwin.win[sys].mbutton[cScreen][child].title,"Log On"); masterx_interupt("log off"); } } } break; } } } // recv a windows command void lostsidedead::recvcmd(char* cmd) { // throw current program to master if(strstr(cmd,"throw")) { themasterwin.win[themasterwin.curwin].windowthrow(); char wbuff[100]; strcpy(wbuff,themasterwin.win[themasterwin.curwin].title); strcat(wbuff," now being thrown to master :) "); mprintf(wbuff,200,0,0); } if(strstr(cmd,"command")) { int xcmd; xcmd = themasterwin.findwindow("Command"); if(xcmd == -1) { mx_cmd = themasterwin.masterWindow("Command",10,10,302,200,RGB(0,0,0)); cmd_disp = themasterwin.win[mx_cmd].createmasterdisplay(0,(displaylist*)&cmdl,500,5,5,290,160,8); themasterwin.win[mx_cmd].mdisplay[0][cmd_disp].add("MasterX - Command Shell",RGB(200,0,0)); themasterwin.win[mx_cmd].mdisplay[0][cmd_disp].back_fill = RGB(0,0,0); themasterwin.win[mx_cmd].mdisplay[0][cmd_disp].back_out = themasterwin.win[mx_cmd].outline; cmd_input = themasterwin.win[mx_cmd].createinput(0,7,165,40); // give the input focus to this one themasterwin.win[mx_cmd].input[0][cmd_input].focus = true; } } // is successful if(isstrequal(cmd,"display_help")) { int hlp; hlp = themasterwin.findwindow("About"); if(hlp == -1) { int img; hlp = themasterwin.masterWindow("About",10,10,302,214,RGB(0,0,0)); mxhlp = hlp; img = themasterwin.win[hlp].createimage(0,"lsdlogo3.bmp",0,0); int px; int py; int pw; int ph; px = 10; pw = 95; py = 5; ph = 292; hdisp = themasterwin.win[hlp].createmasterdisplay(0,(displaylist*)&adisplay,px,py,pw,ph,100,7); COLORREF xbg; xbg = RGB(53,32,215); COLORREF xr; xr = RGB(0,0,0); themasterwin.win[hlp].mdisplay[0][hdisp].back_fill = xbg; themasterwin.win[hlp].mdisplay[0][hdisp].add("MasterX Online Virtual Dimension",RGB(200,0,0)); themasterwin.win[hlp].mdisplay[0][hdisp].add("Lost Side Dead =)> Software",RGB(0,0,200)); themasterwin.win[hlp].mdisplay[0][hdisp].add("",RGB(0,0,0)); themasterwin.win[hlp].mdisplay[0][hdisp].add("This Application is Dedicated to you",RGB(100,100,100)); themasterwin.win[hlp].mdisplay[0][hdisp].add("You know who you are.",RGB(100,100,100)); themasterwin.win[hlp].mdisplay[0][hdisp].add("Pyschedelic String: Means a artistic expression/ ",RGB(0,0,0)); themasterwin.win[hlp].mdisplay[0][hdisp].add("graphics program done with code",RGB(100,0,0)); themasterwin.win[hlp].mdisplay[0][hdisp].add("[web site url]",RGB(100,0,0)); themasterwin.win[hlp].mdisplay[0][hdisp].add("Coded by Jared Bruni",RGB(100,100,100)); themasterwin.win[hlp].mdisplay[0][hdisp].add("Graphics by Jared Bruni/Soul",xr); themasterwin.win[hlp].mdisplay[0][hdisp].add("Additonal BASIC code, [x]",xr); themasterwin.win[hlp].mdisplay[0][hdisp].add("[web site url]",xr); themasterwin.win[hlp].mdisplay[0][hdisp].add("",xr); themasterwin.win[hlp].mdisplay[0][hdisp].add("Creator of MasterX/Head Programmer Jared Bruni",xr); themasterwin.win[hlp].mdisplay[0][hdisp].add("",xr); themasterwin.win[hlp].mdisplay[0][hdisp].add("",xr); int bt_quit; bt_quit = themasterwin.win[hlp].createbutton(0," Ok!","#hlpok",243,165,50,25); themasterwin.win[hlp].mbutton[0][bt_quit].down_backcolor = xbg; themasterwin.win[hlp].mbutton[0][bt_quit].down_outline = xbg; themasterwin.win[hlp].mbutton[0][bt_quit].up_backcolor = xbg; themasterwin.win[hlp].mbutton[0][bt_quit].up_backcolor = xbg; // xbg = RGB(53,32,215); COLORREF xbgli= RGB(70,40,255); COLORREF xbgdark = RGB(70,30,100); themasterwin.win[hlp].mbutton[0][bt_quit].push_black = xbgdark; themasterwin.win[hlp].mbutton[0][bt_quit].push_white = xbgli; } else { themasterwin.selectwindow(hlp); } } if(isstrequal(cmd, "display_settings")) { int set; set = themasterwin.findwindow("Settings.."); if(set == -1) { themasterwin.masterWindow("Settings..",40,10,200,200,RGB(0,0,0)); } else { themasterwin.selectwindow(set); } } } // frames for debug void lostsidedead::dumpframe() { if(debug) { char frameb[105]; strcpy(frameb,"debug-on ["); strcat(frameb,"frame: "); char frameb2[10]; itoa(frame,frameb2,10); strcat(frameb,frameb2); strcat(frameb,"]"); game->text.printtext(frameb,10,10); } } // the destroyer of death void lostsidedead::kill() { // anything i need to do before i DIE die_test = false; // kill all graphics. killgraphics(); themasterwin.killgraphics(); themaster.killgraphics(); thespace.killgraphics(); runmenu.killgraphics(); for(int i = 0; i < MASTER_MAXWIN;i++) { if(themasterwin.win[i].on) { themasterwin.win[i].killgraphics(); } } game->scr = NULL; game = NULL; themasterwin.game = NULL; for(i = 0; i < MASTER_MAXWIN;i++) { if(themasterwin.win[i].game) { game = NULL; } } runmenu.game = NULL; thespace.game = NULL; themaster.game = NULL; thechat.game = NULL; } // keyinput void lostsidedead::keyinput(int key) { // keyinput if(debug) { if(key == VK_ESCAPE){ exit(0); } // bail out } switch(screen) { case 0: if(GetAsyncKeyState(16)) { if((key == VK_DOWN)||(key == VK_LEFT)||(key == VK_RIGHT)||(key == VK_UP)) { themasterwin.keyinput(key); return; } } // master window throw if(thestate == 0) { themaster.keypress(key); } else { // master window trip if(GetAsyncKeyState(16)) { char bx; bx = key; if(bx == 'R') { masterx_interupt("#mxw_trip "); masterx_interupt("#mxw_winfix "); return; } if(bx == 'T') { masterx_interupt("#mxw_throw"); return; } } themasterwin.keyinput(key); } break; case 1: thespace.keyinput(key); break; } } // click of the mouse has occured void lostsidedead::mouseclick(int x, int y) { int mx; int my; mx = x; my = y; // the um movements for interface shit if(mx > 605) { if(my > themasterwin.bary) { if(my < themasterwin.bary+20) { if(run_visible == false) { run_visible = true; } else { run_visible = false; } } } } if(mx < 605) { run_visible = false; } switch(screen) { case 0: // do code to approximate who gets input // what program (via) master , im etc thechat.mouseclick(x,y); themasterwin.mouseclick(x, y); break; case 1: break; } } // incoming mouse movements void lostsidedead::mousemove(int mx, int my, long mbutton) { cursorx = mx; cursory = my; runstate = 0; if(mx > 605) { if(my > themasterwin.bary) { if(my < themasterwin.bary+20) { runstate = 1; } } } if(mx < 605) { if(mbutton) { run_visible = false; } } themasterwin.mousemove(mx,my,mbutton); } // update void lostsidedead::update() { if(xstart == false) { xstartc++; if(xstartc > 7) { soundswitch("masterwelcome"); xstart = true; } } if(die_test) { game->clear(); drawbg(); draw(); drawcursor(); /* int ax,ay,aw,ah; ax = 10; ay = 10; aw = 100; ah = 100; // x game->text.printtextrect("Hey Testing..\nTesting\nagian and agian and agian she says\nplease hear me out man\nyeah thats the truth",ax,ay,aw+ax,ah+ay); */ if(theswitch == true) { themasterwin.barchange(); themasterwin.bswitch = true; } else { themasterwin.bswitch = false; } game->update(); frame++; if(frame > 100) { frame = 0; } } } // draw appropriate screen void lostsidedead::draw() { switch(screen) { case 0: themasterwin.update(); draw_master(); HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,16,16); // change stuff drawswitch(); if(theswitch == false) { ddrval = game->scr->lpBack->BltFast(themasterwin.barx+5,themasterwin.bary+1,surf[curstate],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); //if(ddrval != DD_OK) { loadgraphics(); game->scr->lpBack->Restore(); } if(ddrval != DD_OK) { reloadgraphics();} } themasterwin.barover(); // draw run & or run menu COLORREF pBg; pBg = game->text.bk; if(runstate == 0) { game->text.settextcolor(RGB(255,0,0)); } else { game->text.settextcolor(RGB(0,0,255)); } game->text.setbkcolor(RGB(164,149,149)); if(theswitch == false) { game->text.printtext("Run",605,themasterwin.bary+3); } game->text.bk = pBg; // draw the RUN MENU drawrun(); break; case 1: draw_space(); break; } dumpframe(); } // draw master screen void lostsidedead::draw_master() { if(thestate == 0) { if(theswitch == false) { themaster.update(); } } // thechat.update(); // have the master win , return windows message processing information. // themasterwin.update(); } void lostsidedead::draw_space() { thespace.update(); } // the screen stuff for drawing his screen (input/output) stream void masterscreen::logto(char* filename) { if(logon == true) { logoff(); } logout.open(filename); logon = true; logout << "MasterX\n"; logout << "www.8op.com/masterx/\n"; logout << "everything inside of { } are the RGB defined before its |\n"; logout << "all others are standard color.\n"; char datebuf[9]; char timebuf[9]; _strdate(datebuf); _strtime(timebuf); logout << "log started on: " << datebuf << " started at: " << timebuf << "\n"; } void masterscreen::logoff() { if(logon == true) { char datebuf[9]; char timebuf[9]; _strdate(datebuf); _strtime(timebuf); logout << "log stoped on: " << datebuf << " stoped at: " << timebuf << "\n"; logon = false; logout.close(); } logon = false; } // screen deconstructor masterscreen::~masterscreen() { if(logon) { logoff(); } } // addline void masterscreen::addline(char* buff) { if(curline >= MASTER_SCREENLINE) { clear(); } strcpy(line[curline].line,buff); curline++; curpos = curline - 12; // format buff, for just data within (no colors) if(strstr(buff, "=)>")) { } else { if(logon == true) { logstr(buff); } } } // log buffer string to data file void masterscreen::logstr(char* buff) { if(logon == true) { // format buffer int ck1; int ck2; int ck3; ck1 = instr(buff, "{"); ck2 = instr(buff, "|"); ck3 = instr(buff, "}"); char lbuff[150]; char lbuff2[150]; if(logrgb == true) { ck2 = 0; } if((ck2)) { rightstr(buff,lbuff,ck2+1); ck3 = instr(lbuff,"}"); leftstr(lbuff,lbuff2,ck3-1); logout << lbuff2 << "\n"; } else { logout << buff << "\n"; } } } // clear the screen void masterscreen::clear() { for(int z=0;z 0) { curpos--; } } // change any line manual l33tr0 void masterscreen::cpyline(int linex, char* buff) { strcpy(line[linex].line,buff); // manual logstr(buff); } // attach data to end of any line void masterscreen::catline(int linex,char* buff) { char** temp; char* ptemp; temp = new PCHAR[strlen(line[linex].line)+strlen(buff)]; ptemp = (char*)temp; leftstr(line[linex].line,ptemp,instr(line[linex].line,"}")-1); strcat(ptemp,buff); strcat(ptemp,"}"); strcpy(line[linex].line,ptemp); logstr(buff); } // scroll the data down void masterscreen::scrolldown() { if(curpos < curline - 12) { curpos++; } } // get the length (how many total lines) int masterscreen::getlen() { return curline; } // find a string in the current (linex) and return its position int masterscreen::findlinestr(int linex, char* buff) { int rt; rt = instr(line[linex].line,buff); return rt; } // find a string in the total and return its line int masterscreen::findstr(char* buff) { for(int i = 0; i < getlen(); i++) { int chk; chk = instr(line[i].line,buff); if(chk) { return i; } } return -1; // fail } // master the wise compbot // deconstructor master::~master() { } void master::killgraphics() { for(int i = 0; i < 6;i++) { if(background[i]) { background[i]->Release(); } } if(bg2) { bg2->Release(); } } void master::init(MasterXHWND* gamex,int xx, int yy) { game = gamex; x = xx; y = yy; loadgraphic(); curpos = 0; mbg_index = 0; dir = true; } // debug switch void master::debugswitch(bool sx) { debug = sx; } // update the master void master::update() { HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,640,195); if(xmode) { ddrval = game->scr->lpBack->BltFast(x,y,background[mbg_index],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphic();} } else { ddrval = game->scr->lpBack->BltFast(x,y,bg2,&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphic(); } } drawtext(); if(debug) { game->text.printtext("// ; [master-on]",10,30); } // finaly draw a rectangle game->mxdrawrect(0,475,640,480,RGB(0,0,0),RGB(0,0,0)); if(dir) { mbg_index++; } else { mbg_index--; } if(mbg_index >= 6) { dir = false; mbg_index = 5; } if(mbg_index <= 0) { dir = true; mbg_index = 0; } } // keyinput void master::keypress(int key) { if(true) { // key switch if(input_on == false) { switch(key) { case 13: break; case VK_DOWN: scrolldown(); break; case VK_UP: scrollup(); break; } } else { switch(key) { case 8: if(input_temppos > 0) { input_temppos--; input_temp[input_temppos] = 0; return; } else { return; } break; case 20: if(caps) { caps = 0; } else { caps = 420; } return; break; case VK_DOWN: case VK_UP: case VK_LEFT: case VK_RIGHT: case 16: case 44: case 17: return; break; case 13:// enter input_on = false; strcat(input_temp," "); drawscr.catline(drawscr.getlen()-1,input_temp); inputproc(input_name,input_temp); ZeroMemory(input_temp,sizeof(input_temp)); strcpy(input_temp,""); input_temp[0] = 0; game->playsound(IDR_WAVE2); return; break; } char cur; cur = fixkey(key,caps,true); // 20 & 9 if(line_len < 80) { input_temp[input_temppos] = cur; input_temppos++; } } } } // load graphics void master::loadgraphic() { background[0] = DDLoadBitmap(game->scr->lpDD,"Masterbg.bmp"); background[1] = DDLoadBitmap(game->scr->lpDD,"Masterbg2.bmp"); background[2] = DDLoadBitmap(game->scr->lpDD,"Masterbg3.bmp"); background[3] = DDLoadBitmap(game->scr->lpDD,"Masterbg4.bmp"); background[4] = DDLoadBitmap(game->scr->lpDD,"Masterbg5.bmp"); background[5] = DDLoadBitmap(game->scr->lpDD,"Masterbg6.bmp"); bg2 = DDLoadBitmap(game->scr->lpDD,"Masterbg_mode2.bmp"); } void master::reloadgraphic() { bg2->Restore(); game->scr->lpBack->Restore(); DDReLoadBitmap(background[0],"Masterbg.bmp"); DDReLoadBitmap(background[1],"Masterbg2.bmp"); DDReLoadBitmap(background[2],"Masterbg3.bmp"); DDReLoadBitmap(background[3],"Masterbg4.bmp"); DDReLoadBitmap(background[4],"Masterbg5.bmp"); DDReLoadBitmap(background[5],"Masterbg6.bmp"); DDReLoadBitmap(bg2,"Masterbg_mode2.bmp"); } // draw text void master::drawtext() { // process data to automaticly terminate the string with / on end int startx,starty; startx= 30; starty = 305; int drawpos; drawpos = drawscr.curpos; for(int i = 0; i < 12; i++) { strcpy(curdata,drawscr.line[drawpos].line); if(strlen(curdata)) { // draw current data with color int chk; chk = instr(curdata, "{"); if(chk+1)// test if we have colorz { int len; len = strlen(curdata); int openc[100]; int closec[100]; int braceo_index = 0; int bracec_index = 0; for(int r = 0; r < len; r++) { if(curdata[r] == '{') { openc[braceo_index] = r; braceo_index++; } if(curdata[r] == '}') { closec[bracec_index] = r; bracec_index++; } } // proccess line for display in rich color int printx; printx = startx; for(int z = 0; z < bracec_index; z++) { char cursec[100]; midstr(curdata,cursec,openc[z]+1,closec[z]-1); char colordat[25]; char pdat[100]; int sep; sep = instr(cursec, "|"); rightstr(cursec,pdat,sep+1); leftstr(cursec,colordat,sep-1); char cR[10]; char cG[10]; char cB[10]; int fchk; fchk = instr(colordat,","); midstr(colordat,cR,0,fchk); char tbuff[25]; midstr(colordat,tbuff,fchk+1,strlen(colordat)); fchk = instr(tbuff, ","); midstr(tbuff,cG,0,fchk); midstr(tbuff,cB,fchk+1,strlen(tbuff)); int cr; int cg; int cb; cr = atoi(cR); cg = atoi(cG); cb = atoi(cB); if(strlen(cR)) { game->text.settextcolor(RGB(cr,cg,cb)); } if(input_on) { if(i == 11) { strcat(pdat,input_temp); countx++; if(countx > 4) { countx = 0; strcat(pdat, "_"); } line_len = strlen(pdat); } } game->text.setbkcolor(RGB(0,0,0)); game->text.printtext(pdat,printx,starty); printx = printx + strlen(pdat); } // game->text.printtext("testing",startx,starty); } else { if(input_on) { if(i == 1) { strcat(curdata,input_temp); countx++; if(countx > 4) { strcat(curdata,"_"); countx = 0; } line_len = strlen(curdata); } game->text.settextcolor(RGB(255,0,0)); game->text.printtext(curdata,startx,starty); } } // game->text.printtext(curdata,startx,starty); } // if cursor draw it starty = starty+12; drawpos++; } } // inputdat void master::inputtext(char* name) { // change mode, select position of cursor input_on = true; input_pos = strlen(drawscr.line[drawscr.getlen()].line) + 1; strcpy(input_name,name); input_temppos = 0; // inputi s now on } // proccess new data input after word (via shit continues) void master::inputproc(char* name, char* input) { // software interupt by command prompt if(strstr(name,"mastercmd")) { cmdproc(input); printtextf("entercmd =)> ",0,255,255); inputtext("mastercmd"); } // software interupt if(strstr(name,"masterinterupt")) { char** t; t = new PCHAR[strlen(input)+10]; char* pt; pt = (char*) t; strcpy(pt, "masterXinterupt =)> "); strcat(pt, input); strcat(pt, " "); printtextf(pt,0,0,255); drawscr.logstr(pt); cmdproc(input); printtextf("entercmd =)> ",0,255,255); int pre_pos; pre_pos = input_temppos; inputtext("mastercmd"); input_temppos = pre_pos; } if(strstr(name, "masterinsert")) { char** mbuff; mbuff = new PCHAR[strlen(input)+20]; char* inbuff; inbuff = (char*)mbuff; if(strstr(name,"masterinsertf")) { strcpy(inbuff,input); } else { strcpy(inbuff,"{0,255,255|"); strcat(inbuff,input); strcat(inbuff," }"); } drawscr.cpyline(drawscr.getlen()-1,inbuff); // printtextf(input,0,255,255); printtextf("entercmd =)> ",0,255,255); inputtext("mastercmd"); } // insert color text if(strstr(name, "masterinsert_format")) { } if(strstr(name, "username")) { strcpy(user,input); } if(strstr(name,"usersetup")) { strcpy(theuser.user,input); ofstream fout("muser.lsd",ios::binary); fout.write((char*)&theuser,sizeof(theuser)); fout.close(); inputproc("mastercmd",""); } // master bot input proc mbot.incomingmessage(input); } // command proccess (for OS) void master::cmdproc(char* cmd) { mx_opz = getop(); if(mx_opz.cmdcase == false) { lcase(cmd); } if(strstr(cmd,"#mxw_winfix")) { winfix(); mprintf("masterX [-win re-adjust]-.",0,0,200); return; } // master x sound command if(strstr(cmd,"#mxs_")) { soundswitch(cmd); } if((strstr(cmd,"time")) || (strstr(cmd,"date"))) { char datebuf[9]; char timebuf[9]; _strdate(datebuf); _strtime(timebuf); char otime[100]; strcpy(otime," current time: "); strcat(otime, timebuf); strcat(otime, " "); mprintf(otime,200,0,0); strcpy(otime," current date: "); strcat(otime, datebuf); strcat(otime," "); mprintf(otime,200,0,0); return; } if(strstr(cmd,"xmode off;")) { if(xmode != false) { xmode = false; mprintf("Master [X] Mode Deactivation ",200,0,0); } else { mprintf("Already Deactive..",200,0,0); } } if(strstr(cmd,"xmode on;")) { if(xmode != true) { xmode = true; mprintf("Master [X] Mode Activated..",200,0,0); } else { mprintf("Master [X] mode already on..",200,0,0); } } // mxw if(strstr(cmd,"#mxw_trip")) { masterx_interupt("#mxw_throw "); mxforceup(); mprintf("- (auto bar up flip) ",200,0,0); return; } if(strstr(cmd,"#mxw_winscan")) { mxdisplaywin(); return; } if(strstr(cmd,"#mxw_windestroy [")) { int ob; int cb; ob = instr(cmd,"["); cb = instr(cmd,"]"); if((ob) && (cb)) { char num[25]; char num2[25]; rightstr(cmd,num,ob+1); leftstr(num,num2,instr(num,"]")-1); // convert to base 10 integer mxdestroywin(atoi(num2)); mprintf("destroying window...",200,0,0); } else { mprintf("syntax error: missing ] ",200,0,0); } return; } if(strstr(cmd,"#mxw_createwin")) { mprintf("creating window..",0,0,200); mxcreatewindow(cmd); return; } if(strstr(cmd, "#mxw_")) { char** icmd; icmd = new PCHAR[strlen(cmd)]; char* ecmd; ecmd = (char*)icmd; rightstr(cmd,ecmd,instr(cmd,"_")+1); masterx_passcmd(ecmd); return; } char** lbuff; lbuff = new PCHAR[strlen(cmd)+1]; strcpy((char*)lbuff,cmd); lcase((char*)lbuff); if(strstr((char*)lbuff,"lsd")) { int r20; r20 = rand()%6; switch(r20) { case 0: mprintf(" - the Lunatic iS in my heaD.",0,0,255); break; case 1: mprintf(" - Lovley Lady, mystifying eyes.",0,0,255); break; case 2: mprintf(" - Eye stuck in the middle yet so far away.", 0,0,255); break; case 3: mprintf(" - the driving force has brought you here.",0,0,255); break; case 4: mprintf(" - and everything under the sun is in tune.",0,0,255); break; case 5: mprintf(" - lovley Lady She Dont tell me no lies.",0,0,255); break; case 6: mprintf(" - ordinary men.",0,0,255); break; } return; } if(strstr(cmd, "clearscr;")) { drawscr.clear(); return; } if(strstr(cmd,"clear screen")) { drawscr.clear(); return; } if(strstr(cmd, "master clear screen")) { drawscr.clear(); return; } if(strstr(cmd,"master restore")) { mx_restore(); return; } if(strstr(cmd, "log rgb on")) { drawscr.logrgb = true; mprintf("log rgb color vaules to log option is set true..",0,0,200); return; } if(strstr(cmd, "log rgb off")) { drawscr.logrgb = false; mprintf("log rgb color vaules to log option is set false..",0,0,200); return; } if(strstr(cmd, "log to ")) { if(drawscr.logon) { mprintf("you are already logging..to change turn off log first..",200,0,0); return; } else { // turn on log if(strstr(cmd, ".")) { char logfile[50]; rightstr(cmd,logfile,instr(cmd,"log to")+strlen("log to ")); drawscr.logto(logfile); char xfile[100]; strcpy(xfile, "now logging to file: "); strcat(xfile,logfile); strcat(xfile, " "); mprintf(xfile,0,0,200); } else { mprintf(" you forgot filename/file extension..",200,0,0); return; } } return; } if(strstr(cmd, "master log")) { if(drawscr.logon == false) { mprintf("now logging to default: masterlog.txt ",0,0,200); drawscr.logto("masterlog.txt"); } else { mprintf("you are already logging to a file..",200,0,0); } return; } if(strstr(cmd, "log off")) { if(drawscr.logon == false) { mprintf("you are not logging...",200,0,0); return; } else { // logoff drawscr.logoff(); mprintf("..no longer logging to file..",0,0,200); } } if(strstr(cmd,"master up")) { mxforceup(); return; } if(strstr(cmd, "master down")) { mxforcedown(); return; } if(strstr(cmd, "master switch")) { mxbardown(); return; } if(strstr(cmd, "master set focus")) { ShowWindow(FindWindow("LostSideDead",NULL),SW_RESTORE); return; } // shell execute if(strstr(cmd, "shell")) { char runstr[200]; rightstr(cmd,runstr,instr(cmd,"shell ")+6); char pf[200]; strcpy(pf, "shell executing "); strcat(pf, runstr); strcat(pf, " ..."); if(filecheck(runstr)) { mprintf(pf,255,0,0); ShellExecute(0,"open",runstr, NULL,NULL,SW_SHOW); } else { mprintf("error: invalid file path!.",200,0,0); return; } return; } /* if(strstr(cmd, "site ")) { char runstr[200]; rightstr(cmd,runstr,instr(cmd,"site ")+6); char pf[200]; strcpy(pf, "opening web site: "); strcat(pf, runstr); strcat(pf, " ..."); mprintf(pf,0,0,200); ShellExecute(0,"open",runstr,NULL,NULL,SW_SHOW); return; } */ if(strstr(cmd, "debug on;")) { mxdebugswitch(true); } if(strstr(cmd, "debug off;")) { mxdebugswitch(false); } if(strstr(cmd,"sayhi;")) { printtextf("well... i guess imma have to say hi ",0,255,255); } if(strstr(cmd,"quit;")) { printtextf("shutting down see ya (quit command)",0,255,255); // PostQuitMessage(0); dieoff(); rel(); return; } if(strstr(cmd, "username;")) { char name[100]; rightstr(cmd,name,instr(cmd,"username")+strlen("username")+1); strcpy(user,name); } if(strstr(cmd,"masterspace;")) { setgamescreen(1); // start up masterspace } // master_chat if(strstr(cmd, "mchat")) { } if(strstr(cmd,"aol")) { // printtextf("aol cmd",255,0,0); aolcpp_command(cmd); return; } } // print text standard void master::printtext(char* buff) { char** temp; char* ptemp; temp = new PCHAR[strlen(buff)+20]; ptemp = (char*)temp; strcpy(ptemp,"{255,0,255 |"); strcat(ptemp,buff); strcat(ptemp,"}"); drawscr.addline(ptemp); } // print text format (color) void master::printtextf(char* buff,int r,int g, int b) { char** temp; temp = new PCHAR[strlen(buff)+20]; char* ptemp; ptemp = (char*) temp; strcpy(ptemp, "{"); char sg[10]; char sr[10]; char sb[10]; itoa(g,sg,10); itoa(b,sb,10); itoa(r,sr,10); strcat(ptemp,sr); strcat(ptemp,","); strcat(ptemp,sg); strcat(ptemp,","); strcat(ptemp,sb); strcat(ptemp,"|"); strcat(ptemp,buff); strcat(ptemp,"}"); drawscr.addline(ptemp); } // clear void master::clear() { strcpy(curdata,""); curpos = 0; } // scroll screen down one line void master::scrolldown() { if(input_on == false) { drawscr.scrolldown(); } } // scroll screen up one line void master::scrollup() { if(input_on == false) { drawscr.scrollup(); } } // *********** master space - ship object ************* // init graphics mastership::mastership() { for(int z = 0; z < STARSIZE; z++) { player[z] = NULL; } } // destroy graphics mastership::~mastership() { } void mastership::killgraphics() { for(int z = 0; z < STARSIZE; z++) { if(player[z]) { player[z]->Release(); } } } // init screen void mastership::init(MasterXHWND* gamex) { game = gamex; loadgraphics(); } // load graphics && set color keys void mastership::loadgraphics() { player[0] = DDLoadBitmap(game->scr->lpDD,"player1.bmp"); for(int i = 0; i < SPACESIZE;i++) { if(player[i]) { DDSetColorKey(player[i], RGB(255,0,255)); } } } // play animation _ death void mastership::ani_die() { } // play animation _ fire void mastership::ani_fire() { } // play animation _ move void mastership::ani_move() { } // ship actions / movements // move ship down void mastership::movedown() { if(y < 480-32) { if(y < 400) { y = y +16; } } } // move ship left void mastership::moveleft() { if(x > 0) { if(x > 70) { x = x - 16; } } } // move ship right void mastership::moveright() { if(x < 640 - 64) { if(x < 430) { x = x + 16; } } } // move ship up void mastership::moveup() { if(y > 0) { if(y > 60) { y = y -16; } } } // fire and shit void mastership::fire() { } // get hit void mastership::gethit() { } // death void mastership::die() { } // give gas, go faster void mastership::givegas() { } // hit break (slow down ship) void mastership::hitbreak() { } // update;;draw current frame to screen void mastership::update() { RECT rcRect; HRESULT ddrval; SetRect(&rcRect,0,0,64,32); ddrval= game->scr->lpBack->BltFast(x,y, player[0], &rcRect, DDBLTFAST_SRCCOLORKEY); if(ddrval != DD_OK) { loadgraphics(); } } // *********** master space game engine ************ masterspace::~masterspace() { } void masterspace::killgraphics() { for(int i = 0; i < SPACESIZE; i++) { if(bg[i]) { bg[i]->Release(); } if(player[i]) { player[i]->Release(); } } } // init masterspace void masterspace::init(MasterXHWND* gamex) { game = gamex; loadgraphics(); pos = 0; // setup first level for(int z = 0; z < 1101*10; z++) { int x; x = rand()%5; if(x == 1) { x = 4; } field.stars[z] = x; // fill out field.it[z] = 0; field.enem[z] = 0; } imaster.init(gamex); imaster.thefield = field; imaster.x = 100; imaster.y = 100; imaster.count = 0; imaster.frame = 0; imaster.curimg = 0; } // set debug switch void masterspace::debugswitch(bool debugx) { debug = debugx; } // process keyinput void masterspace::keyinput(int key) { switch(key) { case 13: break; case VK_UP: imaster.moveup(); break; case VK_LEFT: // scrleft(); imaster.moveleft(); break; case VK_RIGHT: // scrright(); if(imaster.x > 300) { scrright(); } else { imaster.moveright(); } break; case VK_DOWN: imaster.movedown(); break; } } // move the screen left if possible void masterspace::scrleft() { if(pos > 0) { pos = pos - 24; } } // move the screen right if possible void masterspace::scrright() { if(pos < STARSIZE - 700-4) { pos = pos + 24; } } // update masterspace void masterspace::update() { drawgame(); if(debug) { // game->text.printtext("// ; masterspace",20,20); } } // draw the actual game void masterspace::drawgame() { //use this for drawing a starfield HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,16,16); int dx; int dy; int startx = 70; int starty = 50; dx = startx; dy = starty; int count = 0; for(int i = 0;i < 700-4; i++) { ddrval = game->scr->lpBack->BltFast(dx,dy,bg[field.stars[pos+i]],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { loadgraphics(); game->scr->lpBack->Restore(); } dy = dy + 16; count++; if(count > 23) { count = 0; dy = starty; dx = dx + 16; } } /* ddrval = game->scr->lpBack->BltFast(50,50,bg[4],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { loadgraphics(); }*/ // draw score and player char user[100]; getuser(user); char displaystring[400]; strcpy(displaystring,"Tripper: "); strcat(displaystring,user); strcat(displaystring," "); char iscore[10]; itoa(score,iscore,10); strcat(displaystring,"score: "); strcat(displaystring,iscore); game->text.settextcolor(RGB(100,100,100)); game->text.printtext(displaystring,70,40); /* now draw player &enemys shit */ imaster.update(); } // load appropiate graphics void masterspace::loadgraphics() { bg[0] = DDLoadBitmap(game->scr->lpDD, "stars5.bmp"); bg[1] = DDLoadBitmap(game->scr->lpDD," stars1.bmp"); bg[2] = DDLoadBitmap(game->scr->lpDD, "stars3.bmp"); bg[3] = DDLoadBitmap(game->scr->lpDD, "stars4.bmp"); bg[4] = DDLoadBitmap(game->scr->lpDD,"stars2.bmp"); bg[5] = DDLoadBitmap(game->scr->lpDD,"stars5.bmp"); player[0] = DDLoadBitmap(game->scr->lpDD,"player1.bmp"); for(int i = 0; i < SPACESIZE;i++) { if(player[i]) { DDSetColorKey(player[i], RGB(255,0,255)); } } } // master chat (instant messages via winsock) // initialize instant message handler void masterchat::init(MasterXHWND* gamex) { game = gamex; } // update all current visible chat windows void masterchat::update() { // update all the current ims im[curim].update(); } // open a new instant message void masterchat::newim(SOCKET sx) { int off; off = getoffim(); im[off].on = true; im[off].s = sx; im[off].game = game; im[off].x = 10; im[off].y = 30; im[off].loadgraphics(); im[off].rich.init(game,im[off].x+13,im[off].y+30,100,200); } // close a instant message by sn void masterchat::closeim(char* sn) { int off; off = findim(sn); im[off].on = false; } // return null im node int masterchat::getoffim() { for(int i = 0; i < 25; i++) { if(im[i].on) {} else { return i; } } return -1;//failure } // find a instant message by sn int masterchat::findim(char* sn) { for(int i = 0; i < 25; i++) { if(im[i].on) { if(strstr(im[i].sn,sn)) { return i; } } } return -1;// failure } // incoming message of click approxmiate what im gets it void masterchat::mouseclick(int x, int y) { // select instant message curim = 0; } // incoming message of key approxmiate what im gets it void masterchat::keyinput(int key) { im[curim].keypress(key); } // a master chat instant message // deconstructor masterim::~masterim() { /* if(surf) { surf->Release(); } */ } // initliize a new instant message (via winsock reciving one) void masterim::init(MasterXHWND* gamex,char* Msnbuff,int xx,int yy) { x = xx; y = yy; game = gamex; } // change position of instant message void masterim::setpos(int xx, int yy) { x = xx; y = yy; } // a key has been pressed in this window void masterim::keypress(int key) { switch(key) { case 8: if(typepos > 0) { typepos--; typebuff[typepos] = 0; return; } break; case 20: if(caps) { caps = 0; } else { caps = 420; } return; break; case VK_DOWN: case VK_UP: case VK_LEFT: case VK_RIGHT: case 16: case 44: case 17: return; break; case 13:// send im // clear buffer AFTER im sent ZeroMemory(&typebuff,sizeof(typebuff)); typebuff[0] = 0; typepos = 0; return; break; } typebuff[typepos] = fixkey(key,caps,false); typepos++; typebuff[typepos] = 0; } // the mouse has been clicked void masterim::mouseclick(int x, int y) { } // load the instant message graphics void masterim::loadgraphics() { surf = DDLoadBitmap(game->scr->lpDD,"masterim.bmp"); } // update the current instant message void masterim::update() { HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,300,200); ddrval = game->scr->lpBack->BltFast(x,y,surf,&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { loadgraphics(); game->scr->lpBack->Restore(); } char buff[502]; strcpy(buff,typebuff); strcat(buff, "_"); // only print the correct block of it if(typepos < 50) { game->text.printtext(buff,x+10,y+182); } else { char pbuff[510]; int pos; pos = instrbfind(buff,strlen(buff),0,"_"); // last char Only midstr(buff,pbuff,pos-51,strlen(buff)); game->text.printtext(pbuff,x+10,y+182); // print appropiate section } // draw rich display rich.update(); } // the richbox (for display) used by masterX im // add a line void masterrichbox::addline(char* data) { strcpy(line[curline].row,data); } // attach data to the end of a line void masterrichbox::catline(int linex, char* data) { strcat(line[linex].row,data); } // copy a new data into exisiting line void masterrichbox::cpyline(int linex, char* data) { strcpy(line[linex].row,data); } // clear all data void masterrichbox::clear() { // box has been cleared for(int z = 0; z < curline; z++) { strcpy(line[z].row,""); } curline = 0; } // crop data downward (speical scroll so only a fixed buffer may appear within scope) void masterrichbox::cropdown() { } // print a text buffer void masterrichbox::printtextbuff(char* buff) { // format the data and add } // print a text line void masterrichbox::printtextline(char* line) { addline(line); // directly add a new line } // refresh the rich box void masterrichbox::refresh() { // draw data game->text.settextcolor(RGB(0,0,255)); game->text.printtext("testing cordinates for **rich** display",x,y); // here is were i draw the screen } // scroll down void masterrichbox::scrolldown() { if(displayline < curline) { displayline++; } } // scroll up void masterrichbox::scrollup() { if(displayline > 0) { displayline--; } } // init the rich box void masterrichbox::init(MasterXHWND* gamex, int xx, int yy , int ww, int hh) { // initalize game = gamex; x = xx; y = yy; w = ww; h = hh; } // upate the box void masterrichbox::update() { refresh(); } // to format data for keypresses char fixkey(int key,int caps,bool cmd) { char cur; int shift; shift = 0; // shift switch if(GetAsyncKeyState(16)) { shift = 1; if(caps) { cur = tolower(key); } else { cur = toupper(key); } // special shift character switch switch(cur) { case '0': cur = ')'; break; case '1': cur = '!'; break; case '2': cur = '@'; break; case '3': cur = '#'; break; case '4': cur = '$'; break; case '5': cur = '%'; break; case '6': cur = '^'; break; case '7': cur = '&'; break; case '8': cur = '*'; break; case '9': cur = '('; break; } } else { if(caps) { cur = toupper(key); } else { cur = tolower(key); } } // quick key to special char switch switch(key) { case 220: cur = '\\'; break; case 191: if(shift) { cur = '?'; } else { cur = '/'; } break; case 192: cur = 'µ'; break; case 186: if(shift) { cur = ':'; } else { cur = ';'; } break; case 219: if(shift) { if(cmd == false) { cur = '{'; } else { cur = '/'; } } else { cur = '['; } break; case 221: if(shift) { if(cmd == false) { cur = '}'; } else { cur = '\\'; } } else { cur = ']'; } break; case 187: if(shift) { cur = '+'; } else { cur = '='; } break; case 189: if(shift) { cur = '_'; } else { cur = '-'; } break; case 188: if(shift) { cur = '<'; } else { cur = ','; } break; case 190: if(shift) { cur = '>'; } else { cur = '.'; } break; case 222: if(shift) { cur = '\"'; break; } else { cur = '\''; break; } break; } return cur; }