diff --git a/sc2/src/uqm/comm.c b/sc2/src/uqm/comm.c index 5ac878fd3..f91431b7b 100644 --- a/sc2/src/uqm/comm.c +++ b/sc2/src/uqm/comm.c @@ -491,20 +491,11 @@ FeedbackPlayerPhrase (UNICODE *pStr) static void InitSpeechGraphics (void) { - RECT r; - RECT sr; - FRAME f; + InitOscilloscope (SetAbsFrameIndex (ActivityFrame, 9)); - InitOscilloscope (0, 0, RADAR_WIDTH, RADAR_HEIGHT, - SetAbsFrameIndex (ActivityFrame, 9)); - - f = SetAbsFrameIndex (ActivityFrame, 2); - GetFrameRect (f, &r); - SetSliderImage (f); - f = SetAbsFrameIndex (ActivityFrame, 5); - GetFrameRect (f, &sr); - InitSlider (0, SLIDER_Y, SIS_SCREEN_WIDTH, sr.extent.height, - r.extent.width, r.extent.height, f); + InitSlider (0, SLIDER_Y, SIS_SCREEN_WIDTH, + SetAbsFrameIndex (ActivityFrame, 5), + SetAbsFrameIndex (ActivityFrame, 2)); } static void diff --git a/sc2/src/uqm/oscill.c b/sc2/src/uqm/oscill.c index dc4e00794..142778716 100644 --- a/sc2/src/uqm/oscill.c +++ b/sc2/src/uqm/oscill.c @@ -18,9 +18,6 @@ #include "oscill.h" -// XXX: we should not refer to units.h here because we should not be -// using RADAR_WIDTH constants! -#include "units.h" #include "setup.h" // for OffScreenContext #include "libs/graphics/gfx_common.h" @@ -33,12 +30,13 @@ static FRAME scope_frame; static int scope_init = 0; static FRAME scopeWork; static Color scopeColor; +static EXTENT scopeSize; BOOLEAN oscillDisabled = FALSE; void -InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f) +InitOscilloscope (FRAME scopeBg) { - scope_frame = f; + scope_frame = scopeBg; if (!scope_init) { EXTENT size = GetFrameBounds (scope_frame); @@ -51,11 +49,12 @@ InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f) WANT_PIXMAP | MAPPED_TO_DISPLAY, size.width, size.height, 1)); + // assume and subtract the borders + scopeSize.width = size.width - 2; + scopeSize.height = size.height - 2; + scope_init = 1; } - /* remove compiler warnings */ - (void) x; - (void) y; } void @@ -72,12 +71,15 @@ void DrawOscilloscope (void) { STAMP s; - BYTE scope_data[RADAR_WIDTH - 2]; + BYTE scope_data[128]; if (oscillDisabled) return; - if (GraphForegroundStream (scope_data, RADAR_WIDTH - 2, RADAR_HEIGHT - 2)) + assert (scopeSize.width <= sizeof scope_data); + assert (scopeSize.height < 256); + + if (GraphForegroundStream (scope_data, scopeSize.width, scopeSize.height)) { int i; CONTEXT oldContext; @@ -94,7 +96,7 @@ DrawOscilloscope (void) // draw the scope lines SetContextForeGroundColor (scopeColor); - for (i = 0; i < RADAR_WIDTH - 3; ++i) + for (i = 0; i < scopeSize.width - 1; ++i) { LINE line; @@ -139,15 +141,20 @@ BOOLEAN sliderDisabled = FALSE; */ void -InitSlider (int x, int y, int width, int height, - int bwidth, int bheight, FRAME f) +InitSlider (int x, int y, int width, FRAME sliderFrame, FRAME buttonFrame) { + EXTENT sliderSize = GetFrameBounds (sliderFrame); + EXTENT buttonSize = GetFrameBounds (buttonFrame); + sliderStamp.origin.x = x; sliderStamp.origin.y = y; - sliderStamp.frame = f; + sliderStamp.frame = sliderFrame; + buttonStamp.origin.x = x; - buttonStamp.origin.y = y - ((bheight - height) >> 1); - sliderSpace = width - bwidth; + buttonStamp.origin.y = y - ((buttonSize.height - sliderSize.height) / 2); + buttonStamp.frame = buttonFrame; + + sliderSpace = width - buttonSize.width; } void diff --git a/sc2/src/uqm/oscill.h b/sc2/src/uqm/oscill.h index 40dbe78de..34e3f2a94 100644 --- a/sc2/src/uqm/oscill.h +++ b/sc2/src/uqm/oscill.h @@ -23,13 +23,12 @@ extern BOOLEAN sliderDisabled; extern BOOLEAN oscillDisabled; -extern void InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, - FRAME f); +extern void InitOscilloscope (FRAME scopeBg); extern void DrawOscilloscope (void); extern void UninitOscilloscope (void); -extern void InitSlider (int x, int y, int width, int height, - int bwidth, int bheight, FRAME f); +extern void InitSlider (int x, int y, int width, FRAME sliderFrame, + FRAME buttonFrame); extern void SetSliderImage (FRAME f); void DrawSlider (void);