/* * ItemColor_Draw. We don't draw the title, so return 0 if value is NULL */ int ItemColor_Draw( int column, void *value, LWRasterID raster, int x, int y, int w, int h, IMPGhostModes ghosting ) { // Figure out the color square's size int draw_x = x + 6; int draw_y = y + 3; int draw_w = w - 12; int draw_h = h - 6; int color; int text_color = (ghosting == IMPGHOST_DISABLED) ? RGB_( 80, 80, 80 ) : RGB_( 0, 0, 0 ); if( value == NULL ) return 0; if( draw_w > 40 ) draw_w = 40; if( raster == NULL ) return 40; color = *(int *)value; // Draw the square EmptyBox( raster, raster_funcs, draw_x, draw_y, draw_w, draw_h, 1, 1, RGB_( 80, 80, 80 ), RGB_( 200, 200, 200 ) ); raster_funcs->drawRGBBox( raster, ItemColors[ color ][ 0 ], ItemColors[ color ][ 1 ], ItemColors[ color ][ 2 ], draw_x+1, draw_y+1, draw_w-2, draw_h-2 ); // Draw the text if( (color >= 0) && (color < 15) ) raster_funcs->drawText( raster, (char *)item_color_list[ color ], text_color, draw_x + draw_w + 10, draw_y ); return 40; }
// FilledBox(): // Draws a filled box bool GLTDraw2D::FilledBox( int x, int y, int width, int height, int x_thickness, int y_thickness, int shine_r, int shine_g, int shine_b, int shadow_r, int shadow_g, int shadow_b, int fill_r, int fill_g, int fill_b ) { EmptyBox( x, y, width, height, x_thickness, y_thickness, shine_r, shine_g, shine_b, shadow_r, shadow_g, shadow_b ); glColor3ub( fill_r, fill_g, fill_b ); glRecti( x+x_thickness, y+y_thickness, x + width - x_thickness, y + height - y_thickness ); return true; }
// Button(): // Draws a button. This is the same as FilledBox(), but adds // a 1-pixel wide black border around it bool GLTDraw2D::Button( int x, int y, int width, int height, int x_thickness, int y_thickness, int shine_r, int shine_g, int shine_b, int shadow_r, int shadow_g, int shadow_b, int fill_r, int fill_g, int fill_b ) { FilledBox( x+1, y+1, width-2, height-2, x_thickness, y_thickness, shine_r, shine_g, shine_b, shadow_r, shadow_g, shadow_b, fill_r, fill_g, fill_b ); EmptyBox( x, y, width, height, 1, 1, 0, 0, 0, 0, 0, 0 ); return true; }
/* * DrawLWIcon(): * Draws a Lightwave-like icon into the interface. */ int DrawLWIcon( LWRasterID raster, LWRasterFuncs *df, int x, int y, enum IconType type, int prime_color, int second_color ) { switch( type ) { case ICON_DOT: df->drawBox( raster, prime_color, x+5, y+4, 3, 1 ); df->drawBox( raster, prime_color, x+4, y+5, 5, 3 ); df->drawBox( raster, prime_color, x+5, y+8, 3, 1 ); break; case ICON_BOUNDING_BOX: EmptyBox( raster, df, x+2, y+2, 9, 9, 1, 1, prime_color, prime_color ); break; case ICON_FRONTFACE: EmptyBox( raster, df, x+2, y+2, 9, 9, 1, 1, prime_color, prime_color ); df->drawLine( raster, prime_color, x+6, y+3, x+ 6, y+9 ); df->drawLine( raster, prime_color, x+3, y+6, x+10, y+6 ); break; case ICON_POINTS_ONLY: df->drawPixel( raster, prime_color, x+ 2, y+2 ); df->drawPixel( raster, prime_color, x+ 6, y+2 ); df->drawPixel( raster, prime_color, x+10, y+2 ); df->drawPixel( raster, prime_color, x+ 4, y+4 ); df->drawPixel( raster, prime_color, x+ 8, y+4 ); df->drawPixel( raster, prime_color, x+ 2, y+6 ); df->drawPixel( raster, prime_color, x+ 6, y+6 ); df->drawPixel( raster, prime_color, x+10, y+6 ); df->drawPixel( raster, prime_color, x+ 4, y+8 ); df->drawPixel( raster, prime_color, x+ 8, y+8 ); df->drawPixel( raster, prime_color, x+ 2, y+10 ); df->drawPixel( raster, prime_color, x+ 6, y+10 ); df->drawPixel( raster, prime_color, x+10, y+10 ); break; case ICON_SOLID: df->drawBox( raster, prime_color, x+ 2, y+2, 9, 9 ); break; case ICON_TEXTURED: df->drawBox( raster, prime_color, x+ 2, y+2, 9, 9 ); df->drawBox( raster, second_color, x+ 4, y+4, 5, 1 ); df->drawBox( raster, second_color, x+ 6, y+4, 1, 5 ); break; case ICON_WIREFRAME: EmptyBox( raster, df, x+2, y+2, 9, 9, 1, 1, prime_color, prime_color ); df->drawLine( raster, prime_color, x+6, y+3, x+6, y+9 ); df->drawLine( raster, prime_color, x+3, y+6, x+9, y+6 ); df->drawPixel( raster, prime_color, x+ 3, y+ 3 ); df->drawPixel( raster, prime_color, x+ 4, y+ 4 ); df->drawPixel( raster, prime_color, x+ 5, y+ 5 ); df->drawPixel( raster, prime_color, x+ 7, y+ 5 ); df->drawPixel( raster, prime_color, x+ 8, y+ 4 ); df->drawPixel( raster, prime_color, x+ 9, y+ 3 ); df->drawPixel( raster, prime_color, x+ 5, y+ 7 ); df->drawPixel( raster, prime_color, x+ 4, y+ 8 ); df->drawPixel( raster, prime_color, x+ 3, y+ 9 ); df->drawPixel( raster, prime_color, x+ 9, y+ 9 ); df->drawPixel( raster, prime_color, x+ 8, y+ 8 ); df->drawPixel( raster, prime_color, x+ 7, y+ 7 ); break; case ICON_CHECK: df->drawPixel( raster, prime_color, x+11, y+ 3 ); df->drawBox( raster, prime_color, x+10, y+ 4, 2, 1 ); df->drawBox( raster, prime_color, x+ 9, y+ 5, 2, 1 ); df->drawBox( raster, prime_color, x+ 2, y+ 6, 2, 1 ); df->drawBox( raster, prime_color, x+ 8, y+ 6, 2, 1 ); df->drawBox( raster, prime_color, x+ 7, y+ 7, 2, 1 ); df->drawBox( raster, prime_color, x+ 2, y+ 7, 3, 1 ); df->drawBox( raster, prime_color, x+ 3, y+ 8, 5, 1 ); df->drawBox( raster, prime_color, x+ 4, y+ 9, 3, 1 ); df->drawPixel( raster, prime_color, x+ 5, y+10 ); break; case ICON_LOCK: df->drawBox( raster, prime_color, x+5, y+2, 3, 1 ); df->drawBox( raster, prime_color, x+4, y+3, 1, 3 ); df->drawBox( raster, prime_color, x+8, y+3, 1, 3 ); df->drawBox( raster, prime_color, x+3, y+6, 7, 5 ); break; case ICON_VISIBILITY_EYE: df->drawBox( raster, prime_color, x+ 1, y+4, 2, 1 ); df->drawBox( raster, prime_color, x+ 3, y+3, 6, 1 ); df->drawBox( raster, prime_color, x+ 9, y+4, 2, 1 ); df->drawPixel( raster, prime_color, x+11, y+5 ); df->drawPixel( raster, prime_color, x+ 1, y+7 ); df->drawBox( raster, prime_color, x+ 2, y+6, 2, 1 ); df->drawBox( raster, prime_color, x+ 4, y+5, 1, 4 ); df->drawBox( raster, prime_color, x+ 5, y+5, 3, 1 ); df->drawBox( raster, prime_color, x+ 6, y+6, 4, 1 ); df->drawBox( raster, prime_color, x+ 6, y+7, 2, 1 ); df->drawBox( raster, prime_color, x+ 5, y+8, 3, 1 ); df->drawBox( raster, prime_color, x+ 5, y+9, 2, 1 ); df->drawBox( raster, prime_color, x+ 9, y+7, 2, 1 ); df->drawPixel( raster, prime_color, x+10, y+8 ); df->drawPixel( raster, prime_color, x+ 9, y+9 ); df->drawBox( raster, prime_color, x+ 3, y+10, 6, 1 ); df->drawPixel( raster, prime_color, x+ 2, y+9 ); break; } return 1; }
// Mesage handler for work box. LRESULT CALLBACK DrugProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { const int nrItem = 5; switch (message) { case WM_INITDIALOG: SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL); break; case WM_COMMAND: if (LOWORD(wParam) == IDOK) { if(EmptyBox(hDlg, IDC_FIT, nrItem) != true) { SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL); MessageBox(hDlg, "Now the Drug is saved \nJust load the game...", "Now Saved", MB_OK); DestroyWindow(hDlg); } } if (LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } if (LOWORD(wParam) == IDC_LOAD) { SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL); EndDialog(hDlg, LOWORD(wParam)); DialogBox(hInst, (LPCTSTR)IDD_STARTDLG, NULL, (DLGPROC)Start); } if (LOWORD(wParam) == IDC_DELETE) { char objectName[MAX_NAME_LENGTH]; strcpy(objectName, drug[activeDrug].name); for(int i = activeDrug; i < antDrug-1; i++) { strcpy(drug[i].name, drug[i+1].name); strcpy(drug[i].text, drug[i+1].text); drug[i].id = i; drug[i].nWage = drug[i+1].nWage; drug[i].nCostInSleep = drug[i+1].nCostInSleep; drug[i].nFitnes = drug[i+1].nFitnes; } strcpy(drug[i].name, ""); strcpy(drug[i].text, ""); drug[i].id = 0; drug[i].nCostInSleep = 0; drug[i].nWage = 0; drug[i].nFitnes = 0; if(antDrug > 0) antDrug--; activeDrug--; SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL); MessageBox(hDlg, "Object Deleted", objectName, MB_OK | MB_ICONEXCLAMATION); } if (LOWORD(wParam) == IDC_RIGHT) { if(EmptyBox(hDlg, IDC_FIT, nrItem) != true) { SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL); if(activeDrug < antDrug-1) { activeDrug++; } else { if(MessageBox(hDlg, "Add one more Drug object?", "Add?", MB_ICONQUESTION | MB_YESNO) == IDYES) if(antDrug < MAX_WORK) { antDrug++; activeDrug++; drug[activeDrug].id = activeDrug; } else MessageBox(hDlg, "Max Drug\n Contact programmer !!!", "Array overflow", MB_OK); } SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL); } } if (LOWORD(wParam) == IDC_LEFT) { SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL); if(activeDrug > 0) activeDrug--; SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL); } if (LOWORD(wParam) == UPDATE_DLG) { char* str[nrItem+1]; str[0] = IntToChar(drug[activeDrug].id); str[1] = IntToChar(drug[activeDrug].nFitnes); str[2] = IntToChar(drug[activeDrug].nCostInSleep); str[3] = IntToChar(drug[activeDrug].nWage); str[4] = drug[activeDrug].name; str[5] = drug[activeDrug].text; int i = 0; for(int item = IDC_ID; i < nrItem+1; i++, item++) SetDlgItemText(hDlg, item, str[i]); } if (LOWORD(wParam) == SAVE_DLG) { String str[nrItem]; char* tmpStr; int i= 0; int len; bool emptyBox = false; for(int item = IDC_FIT; i < nrItem && emptyBox != true; i++, item++) { len = GetWindowTextLength(GetDlgItem(hDlg, item)); if(len > 0) { tmpStr = (char*)GlobalAlloc(GPTR, len + 1); GetDlgItemText(hDlg, item, tmpStr, len + 1); str[i] = tmpStr; GlobalFree((HANDLE)tmpStr); } else { emptyBox = true; MessageBox(hDlg, "All fields are not filled!!!", "Oups!", MB_OK); } } if(emptyBox == false) { drug[activeDrug].id = activeDrug; drug[activeDrug].nFitnes = str[0].convertToInt(); drug[activeDrug].nCostInSleep = str[1].convertToInt(); drug[activeDrug].nWage = str[2].convertToInt(); strcpy(drug[activeDrug].name, str[3].getString()); strcpy(drug[activeDrug].text, str[4].getString()); NewSaveDrug(file); } } break; case WM_DESTROY: PostQuitMessage(0); return TRUE; } return FALSE; }