// runmenu.cpp ** menu source file (jared bruni) // init the shit #include "runmenu.h" // deconstructor masterrun::~masterrun() { /* */ } void masterrun::killgraphics() { for(int z = 0; z < 10; z++) { if(surf[z]) { surf[z]->Release(); } } } // init void masterrun::init(MasterXHWND* gamex) { game = gamex; selected = 0; selected_state = false; loadgraphics(); strcpy(defmenu[0].it,"My Programs"); strcpy(defmenu[0].cmd,"runProg"); defmenu[0].seticon = true; strcpy(defmenu[0].icon,"progicon2.bmp"); defmenu[0].icpos = 1; for(int i = 1; i < 10; i++) { strcpy(defmenu[i].it,"new item"); strcpy(defmenu[i].cmd,"n"); } strcpy(defmenu[1].it, "Programming"); strcpy(defmenu[1].cmd, "master_xProg"); strcpy(defmenu[1].icon,"progicon.bmp"); defmenu[1].seticon = true; defmenu[1].icpos = 0; strcpy(defmenu[2].it, "Internet"); strcpy(defmenu[2].cmd,"INET"); defmenu[2].seticon = true; defmenu[2].icpos = 9; defmenu[2].submenu = true; strcpy(defmenu[2].sub[0].name, "Send IP Instant Message"); strcpy(defmenu[2].sub[0].cmd, "sendipim"); strcpy(defmenu[2].sub[1].name, "Join IP Chat Room"); strcpy(defmenu[2].sub[1].cmd, "joinipchat"); strcpy(defmenu[2].sub[2].name, "Host IP Chat Room"); strcpy(defmenu[2].sub[2].cmd, "hostipchat"); for(int d = 0; d < 3; d++) { defmenu[2].sub[d].on = true; } strcpy(defmenu[3].it, "MasterX AOL"); strcpy(defmenu[3].cmd, "AOL"); defmenu[3].seticon = true; strcpy(defmenu[3].icon,"mxaol2.bmp"); defmenu[3].icpos = 2; defmenu[3].submenu = true; strcpy(defmenu[3].sub[0].name, "Connect to MasterX Host"); strcpy(defmenu[3].sub[0].cmd, "connectmhost"); strcpy(defmenu[3].sub[1].name, "Connect to MasterX user"); strcpy(defmenu[3].sub[1].cmd, "connectXuser"); strcpy(defmenu[3].sub[2].name, "MasterX user search"); strcpy(defmenu[3].sub[2].cmd, "chatsearch"); strcpy(defmenu[3].sub[3].name, "MasterX mail/file server"); strcpy(defmenu[3].sub[3].cmd, "MasterXServer"); strcpy(defmenu[3].sub[4].name, "Send MasterX IM"); strcpy(defmenu[3].sub[4].cmd, "SendXIM"); strcpy(defmenu[3].sub[5].name, "Misc......"); strcpy(defmenu[3].sub[5].cmd, "misc"); defmenu[3].sub[5].on = true; defmenu[3].sub[4].on = true; defmenu[3].sub[3].on = true; defmenu[3].sub[2].on = true; defmenu[3].sub[1].on = true; defmenu[3].sub[0].on = true; strcpy(defmenu[4].it, "Games"); strcpy(defmenu[4].cmd, "games"); defmenu[4].icpos = 8; defmenu[4].seticon = true; defmenu[4].submenu = true; strcpy(defmenu[4].sub[0].name, "aol duel"); strcpy(defmenu[4].sub[0].cmd, "aolduel"); strcpy(defmenu[4].sub[1].name, "aol speed"); strcpy(defmenu[4].sub[1].cmd, "aolspeed"); strcpy(defmenu[4].sub[2].name, "aol luck"); strcpy(defmenu[4].sub[2].cmd, "aolluck"); strcpy(defmenu[4].sub[3].name, "aol rulet"); strcpy(defmenu[4].sub[3].cmd, "aolrulet"); strcpy(defmenu[4].sub[4].name, "** aol death match**"); strcpy(defmenu[4].sub[4].cmd, "deathmatch"); for(int q = 0; q < 5; q++) { defmenu[4].sub[q].on = true; } strcpy(defmenu[5].it, "My Server"); strcpy(defmenu[5].cmd, "My Server"); defmenu[5].seticon = true; defmenu[5].icpos = 7; strcpy(defmenu[6].it, "Startup"); strcpy(defmenu[6].cmd, "Startup"); defmenu[6].seticon = true; defmenu[6].icpos = 6; strcpy(defmenu[9].it, "Shutdown"); strcpy(defmenu[9].cmd,"shut_down"); defmenu[9].icpos = 4; defmenu[9].seticon = true; strcpy(defmenu[8].it, "Help/About"); defmenu[8].icpos = 3; defmenu[8].seticon = true; strcpy(defmenu[8].cmd,"help_about"); strcpy(defmenu[7].it, "Settings.."); strcpy(defmenu[7].cmd, "setting.mx"); defmenu[7].seticon = true; defmenu[7].icpos = 5; } // single message proc click void masterrun::procmenu() { char cmd[100]; strcpy(cmd,defmenu[selected].cmd); strcpy(icmd,cmd); if(defmenu[selected].submenu) { char icmd[100]; strcpy(icmd,defmenu[selected].sub[selsub].cmd); // is the command this one if(isstrequal(icmd,"connectmhost")) { // exit(0); // forcemastermessage("#mxw_test"); } } else { // then we proc this one if(strstr(cmd, "shut_down")) { // PostQuitMessage(0); //mxquit(); ShowWindow(getmxhwnd(),SW_MINIMIZE); } if(strstr(cmd,"help_about")) { forcemastermessage("#mxw_display_help"); } if(strstr(cmd, "setting.mx")) { forcemastermessage("#mxw_display_settings"); } } } // load graphics void masterrun::loadgraphics() { surf[0] = DDLoadBitmap(game->scr->lpDD,"progicon.bmp"); surf[1] = DDLoadBitmap(game->scr->lpDD,"progicon2.bmp"); surf[2] = DDLoadBitmap(game->scr->lpDD,"mxaol2.bmp"); surf[3] = DDLoadBitmap(game->scr->lpDD,"mqicon.bmp"); surf[4] = DDLoadBitmap(game->scr->lpDD,"mxicon.bmp"); surf[5] = DDLoadBitmap(game->scr->lpDD,"msicon.bmp"); surf[6] = DDLoadBitmap(game->scr->lpDD,"sticon.bmp"); surf[7] = DDLoadBitmap(game->scr->lpDD,"servicon.bmp"); surf[8] = DDLoadBitmap(game->scr->lpDD,"shicon.bmp"); surf[9] = DDLoadBitmap(game->scr->lpDD,"inicon.bmp"); } // graphic reload void masterrun::reloadgraphics() { DDReLoadBitmap(surf[0],"progicon.bmp"); DDReLoadBitmap(surf[1],"progicon2.bmp"); DDReLoadBitmap(surf[2],"mxaol2.bmp"); DDReLoadBitmap(surf[3],"mqicon.bmp"); DDReLoadBitmap(surf[4],"mxicon.bmp"); DDReLoadBitmap(surf[5],"msicon.bmp"); DDReLoadBitmap(surf[6],"sticon.bmp"); DDReLoadBitmap(surf[7],"servicon.bmp"); DDReLoadBitmap(surf[8],"shicon.bmp"); DDReLoadBitmap(surf[9],"inicon.bmp"); game->scr->lpBack->Restore(); } // update master run void masterrun::update() { // if he is visible if(visible) { // draw background draw_bg(); killwindowlock(); } } // draw the background void masterrun::draw_bg() { h = 230+1; w = 100; COLORREF gray; gray = RGB(164,149,149); fillcolor = RGB(164,149,149);// RGB(50,100,100);//RGB(0,0,0); outline = fillcolor; // RGB(50,100,100); COLORREF routline; routline =RGB(170,170,170); //RGB(164,149,149); COLORREF greenout; greenout = outline; COLORREF black; black = fillcolor; COLORREF red; red = RGB(200,0,0); int dy; dy = getbarY()-h; int xpos; xpos = 640-w; // game.mxdrawrect(xpos,dy,xpos+w,dy+h,fillcolor,outline); game->mxdrawroundrect(xpos,dy,xpos+w,dy+h,10,10,fillcolor,RGB(0,0,0));//outline); fillcolor = outline; game->mxdrawroundrect(xpos+1,dy+1,xpos+w-1,dy+20,10,10,routline,RGB(0,0,0)); game->mxdrawrect(xpos,dy+18,xpos+w,dy+18+2,RGB(0,0,0),RGB(0,0,0)); COLORREF rt; rt = game->text.bk; game->text.bk = routline; game->text.settextcolor(RGB(100,0,0)); game->text.printtext("MasterX RunMenu",xpos+5,dy+3); int cury; cury = dy+20+1; outline = RGB(100,0,0); // drawicon shit HRESULT ddrval; RECT rcRect; SetRect(&rcRect,0,0,16,16); for(int z = 0; z < 10; z++) { if(z == selected) { outline = RGB(0,0,150); game->mxdrawroundrect(xpos+2,cury+1,xpos+w-2,cury+20,10,10,outline,RGB(0,0,255)); game->text.bk = outline; game->text.settextcolor(RGB(100,0,0)); game->text.printtext(defmenu[selected].it,xpos+5,cury+3); // draw icon if(defmenu[z].seticon) { ddrval = game->scr->lpBack->BltFast(617,cury+2,surf[defmenu[z].icpos],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { loadgraphics(); game->scr->lpBack->Restore(); } } // draw sub menu if it exisits if(defmenu[z].submenu) { runx = xpos+2; // runx = xpos+2-strlen("testing")*5; runy = cury+1; drawsubmenu(); } } else { game->text.bk = greenout; game->text.settextcolor(RGB(0,0,220)); game->text.printtext(defmenu[z].it,xpos+5,cury+3); game->text.bk = black; game->text.settextcolor(RGB(50,100,100)); if(defmenu[z].seticon) { ddrval = game->scr->lpBack->BltFast(617,cury+2,surf[defmenu[z].icpos],&rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); if(ddrval != DD_OK) { reloadgraphics(); } } } cury = cury + 20 + 1; } game->text.bk = rt; // draw the begining menu } // sub menu draw stuff void masterrun::drawsubmenu() { // drawing a sub menu ** FIXED SIZE MENU ? ** COLORREF routline; routline = RGB(164,149,149); // write a function to seperate all the data, and display it int w; int h = 0; w=125; int count = 0; for(int i = 0; i < 10; i++) { if(defmenu[selected].sub[i].on) { h = h + 20; count++; } } selh = h; game->mxdrawrect(runx-w-1,runy,runx,runy+h,routline,RGB(0,0,0)); game->mxdrawrect(runx-w+1,runy+h-2,runx-1,runy+h-1,RGB(170,170,170),RGB(170,170,170)); game->mxdrawrect(runx-w+1,runy+1,runx-1,runy+2,RGB(50,50,50),RGB(50,50,50)); game->mxdrawrect(runx-2,runy+3,runx-1,runy+h-1,RGB(170,170,170),RGB(170,170,170)); game->mxdrawrect(runx-w+1,runy+1,runx-w,runy+h-1,RGB(50,50,50),RGB(50,50,50)); int py; py = runy+3; for(int r = 0; r < count; r++) { if(selsub == r) { game->text.settextcolor(RGB(0,0,200)); } else { game->text.settextcolor(RGB(200,0,0)); } game->text.setbkcolor(routline); game->text.printtext(defmenu[selected].sub[r].name,runx-w+2,py+1); py = py + 20; } } // input stuff void masterrun::keypress(int key) { if(selected_state == false) { if(visible) { switch(key) { case VK_DOWN: if(selected < 9) { selected++; } break; case VK_UP: if(selected > 0) { selected--; } break; case 13: procmenu(); setrunstate(false); break; } } } } void masterrun::mouseclick(int x, int y) { if(x > 640-w) { if(y < getbarY()) { // proc message procmenu(); } } // we have sub menu if(defmenu[selected].submenu) { if(x > 640-w-125) { if(y > runy) { if(y < runy+selh) { procmenu(); } } } } } void masterrun::mousemove(int x, int y, long button) { int dy; dy = getbarY()-h; int xpos; xpos = 640-w; int cury; cury = dy+20+1; for(int z = 0; z < 10; z++) { if(x > xpos) { if(y >= cury) { if(y <= cury+w) { selected = z; } } } cury = cury + 20 + 1; } // right here is the check for position of sub menu int subh; if(defmenu[selected].submenu) { int count = 0; subh = 0; for(int i = 0; i < 10; i++) { if(defmenu[selected].sub[i].on) { count++; subh = subh + 20; } } // right here int py; py = runy; for(int r = 0; r < count; r++) { if(y > py) { if(y < py+20) { selsub = r; } } py = py + 20; } } }