From: Ketmar Dark Date: Sun, 3 Sep 2017 14:05:18 +0000 (+0300) Subject: holmes cosmetix X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=767bb2910b40451cc6750b15debad98c9ad82c2a;p=d2df-sdl.git holmes cosmetix --- diff --git a/src/game/g_holmes.inc b/src/game/g_holmes.inc index d103cdb..3cfdd17 100644 --- a/src/game/g_holmes.inc +++ b/src/game/g_holmes.inc @@ -434,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; @@ -462,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 @@ -517,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 @@ -558,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); @@ -597,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; @@ -624,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); diff --git a/src/game/g_holmes_ui.inc b/src/game/g_holmes_ui.inc index d9909a2..0580a47 100644 --- a/src/game/g_holmes_ui.inc +++ b/src/game/g_holmes_ui.inc @@ -874,12 +874,12 @@ var begin if mDragging then begin - drawRect(mX+4, mY+4, mWidth-8, mHeight-8, r, g, b); + drawRectUI(mX+4, mY+4, mWidth-8, mHeight-8, r, g, b); end else begin - drawRect(mX+3, mY+3, mWidth-6, mHeight-6, r, g, b); - drawRect(mX+5, mY+5, mWidth-10, mHeight-10, r, g, b); + drawRectUI(mX+3, mY+3, mWidth-6, mHeight-6, r, g, b); + drawRectUI(mX+5, mY+5, mWidth-10, mHeight-10, r, g, b); setScissor(mFrameWidth, 0, 3*8, 8); fillRect(mX+mFrameWidth, mY, 3*8, 8, 0, 0, 128); drawText8(mX+mFrameWidth, mY, '[ ]', r, g, b);