diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 9bcee0d8f..ae5fdca48 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.4: +- Abstracted window-drawing code from confirm.c -Michael - Fixed blue comms screen problem (bug #363), from Joel Holveck & Nic - Automatically adding an icon for Darwin builds, from Nic - Fixed Roster-F10-Quit bug (#591), - Michael diff --git a/sc2/src/sc2code/confirm.c b/sc2/src/sc2code/confirm.c index 1a007bbe1..5a8ca9f2d 100644 --- a/sc2/src/sc2code/confirm.c +++ b/sc2/src/sc2code/confirm.c @@ -20,6 +20,7 @@ #include "starcon.h" #include "commglue.h" #include "comm.h" +#include "libs/graphics/widgets.h" #include "libs/sound/trackplayer.h" #define CONFIRM_WIN_WIDTH 80 @@ -28,45 +29,23 @@ static void DrawConfirmationWindow (BOOLEAN answer) { - COLOR oldfg = SetContextForeGroundColor (MENU_BACKGROUND_COLOR); + COLOR oldfg = SetContextForeGroundColor (MENU_TEXT_COLOR); + COLOR dark, medium; FONT oldfont = SetContextFont (StarConFont); FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0); RECT r; TEXT t; + + dark = BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F); + medium = BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19); + BatchGraphics (); - - r.corner.x = ((SCREEN_WIDTH - CONFIRM_WIN_WIDTH) >> 1) - 2; - r.corner.y = ((SCREEN_HEIGHT - CONFIRM_WIN_HEIGHT) >> 1) - 2; - r.extent.width = CONFIRM_WIN_WIDTH + 4; - r.extent.height = CONFIRM_WIN_HEIGHT + 4; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F)); - DrawFilledRectangle (&r); - - r.corner.x = ((SCREEN_WIDTH - CONFIRM_WIN_WIDTH) >> 1); - r.corner.y = ((SCREEN_HEIGHT - CONFIRM_WIN_HEIGHT) >> 1); - r.extent.width = CONFIRM_WIN_WIDTH + 2; - r.extent.height = CONFIRM_WIN_HEIGHT + 2; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); - DrawFilledRectangle (&r); - - r.corner.x = ((SCREEN_WIDTH - CONFIRM_WIN_WIDTH) >> 1) - 1; - r.corner.y = ((SCREEN_HEIGHT + CONFIRM_WIN_HEIGHT) >> 1) + 1; - r.extent.height = 1; - DrawFilledRectangle (&r); - - r.corner.x = ((SCREEN_WIDTH + CONFIRM_WIN_WIDTH) >> 1) + 1; - r.corner.y = ((SCREEN_HEIGHT - CONFIRM_WIN_HEIGHT) >> 1) - 1; - r.extent.width = 1; - DrawFilledRectangle (&r); - r.corner.x = (SCREEN_WIDTH - CONFIRM_WIN_WIDTH) >> 1; r.corner.y = (SCREEN_HEIGHT - CONFIRM_WIN_HEIGHT) >> 1; r.extent.width = CONFIRM_WIN_WIDTH; r.extent.height = CONFIRM_WIN_HEIGHT; - SetContextForeGroundColor (MENU_BACKGROUND_COLOR); - DrawFilledRectangle (&r); + DrawShadowedBox (&r, MENU_BACKGROUND_COLOR, dark, medium); - SetContextForeGroundColor (MENU_TEXT_COLOR); t.baseline.x = r.corner.x + (r.extent.width >> 1); t.baseline.y = r.corner.y + 8; t.pStr = "Really Quit?"; diff --git a/sc2/src/sc2code/libs/graphics/Makeinfo b/sc2/src/sc2code/libs/graphics/Makeinfo index 51e1a8854..7d7e5d438 100644 --- a/sc2/src/sc2code/libs/graphics/Makeinfo +++ b/sc2/src/sc2code/libs/graphics/Makeinfo @@ -1,4 +1,4 @@ uqm_SUBDIRS="sdl" uqm_CFILES="boxint.c clipline.c cmap.c context.c drawable.c filegfx.c font.c frame.c gfx_common.c intersec.c loaddisp.c - pixmap.c resgfx.c tfb_draw.c tfb_prim.c" + pixmap.c resgfx.c tfb_draw.c tfb_prim.c widgets.c" diff --git a/sc2/src/sc2code/libs/graphics/widgets.c b/sc2/src/sc2code/libs/graphics/widgets.c new file mode 100644 index 000000000..d2a1ef089 --- /dev/null +++ b/sc2/src/sc2code/libs/graphics/widgets.c @@ -0,0 +1,41 @@ +#include "starcon.h" +#include "graphics/widgets.h" + +void +DrawShadowedBox(PRECT r, COLOR bg, COLOR dark, COLOR medium) +{ + RECT t; + COLOR oldcolor; + + BatchGraphics (); + + t.corner.x = r->corner.x - 2; + t.corner.y = r->corner.y - 2; + t.extent.width = r->extent.width + 4; + t.extent.height = r->extent.height + 4; + oldcolor = SetContextForeGroundColor (dark); + DrawFilledRectangle (&t); + + t.corner.x += 2; + t.corner.y += 2; + t.extent.width -= 2; + t.extent.height -= 2; + SetContextForeGroundColor (medium); + DrawFilledRectangle (&t); + + t.corner.x -= 1; + t.corner.y += r->extent.height + 1; + t.extent.height = 1; + DrawFilledRectangle (&t); + + t.corner.x += r->extent.width + 2; + t.corner.y -= r->extent.height + 2; + t.extent.width = 1; + DrawFilledRectangle (&t); + + SetContextForeGroundColor (bg); + DrawFilledRectangle (r); + + SetContextForeGroundColor (oldcolor); + UnbatchGraphics (); +} diff --git a/sc2/src/sc2code/libs/graphics/widgets.h b/sc2/src/sc2code/libs/graphics/widgets.h new file mode 100644 index 000000000..5ac7580a9 --- /dev/null +++ b/sc2/src/sc2code/libs/graphics/widgets.h @@ -0,0 +1,24 @@ +// Copyright Michael Martin, 2004. + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _WIDGETS_H +#define _WIDGETS_H + +void DrawShadowedBox(PRECT r, COLOR bg, COLOR dark, COLOR medium); + +#endif /* _WIDGETS_H */