X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_holmes.inc;h=3cfdd17b09580471164bfc819190b7ee85d861e6;hb=8cd6b5c965cd6cae75db5f554e61d0d150d08b46;hp=6ebe034614d4fc5b144ce7453b36cc2433940ead;hpb=d09b8c3ec24bef1affd89ee478b94cf0517fa69d;p=d2df-sdl.git diff --git a/src/game/g_holmes.inc b/src/game/g_holmes.inc index 6ebe034..3cfdd17 100644 --- a/src/game/g_holmes.inc +++ b/src/game/g_holmes.inc @@ -21,29 +21,29 @@ const curWidth = 17; const curHeight = 23; const cursorImg: array[0..curWidth*curHeight-1] of Byte = ( - 0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,0,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,4,2,2,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,4,4,2,2,0,0,0,0,0,0,0,0,0, - 1,1,3,3,4,4,4,2,2,0,0,0,0,0,0,0,0, - 1,1,3,3,4,4,4,4,2,2,0,0,0,0,0,0,0, - 1,1,3,3,4,4,4,5,6,2,2,0,0,0,0,0,0, - 1,1,3,3,4,4,5,6,7,5,2,2,0,0,0,0,0, - 1,1,3,3,4,5,6,7,5,4,5,2,2,0,0,0,0, - 1,1,3,3,5,6,7,5,4,5,6,7,2,2,0,0,0, - 1,1,3,3,6,7,5,4,5,6,7,7,7,2,2,0,0, - 1,1,3,3,7,5,4,5,6,7,7,7,7,7,2,2,0, - 1,1,3,3,5,4,5,6,8,8,8,8,8,8,8,8,2, - 1,1,3,3,4,5,6,3,8,8,8,8,8,8,8,8,8, - 1,1,3,3,5,6,3,3,1,1,1,1,1,1,1,0,0, - 1,1,3,3,6,3,3,1,1,1,1,1,1,1,1,0,0, - 1,1,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0, -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 begin GetMem(tex, curTexWidth*curTexHeight*4); FillChar(tex^, curTexWidth*curTexHeight*4, 0); - tpp := tex; + // draw shadow + for y := 0 to curHeight-1 do + begin + for x := 0 to curWidth-1 do + begin + if (cursorImg[y*curWidth+x] <> 0) then + begin + c := 1*4; + tpp := tex+((y+1)*(curTexWidth*4)+(x+3)*4); + tpp^ := cursorPal[c+0]; Inc(tpp); + tpp^ := cursorPal[c+1]; Inc(tpp); + tpp^ := cursorPal[c+2]; Inc(tpp); + tpp^ := cursorPal[c+3]; Inc(tpp); + tpp^ := cursorPal[c+0]; Inc(tpp); + tpp^ := cursorPal[c+1]; Inc(tpp); + tpp^ := cursorPal[c+2]; Inc(tpp); + tpp^ := cursorPal[c+3]; Inc(tpp); + end; + end; + end; + + // draw cursor for y := 0 to curHeight-1 do begin - tpp := tex+(y*(curTexWidth*4)); for x := 0 to curWidth-1 do begin c := cursorImg[y*curWidth+x]*4; - tpp^ := cursorPal[c+0]; Inc(tpp); - tpp^ := cursorPal[c+1]; Inc(tpp); - tpp^ := cursorPal[c+2]; Inc(tpp); - tpp^ := cursorPal[c+3]; Inc(tpp); + if (c <> 0) then + begin + tpp := tex+(y*(curTexWidth*4)+x*4); + tpp^ := cursorPal[c+0]; Inc(tpp); + tpp^ := cursorPal[c+1]; Inc(tpp); + tpp^ := cursorPal[c+2]; Inc(tpp); + tpp^ := cursorPal[c+3]; Inc(tpp); + end; end; end; @@ -114,14 +138,14 @@ begin glEnable(GL_TEXTURE_2D); // color and opacity glColor4f(1, 1, 1, 0.9); - Dec(msX, 2); + //Dec(msX, 2); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex2i(msX, msY); // top-left glTexCoord2f(1.0, 0.0); glVertex2i(msX+curTexWidth, msY); // top-right glTexCoord2f(1.0, 1.0); glVertex2i(msX+curTexWidth, msY+curTexHeight); // bottom-right glTexCoord2f(0.0, 1.0); glVertex2i(msX, msY+curTexHeight); // bottom-left glEnd(); - Inc(msX, 2); + //Inc(msX, 2); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glColor4f(1, 1, 1, 1); @@ -410,6 +434,17 @@ begin end; +// ////////////////////////////////////////////////////////////////////////// // +procedure normRGBA (var r, g, b, a: Integer); inline; +begin + if (a < 0) then a := 0 else if (a > 255) then a := 255; + if (r < 0) then r := 0 else if (r > 255) then r := 255; + if (g < 0) then g := 0 else if (g > 255) then g := 255; + if (b < 0) then b := 0 else if (b > 255) then b := 255; +end; + + +// ////////////////////////////////////////////////////////////////////////// // function textWidth6 (const s: AnsiString): Integer; var f: Integer; @@ -438,10 +473,7 @@ var begin result := 0; if (Length(s) = 0) then exit; - if (a < 0) then a := 0 else if (a > 255) then a := 255; - if (r < 0) then r := 0 else if (r > 255) then r := 255; - if (g < 0) then g := 0 else if (g > 255) then g := 255; - if (b < 0) then b := 0 else if (b > 255) then b := 255; + normRGBA(r, g, b, a); if (a < 255) then begin @@ -493,10 +525,7 @@ end; // ////////////////////////////////////////////////////////////////////////// // procedure drawLine (x1, y1, x2, y2: Integer; r, g, b: Integer; a: Integer=255); begin - if (a < 0) then a := 0 else if (a > 255) then a := 255; - if (r < 0) then r := 0 else if (r > 255) then r := 255; - if (g < 0) then g := 0 else if (g > 255) then g := 255; - if (b < 0) then b := 0 else if (b > 255) then b := 255; + normRGBA(r, g, b, a); if (a < 255) then begin @@ -534,10 +563,7 @@ end; procedure drawRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255); begin if (w < 0) or (h < 0) then exit; - if (a < 0) then a := 0 else if (a > 255) then a := 255; - if (r < 0) then r := 0 else if (r > 255) then r := 255; - if (g < 0) then g := 0 else if (g > 255) then g := 255; - if (b < 0) then b := 0 else if (b > 255) then b := 255; + normRGBA(r, g, b, a); if (a < 255) then begin glEnable(GL_BLEND); @@ -573,6 +599,12 @@ begin end; +procedure drawRectUI (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255); +begin + drawRect(x, y, w, h, r, g, b, a); +end; + + procedure darkenRect (x, y, w, h: Integer; a: Integer); begin if (w < 0) or (h < 0) then exit; @@ -600,10 +632,7 @@ end; procedure fillRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255); begin if (w < 0) or (h < 0) then exit; - if (a < 0) then a := 0 else if (a > 255) then a := 255; - if (r < 0) then r := 0 else if (r > 255) then r := 255; - if (g < 0) then g := 0 else if (g > 255) then g := 255; - if (b < 0) then b := 0 else if (b > 255) then b := 255; + normRGBA(r, g, b, a); if (a < 255) then begin glEnable(GL_BLEND);