Implementation of Color struct

This commit is contained in:
Nathan Fulton 2017-06-03 20:14:34 -04:00
parent 9e7be9055b
commit 8619337473
8 changed files with 30 additions and 39 deletions

View File

@ -353,15 +353,10 @@ bool EcomTextControl::Init(Form *pfrm, IniReader *pini, FindProp *pfind)
m_wf |= kfLblMultiLine;
m_cchCur = 0;
byte biclr;
biclr = GetColor(kiclrJana) & 0xff;
m_aiclrEcom[kiaiclrJana] = MAKEDWORD(biclr);
biclr = GetColor(kiclrAndy) & 0xff;
m_aiclrEcom[kiaiclrAndy] = MAKEDWORD(biclr);
biclr = GetColor(kiclrOlstrom) & 0xff;
m_aiclrEcom[kiaiclrOlstrom] = MAKEDWORD(biclr);
biclr = GetColor(kiclrFox) & 0xff;
m_aiclrEcom[kiaiclrFox] = MAKEDWORD(biclr);
m_aclrEcom[kiaiclrJana] = GetColor(kiclrJana);
m_aclrEcom[kiaiclrAndy] = GetColor(kiclrAndy);
m_aclrEcom[kiaiclrOlstrom] = GetColor(kiclrOlstrom);
m_aclrEcom[kiaiclrFox] = GetColor(kiclrFox);
return true;
}
@ -460,9 +455,7 @@ void EcomTextControl::DrawText(DibBitmap *pbm, Font *pfnt, char *psz, int x, int
char *pszNextSpeech = psz;
int cchSpeech;
byte biclr = GetColor(kiclrWhite) & 0xff; // make into a dword
dword dwiclr = MAKEDWORD(biclr); // default color
dword dwiColorName = dwiclr; // save for doing names
Color clr = GetColor(kiclrWhite); // default color
int xStart = x;
int cxStart = cx;
@ -486,19 +479,19 @@ void EcomTextControl::DrawText(DibBitmap *pbm, Font *pfnt, char *psz, int x, int
// set the color for a new speech
switch (*pszNextSpeech) {
case 'A':
dwiclr = m_aiclrEcom[kiaiclrAndy];
clr = m_aclrEcom[kiaiclrAndy];
iszNames = 1;
break;
case 'J':
dwiclr = m_aiclrEcom[kiaiclrJana];
clr = m_aclrEcom[kiaiclrJana];
iszNames = 2;
break;
case 'O':
dwiclr = m_aiclrEcom[kiaiclrOlstrom];
clr = m_aclrEcom[kiaiclrOlstrom];
iszNames = 3;
break;
case 'F':
dwiclr = m_aiclrEcom[kiaiclrFox];
clr = m_aclrEcom[kiaiclrFox];
iszNames = 4;
break;
default:
@ -513,7 +506,7 @@ void EcomTextControl::DrawText(DibBitmap *pbm, Font *pfnt, char *psz, int x, int
// seems wonky to use both dwWhite and dwiscColor but palm compiler
// messes it up if I don't use the intermediate variable
pfnt->DrawText(pbm, s_aszNames[iszNames], x, y, -1, &dwiColorName );
pfnt->DrawText(pbm, s_aszNames[iszNames], x, y, -1, &clr);
int cxName = pfnt->GetTextExtent(s_aszNames[iszNames]);
x += cxName;
cx -= cxName;
@ -542,7 +535,7 @@ void EcomTextControl::DrawText(DibBitmap *pbm, Font *pfnt, char *psz, int x, int
if (cch >= cchSpeech)
cch = cchSpeech;
cchSpeech -= cch;
int iret = pfnt->DrawText(pbm, pszStart, x, y, cch, &dwiclr);
int iret = pfnt->DrawText(pbm, pszStart, x, y, cch, &clr);
// cch does not include the whitespace char being used
// to break the line!

View File

@ -536,11 +536,11 @@ void GraffitiScrollControl::OnPaint(DibBitmap *pbm)
Rect rcT = m_rc;
rcT.Offset(rcForm.left, rcForm.top);
int iclr = GetColor(kiclrWhite);
pbm->Fill(rcT.left + 1, rcT.top, rcT.Width() - 2, 1, iclr);
pbm->Fill(rcT.left, rcT.top + 1, 1, rcT.Height() - 2, iclr);
pbm->Fill(rcT.right - 1, rcT.top + 1, 1, rcT.Height() - 2, iclr);
pbm->Fill(rcT.left + 1, rcT.bottom - 1, rcT.Width() - 2, 1, iclr);
Color clr = GetColor(kiclrWhite);
pbm->Fill(rcT.left + 1, rcT.top, rcT.Width() - 2, 1, clr);
pbm->Fill(rcT.left, rcT.top + 1, 1, rcT.Height() - 2, clr);
pbm->Fill(rcT.right - 1, rcT.top + 1, 1, rcT.Height() - 2, clr);
pbm->Fill(rcT.left + 1, rcT.bottom - 1, rcT.Width() - 2, 1, clr);
}
bool GraffitiScrollControl::IsPainting()

View File

@ -454,15 +454,15 @@ void StructGob::Draw(DibBitmap *pbm, int xViewOrigin, int yViewOrigin, int nLaye
switch (nLayer) {
case knLayerMiniMap:
{
int iclr;
Color clr;
if (m_ff & kfGobSelected)
iclr = kiclrWhite;
clr = GetColor(kiclrWhite);
else
iclr = GetSideColor(m_pplr->GetSide());
clr = GetSideColor(m_pplr->GetSide());
int cxy = gsim.GetMiniMapScale();
pbm->Fill(xViewOrigin + MmcFromWc(m_wx), yViewOrigin + MmcFromWc(m_wy), m_pstruc->ctx * cxy, m_pstruc->cty * cxy,
GetColor(iclr));
clr);
}
return;

View File

@ -193,7 +193,7 @@ int DibBitmap::GetPitch()
void DibBitmap::Fill(int x, int y, int cx, int cy, Color clr)
{
SDL_Rect rc = { x, y, cx, cy };
SDL_FillRect(m_surface, &rc, clr);
SDL_FillRect(m_surface, &rc, SDL_MapRGB(m_surface->format, clr.r, clr.g, clr.b));
}
void DibBitmap::FillTo(class DibBitmap *pbmDst, int xDst, int yDst,
@ -243,10 +243,7 @@ void DibBitmap::DrawLine(short x1, short y1, short x2, short y2, Color clr)
if ((m_renderer = SDL_CreateSoftwareRenderer(m_surface)) == NULL)
return;
byte r, g, b;
SDL_GetRGB(clr, m_surface->format, &r, &g, &b);
SDL_SetRenderDrawColor(m_renderer, r, g, b, 255);
SDL_SetRenderDrawColor(m_renderer, clr.r, clr.g, clr.b, 255);
SDL_RenderDrawLine(m_renderer, x1, y1, x2, y2);
}

View File

@ -308,7 +308,7 @@ int Font::CalcBreak(int cx, char **ppsz, bool fChop)
return cch;
}
int Font::DrawText(DibBitmap *pbm, char *psz, int x, int y, int cch, dword *mpscaiclr)
int Font::DrawText(DibBitmap *pbm, char *psz, int x, int y, int cch, Color *pclr)
{
if (cch == -1)
cch = (int)strlen(psz);

View File

@ -1175,6 +1175,7 @@ bool Game::InitDisplay(int immRequested)
// Set the global fixed colors table
switch (m_amm[m_immCurrent].nDepthData) {
#if 0
case 4:
gaclrFixed = gaclr4bpp;
gfGrayscale = true;
@ -1184,7 +1185,7 @@ bool Game::InitDisplay(int immRequested)
gaclrFixed = gaclr8bpp;
gfGrayscale = false;
break;
#endif
case 24:
case 32:
gaclrFixed = gaclr24bpp;
@ -1664,7 +1665,7 @@ int Game::RunSimulation(Stream *pstm, char *pszLevel, word wfRole,
DialogForm *pfrm = (DialogForm *)gpmfrmm->LoadForm(gpiniForms, kidfLoading, new DialogForm());
if (pfrm != NULL) {
pfrm->SetBackgroundColorIndex(kiclrBlack);
pfrm->SetTitleColor(kiclrBlack);
pfrm->SetTitleColor(GetColor(kiclrBlack));
pfrm->SetBorderColorIndex(kiclr0CyanSide);
gpmfrmm->DrawFrame(false);
}

View File

@ -3083,7 +3083,7 @@ private:
void CalcRect() secEcom;
int m_cchCur;
dword m_aiclrEcom[4];
Color m_aclrEcom[4];
long m_ctPrevTime;
};

View File

@ -649,7 +649,7 @@ int GetFancyTextExtent(Font *pfntDefault, char *psz, int cch)
int FancyTextCore(DibBitmap *pbm, Font *pfntDefault, char *psz, int x, int y, int cch, bool fGetExtent)
{
dword *mpscaiclr = NULL;
Color *pclr = NULL;
Font *pfnt = pfntDefault;
if (cch == 0)
@ -668,7 +668,7 @@ int FancyTextCore(DibBitmap *pbm, Font *pfntDefault, char *psz, int x, int y, in
if (fGetExtent) {
cx += pfnt->GetTextExtent(psz, (int)(pchT - psz - 1));
} else {
cx += pfnt->DrawText(pbm, psz, x, y, (int)(pchT - psz - 1), mpscaiclr);
cx += pfnt->DrawText(pbm, psz, x, y, (int)(pchT - psz - 1), pclr);
x += cx;
}
psz = pchT;
@ -702,7 +702,7 @@ int FancyTextCore(DibBitmap *pbm, Font *pfntDefault, char *psz, int x, int y, in
if (fGetExtent)
cx += pfnt->GetTextExtent(psz, (int)(pchT - psz));
else
cx += pfnt->DrawText(pbm, psz, x, y, (int)(pchT - psz), mpscaiclr);
cx += pfnt->DrawText(pbm, psz, x, y, (int)(pchT - psz), pclr);
}
return cx;