forked from Mirrors/openclonk
Remove a lot of old obsolete palette code
Hardcode the few remaining palette references instead. We might want to include some method to customize some colors again, but not for debug display and such things.stable-5.1
parent
9a4c56fc10
commit
e109df627c
|
@ -489,10 +489,7 @@ bool C4Game::Init()
|
|||
if (!InitGameFinal()) return false;
|
||||
SetInitProgress(99);
|
||||
|
||||
// Color palette
|
||||
if (Application.isFullScreen) Application.DDraw->WipeSurface(FullScreen.pSurface);
|
||||
GraphicsSystem.SetPalette();
|
||||
GraphicsSystem.SetDarkColorTable();
|
||||
// Gamma
|
||||
GraphicsSystem.ApplyGamma();
|
||||
|
||||
// Message board and upper board
|
||||
|
@ -872,10 +869,6 @@ bool C4Game::InitMaterialTexture()
|
|||
// Cross map mats (after texture init, because Material-Texture-combinations are used)
|
||||
if (!::MaterialMap.CrossMapMaterials()) return false;
|
||||
|
||||
// mapping to landscape palette will occur when landscape has been created
|
||||
// set the pal
|
||||
::GraphicsSystem.SetPalette();
|
||||
|
||||
// get material script funcs
|
||||
::MaterialMap.UpdateScriptPointers();
|
||||
|
||||
|
|
|
@ -121,13 +121,6 @@ void C4GraphicsSystem::Clear()
|
|||
DeactivateDebugOutput();
|
||||
}
|
||||
|
||||
bool C4GraphicsSystem::SetPalette()
|
||||
{
|
||||
// Set primary palette by game palette
|
||||
if (!Application.DDraw->SetPrimaryPalette(::GraphicsResource.GamePalette, ::GraphicsResource.AlphaPalette)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
extern int32_t iLastControlSize,iPacketDelay;
|
||||
extern int32_t ControlQueueSize,ControlQueueDataSize;
|
||||
|
||||
|
@ -223,9 +216,6 @@ void C4GraphicsSystem::Execute()
|
|||
::pGUI->Render(false);
|
||||
}
|
||||
|
||||
// Palette update
|
||||
if (fSetPalette) { SetPalette(); /*SetDarkColorTable();*/ fSetPalette=false; }
|
||||
|
||||
// gamma update
|
||||
if (fSetGamma)
|
||||
{
|
||||
|
@ -336,7 +326,6 @@ void C4GraphicsSystem::Default()
|
|||
ShowHelp=false;
|
||||
FlashMessageText[0]=0;
|
||||
FlashMessageTime=0; FlashMessageX=FlashMessageY=0;
|
||||
fSetPalette=false;
|
||||
Video.Default();
|
||||
for (int32_t iRamp=0; iRamp<3*C4MaxGammaRamps; iRamp+=3)
|
||||
{ dwGamma[iRamp+0]=0; dwGamma[iRamp+1]=0x808080; dwGamma[iRamp+2]=0xffffff; }
|
||||
|
@ -693,25 +682,6 @@ void C4GraphicsSystem::DrawHoldMessages()
|
|||
}
|
||||
}
|
||||
|
||||
BYTE FindPaletteColor(BYTE *bypPalette, int32_t iRed, int32_t iGreen, int32_t iBlue)
|
||||
{
|
||||
int32_t iClosest=0;
|
||||
for (int32_t iColor=1; iColor<256; iColor++)
|
||||
if (Abs(bypPalette[iColor*3+0]-iRed)+Abs(bypPalette[iColor*3+1]-iGreen)+Abs(bypPalette[iColor*3+2]-iBlue)
|
||||
< Abs(bypPalette[iClosest*3+0]-iRed)+Abs(bypPalette[iClosest*3+1]-iGreen)+Abs(bypPalette[iClosest*3+2]-iBlue) )
|
||||
iClosest = iColor;
|
||||
return iClosest;
|
||||
}
|
||||
|
||||
void C4GraphicsSystem::SetDarkColorTable()
|
||||
{
|
||||
const int32_t iDarkening=80;
|
||||
// Using GamePalette
|
||||
BYTE *bypPalette = ::GraphicsResource.GamePalette;
|
||||
for (int32_t iColor=0; iColor<256; iColor++)
|
||||
DarkColorTable[iColor]=FindPaletteColor(bypPalette,Max<int32_t>(bypPalette[iColor*3+0]-iDarkening,0),Max<int32_t>(bypPalette[iColor*3+1]-iDarkening,0),Max<int32_t>(bypPalette[iColor*3+2]-iDarkening,0));
|
||||
}
|
||||
|
||||
void C4GraphicsSystem::FlashMessage(const char *szMessage)
|
||||
{
|
||||
// Store message
|
||||
|
|
|
@ -54,8 +54,6 @@ public:
|
|||
bool ShowPathfinder;
|
||||
bool ShowNetstatus;
|
||||
bool ShowSolidMask;
|
||||
BYTE DarkColorTable[256];
|
||||
bool fSetPalette;
|
||||
uint32_t dwGamma[C4MaxGammaRamps*3]; // gamma ramps
|
||||
bool fSetGamma; // must gamma ramp be reassigned?
|
||||
C4Video Video;
|
||||
|
@ -67,7 +65,6 @@ public:
|
|||
void Execute();
|
||||
void FlashMessage(const char *szMessage);
|
||||
void FlashMessageOnOff(const char *strWhat, bool fOn);
|
||||
void SetDarkColorTable();
|
||||
void DeactivateDebugOutput();
|
||||
void MouseMove(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, class C4Viewport *pVP); // pVP specified for console mode viewports only
|
||||
void SetMouseInGUI(bool fInGUI, bool fByMouse);
|
||||
|
@ -80,7 +77,6 @@ public:
|
|||
void EnableLoaderDrawing(); // reset black screen loader flag
|
||||
bool SaveScreenshot(bool fSaveAll);
|
||||
bool DoSaveScreenshot(bool fSaveAll, const char *szFilename);
|
||||
bool SetPalette();
|
||||
bool CreateViewport(int32_t iPlayer, bool fSilent);
|
||||
bool CloseViewport(int32_t iPlayer, bool fSilent);
|
||||
int32_t GetAudibility(int32_t iX, int32_t iY, int32_t *iPan, int32_t iAudibilityRadius=0);
|
||||
|
|
|
@ -452,10 +452,10 @@ void C4EditCursor::Draw(C4TargetFacet &cgo, float Zoom)
|
|||
}
|
||||
// Draw drag frame
|
||||
if (DragFrame)
|
||||
Application.DDraw->DrawFrame(cgo.Surface,Min(X,X2)*Zoom+cgo.X-cgo.TargetX*Zoom,Min(Y,Y2)*Zoom+cgo.Y-cgo.TargetY*Zoom,Max(X,X2)*Zoom+cgo.X-cgo.TargetX*Zoom,Max(Y,Y2)*Zoom+cgo.Y-cgo.TargetY*Zoom,CWhite);
|
||||
Application.DDraw->DrawFrameDw(cgo.Surface,Min(X,X2)*Zoom+cgo.X-cgo.TargetX*Zoom,Min(Y,Y2)*Zoom+cgo.Y-cgo.TargetY*Zoom,Max(X,X2)*Zoom+cgo.X-cgo.TargetX*Zoom,Max(Y,Y2)*Zoom+cgo.Y-cgo.TargetY*Zoom,0xffffffff);
|
||||
// Draw drag line
|
||||
if (DragLine)
|
||||
Application.DDraw->DrawLine(cgo.Surface,X*Zoom+cgo.X-cgo.TargetX*Zoom,Y*Zoom+cgo.Y-cgo.TargetY*Zoom,X2*Zoom+cgo.X-cgo.TargetX*Zoom,Y2*Zoom+cgo.Y-cgo.TargetY*Zoom,CWhite);
|
||||
Application.DDraw->DrawLineDw(cgo.Surface,X*Zoom+cgo.X-cgo.TargetX*Zoom,Y*Zoom+cgo.Y-cgo.TargetY*Zoom,X2*Zoom+cgo.X-cgo.TargetX*Zoom,Y2*Zoom+cgo.Y-cgo.TargetY*Zoom,0xffffffff);
|
||||
// Draw drop target
|
||||
if (DropTarget)
|
||||
::GraphicsResource.fctDropTarget.Draw(cgo.Surface,
|
||||
|
|
|
@ -708,8 +708,6 @@ void C4ToolsDlg::UpdatePreview()
|
|||
Grade,
|
||||
bCol, Pattern, *::Landscape.GetPal());
|
||||
|
||||
Application.DDraw->AttachPrimaryPalette(sfcPreview);
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
|
|
|
@ -732,7 +732,7 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo
|
|||
Surface32 = new CSurface();
|
||||
Surface8 = new CSurface8();
|
||||
if (!Surface32->Create(Width, Height, true, false, lpDDraw->IsShaderific() ? 0 : 64)
|
||||
|| !Surface8->Create(Width, Height, true)
|
||||
|| !Surface8->Create(Width, Height)
|
||||
|| !Mat2Pal())
|
||||
{
|
||||
delete Surface8; delete Surface32;
|
||||
|
@ -767,9 +767,6 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo
|
|||
// Load diff, if existant
|
||||
ApplyDiff(hGroup);
|
||||
|
||||
// enforce first color to be transparent
|
||||
Surface8->EnforceC0Transparency();
|
||||
|
||||
// after map/landscape creation, the seed must be fixed again, so there's no difference between clients creating
|
||||
// and not creating the map
|
||||
Game.FixRandom(Game.RandomSeed);
|
||||
|
@ -2146,13 +2143,13 @@ bool ConstructionCheck(C4PropList * PropList, int32_t iX, int32_t iY, C4Object *
|
|||
// Check def
|
||||
if (!(ndef=PropList->GetDef()))
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_UNDEF"), PropList->GetName()).getData(),pByObj,FRed);
|
||||
if (pByObj) GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_UNDEF"), PropList->GetName()).getData(),pByObj);
|
||||
return false;
|
||||
}
|
||||
// Constructable?
|
||||
if (!ndef->Constructable)
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCON"),ndef->GetName()).getData(),pByObj,FRed);
|
||||
if (pByObj) GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOCON"),ndef->GetName()).getData(),pByObj);
|
||||
return false;
|
||||
}
|
||||
// Check area
|
||||
|
@ -2161,19 +2158,19 @@ bool ConstructionCheck(C4PropList * PropList, int32_t iX, int32_t iY, C4Object *
|
|||
rtx=iX-wdt/2; rty=iY-hgt;
|
||||
if (::Landscape.AreaSolidCount(rtx,rty,wdt,hgt)>(wdt*hgt/20))
|
||||
{
|
||||
if (pByObj) GameMsgObject(LoadResStr("IDS_OBJ_NOROOM"),pByObj,FRed);
|
||||
if (pByObj) GameMsgObjectError(LoadResStr("IDS_OBJ_NOROOM"),pByObj);
|
||||
return false;
|
||||
}
|
||||
if (::Landscape.AreaSolidCount(rtx,rty+hgt,wdt,5)<(wdt*2))
|
||||
{
|
||||
if (pByObj) GameMsgObject(LoadResStr("IDS_OBJ_NOLEVEL"),pByObj,FRed);
|
||||
if (pByObj) GameMsgObjectError(LoadResStr("IDS_OBJ_NOLEVEL"),pByObj);
|
||||
return false;
|
||||
}
|
||||
// Check other structures
|
||||
C4Object *other;
|
||||
if ((other=Game.OverlapObject(rtx,rty,wdt,hgt,ndef->Category)))
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ()).getData(),pByObj,FRed);
|
||||
if (pByObj) GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ()).getData(),pByObj);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -244,44 +244,44 @@ bool C4PathFinderRay::Execute()
|
|||
|
||||
void C4PathFinderRay::Draw(C4TargetFacet &cgo)
|
||||
{
|
||||
BYTE byColor=CRed;
|
||||
uint32_t Color=0xffff0000;
|
||||
switch (Status)
|
||||
{
|
||||
case C4PF_Ray_Crawl: byColor=CRed; break;
|
||||
case C4PF_Ray_Still: byColor=CDRed; break;
|
||||
case C4PF_Ray_Failure: byColor=CYellow; break;
|
||||
case C4PF_Ray_Deleted: byColor=CGray2; break;
|
||||
case C4PF_Ray_Crawl: Color=C4RGB(0xff, 0, 0); break;
|
||||
case C4PF_Ray_Still: Color=C4RGB(0x50, 0, 0); break;
|
||||
case C4PF_Ray_Failure: Color=C4RGB(0xff, 0xff, 0); break;
|
||||
case C4PF_Ray_Deleted: Color=C4RGB(0x59, 0x59, 0x59); break;
|
||||
}
|
||||
if (UseZone) byColor=CBlue;
|
||||
if (UseZone) Color=C4RGB(0, 0, 0xff);
|
||||
|
||||
// Crawl attachment
|
||||
if (Status==C4PF_Ray_Crawl)
|
||||
{
|
||||
int32_t iX=0,iY=0; CrawlToAttach(iX,iY,CrawlAttach);
|
||||
lpDDraw->DrawLine(cgo.Surface,
|
||||
lpDDraw->DrawLineDw(cgo.Surface,
|
||||
cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY,
|
||||
cgo.X+X2-cgo.TargetX+7*iX,cgo.Y+Y2-cgo.TargetY+7*iY,
|
||||
CRed);
|
||||
C4RGB(0xff, 0, 0));
|
||||
//sprintf(OSTR,"%d",Depth); lpDDraw->TextOut(OSTR,cgo.Surface,cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY+20,CGray4);
|
||||
}
|
||||
|
||||
// Ray line
|
||||
lpDDraw->DrawLine(cgo.Surface,
|
||||
lpDDraw->DrawLineDw(cgo.Surface,
|
||||
cgo.X+X-cgo.TargetX,cgo.Y+Y-cgo.TargetY,
|
||||
cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY,
|
||||
byColor);
|
||||
Color);
|
||||
|
||||
// Crawler point
|
||||
lpDDraw->DrawFrame(cgo.Surface,
|
||||
lpDDraw->DrawFrameDw(cgo.Surface,
|
||||
cgo.X+X2-cgo.TargetX-1,cgo.Y+Y2-cgo.TargetY-1,
|
||||
cgo.X+X2-cgo.TargetX+1,cgo.Y+Y2-cgo.TargetY+1,
|
||||
(Status==C4PF_Ray_Crawl) ? ((Direction==C4PF_Direction_Left) ? CGreen : CBlue) : byColor);
|
||||
(Status==C4PF_Ray_Crawl) ? ((Direction==C4PF_Direction_Left) ? C4RGB(0, 0xff, 0) : C4RGB(0, 0, 0xff)) : Color);
|
||||
|
||||
// Search target point
|
||||
lpDDraw->DrawFrame(cgo.Surface,
|
||||
lpDDraw->DrawFrameDw(cgo.Surface,
|
||||
cgo.X+TargetX-cgo.TargetX-2,cgo.Y+TargetY-cgo.TargetY-2,
|
||||
cgo.X+TargetX-cgo.TargetX+2,cgo.Y+TargetY-cgo.TargetY+2,
|
||||
CYellow);
|
||||
C4RGB(0xff, 0xff, 0));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,8 @@ void C4Sky::SetFadePalette(int32_t *ipColors)
|
|||
// If colors all zero, use game palette default blue
|
||||
if (ipColors[0]+ipColors[1]+ipColors[2]+ipColors[3]+ipColors[4]+ipColors[5]==0)
|
||||
{
|
||||
BYTE *pClr=::GraphicsResource.GamePalette+3*CSkyDef1;
|
||||
FadeClr1=C4RGB(pClr[0], pClr[1], pClr[2]);
|
||||
FadeClr2=C4RGB(pClr[3*19+0], pClr[3*19+1], pClr[3*19+2]);
|
||||
FadeClr1=C4RGB(0x1c, 0x40, 0x99);
|
||||
FadeClr2=C4RGB(0xc2, 0xc6, 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -115,12 +114,6 @@ bool C4Sky::Init(bool fSavegame)
|
|||
if (loaded)
|
||||
{
|
||||
// surface loaded, store first color index
|
||||
/*if (Surface->HasOwnPal())
|
||||
{
|
||||
FadeClr1=Surface->pPal->GetClr(0);
|
||||
FadeClr2=Surface->pPal->GetClr(19);
|
||||
}
|
||||
else*/
|
||||
FadeClr1=FadeClr2=0xffffffff;
|
||||
// enlarge surface to avoid slow 1*1-px-skies
|
||||
if (!SurfaceEnsureSize(&Surface, 128, 128)) return false;
|
||||
|
|
|
@ -1724,9 +1724,6 @@ bool C4Command::FlightControl() // Called by DFA_WALK, DFA_FLIGHT
|
|||
for (iTopFree=0; (iTopFree<50) && !GBackSolid(cx,cy+cObj->Shape.GetY()-iTopFree); ++iTopFree) {}
|
||||
if (iTopFree>=15)
|
||||
{
|
||||
//sprintf(OSTR,"Flight take off at %d (%d)",iAngle,Distance(cx,cy,Tx,Ty)); Log(OSTR); GameMsgObject(OSTR,cObj);
|
||||
//cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); return true;
|
||||
|
||||
// Take off
|
||||
cObj->SetActionByName("Fly"); // This is a little primitive... we should have a ObjectActionFly or maybe a command for this...
|
||||
}
|
||||
|
@ -1756,7 +1753,6 @@ bool C4Command::JumpControl() // Called by DFA_WALK
|
|||
for (iTopFree=0; (iTopFree<50) && !GBackSolid(cx,cy+cObj->Shape.GetY()-iTopFree); ++iTopFree) {}
|
||||
if (iTopFree>=15)
|
||||
{
|
||||
//sprintf(OSTR,"Diagonal %d (%d)",iAngle,Distance(cx,cy,Tx,Ty)); GameMsgObject(OSTR,cObj);
|
||||
cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); return true;
|
||||
}
|
||||
}
|
||||
|
@ -1780,27 +1776,19 @@ bool C4Command::JumpControl() // Called by DFA_WALK
|
|||
cObj->AddCommand(C4CMD_MoveTo,NULL,iSideX,iSideY,50);
|
||||
return true;
|
||||
}
|
||||
/*else
|
||||
{ sprintf(OSTR,"Side move %d/%d path not free",iSideX,iSideY); GameMsgObject(OSTR,cObj); }*/
|
||||
}
|
||||
/*else
|
||||
{ sprintf(OSTR,"Side move %d out of range",iSideX-cx); GameMsgObject(OSTR,cObj); }*/
|
||||
}
|
||||
/*else
|
||||
{ sprintf(OSTR,"No high range %d",cy-Ty); GameMsgObject(OSTR,cObj); }*/
|
||||
|
||||
// Low side contact jump
|
||||
int32_t iLowSideRange=5;
|
||||
if (cObj->t_contact & CNAT_Right)
|
||||
if (Inside(iAngle-JumpLowAngle,-iLowSideRange*JumpAngleRange,+iLowSideRange*JumpAngleRange))
|
||||
{
|
||||
//sprintf(OSTR,"Low contact right %d",iAngle); GameMsgObject(OSTR,cObj);
|
||||
cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); return true;
|
||||
}
|
||||
if (cObj->t_contact & CNAT_Left)
|
||||
if (Inside(iAngle+JumpLowAngle,-iLowSideRange*JumpAngleRange,+iLowSideRange*JumpAngleRange))
|
||||
{
|
||||
//sprintf(OSTR,"Low contact left %d",iAngle); GameMsgObject(OSTR,cObj);
|
||||
cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); return true;
|
||||
}
|
||||
|
||||
|
@ -2046,7 +2034,7 @@ void C4Command::Fail(const char *szFailMessage)
|
|||
// Message (if not empty)
|
||||
if (!!str)
|
||||
{
|
||||
::Messages.Append(C4GM_Target, str.getData(), l_Obj, NO_OWNER, 0, 0, FWhite, true);
|
||||
::Messages.Append(C4GM_Target, str.getData(), l_Obj, NO_OWNER, 0, 0, C4RGB(0xff, 0xff, 0xff), true);
|
||||
}
|
||||
// Fail sound
|
||||
StartSoundEffect("CommandFailure*",false,100,l_Obj);
|
||||
|
|
|
@ -662,7 +662,7 @@ void C4Def::Draw(C4Facet &cgo, bool fSelected, DWORD iColor, C4Object *pObj, int
|
|||
if (pObj) if (pObj->PictureRect.Wdt) fctPicRect = pObj->PictureRect;
|
||||
|
||||
if (fSelected)
|
||||
Application.DDraw->DrawBox(cgo.Surface,cgo.X,cgo.Y,cgo.X+cgo.Wdt-1,cgo.Y+cgo.Hgt-1,CRed);
|
||||
Application.DDraw->DrawBoxDw(cgo.Surface, cgo.X, cgo.Y, cgo.X + cgo.Wdt - 1, cgo.Y + cgo.Hgt - 1, C4RGB(0xca, 0, 0));
|
||||
|
||||
C4DefGraphics* graphics = pObj ? pObj->GetGraphics() : &Graphics;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
C4Surface* surface = new C4Surface;
|
||||
// Suppress error message here, StdMeshMaterial loader
|
||||
// will show one.
|
||||
if (!surface->Read(Group, GetExtension(filename), false))
|
||||
if (!surface->Read(Group, GetExtension(filename)))
|
||||
{ delete surface; surface = NULL; }
|
||||
return surface;
|
||||
}
|
||||
|
|
|
@ -126,9 +126,9 @@ void DrawVertex(C4Facet &cgo, int32_t tx, int32_t ty, int32_t col, int32_t conta
|
|||
{
|
||||
if (Inside<int32_t>(tx,1,cgo.Wdt-2) && Inside<int32_t>(ty,1,cgo.Hgt-2))
|
||||
{
|
||||
Application.DDraw->DrawHorizontalLine(cgo.Surface,cgo.X+tx-1,cgo.X+tx+1,cgo.Y+ty,col);
|
||||
Application.DDraw->DrawVerticalLine(cgo.Surface,cgo.X+tx,cgo.Y+ty-1,cgo.Y+ty+1,col);
|
||||
if (contact) Application.DDraw->DrawFrame(cgo.Surface,cgo.X+tx-2,cgo.Y+ty-2,cgo.X+tx+2,cgo.Y+ty+2,CWhite);
|
||||
Application.DDraw->DrawLineDw(cgo.Surface, cgo.X + tx - 1, cgo.Y + ty, cgo.X + tx + 1, cgo.Y + ty, col);
|
||||
Application.DDraw->DrawLineDw(cgo.Surface, cgo.X + tx, cgo.Y + ty - 1, cgo.X + tx, cgo.Y + ty + 1, col);
|
||||
if (contact) Application.DDraw->DrawFrameDw(cgo.Surface,cgo.X+tx-2,cgo.Y+ty-2,cgo.X+tx+2,cgo.Y+ty+2,C4RGB(0xff, 0xff, 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1820,7 +1820,7 @@ bool C4Object::Push(C4Real txdir, C4Real dforce, bool fStraighten)
|
|||
if (!::Game.iTick35) if (txdir) if (!Def->NoHorizontalMove)
|
||||
if (ContactCheck(GetX(), GetY())) // Resets t_contact
|
||||
{
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_STUCK"),GetName()).getData(),this);
|
||||
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_STUCK"),GetName()).getData(),this);
|
||||
Call(PSF_Stuck);
|
||||
}
|
||||
|
||||
|
@ -1848,7 +1848,7 @@ bool C4Object::Lift(C4Real tydir, C4Real dforce)
|
|||
if (tydir != -GravAccel)
|
||||
if (ContactCheck(GetX(), GetY())) // Resets t_contact
|
||||
{
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_STUCK"),GetName()).getData(),this);
|
||||
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_STUCK"),GetName()).getData(),this);
|
||||
Call(PSF_Stuck);
|
||||
}
|
||||
return true;
|
||||
|
@ -2339,8 +2339,8 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
|
|||
// Path
|
||||
x1=ccx-cotx; y1=ccy-coty;
|
||||
x2=pCom->Tx._getInt()-cotx; y2=pCom->Ty-coty;
|
||||
Application.DDraw->DrawLine(cgo.Surface,cgo.X+x1,cgo.Y+y1,cgo.X+x2,cgo.Y+y2,CRed);
|
||||
Application.DDraw->DrawFrame(cgo.Surface,cgo.X+x2-1,cgo.Y+y2-1,cgo.X+x2+1,cgo.Y+y2+1,CRed);
|
||||
Application.DDraw->DrawLineDw(cgo.Surface,cgo.X+x1,cgo.Y+y1,cgo.X+x2,cgo.Y+y2,C4RGB(0xca,0,0));
|
||||
Application.DDraw->DrawFrameDw(cgo.Surface,cgo.X+x2-1,cgo.Y+y2-1,cgo.X+x2+1,cgo.Y+y2+1,C4RGB(0xca,0,0));
|
||||
if (x1>x2) Swap(x1,x2); if (y1>y2) Swap(y1,y2);
|
||||
ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
|
||||
// Message
|
||||
|
@ -2370,8 +2370,8 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
|
|||
// Path
|
||||
x1=ccx-cotx; y1=ccy-coty;
|
||||
x2=pCom->Tx._getInt()-cotx; y2=pCom->Ty-coty;
|
||||
Application.DDraw->DrawLine(cgo.Surface,cgo.X+x1,cgo.Y+y1,cgo.X+x2,cgo.Y+y2,CGreen);
|
||||
Application.DDraw->DrawFrame(cgo.Surface,cgo.X+x2-1,cgo.Y+y2-1,cgo.X+x2+1,cgo.Y+y2+1,CGreen);
|
||||
Application.DDraw->DrawLineDw(cgo.Surface,cgo.X+x1,cgo.Y+y1,cgo.X+x2,cgo.Y+y2,C4RGB(0,0xca,0));
|
||||
Application.DDraw->DrawFrameDw(cgo.Surface,cgo.X+x2-1,cgo.Y+y2-1,cgo.X+x2+1,cgo.Y+y2+1,C4RGB(0,0xca,0));
|
||||
if (x1>x2) Swap(x1,x2); if (y1>y2) Swap(y1,y2);
|
||||
ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
|
||||
// Message
|
||||
|
@ -2513,7 +2513,7 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
|
|||
DrawVertex(cgo,
|
||||
cox-Shape.GetX()+Shape.VtxX[cnt],
|
||||
coy-Shape.GetY()+Shape.VtxY[cnt],
|
||||
(Shape.VtxCNAT[cnt] & CNAT_NoCollision) ? CBlue : (Mobile ? CRed : CYellow),
|
||||
(Shape.VtxCNAT[cnt] & CNAT_NoCollision) ? C4RGB(0, 0, 0xff) : (Mobile ? C4RGB(0xff, 0, 0) : C4RGB(0xef, 0xef, 0)),
|
||||
Shape.VtxContactCNAT[cnt]);
|
||||
}
|
||||
}
|
||||
|
@ -2521,17 +2521,17 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
|
|||
if (::GraphicsSystem.ShowEntrance) if (eDrawMode!=ODM_BaseOnly)
|
||||
{
|
||||
if (OCF & OCF_Entrance)
|
||||
Application.DDraw->DrawFrame(cgo.Surface,cgo.X+cox-Shape.x+Def->Entrance.x,
|
||||
Application.DDraw->DrawFrameDw(cgo.Surface,cgo.X+cox-Shape.x+Def->Entrance.x,
|
||||
cgo.Y+coy-Shape.y+Def->Entrance.y,
|
||||
cgo.X+cox-Shape.x+Def->Entrance.x+Def->Entrance.Wdt-1,
|
||||
cgo.Y+coy-Shape.y+Def->Entrance.y+Def->Entrance.Hgt-1,
|
||||
CBlue);
|
||||
C4RGB(0, 0, 0xff));
|
||||
if (OCF & OCF_Collection)
|
||||
Application.DDraw->DrawFrame(cgo.Surface,cgo.X+cox-Shape.x+Def->Collection.x,
|
||||
Application.DDraw->DrawFrameDw(cgo.Surface,cgo.X+cox-Shape.x+Def->Collection.x,
|
||||
cgo.Y+coy-Shape.y+Def->Collection.y,
|
||||
cgo.X+cox-Shape.x+Def->Collection.x+Def->Collection.Wdt-1,
|
||||
cgo.Y+coy-Shape.y+Def->Collection.y+Def->Collection.Hgt-1,
|
||||
CRed);
|
||||
C4RGB(0xca, 0, 0));
|
||||
}
|
||||
|
||||
if (::GraphicsSystem.ShowAction) if (eDrawMode!=ODM_BaseOnly)
|
||||
|
@ -3080,7 +3080,7 @@ C4Object *C4Object::ComposeContents(C4ID id)
|
|||
// BuildNeedsMaterial call to object...
|
||||
if (!Call(PSF_BuildNeedsMaterial,&C4AulParSet(C4VID(idNeeded), C4VInt(iNeeded))))
|
||||
// ...game message if not overloaded
|
||||
GameMsgObject(Needs.getData(),this);
|
||||
GameMsgObjectError(Needs.getData(),this);
|
||||
// Return
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ bool ObjectComDig(C4Object *cObj) // by DFA_WALK
|
|||
C4PhysicalInfo *phys=cObj->GetPhysical();
|
||||
if (!phys->CanDig || !ObjectActionDig(cObj))
|
||||
{
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj);
|
||||
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -403,7 +403,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
// Check physical
|
||||
if (!cObj->GetPhysical()->CanConstruct)
|
||||
{
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()).getData(),cObj); return false;
|
||||
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()).getData(),cObj); return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - Line pickup - - - - - - - - - - - - - - - - -
|
||||
|
@ -421,7 +421,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
|| (cline->Action.Target2 && (cline->Action.Target2->Def->id==C4ID::Linekit)) )
|
||||
{
|
||||
StartSoundEffect("Error",false,100,cObj);
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODOUBLEKIT"),cline->GetName()).getData(),cObj); return false;
|
||||
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NODOUBLEKIT"),cline->GetName()).getData(),cObj); return false;
|
||||
}
|
||||
// Create new linekit
|
||||
if (!(linekit=Game.CreateObject(C4ID::Linekit,cObj,cline->Owner))) return false;
|
||||
|
@ -455,7 +455,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
{
|
||||
// No connect
|
||||
StartSoundEffect("Error",false,100,cObj);
|
||||
GameMsgObject(LoadResStr("IDS_OBJ_NOCONNECT"),cObj); return false;
|
||||
GameMsgObjectError(LoadResStr("IDS_OBJ_NOCONNECT"),cObj); return false;
|
||||
}
|
||||
|
||||
// Check short circuit -> removal
|
||||
|
@ -485,7 +485,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
if (!connect_okay)
|
||||
{
|
||||
StartSoundEffect("Error",false,100,cObj);
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCONNECTTYPE"),cline->GetName(),tstruct->GetName()).getData(),tstruct);
|
||||
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOCONNECTTYPE"),cline->GetName(),tstruct->GetName()).getData(),tstruct);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
if (!tstruct || !(ocf & OCF_LineConstruct))
|
||||
{
|
||||
StartSoundEffect("Error",false,100,cObj);
|
||||
GameMsgObject(LoadResStr("IDS_OBJ_NONEWLINE"),cObj); return false;
|
||||
GameMsgObjectError(LoadResStr("IDS_OBJ_NONEWLINE"),cObj); return false;
|
||||
}
|
||||
|
||||
// Determine new line type
|
||||
|
@ -532,7 +532,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
if (linetype==C4ID::None)
|
||||
{
|
||||
StartSoundEffect("Error",false,100,cObj);
|
||||
GameMsgObject(LoadResStr("IDS_OBJ_NONEWLINE"),cObj); return false;
|
||||
GameMsgObjectError(LoadResStr("IDS_OBJ_NONEWLINE"),cObj); return false;
|
||||
}
|
||||
|
||||
// Create new line
|
||||
|
@ -693,7 +693,7 @@ bool ObjectComChop(C4Object *cObj, C4Object *pTarget)
|
|||
if (!pTarget) return false;
|
||||
if (!cObj->GetPhysical()->CanChop)
|
||||
{
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCHOP"),cObj->GetName()).getData(),cObj);
|
||||
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOCHOP"),cObj->GetName()).getData(),cObj);
|
||||
return false;
|
||||
}
|
||||
if (cObj->GetProcedure()!=DFA_WALK) return false;
|
||||
|
|
|
@ -2334,7 +2334,7 @@ static C4Value FnAddMessage_C4V(C4AulObjectContext *cthr, C4Value *c4vMessage, C
|
|||
C4String * szMessage = c4vMessage->getStr();
|
||||
if (!szMessage) return C4VBool(false);
|
||||
|
||||
::Messages.Append(C4GM_Target,FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7,iPar8).getData(),cthr->Obj,NO_OWNER,0,0,FWhite);
|
||||
::Messages.Append(C4GM_Target,FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7,iPar8).getData(),cthr->Obj,NO_OWNER,0,0,C4RGB(0xff, 0xff, 0xff));
|
||||
|
||||
return C4VBool(true);
|
||||
}
|
||||
|
|
|
@ -139,10 +139,10 @@ void C4TransferZones::Draw(C4TargetFacet &cgo)
|
|||
void C4TransferZone::Draw(C4TargetFacet &cgo, bool fHighlight)
|
||||
{
|
||||
if (Used) fHighlight=true;
|
||||
lpDDraw->DrawFrame(cgo.Surface,
|
||||
lpDDraw->DrawFrameDw(cgo.Surface,
|
||||
int(cgo.X+X-cgo.TargetX),int(cgo.Y+Y-cgo.TargetY),
|
||||
int(cgo.X+X-cgo.TargetX+Wdt-1),int(cgo.Y+Y-cgo.TargetY+Hgt-1),
|
||||
fHighlight ? CGreen : CRed);
|
||||
fHighlight ? C4RGB(0, 0xca, 0) : C4RGB(0xca, 0, 0));
|
||||
}
|
||||
|
||||
bool C4TransferZone::At(int32_t iX, int32_t iY)
|
||||
|
|
|
@ -301,14 +301,6 @@ void C4GameMessageList::Execute()
|
|||
}
|
||||
}
|
||||
|
||||
bool C4GameMessageList::New(int32_t iType, const char *szText,
|
||||
C4Object *pTarget, int32_t iPlayer,
|
||||
int32_t iX, int32_t iY,
|
||||
uint8_t bCol)
|
||||
{
|
||||
return New(iType, StdStrBuf(szText), pTarget, iPlayer, iX, iY, 0xff000000|Application.DDraw->Pal.GetClr(FColors[bCol]));
|
||||
}
|
||||
|
||||
bool C4GameMessageList::New(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID, const char *szPortraitDef, uint32_t dwFlags, int32_t width)
|
||||
{
|
||||
return New(iType, StdStrBuf(szText), pTarget, iPlayer, iX, iY, dwClr, idDecoID, szPortraitDef, dwFlags, width);
|
||||
|
@ -340,7 +332,7 @@ bool C4GameMessageList::New(int32_t iType, const StdStrBuf & sText, C4Object *pT
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4GameMessageList::Append(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint8_t bCol, bool fNoDuplicates)
|
||||
bool C4GameMessageList::Append(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t bCol, bool fNoDuplicates)
|
||||
{
|
||||
C4GameMessage *cmsg = NULL;
|
||||
if (iType == C4GM_Target)
|
||||
|
@ -399,4 +391,9 @@ void C4GameMessageList::Draw(C4TargetFacet &cgo, int32_t iPlayer, float Zoom)
|
|||
}
|
||||
}
|
||||
|
||||
void GameMsgObjectError(const char *szText, C4Object *pTarget, bool Red)
|
||||
{
|
||||
::Messages.New(C4GM_TargetPlayer,szText,pTarget,pTarget->Controller,0,0, Red ? C4RGB(0xca, 0, 0) : C4RGB(0xff, 0xff, 0xff));
|
||||
}
|
||||
|
||||
C4GameMessageList Messages;
|
||||
|
|
|
@ -96,23 +96,24 @@ public:
|
|||
void ClearPointers(C4Object *pObj);
|
||||
void UpdateDef(C4ID idUpdDef); // called after reloaddef
|
||||
bool New(int32_t iType, const StdStrBuf & Text, C4Object *pTarget, int32_t iPlayer, int32_t iX = -1, int32_t iY = -1, uint32_t dwClr = 0xffFFFFFF, C4ID idDecoID=C4ID::None, const char *szPortraitDef=NULL, uint32_t dwFlags=0u, int32_t width=0);
|
||||
bool New(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint8_t bCol);
|
||||
bool New(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID=C4ID::None, const char *szPortraitDef=NULL, uint32_t dwFlags=0u, int32_t width=0);
|
||||
bool Append(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint8_t bCol, bool fNoDuplicates = false);
|
||||
bool Append(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t bCol, bool fNoDuplicates = false);
|
||||
};
|
||||
|
||||
extern C4GameMessageList Messages;
|
||||
|
||||
inline void GameMsgObject(const char *szText, C4Object *pTarget, int32_t iFCol=FWhite)
|
||||
inline void GameMsgObject(const char *szText, C4Object *pTarget)
|
||||
{
|
||||
::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,(uint8_t) iFCol);
|
||||
::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,C4RGB(0xff, 0xff, 0xff));
|
||||
}
|
||||
|
||||
inline void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iFCol=FWhite)
|
||||
inline void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer)
|
||||
{
|
||||
::Messages.New(C4GM_TargetPlayer,szText,pTarget,iPlayer,0,0,(uint8_t) iFCol);
|
||||
::Messages.New(C4GM_TargetPlayer,szText,pTarget,iPlayer,0,0, C4RGB(0xff, 0xff, 0xff));
|
||||
}
|
||||
|
||||
void GameMsgObjectError(const char *szText, C4Object *pTarget, bool Red = true);
|
||||
|
||||
inline void GameMsgObjectDw(const char *szText, C4Object *pTarget, uint32_t dwClr)
|
||||
{
|
||||
::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,dwClr);
|
||||
|
|
|
@ -169,7 +169,7 @@ void C4MenuItem::DrawElement(C4TargetFacet &cgo)
|
|||
// Select mark
|
||||
if (iStyle!=C4MN_Style_Info)
|
||||
if (fSelected && TextDisplayProgress)
|
||||
Application.DDraw->DrawBox(cgo.Surface,cgoOut.X,cgoOut.Y,cgoOut.X+cgoOut.Wdt-1,cgoOut.Y+cgoOut.Hgt-1,CRed);
|
||||
Application.DDraw->DrawBoxDw(cgo.Surface, cgoOut.X, cgoOut.Y, cgoOut.X + cgoOut.Wdt - 1, cgoOut.Y + cgoOut.Hgt - 1, C4RGB(0xca, 0, 0));
|
||||
// Symbol/text areas
|
||||
C4Facet cgoItemSymbol,cgoItemText;
|
||||
cgoItemSymbol=cgoItemText=cgoOut;
|
||||
|
@ -934,10 +934,7 @@ void C4Menu::DrawElement(C4TargetFacet &cgo)
|
|||
|
||||
void C4Menu::DrawFrame(SURFACE sfcSurface, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt)
|
||||
{
|
||||
lpDDraw->DrawFrame(sfcSurface,iX+1,iY+1,iX+iWdt-1,iY+iHgt-1,80);
|
||||
// lpDDraw->DrawFrame(sfcSurface,iX,iY,iX+iWdt-2,iY+iHgt-2,87);
|
||||
// lpDDraw->SetPixel(sfcSurface,iX+iWdt-1,iY,85);
|
||||
// lpDDraw->SetPixel(sfcSurface,iX,iY+iHgt-1,85);
|
||||
lpDDraw->DrawFrameDw(sfcSurface, iX+1, iY+1, iX+iWdt-1,iY+iHgt-1, C4RGB(0x44, 0, 0));
|
||||
}
|
||||
|
||||
void C4Menu::SetAlignment(int32_t iAlignment)
|
||||
|
|
|
@ -225,7 +225,6 @@ protected:
|
|||
bool RefillInternal();
|
||||
void DrawButton(C4Facet &cgo);
|
||||
void DrawScrollbar(C4Facet &cgo, int32_t iTotal, int32_t iVisible, int32_t iPosition);
|
||||
void DrawFrame(C4Facet &cgo, int32_t iAlign);
|
||||
void DrawFrame(SURFACE sfcSurface, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt);
|
||||
void InitLocation(C4Facet &cgo);
|
||||
void InitSize();
|
||||
|
|
|
@ -506,12 +506,12 @@ void C4MouseControl::Draw(C4TargetFacet &cgo, const ZoomData &GameZoom)
|
|||
//------------------------------------------------------------------------------------------
|
||||
case C4MC_Drag_Selecting:
|
||||
// Draw frame
|
||||
Application.DDraw->DrawFrame( cgo.Surface,
|
||||
Application.DDraw->DrawFrameDw(cgo.Surface,
|
||||
int32_t(cgo.X + GuiX),
|
||||
int32_t(cgo.Y + GuiY),
|
||||
int32_t(cgo.X + (DownX - cgo.TargetX) * GameZoom.Zoom / GuiZoom.Zoom),
|
||||
int32_t(cgo.Y + (DownY - cgo.TargetY) * GameZoom.Zoom / GuiZoom.Zoom),
|
||||
CRed );
|
||||
C4RGB(0xca, 0, 0));
|
||||
break;
|
||||
//------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
|
|
@ -150,48 +150,6 @@ bool CPathFinderRay::Execute()
|
|||
return true;
|
||||
}
|
||||
|
||||
/*void CPathFinderRay::Draw(C4TargetFacet &cgo)
|
||||
{
|
||||
BYTE byColor=CRed;
|
||||
switch (Status)
|
||||
{
|
||||
case PF_Ray_Crawl: byColor=CRed; break;
|
||||
case PF_Ray_Still: byColor=CDRed; break;
|
||||
case PF_Ray_Failure: byColor=CYellow; break;
|
||||
case PF_Ray_Deleted: byColor=CGray2; break;
|
||||
}
|
||||
|
||||
// Crawl attachment
|
||||
if (Status==PF_Ray_Crawl)
|
||||
{
|
||||
int iX=0,iY=0; CrawlToAttach(iX,iY,CrawlAttach);
|
||||
lpDDraw->DrawLine(cgo.Surface,
|
||||
cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY,
|
||||
cgo.X+X2-cgo.TargetX+7*iX,cgo.Y+Y2-cgo.TargetY+7*iY,
|
||||
CRed);
|
||||
//sprintf(OSTR,"%d",Depth); lpDDraw->TextOut(OSTR,cgo.Surface,cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY+20,CGray4);
|
||||
}
|
||||
|
||||
// Ray line
|
||||
lpDDraw->DrawLine(cgo.Surface,
|
||||
cgo.X+X-cgo.TargetX,cgo.Y+Y-cgo.TargetY,
|
||||
cgo.X+X2-cgo.TargetX,cgo.Y+Y2-cgo.TargetY,
|
||||
byColor);
|
||||
|
||||
// Crawler point
|
||||
lpDDraw->DrawFrame(cgo.Surface,
|
||||
cgo.X+X2-cgo.TargetX-1,cgo.Y+Y2-cgo.TargetY-1,
|
||||
cgo.X+X2-cgo.TargetX+1,cgo.Y+Y2-cgo.TargetY+1,
|
||||
(Status==PF_Ray_Crawl) ? ((Direction==PF_Direction_Left) ? CGreen : CBlue) : byColor);
|
||||
|
||||
// Search target point
|
||||
lpDDraw->DrawFrame(cgo.Surface,
|
||||
cgo.X+TargetX-cgo.TargetX-2,cgo.Y+TargetY-cgo.TargetY-2,
|
||||
cgo.X+TargetX-cgo.TargetX+2,cgo.Y+TargetY-cgo.TargetY+2,
|
||||
CYellow);
|
||||
|
||||
}*/
|
||||
|
||||
bool CPathFinderRay::PathFree(int &rX, int &rY, int iToX, int iToY)
|
||||
{
|
||||
int d,dx,dy,aincr,bincr,xincr,yincr,x,y;
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
// color definitions
|
||||
const int FTrans=-1,FWhite=0,FBlack=1,FPlayer=2,FRed=3;
|
||||
const int CBlack=0,CGray1=1,CGray2=2,CGray3=3,CGray4=4,CGray5=5,CWhite=6,
|
||||
CDRed=7,CDGreen=8,CDBlue=9,CRed=10,CGreen=11,CLBlue=12,CYellow=13,CBlue=14;
|
||||
extern const BYTE FColors [];
|
||||
|
||||
// helper function
|
||||
#define RGBA(r, g, b, a) (((DWORD)(a)<<24)|(((DWORD)(r)&0xff)<<16)|(((DWORD)(g)&0xff)<<8)|((b)&0xff))
|
||||
|
||||
|
|
|
@ -253,21 +253,6 @@ C4Facet C4Facet::Truncate(int32_t iAlign, int32_t iSize)
|
|||
return fctResult;
|
||||
}
|
||||
|
||||
void C4Facet::DrawSectionSelect(C4Facet &cgo, int32_t iSelection, int32_t iMaxSelect)
|
||||
{
|
||||
int32_t sections = cgo.GetSectionCount();
|
||||
int32_t idnum = iMaxSelect;
|
||||
int32_t firstid = BoundBy<int32_t>(iSelection-sections/2,0,Max<int32_t>(idnum-sections,0));
|
||||
C4Facet cgo2;
|
||||
for (int32_t cnt=0; (cnt<sections) && (firstid+cnt<idnum); cnt++)
|
||||
{
|
||||
cgo2 = cgo.GetSection(cnt);
|
||||
if (iSelection==firstid+cnt)
|
||||
lpDDraw->DrawBox(cgo2.Surface,cgo2.X,cgo2.Y,cgo2.X+cgo2.Wdt-1,cgo2.Y+cgo2.Hgt-1,CRed);
|
||||
Draw(cgo2,true,firstid+cnt,0);
|
||||
}
|
||||
}
|
||||
|
||||
void C4Facet::DrawValue(C4Facet &cgo, int32_t iValue, int32_t iSectionX, int32_t iSectionY, int32_t iAlign)
|
||||
{
|
||||
if (!lpDDraw) return;
|
||||
|
@ -362,20 +347,6 @@ void C4Facet::DrawXT(SURFACE sfcTarget, float iX, float iY, int32_t iWdt, int32_
|
|||
true, pTransform);
|
||||
}
|
||||
|
||||
void C4Facet::DrawEnergyLevel(int32_t iLevel, int32_t iRange, int32_t iColor)
|
||||
{
|
||||
if (!lpDDraw) return;
|
||||
iLevel = BoundBy<int32_t>(iLevel,0,iRange);
|
||||
lpDDraw->DrawBox(Surface,
|
||||
X,Y,
|
||||
X+Wdt-1,Y+Hgt-1,
|
||||
40);
|
||||
lpDDraw->DrawBox(Surface,
|
||||
X+1,Y+1+(Hgt-2)-(Hgt-2)*iLevel/Max<int32_t>(iRange,1),
|
||||
X+Wdt-2,Y+Hgt-2,
|
||||
iColor);
|
||||
}
|
||||
|
||||
void C4Facet::DrawEnergyLevelEx(int32_t iLevel, int32_t iRange, const C4Facet &gfx, int32_t bar_idx)
|
||||
{
|
||||
// draw energy level using graphics
|
||||
|
@ -495,12 +466,6 @@ void C4Facet::Expand(int32_t iLeft, int32_t iRight, int32_t iTop, int32_t iBotto
|
|||
Hgt+=iBottom;
|
||||
}
|
||||
|
||||
void C4Facet::Wipe()
|
||||
{
|
||||
if (!lpDDraw || !Surface || !Wdt || !Hgt) return;
|
||||
lpDDraw->WipeSurface(Surface);
|
||||
}
|
||||
|
||||
bool C4Facet::GetPhaseNum(int32_t &rX, int32_t &rY)
|
||||
{
|
||||
// safety
|
||||
|
|
|
@ -131,10 +131,8 @@ public:
|
|||
void Set(CSurface &rSfc);
|
||||
void Set(SURFACE nsfc, int32_t nx, int32_t ny, int32_t nwdt, int32_t nhgt);
|
||||
void Set(const C4Facet &cpy) { *this=cpy; }
|
||||
void Wipe();
|
||||
void Expand(int32_t iLeft=0, int32_t iRight=0, int32_t iTop=0, int32_t iBottom=0);
|
||||
void DrawTile(SURFACE sfcTarget, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt);
|
||||
void DrawEnergyLevel(int32_t iLevel, int32_t iRange, int32_t iColor=45); // draw energy level using solid colors
|
||||
void DrawEnergyLevelEx(int32_t iLevel, int32_t iRange, const C4Facet &gfx, int32_t bar_idx); // draw energy level using graphics
|
||||
void DrawX(SURFACE sfcTarget, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iPhaseX=0, int32_t iPhaseY=0) const;
|
||||
void DrawXFloat(SURFACE sfcTarget, float fX, float fY, float fWdt, float fHgt) const;
|
||||
|
@ -150,7 +148,6 @@ public:
|
|||
void DrawValue2Clr(C4Facet &cgo, int32_t iValue1, int32_t iValue2, DWORD dwClr); // set surface color and draw
|
||||
void DrawXR(SURFACE sfcTarget, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iPhaseX=0, int32_t iPhaseY=0, int32_t r=0); // draw rotated
|
||||
void Draw(SURFACE sfcTarget, float iX, float iY, int32_t iPhaseX=0, int32_t iPhaseY=0);
|
||||
void DrawSectionSelect(C4Facet &cgo, int32_t iSelection, int32_t iMaxSelect);
|
||||
bool GetPhaseNum(int32_t &rX, int32_t &rY); // return number of phases in this graphic
|
||||
C4Facet GetSection(int32_t iSection);
|
||||
C4Facet GetPhase(int iPhaseX=0, int iPhaseY=0);
|
||||
|
|
|
@ -54,46 +54,6 @@ void C4TargetFacet::DrawLineDw(int iX1, int iY1, int iX2, int iY2, uint32_t col1
|
|||
lpDDraw->DrawPix(Surface,(float)(X+iX1),(float)(Y+iY1),col2);
|
||||
}
|
||||
|
||||
void C4TargetFacet::DrawLine(int iX1, int iY1, int iX2, int iY2, BYTE bCol1, BYTE bCol2)
|
||||
{
|
||||
DrawLineDw(iX1, iY1, iX2, iY2, lpDDraw->Pal.GetClr(bCol1), lpDDraw->Pal.GetClr(bCol2));
|
||||
}
|
||||
|
||||
// bolt random size
|
||||
#define DrawBoltR1 7
|
||||
#define DrawBoltR2 3
|
||||
|
||||
void C4TargetFacet::DrawBolt(int iX1, int iY1, int iX2, int iY2, BYTE bCol, BYTE bCol2)
|
||||
{
|
||||
if (!lpDDraw || !Surface || !Wdt || !Hgt) return;
|
||||
// Scroll position
|
||||
iX1-=TargetX; iY1-=TargetY; iX2-=TargetX; iY2-=TargetY;
|
||||
// Facet bounds
|
||||
if (!Inside(iX1,0,Wdt-1) && !Inside(iX2,0,Wdt-1)) return;
|
||||
if (!Inside(iY1,0,Hgt-1) && !Inside(iY2,0,Hgt-1)) return;
|
||||
iX1+=X; iX2+=X; iY1+=Y; iY2+=Y;
|
||||
// Draw bolt
|
||||
float pvtx[2*4];
|
||||
pvtx[0]=iX1; pvtx[1]=iY1; pvtx[2]=iX2; pvtx[3]=iY2;
|
||||
pvtx[4]=iX2+SafeRandom(DrawBoltR1)-DrawBoltR2; pvtx[5]=iY2+SafeRandom(DrawBoltR1)-DrawBoltR2;
|
||||
pvtx[6]=iX1+SafeRandom(DrawBoltR1)-DrawBoltR2; pvtx[7]=iY1+SafeRandom(DrawBoltR1)-DrawBoltR2;
|
||||
// Draw in surface
|
||||
DWORD dwClr1=lpDDraw->Pal.GetClr(bCol),dwClr2;
|
||||
DWORD dwClr3=lpDDraw->Pal.GetClr(bCol2),dwClr4;
|
||||
/*if (DDrawCfg.NoBoxFades)
|
||||
{*/
|
||||
dwClr2=dwClr1;
|
||||
dwClr4=dwClr3;
|
||||
/*}
|
||||
else
|
||||
{
|
||||
DWORD dwClr2=dwClr1|0xff000000; ...this leads to black and white lightning bolts. Who wants that?
|
||||
DWORD dwClr4=dwClr3|0xff000000;
|
||||
}*/
|
||||
lpDDraw->DrawQuadDw(Surface,pvtx,dwClr1,dwClr3,dwClr4,dwClr2);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------
|
||||
// C4FacetSurface
|
||||
|
||||
|
|
|
@ -50,8 +50,6 @@ public:
|
|||
void Set(class CSurface *nsfc, int nx, int ny, int nwdt, int nhgt, float ntx=0, float nty=0);
|
||||
void Set(class CSurface *nsfc, const C4Rect & r, float ntx=0, float nty=0);
|
||||
|
||||
void DrawBolt(int iX1, int iY1, int iX2, int iY2, BYTE bCol, BYTE bCol2);
|
||||
void DrawLine(int iX1, int iY1, int iX2, int iY2, BYTE bCol1, BYTE bCol2);
|
||||
void DrawLineDw(int iX1, int iY1, int iX2, int iY2, uint32_t col1, uint32_t col2);
|
||||
public:
|
||||
C4TargetFacet &operator = (const C4Facet& rhs)
|
||||
|
|
|
@ -51,7 +51,6 @@ void C4GraphicsResource::Default()
|
|||
|
||||
sfcControl.Default();
|
||||
idSfcControl = 0;
|
||||
idPalGrp = 0;
|
||||
|
||||
fctPlayer.Default();
|
||||
fctFlag.Default();
|
||||
|
@ -76,8 +75,6 @@ void C4GraphicsResource::Default()
|
|||
fctGamepad.Default();
|
||||
fctBuild.Default();
|
||||
|
||||
ZeroMem(GamePalette,3*256);
|
||||
ZeroMem(AlphaPalette,256);
|
||||
fctCrewClr.Default();
|
||||
fctFlagClr.Default();
|
||||
fctPlayerClr.Default();
|
||||
|
@ -103,7 +100,6 @@ void C4GraphicsResource::Clear()
|
|||
|
||||
sfcControl.Clear();
|
||||
idSfcControl = 0;
|
||||
idPalGrp = 0;
|
||||
|
||||
fctCrewClr.Clear();
|
||||
fctFlagClr.Clear();
|
||||
|
@ -202,29 +198,6 @@ bool C4GraphicsResource::Init()
|
|||
|
||||
if (!InitFonts()) return false;
|
||||
|
||||
// Game palette - could perhaps be eliminated...
|
||||
int32_t idNewPalGrp;
|
||||
C4Group *pPalGrp=Files.FindEntry("C4.pal", NULL, &idNewPalGrp);
|
||||
if (!pPalGrp) { LogF("%s: %s", LoadResStr("IDS_PRC_FILENOTFOUND"), "C4.pal"); return false; }
|
||||
if (idPalGrp != idNewPalGrp)
|
||||
{
|
||||
if (!pPalGrp->AccessEntry("C4.pal")) { LogFatal("Pal error!"); return false; }
|
||||
if (!pPalGrp->Read(GamePalette,256*3)) { LogFatal("Pal error!"); return false; }
|
||||
for (int32_t cnt=0; cnt<256*3; cnt++) GamePalette[cnt]<<=2;
|
||||
for (int32_t cnt=0; cnt<256; cnt++) AlphaPalette[cnt]=0xff;
|
||||
// Set default force field color
|
||||
GamePalette[191*3+0]=0;
|
||||
GamePalette[191*3+1]=0;
|
||||
GamePalette[191*3+2]=255;
|
||||
AlphaPalette[191]=127;
|
||||
// color 0 is transparent
|
||||
GamePalette[0]=GamePalette[1]=GamePalette[2]=0;
|
||||
AlphaPalette[0]=0;
|
||||
// update game pal
|
||||
if (!::GraphicsSystem.SetPalette()) { LogFatal("Pal error (2)!"); return false; }
|
||||
idPalGrp = idNewPalGrp;
|
||||
}
|
||||
|
||||
// load GUI files
|
||||
if (!LoadFile(sfcCaption, "GUICaption", Files, idSfcCaption)) return false;
|
||||
barCaption.SetHorizontal(sfcCaption, sfcCaption.Hgt, 32);
|
||||
|
|
|
@ -42,14 +42,11 @@ protected:
|
|||
C4Surface sfcScroll, sfcContext;
|
||||
int32_t idSfcCaption, idSfcButton, idSfcButtonD, idSfcScroll, idSfcContext;
|
||||
int32_t idSfcControl; // id of source group of control surface
|
||||
int32_t idPalGrp; // if of source group of pal file
|
||||
// ID of last group in main group set that was already registered into the Files-set
|
||||
// used to avoid doubled entries by subsequent calls to RegisterMainGroups
|
||||
int32_t idRegisteredMainGroupSetFiles;
|
||||
public:
|
||||
C4GroupSet Files;
|
||||
BYTE GamePalette[256*3];
|
||||
BYTE AlphaPalette[256*3]; // TODO: alphapal: Why *3?
|
||||
float ProgressStart, ProgressIncrement;
|
||||
C4FacetID fctPlayer;
|
||||
C4FacetID fctFlag;
|
||||
|
|
|
@ -88,7 +88,7 @@ bool C4Surface::LoadAny(C4GroupSet &hGroupset, const char *szName, bool fOwnPal,
|
|||
return Load(*pGroup,szFilename,fOwnPal,fNoErrIfNotFound);
|
||||
}
|
||||
|
||||
bool C4Surface::Load(C4Group &hGroup, const char *szFilename, bool fOwnPal, bool fNoErrIfNotFound)
|
||||
bool C4Surface::Load(C4Group &hGroup, const char *szFilename, bool, bool fNoErrIfNotFound)
|
||||
{
|
||||
int ScaleToSet = 1;
|
||||
// Image is scaled?
|
||||
|
@ -137,7 +137,7 @@ bool C4Surface::Load(C4Group &hGroup, const char *szFilename, bool fOwnPal, bool
|
|||
if (!fNoErrIfNotFound) LogF("%s: %s%c%s", LoadResStr("IDS_PRC_FILENOTFOUND"), hGroup.GetFullName().getData(), (char) DirectorySeparator, szFilename);
|
||||
return false;
|
||||
}
|
||||
bool fSuccess = Read(hGroup, GetExtension(szFilename), fOwnPal);
|
||||
bool fSuccess = Read(hGroup, GetExtension(szFilename));
|
||||
// loading error? log!
|
||||
if (!fSuccess)
|
||||
LogF("%s: %s%c%s", LoadResStr("IDS_ERR_NOFILE"), hGroup.GetFullName().getData(), (char) DirectorySeparator, szFilename);
|
||||
|
@ -147,7 +147,7 @@ bool C4Surface::Load(C4Group &hGroup, const char *szFilename, bool fOwnPal, bool
|
|||
return fSuccess;
|
||||
}
|
||||
|
||||
bool C4Surface::Read(CStdStream &hGroup, const char * extension, bool fOwnPal)
|
||||
bool C4Surface::Read(CStdStream &hGroup, const char * extension)
|
||||
{
|
||||
// determine file type by file extension and load accordingly
|
||||
if (SEqualNoCase(extension, "png"))
|
||||
|
@ -156,7 +156,7 @@ bool C4Surface::Read(CStdStream &hGroup, const char * extension, bool fOwnPal)
|
|||
|| SEqualNoCase(extension, "jpg"))
|
||||
return ReadJPEG(hGroup);
|
||||
else if (SEqualNoCase(extension, "bmp"))
|
||||
return ReadBMP(hGroup, fOwnPal);
|
||||
return ReadBMP(hGroup);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
bool Save(C4Group &hGroup, const char *szFilename);
|
||||
bool SavePNG(C4Group &hGroup, const char *szFilename, bool fSaveAlpha=true, bool fApplyGamma=false, bool fSaveOverlayOnly=false);
|
||||
bool Copy(C4Surface &fromSfc);
|
||||
bool Read(CStdStream &hGroup, const char * extension, bool fOwnPal=false);
|
||||
bool Read(CStdStream &hGroup, const char * extension);
|
||||
bool ReadPNG(CStdStream &hGroup);
|
||||
bool ReadJPEG(CStdStream &hGroup);
|
||||
};
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
#include <StdSurface8.h>
|
||||
#include <C4Group.h>
|
||||
|
||||
C4Surface *GroupReadSurface(CStdStream &hGroup, BYTE *bpPalette)
|
||||
C4Surface *GroupReadSurface(CStdStream &hGroup)
|
||||
{
|
||||
// create surface
|
||||
C4Surface *pSfc=new C4Surface();
|
||||
if (!pSfc->ReadBMP(hGroup, !!bpPalette))
|
||||
if (!pSfc->ReadBMP(hGroup))
|
||||
{ delete pSfc; return NULL; }
|
||||
return pSfc;
|
||||
}
|
||||
|
@ -40,16 +40,7 @@ CSurface8 *GroupReadSurface8(CStdStream &hGroup)
|
|||
{
|
||||
// create surface
|
||||
CSurface8 *pSfc=new CSurface8();
|
||||
if (!pSfc->Read(hGroup, false))
|
||||
{ delete pSfc; return NULL; }
|
||||
return pSfc;
|
||||
}
|
||||
|
||||
C4Surface *GroupReadSurfaceOwnPal(CStdStream &hGroup)
|
||||
{
|
||||
// create surface
|
||||
C4Surface *pSfc=new C4Surface();
|
||||
if (!pSfc->ReadBMP(hGroup, true))
|
||||
if (!pSfc->Read(hGroup))
|
||||
{ delete pSfc; return NULL; }
|
||||
return pSfc;
|
||||
}
|
||||
|
@ -58,7 +49,7 @@ CSurface8 *GroupReadSurfaceOwnPal8(CStdStream &hGroup)
|
|||
{
|
||||
// create surface
|
||||
CSurface8 *pSfc=new CSurface8();
|
||||
if (!pSfc->Read(hGroup, true))
|
||||
if (!pSfc->Read(hGroup))
|
||||
{ delete pSfc; return NULL; }
|
||||
return pSfc;
|
||||
}
|
||||
|
|
|
@ -23,9 +23,8 @@
|
|||
#ifndef INC_C4SurfaceFile
|
||||
#define INC_C4SurfaceFile
|
||||
|
||||
C4Surface *GroupReadSurface(CStdStream &hGroup, BYTE *bpPalette=NULL);
|
||||
C4Surface *GroupReadSurface(CStdStream &hGroup);
|
||||
CSurface8 *GroupReadSurface8(CStdStream &hGroup);
|
||||
C4Surface *GroupReadSurfaceOwnPal(CStdStream &hGroup);
|
||||
CSurface8 *GroupReadSurfaceOwnPal8(CStdStream &hGroup);
|
||||
|
||||
/*bool SaveSurface(const char *szFilename, SURFACE sfcSurface, BYTE *bpPalette);*/
|
||||
|
|
|
@ -855,12 +855,12 @@ void C4Chart::DrawElement(C4TargetFacet &cgo)
|
|||
// safety: too small?
|
||||
if (tw < 10 || th < 10) return;
|
||||
// draw axis
|
||||
lpDDraw->DrawHorizontalLine(cgo.Surface, tx, tx+tw-1, ty+th, CGray3);
|
||||
lpDDraw->DrawLine(cgo.Surface, tx+tw-1, ty+th, tx+tw-1-AxisArrowLen, ty+th-AxisArrowThickness, CGray3);
|
||||
lpDDraw->DrawLine(cgo.Surface, tx+tw-1, ty+th, tx+tw-1-AxisArrowLen, ty+th+AxisArrowThickness, CGray3);
|
||||
lpDDraw->DrawVerticalLine(cgo.Surface, tx, ty, ty+th, CGray3);
|
||||
lpDDraw->DrawLine(cgo.Surface, tx, ty, tx-AxisArrowThickness, ty+AxisArrowLen, CGray3);
|
||||
lpDDraw->DrawLine(cgo.Surface, tx, ty, tx+AxisArrowThickness, ty+AxisArrowLen, CGray3);
|
||||
lpDDraw->DrawLineDw(cgo.Surface, tx, ty+th, tx+tw-1, ty+th, C4RGB(0x91, 0x91, 0x91));
|
||||
lpDDraw->DrawLineDw(cgo.Surface, tx+tw-1, ty+th, tx+tw-1-AxisArrowLen, ty+th-AxisArrowThickness, C4RGB(0x91, 0x91, 0x91));
|
||||
lpDDraw->DrawLineDw(cgo.Surface, tx+tw-1, ty+th, tx+tw-1-AxisArrowLen, ty+th+AxisArrowThickness, C4RGB(0x91, 0x91, 0x91));
|
||||
lpDDraw->DrawLineDw(cgo.Surface, tx, ty, tx, ty+th, C4RGB(0x91, 0x91, 0x91));
|
||||
lpDDraw->DrawLineDw(cgo.Surface, tx, ty, tx-AxisArrowThickness, ty+AxisArrowLen, C4RGB(0x91, 0x91, 0x91));
|
||||
lpDDraw->DrawLineDw(cgo.Surface, tx, ty, tx+AxisArrowThickness, ty+AxisArrowLen, C4RGB(0x91, 0x91, 0x91));
|
||||
tw -= AxisArrowLen + AxisArrowIndent;
|
||||
th -= AxisArrowLen + AxisArrowIndent; ty += AxisArrowLen + AxisArrowIndent;
|
||||
// do axis numbering
|
||||
|
@ -872,7 +872,7 @@ void C4Chart::DrawElement(C4TargetFacet &cgo)
|
|||
for (; iTime <= iMaxTime; iTime += iXAxisSteps)
|
||||
{
|
||||
iX = tx + tw * (iTime-iMinTime) / dt;
|
||||
lpDDraw->DrawVerticalLine(cgo.Surface, iX, ty+th+1, ty+th+AxisMarkerLen, CGray3);
|
||||
lpDDraw->DrawLineDw(cgo.Surface, iX, ty+th+1, iX, ty+th+AxisMarkerLen, C4RGB(0x91, 0x91, 0x91));
|
||||
sbuf.Format("%d", (int) iTime);
|
||||
lpDDraw->TextOut(sbuf.getData(), rFont, 1.0f, cgo.Surface, iX, ty+th+AxisMarkerLen, 0xff7f7f7f, ACenter, false);
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ void C4Chart::DrawElement(C4TargetFacet &cgo)
|
|||
for (; iVal <= iMaxVal; iVal += iYAxisSteps)
|
||||
{
|
||||
iY = ty+th - int((iVal-iMinVal) / dv * th);
|
||||
lpDDraw->DrawHorizontalLine(cgo.Surface, tx-AxisMarkerLen, tx-1, iY, CGray3);
|
||||
lpDDraw->DrawLineDw(cgo.Surface, tx-AxisMarkerLen, iY, tx-1, iY, C4RGB(0x91, 0x91, 0x91));
|
||||
sbuf.Format("%d", (int) iVal);
|
||||
lpDDraw->TextOut(sbuf.getData(), rFont, 1.0f, cgo.Surface, tx-AxisMarkerLen, iY-rFont.GetLineHeight()/2, 0xff7f7f7f, ARight, false);
|
||||
}
|
||||
|
|
|
@ -169,13 +169,6 @@ bool C4Video::Start(const char *szFilename)
|
|||
pInfo->bmiHeader.biBitCount=Config.Graphics.BitDepth;
|
||||
pInfo->bmiHeader.biCompression=0;
|
||||
pInfo->bmiHeader.biSizeImage = DWordAligned(Width)*Height * Config.Graphics.BitDepth/8;
|
||||
if (Config.Graphics.BitDepth == 8)
|
||||
for (int cnt=0; cnt<256; cnt++)
|
||||
{
|
||||
pInfo->bmiColors[cnt].rgbRed = ::GraphicsResource.GamePalette[cnt*3+0];
|
||||
pInfo->bmiColors[cnt].rgbGreen = ::GraphicsResource.GamePalette[cnt*3+1];
|
||||
pInfo->bmiColors[cnt].rgbBlue = ::GraphicsResource.GamePalette[cnt*3+2];
|
||||
}
|
||||
// Recording flag
|
||||
Recording=true;
|
||||
#endif //_WIN32
|
||||
|
@ -203,9 +196,9 @@ void C4Video::Draw(C4TargetFacet &cgo)
|
|||
// No show
|
||||
if (!ShowFlash) return;
|
||||
// Draw frame
|
||||
Application.DDraw->DrawFrame(cgo.Surface, X+cgo.X,Y+cgo.Y,
|
||||
Application.DDraw->DrawFrameDw(cgo.Surface, X+cgo.X,Y+cgo.Y,
|
||||
X+cgo.X+Width-1,Y+cgo.Y+Height-1,
|
||||
Recording ? CRed : CWhite);
|
||||
Recording ? C4RGB(0xca, 0, 0) : C4RGB(0xff, 0xff, 0xff));
|
||||
// Draw status
|
||||
StdStrBuf str;
|
||||
if (Recording) str.Format("%dx%d Frame %d",Width,Height,AviFrame);
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
// Global access pointer
|
||||
CStdDDraw *lpDDraw=NULL;
|
||||
CStdPalette *lpDDrawPal=NULL;
|
||||
int iGfxEngine=-1;
|
||||
|
||||
// Transformation matrix to convert meshes from Ogre to Clonk coordinate system
|
||||
|
@ -408,27 +407,11 @@ void CStdDDraw::Clear()
|
|||
dwBlitMode = 0;
|
||||
}
|
||||
|
||||
bool CStdDDraw::WipeSurface(SURFACE sfcSurface)
|
||||
{
|
||||
if (!sfcSurface) return false;
|
||||
return sfcSurface->Wipe();
|
||||
}
|
||||
|
||||
bool CStdDDraw::GetSurfaceSize(SURFACE sfcSurface, int &iWdt, int &iHgt)
|
||||
{
|
||||
return sfcSurface->GetSurfaceSize(iWdt, iHgt);
|
||||
}
|
||||
|
||||
bool CStdDDraw::SetPrimaryPalette(BYTE *pBuf, BYTE *pAlphaBuf)
|
||||
{
|
||||
// store into loaded pal
|
||||
memcpy(&Pal.Colors, pBuf, 768);
|
||||
// store alpha pal
|
||||
if (pAlphaBuf) memcpy(Pal.Alpha, pAlphaBuf, 256);
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdDDraw::SubPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
|
||||
{
|
||||
// Set sub primary clipper
|
||||
|
@ -871,12 +854,6 @@ bool CStdDDraw::CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CStdDDraw::AttachPrimaryPalette(SURFACE sfcSurface)
|
||||
{/*
|
||||
if (sfcSurface->SetPaletteEntries(0, lpPalette)!=DD_OK) return false;*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdDDraw::BlitSurface(SURFACE sfcSurface, SURFACE sfcTarget, int tx, int ty, bool fBlitBase)
|
||||
{
|
||||
if (fBlitBase)
|
||||
|
@ -1024,34 +1001,6 @@ void CStdDDraw::DrawPix(SURFACE sfcDest, float tx, float ty, DWORD dwClr)
|
|||
PerformPix(sfcDest, tx, ty, dwClr);
|
||||
}
|
||||
|
||||
void CStdDDraw::DrawBox(SURFACE sfcDest, int iX1, int iY1, int iX2, int iY2, BYTE byCol)
|
||||
{
|
||||
// get color
|
||||
DWORD dwClr=Pal.GetClr(byCol);
|
||||
// offscreen emulation?
|
||||
if (!sfcDest->IsRenderTarget())
|
||||
{
|
||||
int iSfcWdt=sfcDest->Wdt,iSfcHgt=sfcDest->Hgt,xcnt,ycnt;
|
||||
// Lock surface
|
||||
if (!sfcDest->Lock()) return;
|
||||
// Outside of surface/clip
|
||||
if ((iX2<Max(0,iClipX1)) || (iX1>Min(iSfcWdt-1,iClipX2))
|
||||
|| (iY2<Max(0,iClipY1)) || (iY1>Min(iSfcHgt-1,iClipY2)))
|
||||
{ sfcDest->Unlock(); return; }
|
||||
// Clip to surface/clip
|
||||
if (iX1<Max(0,iClipX1)) iX1=Max(0,iClipX1); if (iX2>Min(iSfcWdt-1,iClipX2)) iX2=Min(iSfcWdt-1,iClipX2);
|
||||
if (iY1<Max(0,iClipY1)) iY1=Max(0,iClipY1); if (iY2>Min(iSfcHgt-1,iClipY2)) iY2=Min(iSfcHgt-1,iClipY2);
|
||||
// Set lines
|
||||
for (ycnt=iY2-iY1; ycnt>=0; ycnt--)
|
||||
for (xcnt=iX2-iX1; xcnt>=0; xcnt--)
|
||||
sfcDest->SetPixDw(iX1+xcnt, iY1+ycnt, dwClr);
|
||||
// Unlock surface
|
||||
sfcDest->Unlock();
|
||||
}
|
||||
// draw as primitives
|
||||
DrawBoxDw(sfcDest, iX1, iY1, iX2, iY2, dwClr);
|
||||
}
|
||||
|
||||
void CStdDDraw::DrawLineDw(SURFACE sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr)
|
||||
{
|
||||
ApplyZoom(x1, y1);
|
||||
|
@ -1099,70 +1048,6 @@ void CStdDDraw::DrawLineDw(SURFACE sfcTarget, float x1, float y1, float x2, floa
|
|||
PerformLine(sfcTarget, x1, y1, x2, y2, dwClr);
|
||||
}
|
||||
|
||||
void CStdDDraw::DrawHorizontalLine(SURFACE sfcDest, int x1, int x2, int y, BYTE col)
|
||||
{
|
||||
// if this is a render target: draw it as a box
|
||||
if (sfcDest->IsRenderTarget())
|
||||
{
|
||||
DrawLine(sfcDest, x1, y, x2, y, col);
|
||||
return;
|
||||
}
|
||||
int lWdt=sfcDest->Wdt,lHgt=sfcDest->Hgt,xcnt;
|
||||
// Lock surface
|
||||
if (!sfcDest->Lock()) return;
|
||||
// Fix coordinates
|
||||
if (x1>x2) Swap(x1,x2);
|
||||
// Determine clip
|
||||
int clpx1,clpx2,clpy1,clpy2;
|
||||
clpx1=Max(0,iClipX1); clpy1=Max(0,iClipY1);
|
||||
clpx2=Min(lWdt-1,iClipX2); clpy2=Min(lHgt-1,iClipY2);
|
||||
// Outside clip check
|
||||
if ((x2<clpx1) || (x1>clpx2) || (y<clpy1) || (y>clpy2))
|
||||
{ sfcDest->Unlock(); return; }
|
||||
// Clip to clip
|
||||
if (x1<clpx1) x1=clpx1; if (x2>clpx2) x2=clpx2;
|
||||
// Set line
|
||||
for (xcnt=x2-x1; xcnt>=0; xcnt--) sfcDest->SetPix(x1+xcnt, y, col);
|
||||
// Unlock surface
|
||||
sfcDest->Unlock();
|
||||
}
|
||||
|
||||
void CStdDDraw::DrawVerticalLine(SURFACE sfcDest, int x, int y1, int y2, BYTE col)
|
||||
{
|
||||
// if this is a render target: draw it as a box
|
||||
if (sfcDest->IsRenderTarget())
|
||||
{
|
||||
DrawLine(sfcDest, x, y1, x, y2, col);
|
||||
return;
|
||||
}
|
||||
int lWdt=sfcDest->Wdt,lHgt=sfcDest->Hgt,ycnt;
|
||||
// Lock surface
|
||||
if (!sfcDest->Lock()) return;
|
||||
// Fix coordinates
|
||||
if (y1>y2) Swap(y1,y2);
|
||||
// Determine clip
|
||||
int clpx1,clpx2,clpy1,clpy2;
|
||||
clpx1=Max(0,iClipX1); clpy1=Max(0,iClipY1);
|
||||
clpx2=Min(lWdt-1,iClipX2); clpy2=Min(lHgt-1,iClipY2);
|
||||
// Outside clip check
|
||||
if ((x<clpx1) || (x>clpx2) || (y2<clpy1) || (y1>clpy2))
|
||||
{ sfcDest->Unlock(); return; }
|
||||
// Clip to clip
|
||||
if (y1<clpy1) y1=clpy1; if (y2>clpy2) y2=clpy2;
|
||||
// Set line
|
||||
for (ycnt=y1; ycnt<=y2; ycnt++) sfcDest->SetPix(x, ycnt, col);
|
||||
// Unlock surface
|
||||
sfcDest->Unlock();
|
||||
}
|
||||
|
||||
void CStdDDraw::DrawFrame(SURFACE sfcDest, int x1, int y1, int x2, int y2, BYTE col)
|
||||
{
|
||||
DrawHorizontalLine(sfcDest,x1,x2,y1,col);
|
||||
DrawHorizontalLine(sfcDest,x1,x2,y2,col);
|
||||
DrawVerticalLine(sfcDest,x1,y1,y2,col);
|
||||
DrawVerticalLine(sfcDest,x2,y1,y2,col);
|
||||
}
|
||||
|
||||
void CStdDDraw::DrawFrameDw(SURFACE sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr) // make these parameters float...?
|
||||
{
|
||||
DrawLineDw(sfcDest,(float)x1,(float)y1,(float)x2,(float)y1, dwClr);
|
||||
|
@ -1190,13 +1075,6 @@ bool UnLockSurfaceGlobal(SURFACE sfcTarget)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DLineSPix(int32_t x, int32_t y, int32_t col)
|
||||
{
|
||||
if (!GLSBuffer) return false;
|
||||
GLSBuffer->SetPix(x,y,col);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DLineSPixDw(int32_t x, int32_t y, int32_t dwClr)
|
||||
{
|
||||
if (!GLSBuffer) return false;
|
||||
|
@ -1219,37 +1097,6 @@ void CStdDDraw::DrawPatternedCircle(SURFACE sfcDest, int x, int y, int r, BYTE c
|
|||
sfcDest->Unlock();
|
||||
}
|
||||
|
||||
void CStdDDraw::SurfaceAllowColor(SURFACE sfcSfc, DWORD *pdwColors, int iNumColors, bool fAllowZero)
|
||||
{
|
||||
// safety
|
||||
if (!sfcSfc) return;
|
||||
if (!pdwColors || !iNumColors) return;
|
||||
// change colors
|
||||
int xcnt,ycnt,wdt=sfcSfc->Wdt,hgt=sfcSfc->Hgt;
|
||||
// Lock surface
|
||||
if (!sfcSfc->Lock()) return;
|
||||
for (ycnt=0; ycnt<hgt; ycnt++)
|
||||
{
|
||||
for (xcnt=0; xcnt<wdt; xcnt++)
|
||||
{
|
||||
DWORD dwColor = sfcSfc->GetPixDw(xcnt,ycnt,false);
|
||||
BYTE px = 0;
|
||||
for (int i = 0; i < 256; ++i)
|
||||
if (lpDDrawPal->GetClr(i) == dwColor)
|
||||
{
|
||||
px = i; break;
|
||||
}
|
||||
if (fAllowZero)
|
||||
{
|
||||
if (!px) continue;
|
||||
--px;
|
||||
}
|
||||
sfcSfc->SetPixDw(xcnt, ycnt, pdwColors[px % iNumColors]);
|
||||
}
|
||||
}
|
||||
sfcSfc->Unlock();
|
||||
}
|
||||
|
||||
void CStdDDraw::Grayscale(SURFACE sfcSfc, int32_t iOffset)
|
||||
{
|
||||
// safety
|
||||
|
|
|
@ -49,29 +49,9 @@ class StdMeshInstance;
|
|||
|
||||
// Global DDraw access pointer
|
||||
extern CStdDDraw *lpDDraw;
|
||||
extern CStdPalette *lpDDrawPal;
|
||||
|
||||
extern int iGfxEngine;
|
||||
|
||||
/*const DWORD CColors [] =
|
||||
{
|
||||
0x000000, // CBlack
|
||||
0x2A2A2A, // CGray1
|
||||
0x545454, // CGray2
|
||||
0x7F7F7F, // CGray3
|
||||
0xA9A9A9, // CGray4
|
||||
0xD3D3D3, // CGray5
|
||||
0xFFFFFF, // CWrite
|
||||
0x7F0000, // CDRed
|
||||
0x007F00, // CDGreen
|
||||
0x00007F, // CDBlue
|
||||
0xFF0000, // CRed
|
||||
0x00FF00, // CGreen
|
||||
0x7F7FFF, // CLBlue
|
||||
0xFFFF00, // CYellow
|
||||
0x0000FF, // CBlue
|
||||
};*/
|
||||
|
||||
// font def color indices
|
||||
|
||||
// rotation info class
|
||||
|
@ -212,11 +192,10 @@ class CStdDDraw
|
|||
public:
|
||||
static const StdMeshMatrix OgreToClonk;
|
||||
|
||||
CStdDDraw(): MaxTexSize(0), Saturation(255) { lpDDrawPal=&Pal; }
|
||||
CStdDDraw(): MaxTexSize(0), Saturation(255) { }
|
||||
virtual ~CStdDDraw() { lpDDraw=NULL; }
|
||||
public:
|
||||
CStdApp * pApp; // the application
|
||||
CStdPalette Pal; // 8bit-pal
|
||||
bool Active; // set if device is ready to render, etc.
|
||||
CGammaControl Gamma; // gamma
|
||||
CGammaControl DefRamp; // default gamma ramp
|
||||
|
@ -255,10 +234,6 @@ public:
|
|||
virtual bool OnResolutionChanged(unsigned int iXRes, unsigned int iYRes) = 0; // reinit clipper for new resolution
|
||||
virtual bool IsOpenGL() { return false; }
|
||||
virtual bool IsShaderific() { return false; }
|
||||
// Palette
|
||||
bool SetPrimaryPalette(BYTE *pBuf, BYTE *pAlphaBuf=NULL);
|
||||
bool SetPrimaryPaletteQuad(BYTE *pBuf);
|
||||
bool AttachPrimaryPalette(SURFACE sfcSurface);
|
||||
// Clipper
|
||||
bool GetPrimaryClipper(int &rX1, int &rY1, int &rX2, int &rY2);
|
||||
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2);
|
||||
|
@ -271,8 +246,6 @@ public:
|
|||
virtual bool UpdateClipper() = 0; // set current clipper to render target
|
||||
// Surface
|
||||
bool GetSurfaceSize(SURFACE sfcSurface, int &iWdt, int &iHgt);
|
||||
bool WipeSurface(SURFACE sfcSurface);
|
||||
void SurfaceAllowColor(SURFACE sfcSfc, DWORD *pdwColors, int iNumColors, bool fAllowZero=false);
|
||||
void Grayscale(SURFACE sfcSfc, int32_t iOffset = 0);
|
||||
void LockingPrimary() { PrimaryLocked=true; }
|
||||
void PrimaryUnlocked() { PrimaryLocked=false; }
|
||||
|
@ -305,16 +278,10 @@ public:
|
|||
bool StringOut(const char *szText, CStdFont &rFont, float fZoom, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true);
|
||||
// Drawing
|
||||
virtual void DrawPix(SURFACE sfcDest, float tx, float ty, DWORD dwCol);
|
||||
void DrawBox(SURFACE sfcDest, int iX1, int iY1, int iX2, int iY2, BYTE byCol); // calls DrawBoxDw
|
||||
void DrawBoxDw(SURFACE sfcDest, int iX1, int iY1, int iX2, int iY2, DWORD dwClr); // calls DrawBoxFade
|
||||
void DrawBoxFade(SURFACE sfcDest, float iX, float iY, float iWdt, float iHgt, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4, int iBoxOffX, int iBoxOffY); // calls DrawQuadDw
|
||||
void DrawPatternedCircle(SURFACE sfcDest, int x, int y, int r, BYTE col, CPattern & Pattern, CStdPalette &rPal);
|
||||
void DrawHorizontalLine(SURFACE sfcDest, int x1, int x2, int y, BYTE col);
|
||||
void DrawVerticalLine(SURFACE sfcDest, int x, int y1, int y2, BYTE col);
|
||||
void DrawFrame(SURFACE sfcDest, int x1, int y1, int x2, int y2, BYTE col);
|
||||
void DrawFrameDw(SURFACE sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr);
|
||||
virtual void DrawLine(SURFACE sfcTarget, int x1, int y1, int x2, int y2, BYTE byCol)
|
||||
{ DrawLineDw(sfcTarget, (float) x1, (float) y1, (float) x2, (float) y2, Pal.GetClr(byCol)); }
|
||||
virtual void DrawLineDw(SURFACE sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr);
|
||||
virtual void DrawQuadDw(SURFACE sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4) = 0;
|
||||
// gamma
|
||||
|
|
|
@ -1730,7 +1730,7 @@ void CStdGL::PerformLine(SURFACE sfcTarget, float x1, float y1, float x2, float
|
|||
{
|
||||
// emulate
|
||||
if (!LockSurfaceGlobal(sfcTarget)) return;
|
||||
ForLine((int32_t)x1,(int32_t)y1,(int32_t)x2,(int32_t)y2,&DLineSPix,(int) dwClr);
|
||||
ForLine((int32_t)x1,(int32_t)y1,(int32_t)x2,(int32_t)y2,&DLineSPixDw,(int) dwClr);
|
||||
UnLockSurfaceGlobal(sfcTarget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,14 +184,6 @@ bool CSurface::IsRenderTarget()
|
|||
;
|
||||
}
|
||||
|
||||
bool CSurface::Box(int iX, int iY, int iX2, int iY2, int iCol)
|
||||
{
|
||||
if (!Lock()) return false;
|
||||
for (int cy=iY; cy<=iY2; cy++) HLine(iX,iX2,cy,iCol);
|
||||
Unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSurface::NoClip()
|
||||
{
|
||||
ClipX=0; ClipY=0; ClipX2=Wdt-1; ClipY2=Hgt-1;
|
||||
|
@ -203,15 +195,7 @@ void CSurface::Clip(int iX, int iY, int iX2, int iY2)
|
|||
ClipX2=BoundBy(iX2,0,Wdt-1); ClipY2=BoundBy(iY2,0,Hgt-1);
|
||||
}
|
||||
|
||||
bool CSurface::HLine(int iX, int iX2, int iY, int iCol)
|
||||
{
|
||||
if (!Lock()) return false;
|
||||
for (int cx=iX; cx<=iX2; cx++) SetPix(cx,iY,iCol);
|
||||
Unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSurface::Create(int iWdt, int iHgt, bool fOwnPal, bool fIsRenderTarget, int MaxTextureSize)
|
||||
bool CSurface::Create(int iWdt, int iHgt, bool, bool fIsRenderTarget, int MaxTextureSize)
|
||||
{
|
||||
Clear(); Default();
|
||||
// check size
|
||||
|
@ -516,7 +500,7 @@ IDirect3DSurface9 *CSurface::GetSurface()
|
|||
}
|
||||
#endif //USE_DIRECTX
|
||||
|
||||
bool CSurface::ReadBMP(CStdStream &hGroup, bool fOwnPal)
|
||||
bool CSurface::ReadBMP(CStdStream &hGroup)
|
||||
{
|
||||
int lcnt,iLineRest;
|
||||
CBitmap256Info BitmapInfo;
|
||||
|
@ -538,7 +522,7 @@ bool CSurface::ReadBMP(CStdStream &hGroup, bool fOwnPal)
|
|||
}
|
||||
|
||||
// Create and lock surface
|
||||
if (!Create(BitmapInfo.Info.biWidth,BitmapInfo.Info.biHeight, fOwnPal)) return false;
|
||||
if (!Create(BitmapInfo.Info.biWidth,BitmapInfo.Info.biHeight)) return false;
|
||||
if (!Lock()) { Clear(); return false; }
|
||||
|
||||
// create line buffer
|
||||
|
@ -555,13 +539,10 @@ bool CSurface::ReadBMP(CStdStream &hGroup, bool fOwnPal)
|
|||
switch (BitmapInfo.Info.biBitCount)
|
||||
{
|
||||
case 8:
|
||||
if (fOwnPal)
|
||||
SetPixDw(x, lcnt, C4RGB(
|
||||
BitmapInfo.Colors[*pPix].rgbRed,
|
||||
BitmapInfo.Colors[*pPix].rgbGreen,
|
||||
BitmapInfo.Colors[*pPix].rgbBlue));
|
||||
else
|
||||
SetPix(x, lcnt, *pPix);
|
||||
SetPixDw(x, lcnt, C4RGB(
|
||||
BitmapInfo.Colors[*pPix].rgbRed,
|
||||
BitmapInfo.Colors[*pPix].rgbGreen,
|
||||
BitmapInfo.Colors[*pPix].rgbBlue));
|
||||
++pPix;
|
||||
break;
|
||||
case 24:
|
||||
|
@ -702,21 +683,6 @@ double ColorDistance(BYTE *bpRGB1, BYTE *bpRGB2)
|
|||
return (double) (Abs(bpRGB1[0]-bpRGB2[0]) + Abs(bpRGB1[1]-bpRGB2[1]) + Abs(bpRGB1[2]-bpRGB2[2])) / 6.0;
|
||||
}
|
||||
|
||||
bool CSurface::Wipe()
|
||||
{
|
||||
if (!ppTex) return false;
|
||||
// simply clear it (currently slow...)
|
||||
if (!Lock()) return false;
|
||||
for (int i=0; i<Wdt*Hgt; ++i)
|
||||
if (!fIsBackground)
|
||||
SetPix(i%Wdt, i/Wdt, 0);
|
||||
else
|
||||
SetPixDw(i%Wdt, i/Wdt, 0xff000000);
|
||||
Unlock();
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSurface::GetSurfaceSize(int &irX, int &irY)
|
||||
{
|
||||
// simply assign stored values
|
||||
|
@ -847,11 +813,6 @@ bool CSurface::GetLockTexAt(CTexRef **ppTexRef, int &rX, int &rY)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CSurface::SetPix(int iX, int iY, BYTE byCol)
|
||||
{
|
||||
return SetPixDw(iX, iY, lpDDrawPal->GetClr(byCol));
|
||||
}
|
||||
|
||||
DWORD CSurface::GetPixDw(int iX, int iY, bool fApplyModulation)
|
||||
{
|
||||
BYTE *pBuf = NULL; int iPitch = 0; // TODO: are those initialised to something sensible?
|
||||
|
@ -1598,4 +1559,3 @@ void CTexMgr::IntUnlock()
|
|||
}
|
||||
|
||||
CTexMgr *pTexMgr;
|
||||
const BYTE FColors [] = {31,16,39,47,55,63,71,79,87,95,23,30,99,103};
|
||||
|
|
|
@ -151,8 +151,6 @@ protected:
|
|||
public:
|
||||
void SetBackground() { fIsBackground = true; }
|
||||
int IsLocked() const { return Locked; }
|
||||
bool HLine(int iX, int iX2, int iY, int iCol);
|
||||
bool Box(int iX, int iY, int iX2, int iY2, int iCol);
|
||||
// Note: This uses partial locks, anything but SetPixDw and Unlock is undefined afterwards until unlock.
|
||||
void ClearBoxDw(int iX, int iY, int iWdt, int iHgt);
|
||||
void ClearBox8Only(int iX, int iY, int iWdt, int iHgt); // clear box in 8bpp-surface only
|
||||
|
@ -160,7 +158,6 @@ public:
|
|||
bool Lock();
|
||||
bool GetTexAt(CTexRef **ppTexRef, int &rX, int &rY); // get texture and adjust x/y
|
||||
bool GetLockTexAt(CTexRef **ppTexRef, int &rX, int &rY); // get texture; ensure it's locked and adjust x/y
|
||||
bool SetPix(int iX, int iY, BYTE byCol); // set 8bit-px
|
||||
DWORD GetPixDw(int iX, int iY, bool fApplyModulation); // get 32bit-px
|
||||
bool IsPixTransparent(int iX, int iY); // is pixel's alpha value <= 0x7f?
|
||||
bool SetPixDw(int iX, int iY, DWORD dwCol); // set pix in surface only
|
||||
|
@ -180,10 +177,9 @@ public:
|
|||
void Default();
|
||||
void Clip(int iX, int iY, int iX2, int iY2);
|
||||
void NoClip();
|
||||
bool ReadBMP(class CStdStream &hGroup, bool fOwnPal=false);
|
||||
bool ReadBMP(class CStdStream &hGroup);
|
||||
bool SavePNG(const char *szFilename, bool fSaveAlpha, bool fApplyGamma, bool fSaveOverlayOnly);
|
||||
bool AttachPalette();
|
||||
bool Wipe(); // empty to transparent
|
||||
#ifdef USE_DIRECTX
|
||||
IDirect3DSurface9 *GetSurface(); // get internal surface
|
||||
#endif
|
||||
|
|
|
@ -55,15 +55,10 @@ void CSurface8::Clear()
|
|||
// clear bitmap-copy
|
||||
delete [] Bits; Bits=NULL;
|
||||
// clear pal
|
||||
if (HasOwnPal()) delete pPal;
|
||||
delete pPal;
|
||||
pPal=NULL;
|
||||
}
|
||||
|
||||
bool CSurface8::HasOwnPal()
|
||||
{
|
||||
return pPal != lpDDrawPal;
|
||||
}
|
||||
|
||||
void CSurface8::Box(int iX, int iY, int iX2, int iY2, int iCol)
|
||||
{
|
||||
for (int cy=iY; cy<=iY2; cy++) HLine(iX,iX2,cy,iCol);
|
||||
|
@ -85,22 +80,16 @@ void CSurface8::HLine(int iX, int iX2, int iY, int iCol)
|
|||
for (int cx=iX; cx<=iX2; cx++) SetPix(cx,iY,iCol);
|
||||
}
|
||||
|
||||
bool CSurface8::Create(int iWdt, int iHgt, bool fOwnPal)
|
||||
bool CSurface8::Create(int iWdt, int iHgt)
|
||||
{
|
||||
Clear();
|
||||
// check size
|
||||
if (!iWdt || !iHgt) return false;
|
||||
Wdt=iWdt; Hgt=iHgt;
|
||||
|
||||
// create/link to pal
|
||||
if (fOwnPal)
|
||||
{
|
||||
pPal = new CStdPalette;
|
||||
if (!pPal) return false;
|
||||
memcpy(pPal, &lpDDraw->Pal, sizeof(CStdPalette));
|
||||
}
|
||||
else
|
||||
pPal = &lpDDraw->Pal;
|
||||
// create pal
|
||||
pPal = new CStdPalette;
|
||||
if (!pPal) return false;
|
||||
|
||||
Bits=new BYTE[Wdt*Hgt];
|
||||
if (!Bits) return false;
|
||||
|
@ -111,7 +100,7 @@ bool CSurface8::Create(int iWdt, int iHgt, bool fOwnPal)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CSurface8::Read(CStdStream &hGroup, bool fOwnPal)
|
||||
bool CSurface8::Read(CStdStream &hGroup)
|
||||
{
|
||||
int cnt,lcnt,iLineRest;
|
||||
CBitmap256Info BitmapInfo;
|
||||
|
@ -134,20 +123,17 @@ bool CSurface8::Read(CStdStream &hGroup, bool fOwnPal)
|
|||
//f8BitSfc=false;
|
||||
|
||||
// Create and lock surface
|
||||
if (!Create(BitmapInfo.Info.biWidth,BitmapInfo.Info.biHeight, fOwnPal)) return false;
|
||||
if (!Create(BitmapInfo.Info.biWidth,BitmapInfo.Info.biHeight)) return false;
|
||||
|
||||
if (BitmapInfo.Info.biBitCount == 8)
|
||||
{
|
||||
if (HasOwnPal())
|
||||
// Copy palette
|
||||
for (cnt=0; cnt<256; cnt++)
|
||||
{
|
||||
// Copy palette
|
||||
for (cnt=0; cnt<256; cnt++)
|
||||
{
|
||||
pPal->Colors[cnt*3+0]=BitmapInfo.Colors[cnt].rgbRed;
|
||||
pPal->Colors[cnt*3+1]=BitmapInfo.Colors[cnt].rgbGreen;
|
||||
pPal->Colors[cnt*3+2]=BitmapInfo.Colors[cnt].rgbBlue;
|
||||
pPal->Alpha[cnt]=0xff;
|
||||
}
|
||||
pPal->Colors[cnt*3+0]=BitmapInfo.Colors[cnt].rgbRed;
|
||||
pPal->Colors[cnt*3+1]=BitmapInfo.Colors[cnt].rgbGreen;
|
||||
pPal->Colors[cnt*3+2]=BitmapInfo.Colors[cnt].rgbBlue;
|
||||
pPal->Alpha[cnt]=0xff;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,50 +194,12 @@ bool CSurface8::Save(const char *szFilename, BYTE *bpPalette)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
double ColorDistance(BYTE *bpRGB1, BYTE *bpRGB2)
|
||||
{
|
||||
return (double) (Abs(bpRGB1[0]-bpRGB2[0]) + Abs(bpRGB1[1]-bpRGB2[1]) + Abs(bpRGB1[2]-bpRGB2[2])) / 6.0;
|
||||
}
|
||||
|
||||
void CSurface8::SetPalette(BYTE *bpPalette, bool fAdapt)
|
||||
{
|
||||
if (!HasOwnPal()) return;
|
||||
// Adapt bitmap
|
||||
if (fAdapt)
|
||||
{
|
||||
BYTE AdaptMap[256]; AdaptMap[0]=0;
|
||||
for (int iFromCol=1; iFromCol<256; iFromCol++) // Color zero transparent
|
||||
{
|
||||
int iToCol = 1;
|
||||
for (int cToCol=iToCol+1; cToCol<256; cToCol++)
|
||||
if ( ColorDistance(&pPal->Colors[iFromCol*3],&bpPalette[cToCol*3])
|
||||
< ColorDistance(&pPal->Colors[iFromCol*3],&bpPalette[iToCol*3]) )
|
||||
iToCol = cToCol;
|
||||
|
||||
AdaptMap[iFromCol] = iToCol;
|
||||
}
|
||||
|
||||
MapBytes(AdaptMap);
|
||||
|
||||
}
|
||||
|
||||
// Set palette
|
||||
MemCopy(bpPalette,pPal->Colors,256*3);
|
||||
}
|
||||
*/
|
||||
void CSurface8::MapBytes(BYTE *bpMap)
|
||||
{
|
||||
if (!bpMap) return;
|
||||
for (int cnt=0; cnt<Wdt*Hgt; cnt++) SetPix(cnt%Wdt, cnt/Wdt, bpMap[GetPix(cnt%Wdt, cnt/Wdt)]);
|
||||
}
|
||||
|
||||
void CSurface8::Wipe()
|
||||
{
|
||||
for (int i=0; i<Wdt*Hgt; ++i)
|
||||
SetPix(i%Wdt, i/Wdt, 0);
|
||||
}
|
||||
|
||||
void CSurface8::GetSurfaceSize(int &irX, int &irY)
|
||||
{
|
||||
// simply assign stored values
|
||||
|
|
|
@ -55,16 +55,14 @@ public:
|
|||
{
|
||||
return Bits[y*Pitch+x];
|
||||
}
|
||||
bool Create(int iWdt, int iHgt, bool fOwnPal=false);
|
||||
bool Create(int iWdt, int iHgt);
|
||||
void MoveFrom(CSurface *psfcFrom); // grab data from other surface - invalidates other surface
|
||||
void Clear();
|
||||
void Clip(int iX, int iY, int iX2, int iY2);
|
||||
void NoClip();
|
||||
bool Read(class CStdStream &hGroup, bool fOwnPal);
|
||||
bool Read(class CStdStream &hGroup);
|
||||
bool Save(const char *szFilename, BYTE *bpPalette = NULL);
|
||||
void Wipe(); // empty to transparent
|
||||
void GetSurfaceSize(int &irX, int &irY); // get surface size
|
||||
void EnforceC0Transparency() { pPal->EnforceC0Transparency(); }
|
||||
void AllowColor(BYTE iRngLo, BYTE iRngHi, bool fAllowZero=false);
|
||||
void SetBuffer(BYTE *pbyToBuf, int Wdt, int Hgt, int Pitch);
|
||||
void ReleaseBuffer();
|
||||
|
|
Loading…
Reference in New Issue