diff --git a/docs/de.po b/docs/de.po index b15e5e850..8adc5bc61 100644 --- a/docs/de.po +++ b/docs/de.po @@ -8775,8 +8775,8 @@ msgid "ID of the object definition which is used for decoration of the message. msgstr "ID der Objektdefinition, die für Dekoration der Nachricht verwendet wird. Wenn angegeben, wird die Nachricht von einem Rahmen umgeben. Nur gültig bei angegebenem Portrait." #: sdk/script/fn/CustomMessage.xml:57(desc) -msgid "Picture specification for a picture to the left of the message within the decoration frame." -msgstr "Bildspezifikation für ein Bild links neben der Nachricht im Dekorationsrahmen." +msgid "Definition or object to take the graphics from as a portrait." +msgstr "Definition oder Objekt dessen Grafik als Portrait benutzt werden soll." #: sdk/script/fn/CustomMessage.xml:67(col) #: sdk/script/fn/CreateScriptPlayer.xml:36(col) @@ -8833,8 +8833,8 @@ msgid "Shows the message \"This is madness!\" for player 0 only with the word \" msgstr "Gibt die Nachricht \"This is madness!\" nur für Spieler 0 aus, wobei das Wort \"madness\" in kursiver Schrift angezeigt wird." #: sdk/script/fn/CustomMessage.xml:104(text) -msgid "Displays a message with a decoration frame. The name Tonki is colored yellow. On the left hand side of the message a green clonk portrait will be shown. The decoration definition GUI_MenuDeco needs to be loaded." -msgstr "Gibt eine Nachricht mit Dekorahmen aus. Der Name Tonki ist gelb eingefärbt. Links von der Nachricht wird ein grünes Clonk-Portrait angezeigt. Es muss die Dekorationsdefinition GUI_MenuDeco geladen sein." +msgid "Displays a message with a decoration frame. The name Tonki is colored yellow. On the left hand side of the message a clonk picture will be shown. The decoration definition GUI_MenuDeco needs to be loaded." +msgstr "Gibt eine Nachricht mit Dekorahmen aus. Der Name Tonki ist gelb eingefärbt. Links von der Nachricht wird ein Clonk-Titelbild wird angezeigt. Es muss die Dekorationsdefinition GUI_MenuDeco geladen sein." #: sdk/script/fn/CreateScriptPlayer.xml:16(desc) msgid "Name for the script player. Required." diff --git a/docs/sdk/script/fn/CustomMessage.xml b/docs/sdk/script/fn/CustomMessage.xml index 902ec091c..9f7672f6e 100644 --- a/docs/sdk/script/fn/CustomMessage.xml +++ b/docs/sdk/script/fn/CustomMessage.xml @@ -52,9 +52,9 @@ - string + id/object portrait - Picture specification for a picture to the left of the message within the decoration frame. + Definition or object to take the graphics from as a portrait. @@ -100,8 +100,8 @@ Shows the message "This is madness!" for player 0 only with the word "madness" being written in italic. - CustomMessage("<c ffff00>Tonki:</c> Hello, world", nil, NO_OWNER, 100,100, 0, GUI_MenuDeco, "Portrait:Clonk::00ff00::1); - Displays a message with a decoration frame. The name Tonki is colored yellow. On the left hand side of the message a green clonk portrait will be shown. The decoration definition GUI_MenuDeco needs to be loaded. + CustomMessage("<c ffff00>Tonki:</c> Hello, world", nil, NO_OWNER, 100,100, 0, GUI_MenuDeco, Clonk); + Displays a message with a decoration frame. The name Tonki is colored yellow. On the left hand side of the message a clonk picture will be shown. The decoration definition GUI_MenuDeco needs to be loaded. diff --git a/planet/Graphics.ocg/Portrait1.png b/planet/Graphics.ocg/Portrait1.png deleted file mode 100644 index 79b34a774..000000000 Binary files a/planet/Graphics.ocg/Portrait1.png and /dev/null differ diff --git a/planet/Graphics.ocg/Portrait2.png b/planet/Graphics.ocg/Portrait2.png deleted file mode 100644 index 79b34a774..000000000 Binary files a/planet/Graphics.ocg/Portrait2.png and /dev/null differ diff --git a/planet/Graphics.ocg/Portrait3.png b/planet/Graphics.ocg/Portrait3.png deleted file mode 100644 index 79b34a774..000000000 Binary files a/planet/Graphics.ocg/Portrait3.png and /dev/null differ diff --git a/planet/Graphics.ocg/Portrait4.png b/planet/Graphics.ocg/Portrait4.png deleted file mode 100644 index 79b34a774..000000000 Binary files a/planet/Graphics.ocg/Portrait4.png and /dev/null differ diff --git a/planet/Graphics.ocg/Portrait5.png b/planet/Graphics.ocg/Portrait5.png deleted file mode 100644 index 79b34a774..000000000 Binary files a/planet/Graphics.ocg/Portrait5.png and /dev/null differ diff --git a/planet/Objects.ocd/Goals.ocd/Resource.ocd/Script.c b/planet/Objects.ocd/Goals.ocd/Resource.ocd/Script.c index 5f9117caf..ed372b040 100644 --- a/planet/Objects.ocd/Goals.ocd/Resource.ocd/Script.c +++ b/planet/Objects.ocd/Goals.ocd/Resource.ocd/Script.c @@ -60,7 +60,6 @@ public func Activate(int plr) } // Otherwise open a new message. AddEffect("GoalMessage", this, 100, 0, this); - var portrait_def = Format("%i", GetID()); var message; if (IsFulfilled()) { @@ -80,7 +79,7 @@ public func Activate(int plr) message = Format("%s%s", message, add_msg); } } - CustomMessage(message, nil, plr, 0, 16 + 64, 0xffffff, GUI_MenuDeco, portrait_def, MSG_HCenter); + CustomMessage(message, nil, plr, 0, 16 + 64, 0xffffff, GUI_MenuDeco, this, MSG_HCenter); return; } diff --git a/planet/Tutorial.ocf/Tutorial.ocd/TutGuide.ocd/Portrait1.png b/planet/Tutorial.ocf/Tutorial.ocd/TutGuide.ocd/Portrait1.png deleted file mode 100644 index 80e09f8ae..000000000 Binary files a/planet/Tutorial.ocf/Tutorial.ocd/TutGuide.ocd/Portrait1.png and /dev/null differ diff --git a/planet/Tutorial.ocf/Tutorial.ocd/TutGuide.ocd/Script.c b/planet/Tutorial.ocf/Tutorial.ocd/TutGuide.ocd/Script.c index 36670b4f0..e3cc5505f 100644 --- a/planet/Tutorial.ocf/Tutorial.ocd/TutGuide.ocd/Script.c +++ b/planet/Tutorial.ocf/Tutorial.ocd/TutGuide.ocd/Script.c @@ -115,10 +115,8 @@ private func GuideMessage(int show_index) var message = messages[show_index]; if (!message) return false; - // Guide portrait. - var portrait_def = "Portrait:TutorialGuide::00ff00::1"; // Message as regular one, don't stop the player. - CustomMessage(message, nil, GetOwner(), 0, 16 + TutorialGuide->GetDefHeight(), 0xffffff, GUI_MenuDeco, portrait_def, MSG_HCenter); + CustomMessage(message, nil, GetOwner(), 0, 16 + TutorialGuide->GetDefHeight(), 0xffffff, GUI_MenuDeco, this, MSG_HCenter); var effect = AddEffect("MessageShown", this, 100, 2 * GetLength(message), this); effect.show_index = show_index; // Messages with @ in front are shown infinetely long. diff --git a/src/C4Game.cpp b/src/C4Game.cpp index e8a963cbe..17374df7c 100644 --- a/src/C4Game.cpp +++ b/src/C4Game.cpp @@ -3351,24 +3351,6 @@ bool C4Game::DrawTextSpecImage(C4FacetSurface &fctTarget, const char *szSpec, ui return true; } } - // portrait spec? - else if (SEqual2(szSpec, "Portrait:")) - { - szSpec += 9; - C4ID idPortrait; - const char *szPortraitName = C4Portrait::EvaluatePortraitString(szSpec, idPortrait, C4ID::None, &dwClr); - if (idPortrait == C4ID::None) return false; - C4Def *pPortraitDef = ::Definitions.ID2Def(idPortrait); - if (!pPortraitDef || !pPortraitDef->Portraits) return false; - C4DefGraphics *pDefPortraitGfx = pPortraitDef->Portraits->Get(szPortraitName); - if (!pDefPortraitGfx) return false; - C4PortraitGraphics *pPortraitGfx = pDefPortraitGfx->IsPortrait(); - if (!pPortraitGfx) return false; - C4Surface *sfcPortrait = pPortraitGfx->GetBitmap(dwClr); - if (!sfcPortrait) return false; - fctTarget.Set(sfcPortrait, 0, 0, sfcPortrait->Wdt, sfcPortrait->Hgt); - return true; - } else { // regular ID? -> Draw def diff --git a/src/config/C4Config.cpp b/src/config/C4Config.cpp index eb3fb598b..db43155c7 100644 --- a/src/config/C4Config.cpp +++ b/src/config/C4Config.cpp @@ -80,7 +80,6 @@ void C4ConfigGeneral::CompileFunc(StdCompiler *pComp) pComp->Value(mkNamingAdapt(RXFontSize, "FontSize", 14, false, true)); pComp->Value(mkNamingAdapt(GamepadEnabled, "GamepadEnabled", true )); pComp->Value(mkNamingAdapt(FirstStart, "FirstStart", true )); - pComp->Value(mkNamingAdapt(UserPortraitsWritten,"UserPortraitsWritten",false )); pComp->Value(mkNamingAdapt(ConfigResetSafety, "ConfigResetSafety", static_cast(ConfigResetSafetyVal) )); } @@ -99,8 +98,6 @@ void C4ConfigGraphics::CompileFunc(StdCompiler *pComp) pComp->Value(mkNamingAdapt(GuiResY, "GuiResolutionY", 600 ,false, true)); pComp->Value(mkNamingAdapt(ShowAllResolutions, "ShowAllResolutions", 0 ,false, true)); pComp->Value(mkNamingAdapt(SplitscreenDividers, "SplitscreenDividers", 1 )); - pComp->Value(mkNamingAdapt(AddNewCrewPortraits, "AddNewCrewPortraits", 0 ,false, true)); - pComp->Value(mkNamingAdapt(SaveDefaultPortraits, "SaveDefaultPortraits", 0 ,false, true)); pComp->Value(mkNamingAdapt(ShowStartupMessages, "ShowStartupMessages", 1 ,false, true)); pComp->Value(mkNamingAdapt(ColorAnimation, "ColorAnimation", 0 ,false, true)); pComp->Value(mkNamingAdapt(HighResLandscape, "HighResLandscape", 0 ,false, true)); @@ -158,7 +155,6 @@ void C4ConfigNetwork::CompileFunc(StdCompiler *pComp) pComp->Value(mkNamingAdapt(PortDiscovery, "PortDiscovery", C4NetStdPortDiscovery ,false, true)); pComp->Value(mkNamingAdapt(PortRefServer, "PortRefServer", C4NetStdPortRefServer ,false, true)); pComp->Value(mkNamingAdapt(ControlMode, "ControlMode", 0 )); - pComp->Value(mkNamingAdapt(SendPortraits, "SendPortraits", 0 ,false, true)); pComp->Value(mkNamingAdapt(Nick, "Nick", "" ,false, true)); pComp->Value(mkNamingAdapt(MaxLoadFileSize, "MaxLoadFileSize", 5*1024*1024 ,false, true)); diff --git a/src/config/C4Config.h b/src/config/C4Config.h index fa44481d4..d7466d0a6 100644 --- a/src/config/C4Config.h +++ b/src/config/C4Config.h @@ -60,7 +60,6 @@ public: char ScreenshotPath[CFG_MaxString+1]; bool GamepadEnabled; bool FirstStart; - bool UserPortraitsWritten; // set when default portraits have been copied to the UserPath (this is only done once) public: static int GetLanguageSequence(const char *strSource, char *strTarget); @@ -89,8 +88,6 @@ class C4ConfigGraphics { public: int32_t SplitscreenDividers; - int32_t AddNewCrewPortraits; - int32_t SaveDefaultPortraits; int32_t ShowStartupMessages; int32_t VerboseObjectLoading; int32_t ColorAnimation; @@ -156,7 +153,6 @@ public: int32_t MasterReferencePeriod; int32_t LeagueServerSignUp; int32_t UseAlternateServer; - int32_t SendPortraits; int32_t PortTCP,PortUDP,PortDiscovery,PortRefServer; int32_t ControlMode; ValidatedStdCopyStrBuf Nick; diff --git a/src/control/C4Control.cpp b/src/control/C4Control.cpp index 1f7dd77cb..1a77019b3 100644 --- a/src/control/C4Control.cpp +++ b/src/control/C4Control.cpp @@ -786,8 +786,6 @@ void C4ControlJoinPlayer::Strip() C4Group Grp; if (!Grp.Open(PlayerFilename.getData())) { EraseFile(PlayerFilename.getData()); return; } - // remove portrais - Grp.Delete(C4CFN_Portraits, true); // remove bigicon, if the file size is too large size_t iBigIconSize=0; if (Grp.FindEntry(C4CFN_BigIcon, NULL, &iBigIconSize)) diff --git a/src/control/C4Record.cpp b/src/control/C4Record.cpp index c8aa3baf9..add6aae1e 100644 --- a/src/control/C4Record.cpp +++ b/src/control/C4Record.cpp @@ -1101,7 +1101,6 @@ void C4Playback::Check(C4RecordChunkType eType, const uint8_t *pData, int iSize) { StdStrBuf sErr; sErr.Format("DbgRecPkt Type %s, size %d", GetRecordChunkTypeName(eType), iSize); - int i; sErr.Append(" Replay: "); StdBuf replay(PktInReplay.getData(), PktInReplay.getSize()); sErr.Append(GetDbgRecPktData(eType, replay)); diff --git a/src/game/object/C4Def.cpp b/src/game/object/C4Def.cpp index bacab61de..e3c486589 100644 --- a/src/game/object/C4Def.cpp +++ b/src/game/object/C4Def.cpp @@ -340,8 +340,6 @@ void C4Def::Default() pRankSymbols=NULL; fClonkNamesOwned = fRankNamesOwned = fRankSymbolsOwned = false; iNumRankSymbols=1; - PortraitCount = 0; - Portraits = NULL; } C4Def::~C4Def() @@ -361,8 +359,6 @@ void C4Def::Clear() if (pRankSymbols && fRankSymbolsOwned) delete pRankSymbols; pRankSymbols=NULL; fClonkNamesOwned = fRankNamesOwned = fRankSymbolsOwned = false; - PortraitCount = 0; - Portraits = NULL; C4PropList::Clear(); } @@ -428,14 +424,6 @@ bool C4Def::Load(C4Group &hGroup, return false; } - // Read portraits - if (dwLoadWhat & C4D_Load_Bitmap) - if (!LoadPortraits(hGroup)) - { - DebugLogF(" Error loading portrait graphics of %s (%s)", hGroup.GetFullName().getData(), id.ToString()); - return false; - } - // Read string table StringTable.LoadEx(hGroup, C4CFN_ScriptStringTbl, szLanguage); @@ -638,22 +626,6 @@ void C4Def::Synchronize() { } -bool C4Def::LoadPortraits(C4Group &hGroup) -{ - // reset any previous portraits - Portraits = NULL; PortraitCount = 0; - // search for portraits within def graphics - for (C4DefGraphics *pGfx = &Graphics; pGfx; pGfx=pGfx->GetNext()) - if (pGfx->IsPortrait()) - { - // assign first portrait - if (!Portraits) Portraits = pGfx->IsPortrait(); - // count - ++PortraitCount; - } - return true; -} - int32_t C4Def::GetComponentCount(C4ID idComponent) { return Component.GetIDCount(idComponent); diff --git a/src/game/object/C4Def.h b/src/game/object/C4Def.h index cf6043cb3..a62d28063 100644 --- a/src/game/object/C4Def.h +++ b/src/game/object/C4Def.h @@ -202,8 +202,6 @@ public: C4FacetSurface *pRankSymbols; bool fRankSymbolsOwned; int32_t iNumRankSymbols; // number of rank symbols available, if loaded C4DefGraphics Graphics; // base graphics. points to additional graphics - int32_t PortraitCount; - C4PortraitGraphics *Portraits; // Portraits (linked list of C4AdditionalDefGraphics) protected: C4Facet MainFace; @@ -227,7 +225,6 @@ public: virtual C4Def * GetDef() { return this; } virtual bool IsDef() const { return true; } protected: - bool LoadPortraits(C4Group &hGroup); bool LoadActMap(C4Group &hGroup); void CrossMapActMap(); public: diff --git a/src/game/object/C4DefGraphics.cpp b/src/game/object/C4DefGraphics.cpp index f9c932b1b..d96b87be6 100644 --- a/src/game/object/C4DefGraphics.cpp +++ b/src/game/object/C4DefGraphics.cpp @@ -249,37 +249,6 @@ bool C4DefGraphics::Load(C4Group &hGroup, bool fColorByOwner) if (!pLastGraphics->LoadBitmap(hGroup, Filename, fColorByOwner ? OverlayFn : NULL, fColorByOwner)) return false; } - // load portrait graphics - iWildcardPos = SCharPos('*', C4CFN_Portraits); - hGroup.ResetSearch(); - *Filename=0; - while (hGroup.FindNextEntry(C4CFN_Portraits, Filename, NULL, !!*Filename)) - { - // get graphics name - char GrpName[_MAX_PATH+1]; - SCopy(Filename + iWildcardPos, GrpName, _MAX_PATH); - RemoveExtension(GrpName); - // clip to max length - GrpName[C4MaxName]=0; - // determine file type (bmp or png) - char OverlayFn[_MAX_PATH+1]; *OverlayFn=0; - if (!SEqualNoCase(GetExtension(Filename), "png")) continue; - // create overlay-filename for PNGs - if (fColorByOwner) - { - // PortraitX.png -> OverlayX.png - SCopy(C4CFN_ClrByOwnerExPNG, OverlayFn, _MAX_PATH); - OverlayFn[iOverlayWildcardPos]=0; - SAppend(Filename + iWildcardPos, OverlayFn); - EnforceExtension(OverlayFn, GetExtension(C4CFN_ClrByOwnerExPNG)); - } - // create new graphics - pLastGraphics->pNext = new C4PortraitGraphics(pDef, GrpName); - pLastGraphics = pLastGraphics->pNext; - // load them - if (!pLastGraphics->LoadBitmap(hGroup, Filename, *OverlayFn ? OverlayFn : NULL, fColorByOwner)) - return false; - } // done, success return true; } @@ -295,17 +264,6 @@ C4DefGraphics *C4DefGraphics::Get(const char *szGrpName) return NULL; } -C4PortraitGraphics *C4PortraitGraphics::Get(const char *szGrpName) -{ - // no group or empty string: no gfx - if (!szGrpName || !szGrpName[0]) return NULL; - // search self and additional graphics - for (C4AdditionalDefGraphics *pGrp = this; pGrp; pGrp=pGrp->GetNext()) - if (SEqualNoCase(pGrp->GetName(), szGrpName)) return pGrp->IsPortrait(); - // nothing found - return NULL; -} - bool C4DefGraphics::CopyGraphicsFrom(C4DefGraphics &rSource) { if (Type != TYPE_Bitmap) return false; // TODO! @@ -373,21 +331,6 @@ C4AdditionalDefGraphics::C4AdditionalDefGraphics(C4Def *pOwnDef, const char *szN SCopy(szName, Name, C4MaxName); } -C4PortraitGraphics *C4PortraitGraphics::GetByIndex(int32_t iIndex) -{ - // start from this portrait - C4DefGraphics *pResult = this; - while (iIndex--) - { - // get next indexed - pResult = pResult->GetNext(); if (!pResult) return NULL; - // skip non-portraits - if (!pResult->IsPortrait()) ++iIndex; - } - // return portrait - return pResult->IsPortrait(); -} - C4DefGraphicsPtrBackup::C4DefGraphicsPtrBackup(C4DefGraphics *pSourceGraphics) { // assign graphics + def @@ -453,24 +396,6 @@ void C4DefGraphicsPtrBackup::AssignUpdate(C4DefGraphics *pNewGraphics) if (!pDeco->UpdateGfx()) pObj->Menu->SetFrameDeco(NULL); } - // check all object infos for portraits - for (C4Player *pPlr = ::Players.First; pPlr; pPlr=pPlr->Next) - for (C4ObjectInfo *pInfo = pPlr->CrewInfoList.GetFirst(); pInfo; pInfo=pInfo->Next) - { - if (pInfo->Portrait.GetGfx() == pGraphicsPtr) - { - // portrait found: try to re-set by new name - if (!pInfo->SetPortrait(Name, pDef, false, false)) - // not found: no portrait then - pInfo->ClearPortrait(false); - } - if (pInfo->pNewPortrait && pInfo->pNewPortrait->GetGfx() == pGraphicsPtr) - { - // portrait found as new portrait: simply reset (no complex handling for EM crew changes necessary) - delete pInfo->pNewPortrait; - pInfo->pNewPortrait = NULL; - } - } // done; reset field to indicate finished update pGraphicsPtr = NULL; } @@ -518,129 +443,6 @@ void C4DefGraphicsPtrBackup::AssignRemoval() if (pNext) pNext->AssignRemoval(); } - - -bool C4Portrait::Load(C4Group &rGrp, const char *szFilenamePNG, const char *szOverlayPNG) -{ - // clear previous - Clear(); - // create new gfx - pGfxPortrait = new C4DefGraphics(); - // load - if (!pGfxPortrait->LoadBitmap(rGrp, szFilenamePNG, szOverlayPNG, true)) - { - // load failure - delete pGfxPortrait; pGfxPortrait=NULL; - return false; - } - // assign owned gfx - fGraphicsOwned = true; - // done, success - return true; -} - -bool C4Portrait::Link(C4DefGraphics *pGfxPortrait) -{ - // clear previous - Clear(); - // simply assign ptr - this->pGfxPortrait = pGfxPortrait; - // done, success - return true; -} - -bool C4Portrait::SavePNG(C4Group &rGroup, const char *szFilename, const char *szOverlayFN) -{ - // safety - if (!pGfxPortrait || !szFilename || pGfxPortrait->Type != C4DefGraphics::TYPE_Bitmap || !pGfxPortrait->Bmp.Bitmap) return false; - // save files - if (pGfxPortrait->fColorBitmapAutoCreated) - { - // auto-created ColorByOwner: save file with blue shades to be read by frontend - if (!pGfxPortrait->GetBitmap(0xff)->SavePNG(rGroup, szFilename)) return false; - } - else - { - // save regular baseface - if (!pGfxPortrait->Bmp.Bitmap->SavePNG(rGroup, szFilename)) return false; - // save Overlay - if (pGfxPortrait->Bmp.BitmapClr && szOverlayFN) - if (!pGfxPortrait->Bmp.BitmapClr->SavePNG(rGroup, szOverlayFN, true, false, true)) return false; - } - // done, success - return true; -} - -bool C4Portrait::CopyFrom(C4DefGraphics &rCopyGfx) -{ - // clear previous - Clear(); - // gfx copy - pGfxPortrait = new C4DefGraphics(); - if (!pGfxPortrait->CopyGraphicsFrom(rCopyGfx)) - { Clear(); return false; } - // mark as own gfx - fGraphicsOwned = true; - // done, success - return true; -} - -bool C4Portrait::CopyFrom(C4Portrait &rCopy) -{ - // clear previous - Clear(); - if ((fGraphicsOwned=rCopy.fGraphicsOwned)) - { - // gfx copy - pGfxPortrait = new C4DefGraphics(); - if (!pGfxPortrait->CopyGraphicsFrom(*rCopy.GetGfx())) - { Clear(); return false; } - } - else - { - // simple link - pGfxPortrait = rCopy.GetGfx(); - } - // done, success - return true; -} - -const char *C4Portrait::EvaluatePortraitString(const char *szPortrait, C4ID &rIDOut, C4ID idDefaultID, uint32_t *pdwClrOut) -{ - // examine portrait string - const char *delim_pos; - if ((delim_pos = SSearch(szPortrait, "::"))) - { - // C4ID::PortraitName or C4ID::dwClr::PortraitName - StdStrBuf portrait_id; - portrait_id.Copy(szPortrait, delim_pos-szPortrait-2); - rIDOut = C4ID(portrait_id.getData()); - // color specified? - szPortrait = delim_pos; - delim_pos = SSearch(szPortrait, "::"); - if (delim_pos) - { - char buf[7]; - // delim_pos-szPortrait-2 results in long on 64bit, - // so the template needs to be specialised - SCopy(szPortrait, buf, Min(6, delim_pos-szPortrait-2)); - if (pdwClrOut) sscanf(buf, "%x", pdwClrOut); - szPortrait = delim_pos; - } - // return last part of string - return szPortrait; - } - else - { - // PortraitName. ID is info ID - rIDOut = idDefaultID; - return szPortrait; - } -} - - - - // --------------------------------------------------------------------------- // C4GraphicsOverlay: graphics overlay used to attach additional graphics to objects diff --git a/src/game/object/C4DefGraphics.h b/src/game/object/C4DefGraphics.h index 4dc94ab56..de2283be7 100644 --- a/src/game/object/C4DefGraphics.h +++ b/src/game/object/C4DefGraphics.h @@ -30,16 +30,11 @@ #include "C4InputValidation.h" #include "C4Id.h" -#define C4Portrait_None "none" -#define C4Portrait_Random "random" -#define C4Portrait_Custom "custom" - class C4Def; // defintion graphics class C4AdditionalDefGraphics; class C4DefGraphicsPtrBackup; -class C4PortraitGraphics; class C4DefGraphics { @@ -88,7 +83,6 @@ public: virtual const char *GetName() { return NULL; } // return name to be stored in safe game files C4AdditionalDefGraphics *GetNext() { return pNext; } - virtual C4PortraitGraphics *IsPortrait() { return NULL; } void DrawClr(C4Facet &cgo, bool fAspect=true, DWORD dwClr=0); // set surface color and draw @@ -108,18 +102,6 @@ public: virtual const char *GetName() { return Name; } }; -// portrait graphics within object definition -class C4PortraitGraphics : public C4AdditionalDefGraphics -{ -public: - C4PortraitGraphics(C4Def *pOwnDef, const char *szName) // ctor - : C4AdditionalDefGraphics(pOwnDef, szName) { } - - virtual C4PortraitGraphics *IsPortrait() { return this; } - C4PortraitGraphics *GetByIndex(int32_t iIndex); - C4PortraitGraphics *Get(const char *szGrpName); // get portrait graphics by name -}; - // backup class holding dead graphics pointers and names class C4DefGraphicsPtrBackup { @@ -151,32 +133,6 @@ public: ALLOW_TEMP_TO_REF(C4DefGraphicsAdapt) }; -// portrait link class -class C4Portrait -{ -protected: - C4DefGraphics *pGfxPortrait; // the portrait graphics - bool fGraphicsOwned; // if true, the portrait graphics are owned (and deleted upon destruction) - -public: - C4Portrait() : pGfxPortrait(NULL), fGraphicsOwned(false) {} // ctor - ~C4Portrait() { if (fGraphicsOwned) delete pGfxPortrait; } // dtor - void Default() { pGfxPortrait=NULL; fGraphicsOwned=false; } - void Clear() { if (fGraphicsOwned) { delete pGfxPortrait; fGraphicsOwned=false; } pGfxPortrait=NULL; } - - bool CopyFrom(C4DefGraphics &rCopyGfx); // copy portrait from graphics - bool CopyFrom(C4Portrait &rCopy); // copy portrait - - bool Load(C4Group &rGrp, const char *szFilenamePNG, const char *szOverlayPNG); // load own portrait from group - bool Link(C4DefGraphics *pGfxPortrait); // link with a present portrait surface - bool SavePNG(C4Group &rGroup, const char *szFilename, const char *szOverlayFN); // store portrait gfx to file (including overlay) - - C4DefGraphics *GetGfx() { return pGfxPortrait; } - bool IsOwnedGfx() { return fGraphicsOwned; } // return if it's a custom portrait - - static const char *EvaluatePortraitString(const char *szPortrait, C4ID &rIDOut, C4ID idDefaultID, uint32_t *pdwClrOut); // get portrait source and def from string -}; - // graphics overlay used to attach additional graphics to objects class C4GraphicsOverlay { diff --git a/src/game/object/C4InfoCore.cpp b/src/game/object/C4InfoCore.cpp index af294579b..a32d7d68a 100644 --- a/src/game/object/C4InfoCore.cpp +++ b/src/game/object/C4InfoCore.cpp @@ -201,7 +201,6 @@ void C4ObjectInfoCore::Default(C4ID n_id, sNextRankName.Clear(); NextRankExp=0; DeathMessage[0]='\0'; - *PortraitFile=0; Age=0; ExtraData.Reset(); @@ -312,7 +311,6 @@ void C4ObjectInfoCore::CompileFunc(StdCompiler *pComp) pComp->Value(mkNamingAdapt(id, "id", C4ID::None)); pComp->Value(mkNamingAdapt(toC4CStr(Name), "Name", "Clonk")); pComp->Value(mkNamingAdapt(toC4CStr(DeathMessage), "DeathMessage", "")); - pComp->Value(mkNamingAdapt(toC4CStr(PortraitFile), "PortraitFile", "")); pComp->Value(mkNamingAdapt(Rank, "Rank", 0)); pComp->Value(mkNamingAdapt(sRankName, "RankName", "Clonk")); pComp->Value(mkNamingAdapt(sNextRankName, "NextRankName", "")); diff --git a/src/game/object/C4InfoCore.h b/src/game/object/C4InfoCore.h index dc7cdeb18..b107f92e7 100644 --- a/src/game/object/C4InfoCore.h +++ b/src/game/object/C4InfoCore.h @@ -49,7 +49,6 @@ public: int32_t Birthday,TotalPlayingTime; int32_t Age; char DeathMessage[C4MaxDeathMsg+1]; - char PortraitFile[C4MaxName+2+4+1]; // used portrait C4ValueMapData ExtraData; bool NoSave; // set for _XYZ-CrewMembers public: diff --git a/src/game/object/C4ObjectInfo.cpp b/src/game/object/C4ObjectInfo.cpp index 8f694030a..e5e13af3c 100644 --- a/src/game/object/C4ObjectInfo.cpp +++ b/src/game/object/C4ObjectInfo.cpp @@ -62,12 +62,9 @@ void C4ObjectInfo::Default() Filename[0]=0; Next=NULL; pDef = NULL; - Portrait.Default(); - pNewPortrait = NULL; - pCustomPortrait = NULL; } -bool C4ObjectInfo::Load(C4Group &hMother, const char *szEntryname, bool fLoadPortrait) +bool C4ObjectInfo::Load(C4Group &hMother, const char *szEntryname) { // New version @@ -76,7 +73,7 @@ bool C4ObjectInfo::Load(C4Group &hMother, const char *szEntryname, bool fLoadPor C4Group hChild; if (hChild.OpenAsChild(&hMother,szEntryname)) { - if (!C4ObjectInfo::Load(hChild, fLoadPortrait)) + if (!C4ObjectInfo::Load(hChild)) { hChild.Close(); return false; } // resolve definition, if possible // only works in game, but is not needed in frontend or startup editing anyway @@ -89,79 +86,12 @@ bool C4ObjectInfo::Load(C4Group &hMother, const char *szEntryname, bool fLoadPor return false; } -bool C4ObjectInfo::Load(C4Group &hGroup, bool fLoadPortrait) +bool C4ObjectInfo::Load(C4Group &hGroup) { // Store group file name SCopy(GetFilename(hGroup.GetName()),Filename,_MAX_FNAME); // Load core if (!C4ObjectInfoCore::Load(hGroup)) return false; - // Load portrait - always try linking, even if fLoadPortrait is false (doesn't cost mem anyway) - // evaluate portrait string in info - bool fPortraitFileChecked=false; - if (*PortraitFile) - { - // custom portrait? - if (SEqual(PortraitFile, C4Portrait_Custom)) - { - // try to load it - if (pCustomPortrait) delete pCustomPortrait; - pCustomPortrait = new C4Portrait(); - if (pCustomPortrait->Load(hGroup, C4CFN_Portrait, C4CFN_PortraitOverlay)) - { - // link portrait to custom portrait - Portrait.Link(pCustomPortrait->GetGfx()); - } - else - { - // load failure: reset portrait info - *PortraitFile=0; - delete pCustomPortrait; pCustomPortrait=NULL; - // do not try to load a custom portrait again - fPortraitFileChecked = true; - } - } - else if (SEqual(PortraitFile, C4Portrait_None)) - { - // no portrait - // nothing to be done here :D - } - else - { - // get portrait by info string - const char *szPortraitName; C4ID idPortraitID; - szPortraitName = C4Portrait::EvaluatePortraitString(PortraitFile, idPortraitID, id, NULL); - // get portrait def - C4Def *pPortraitDef = ::Definitions.ID2Def(idPortraitID); - // def found? - if (pPortraitDef && pPortraitDef->Portraits) - { - // find portrait by name - C4DefGraphics *pDefPortraitGfx = pPortraitDef->Portraits->Get(szPortraitName); - C4PortraitGraphics *pPortraitGfx = pDefPortraitGfx ? pDefPortraitGfx->IsPortrait() : NULL; - // link if found - if (pPortraitGfx) - Portrait.Link(pPortraitGfx); - else - { - // portrait not found? Either the specification has been deleted (bad), or this is some scenario with custom portraits - // assume the latter, and temp-assign a random portrait for the duration of this round - if (Config.Graphics.AddNewCrewPortraits) SetRandomPortrait(C4ID::None, false, false); - } - } - } - } - // portrait not defined or invalid (custom w/o file or invalid file) - // assign a new one (local players only) - if (!*PortraitFile && fLoadPortrait) - { - // try to load a custom portrait - if (!fPortraitFileChecked && Portrait.Load(hGroup, C4CFN_Portrait, C4CFN_PortraitOverlay)) - // assign it as custom portrait - SCopy(C4Portrait_Custom, PortraitFile); - else if (Config.Graphics.AddNewCrewPortraits) - // assign a new random crew portrait - SetRandomPortrait(C4ID::None, true, false); - } return true; } @@ -208,53 +138,6 @@ bool C4ObjectInfo::Save(C4Group &hGroup, bool fStoreTiny, C4DefList *pDefs) C4Group hTemp; if (!hTemp.OpenAsChild(&hGroup, Filename, false, true)) return false; - // New portrait present, or old portrait not saved yet (old player begin updated)? - if (!fStoreTiny && Config.Graphics.SaveDefaultPortraits) if (pNewPortrait || (Config.Graphics.AddNewCrewPortraits && Portrait.GetGfx() && !hTemp.FindEntry(C4CFN_Portrait))) - { - C4Portrait *pSavePortrait = pNewPortrait ? pNewPortrait : &Portrait; - C4DefGraphics *pPortraitGfx; - // save new - if (pSavePortrait->GetGfx()) pSavePortrait->SavePNG(hTemp, C4CFN_Portrait, C4CFN_PortraitOverlay); - // save spec - if (pNewPortrait) - { - // owned portrait? - if (pNewPortrait->IsOwnedGfx()) - // use saved portrait - SCopy(C4Portrait_Custom, PortraitFile); - else - { - if ((pPortraitGfx = pNewPortrait->GetGfx()) && pPortraitGfx->pDef) - { - // same ID: save portrait name only - if (pPortraitGfx->pDef->id == id) - SCopy(pPortraitGfx->GetName(), PortraitFile); - else - { - // different ID (crosslinked portrait) - SCopy(pPortraitGfx->pDef->id.ToString(), PortraitFile); - SAppend("::", PortraitFile); - SAppend(pPortraitGfx->GetName(), PortraitFile); - } - } - else - // No portrait - SCopy(C4Portrait_None, PortraitFile); - } - } - // portrait synced - } - - // delete default portraits if they are not desired - if (!fStoreTiny && !Config.Graphics.SaveDefaultPortraits && hTemp.FindEntry(C4CFN_Portrait)) - { - if (!SEqual(PortraitFile, C4Portrait_Custom)) - { - hTemp.Delete(C4CFN_Portrait); - hTemp.Delete(C4CFN_PortraitOverlay); - } - } - // custom rank image present? if (pDefs && !fStoreTiny) { @@ -294,9 +177,6 @@ void C4ObjectInfo::Evaluate() void C4ObjectInfo::Clear() { - Portrait.Clear(); - if (pNewPortrait) { delete pNewPortrait; pNewPortrait=NULL; } - if (pCustomPortrait) { delete pCustomPortrait; pCustomPortrait=NULL; } pDef=NULL; } @@ -329,79 +209,3 @@ void C4ObjectInfo::SetBirthday() { Birthday=time(NULL); } - - - -bool C4ObjectInfo::SetRandomPortrait(C4ID idSourceDef, bool fAssignPermanently, bool fCopyFile) -{ - // No source def specified: use own def - if (!idSourceDef) - idSourceDef = id; - // Get source def - C4Def* pPortraitDef = ::Definitions.ID2Def(idSourceDef); - // Portrait source def not loaded: do not assign a portrait now, so the clonk can get - // the correct portrait later when the source def is available (assuming this clonk is - // not going to be used in this round anyway) - if (!pPortraitDef) - return false; - // Portrait def is loaded but does not have any portraits - if (!pPortraitDef->PortraitCount) - { - // Then use Clonk portraits (2do: base on include chains in latter case)? - pPortraitDef = ::Definitions.ID2Def(C4ID::Clonk); - // Assign permanently, assuming it is some kind of normal clonk here... - fAssignPermanently=true; - fCopyFile=false; - // No Clonk loaded or no portraits present? forget it, then - if (!pPortraitDef || !pPortraitDef->PortraitCount) return false; - } - // shouldn't happen if PortraitCount is != 0 - if (!pPortraitDef->Portraits) return false; - // set a random portrait (note: not net synced!) - return SetPortrait(pPortraitDef->Portraits->GetByIndex(SafeRandom(pPortraitDef->PortraitCount)), fAssignPermanently, fCopyFile); -} - -bool C4ObjectInfo::SetPortrait(const char *szPortraitName, C4Def *pSourceDef, bool fAssignPermanently, bool fCopyFile) -{ - // safety - if (!szPortraitName || !pSourceDef || !pSourceDef->Portraits) return false; - // Special case: custom portrait - if (SEqual(szPortraitName, C4Portrait_Custom)) - // does the info really have a custom portrait? - if (pCustomPortrait) - // set the custom portrait - we're just re-linking the custom portrait (fAssignPermanently or fCopyFile have nothing to do here) - return Portrait.Link(pCustomPortrait->GetGfx()); - // set desired portrait - return SetPortrait(pSourceDef->Portraits->Get(szPortraitName), fAssignPermanently, fCopyFile); -} - -bool C4ObjectInfo::SetPortrait(C4PortraitGraphics *pNewPortraitGfx, bool fAssignPermanently, bool fCopyFile) -{ - // safety - if (!pNewPortraitGfx) return false; - // assign portrait - if (fCopyFile) Portrait.CopyFrom(*pNewPortraitGfx); else Portrait.Link(pNewPortraitGfx); - // store permanently? - if (fAssignPermanently) - { - if (!pNewPortrait) pNewPortrait = new C4Portrait(); - pNewPortrait->CopyFrom(Portrait); - } - // done, success - return true; -} - -bool C4ObjectInfo::ClearPortrait(bool fPermanently) -{ - // no portrait - Portrait.Clear(); - // clear new portrait; do not delete class (because empty class means no-portrait-as-new-setting) - if (fPermanently) - { - if (pNewPortrait) pNewPortrait->Clear(); - else pNewPortrait = new C4Portrait(); - } - // done, success - return true; -} - diff --git a/src/game/object/C4ObjectInfo.h b/src/game/object/C4ObjectInfo.h index 282adee28..f490b31e7 100644 --- a/src/game/object/C4ObjectInfo.h +++ b/src/game/object/C4ObjectInfo.h @@ -40,9 +40,6 @@ public: bool HasDied; int32_t ControlCount; class C4Def *pDef; // definition to ID - only eresolved if defs were loaded at object info loading time - C4Portrait Portrait; // portrait link (usually to def graphics) - C4Portrait *pNewPortrait; // new permanent portrait link (usually to def graphics) - C4Portrait *pCustomPortrait; // if assigned, the Clonk has a custom portrait to be set via SetPortrait("custom") char Filename[_MAX_PATH+1]; C4ObjectInfo *Next; public: @@ -53,12 +50,8 @@ public: void Recruit(); void SetBirthday(); bool Save(C4Group &hGroup, bool fStoreTiny, C4DefList *pDefs); - bool Load(C4Group &hGroup, bool fLoadPortrait); - bool Load(C4Group &hMother, const char *szEntryname, bool fLoadPortrait); - bool SetRandomPortrait(C4ID idSourceDef, bool fAssignPermanently, bool fCopyFile); - bool SetPortrait(const char *szPortraitName, C4Def *pSourceDef, bool fAssignPermanently, bool fCopyFile); - bool SetPortrait(C4PortraitGraphics *pNewPortraitGfx, bool fAssignPermanently, bool fCopyFile); - bool ClearPortrait(bool fPermanently); + bool Load(C4Group &hGroup); + bool Load(C4Group &hMother, const char *szEntryname); }; #endif diff --git a/src/game/object/C4ObjectInfoList.cpp b/src/game/object/C4ObjectInfoList.cpp index c958f5cf4..f1d8387ac 100644 --- a/src/game/object/C4ObjectInfoList.cpp +++ b/src/game/object/C4ObjectInfoList.cpp @@ -59,7 +59,7 @@ void C4ObjectInfoList::Clear() } } -int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits) +int32_t C4ObjectInfoList::Load(C4Group &hGroup) { C4ObjectInfo *ninf; int32_t infn=0; @@ -70,7 +70,7 @@ int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits) while (hGroup.FindNextEntry(C4CFN_ObjectInfoFiles,entryname)) if ((ninf=new C4ObjectInfo)) { - if (ninf->Load(hGroup,entryname,fLoadPortraits)) { Add(ninf); infn++; } + if (ninf->Load(hGroup,entryname)) { Add(ninf); infn++; } else delete ninf; } @@ -87,7 +87,7 @@ int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits) { C4Group ItemGroup; if (ItemGroup.OpenAsChild(&hGroup, entryname)) - Load(ItemGroup, fLoadPortraits); + Load(ItemGroup); } return infn; @@ -173,9 +173,6 @@ C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs) pInfo->Birthday=time(NULL); // Make valid names MakeValidName(pInfo->Name); - // Add new portrait (permanently w/o copying file) - if (Config.Graphics.AddNewCrewPortraits) - pInfo->SetRandomPortrait(C4ID::None, true, false); // Add Add(pInfo); ++iNumCreated; diff --git a/src/game/object/C4ObjectInfoList.h b/src/game/object/C4ObjectInfoList.h index ca700032c..5be9f1e6a 100644 --- a/src/game/object/C4ObjectInfoList.h +++ b/src/game/object/C4ObjectInfoList.h @@ -42,7 +42,7 @@ public: void Clear(); void Evaluate(); void DetachFromObjects(); - int32_t Load(C4Group &hGroup, bool fLoadPortraits); + int32_t Load(C4Group &hGroup); bool Add(C4ObjectInfo *pInfo); bool Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny, C4DefList *pDefs); C4ObjectInfo* New(C4ID n_id, C4DefList *pDefs); diff --git a/src/game/object/C4ObjectScript.cpp b/src/game/object/C4ObjectScript.cpp index 0f1753313..5b99d8ecb 100644 --- a/src/game/object/C4ObjectScript.cpp +++ b/src/game/object/C4ObjectScript.cpp @@ -1701,77 +1701,6 @@ static bool FnSetObjDrawTransform2(C4AulObjectContext *ctx, long iA, long iB, lo return true; } -static bool FnSetPortrait(C4AulObjectContext *ctx, C4String *pstrPortrait, C4ID idSourceDef, bool fPermanent, bool fCopyGfx) -{ - // safety - const char *szPortrait; - if (!pstrPortrait || !*(szPortrait=FnStringPar(pstrPortrait))) return false; - C4Object *pTarget = ctx->Obj; - if (!pTarget->Status || !pTarget->Info) return false; - // special case: clear portrait - if (SEqual(szPortrait, C4Portrait_None)) return pTarget->Info->ClearPortrait(!!fPermanent); - // get source def for portrait - C4Def *pSourceDef; - if (idSourceDef) pSourceDef = ::Definitions.ID2Def(idSourceDef); else pSourceDef=pTarget->Def; - if (!pSourceDef) return false; - // special case: random portrait - if (SEqual(szPortrait, C4Portrait_Random)) return pTarget->Info->SetRandomPortrait(pSourceDef->id, !!fPermanent, !!fCopyGfx); - // try to set portrait - return pTarget->Info->SetPortrait(szPortrait, pSourceDef, !!fPermanent, !!fCopyGfx); -} - -static C4Value FnGetPortrait(C4AulContext *ctx, C4Value *pvfGetID, C4Value *pvfGetPermanent) -{ - // get parameters - C4Object *pObj = ctx->Obj; bool fGetID = pvfGetID->getBool(); bool fGetPermanent = pvfGetPermanent->getBool(); - // check valid object with info section - if (!pObj) - throw new NeedObjectContext("GetPortrait"); - if (!pObj->Status || !pObj->Info) return C4Value(); - // get portrait to examine - C4Portrait *pPortrait; - if (fGetPermanent) - { - // permanent: new portrait assigned? - if (!(pPortrait=pObj->Info->pNewPortrait)) - { - // custom portrait? - if (pObj->Info->pCustomPortrait) - { - if (fGetID) return C4Value(); - else return C4VString(C4Portrait_Custom); - } - // portrait string from info? - const char *szPortrait = pObj->Info->PortraitFile; - // no portrait string: portrait undefined ("none" would mean no portrait) - if (!*szPortrait) return C4Value(); - // evaluate portrait string - C4ID idPortraitSource; - szPortrait = C4Portrait::EvaluatePortraitString(szPortrait, idPortraitSource, pObj->Info->id, NULL); - // return desired value - if (fGetID) - return idPortraitSource ? C4VPropList(C4Id2Def(idPortraitSource)) : C4Value(); - else - return szPortrait ? C4VString(szPortrait) : C4Value(); - } - } - else - // get current portrait - pPortrait = &(pObj->Info->Portrait); - // get portrait graphics - C4DefGraphics *pPortraitGfx = pPortrait->GetGfx(); - // no portrait? - if (!pPortraitGfx) return C4Value(); - // get def or name - if (fGetID) - return (pPortraitGfx->pDef ? C4VPropList(pPortraitGfx->pDef) : C4Value()); - else - { - const char *szPortraitName = pPortraitGfx->GetName(); - return C4VString(szPortraitName ? szPortraitName : C4Portrait_Custom); - } -} - static bool FnSetObjectStatus(C4AulObjectContext *ctx, long iNewStatus, bool fClearPointers) { // local call / safety @@ -2408,7 +2337,6 @@ C4ScriptFnDef C4ScriptObjectFnMap[]= { "AddCommand", 1 ,C4V_Bool ,{ C4V_String ,C4V_C4Object,C4V_Any ,C4V_Int ,C4V_C4Object,C4V_Int ,C4V_Any ,C4V_Int ,C4V_Int ,C4V_Any} ,0 , FnAddCommand }, { "AppendCommand", 1 ,C4V_Bool ,{ C4V_String ,C4V_C4Object,C4V_Any ,C4V_Int ,C4V_C4Object,C4V_Int ,C4V_Any ,C4V_Int ,C4V_Int ,C4V_Any} ,0 , FnAppendCommand }, { "GetCommand", 1 ,C4V_Any ,{ C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnGetCommand }, - { "GetPortrait", 1 ,C4V_Any ,{ C4V_C4Object,C4V_Bool ,C4V_Bool ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetPortrait, 0 }, { "SetCrewExtraData", 1 ,C4V_Any ,{ C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnSetCrewExtraData, 0 }, { "GetCrewExtraData", 1 ,C4V_Any ,{ C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetCrewExtraData, 0 }, @@ -2538,7 +2466,6 @@ void InitObjectFunctionMap(C4AulScriptEngine *pEngine) AddFunc(pEngine, "SetShape", FnSetShape); AddFunc(pEngine, "SetObjDrawTransform", FnSetObjDrawTransform); AddFunc(pEngine, "SetObjDrawTransform2", FnSetObjDrawTransform2, false); - AddFunc(pEngine, "SetPortrait", FnSetPortrait); AddFunc(pEngine, "SetObjectStatus", FnSetObjectStatus, false); AddFunc(pEngine, "GetObjectStatus", FnGetObjectStatus, false); AddFunc(pEngine, "AdjustWalkRotation", FnAdjustWalkRotation, false); diff --git a/src/game/player/C4Player.cpp b/src/game/player/C4Player.cpp index 764a23a00..954b62eff 100644 --- a/src/game/player/C4Player.cpp +++ b/src/game/player/C4Player.cpp @@ -248,11 +248,7 @@ bool C4Player::Init(int32_t iNumber, int32_t iAtClient, const char *szAtClientNa if (szFilename) { // Load core & crew info list - // do not load portraits for remote players - // this will prevent portraits from being shown for "remotely controlled"-Clonks of other players - bool fLoadPortraits = (AtClient==C4ClientIDUnknown) || SEqualNoCase(AtClientName, Game.Clients.getLocalName()); - // fLoadPortraits = true - if (!Load(szFilename, !fScenarioInit, fLoadPortraits)) return false; + if (!Load(szFilename, !fScenarioInit)) return false; } else { @@ -971,7 +967,7 @@ void C4Player::Default() ViewLock = false; } -bool C4Player::Load(const char *szFilename, bool fSavegame, bool fLoadPortraits) +bool C4Player::Load(const char *szFilename, bool fSavegame) { C4Group hGroup; // Open group @@ -984,7 +980,7 @@ bool C4Player::Load(const char *szFilename, bool fSavegame, bool fLoadPortraits) // Load BigIcon if (hGroup.FindEntry(C4CFN_BigIcon)) BigIcon.Load(hGroup, C4CFN_BigIcon); // Load crew info list - CrewInfoList.Load(hGroup, fLoadPortraits); + CrewInfoList.Load(hGroup); // Close group hGroup.Close(); // Success @@ -1000,8 +996,6 @@ bool C4Player::Strip(const char *szFilename, bool fAggressive) // Which type of stripping? if (!fAggressive) { - // remove portrais - Grp.Delete(C4CFN_Portraits, true); // remove bigicon, if the file size is too large size_t iBigIconSize=0; if (Grp.FindEntry(C4CFN_BigIcon, NULL, &iBigIconSize)) @@ -1014,7 +1008,7 @@ bool C4Player::Strip(const char *szFilename, bool fAggressive) // Load info core and crew info list C4PlayerInfoCore PlrInfoCore; C4ObjectInfoList CrewInfoList; - if (!PlrInfoCore.Load(Grp) || !CrewInfoList.Load(Grp, false)) + if (!PlrInfoCore.Load(Grp) || !CrewInfoList.Load(Grp)) return false; // Strip crew info list (remove object infos that are invalid for this scenario) CrewInfoList.Strip(::Definitions); diff --git a/src/game/player/C4Player.h b/src/game/player/C4Player.h index 852c9641c..68a17d50a 100644 --- a/src/game/player/C4Player.h +++ b/src/game/player/C4Player.h @@ -185,7 +185,7 @@ public: bool Save(); bool Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny); bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true); - bool Load(const char *szFilename, bool fSavegame, bool fLoadPortraits); + bool Load(const char *szFilename, bool fSavegame); static bool Strip(const char *szFilename, bool fAggressive); bool Message(const char *szMsg); bool ObjectInCrew(C4Object *tobj); diff --git a/src/game/script/C4GameScript.cpp b/src/game/script/C4GameScript.cpp index d49d50b2e..9d754b188 100644 --- a/src/game/script/C4GameScript.cpp +++ b/src/game/script/C4GameScript.cpp @@ -2242,9 +2242,11 @@ static bool FnPlayVideo(C4AulContext *ctx, C4String *pFilename) return Game.VideoPlayer.PlayVideo(pFilename->GetCStr()); } -static bool FnCustomMessage(C4AulContext *ctx, C4String *pMsg, C4Object *pObj, Nillable iOwner, long iOffX, long iOffY, long dwClr, C4ID idDeco, C4String *sPortrait, long dwFlags, long iHSize) +static bool FnCustomMessage(C4AulContext *ctx, C4String *pMsg, C4Object *pObj, Nillable iOwner, long iOffX, long iOffY, long dwClr, C4ID idDeco, C4PropList *pSrc, long dwFlags, long iHSize) { // safeties + if (pSrc) + if(!pSrc->GetDef() && !pSrc->GetObject()) return false; if (!pMsg) return false; if (pObj && !pObj->Status) return false; const char *szMsg = pMsg->GetCStr(); @@ -2281,7 +2283,7 @@ static bool FnCustomMessage(C4AulContext *ctx, C4String *pMsg, C4Object *pObj, N sMsg.Ref(szMsg); if (dwFlags & C4GM_DropSpeech) sMsg.SplitAtChar('$', NULL); // create it! - return ::Messages.New(iType,sMsg,pObj,iOwner,iOffX,iOffY,(uint32_t)dwClr, idDeco, sPortrait ? sPortrait->GetCStr() : NULL, dwFlags, iHSize); + return ::Messages.New(iType,sMsg,pObj,iOwner,iOffX,iOffY,(uint32_t)dwClr, idDeco, pSrc, dwFlags, iHSize); } /*static long FnSetSaturation(C4AulContext *ctx, long s) diff --git a/src/gui/C4FileSelDlg.cpp b/src/gui/C4FileSelDlg.cpp index af8dac17a..2cf7d155a 100644 --- a/src/gui/C4FileSelDlg.cpp +++ b/src/gui/C4FileSelDlg.cpp @@ -563,9 +563,8 @@ void C4PortraitSelDlg::LoaderThread::Execute() // --------------------------------------------------- // C4PortraitSelDlg -C4PortraitSelDlg::C4PortraitSelDlg(C4FileSel_BaseCB *pSelCallback, bool fSetPicture, bool fSetBigIcon) +C4PortraitSelDlg::C4PortraitSelDlg(C4FileSel_BaseCB *pSelCallback) : C4FileSelDlg(Config.General.ExePath, FormatString(LoadResStr("IDS_MSG_SELECT"), LoadResStr("IDS_TYPE_PORTRAIT")).getData(), pSelCallback, false) - , pCheckSetPicture(NULL), pCheckSetBigIcon(NULL), fDefSetPicture(fSetPicture), fDefSetBigIcon(fSetBigIcon) { char path[_MAX_PATH+1]; // add common picture locations @@ -596,17 +595,6 @@ C4PortraitSelDlg::C4PortraitSelDlg(C4FileSel_BaseCB *pSelCallback, bool fSetPict SetCurrentLocation(Config.Startup.LastPortraitFolderIdx, false); } -void C4PortraitSelDlg::AddExtraOptions(const C4Rect &rcOptionsRect) -{ - C4GUI::ComponentAligner caOptions(rcOptionsRect, C4GUI_DefDlgIndent,C4GUI_DefDlgSmallIndent,false); - CStdFont *pUseFont = &(::GraphicsResource.TextFont); - AddElement(new C4GUI::Label(LoadResStr("IDS_CTL_IMPORTIMAGEAS"), caOptions.GetGridCell(0,3, 0,1, -1,pUseFont->GetLineHeight(), true), ALeft)); - AddElement(pCheckSetPicture = new C4GUI::CheckBox(caOptions.GetGridCell(1,3, 0,1, -1,pUseFont->GetLineHeight(), true), LoadResStr("IDS_TEXT_PLAYERIMAGE"), fDefSetPicture)); - pCheckSetPicture->SetToolTip(LoadResStr("IDS_DESC_CHANGESTHEIMAGEYOUSEEINTH")); - AddElement(pCheckSetBigIcon = new C4GUI::CheckBox(caOptions.GetGridCell(2,3, 0,1, -1,pUseFont->GetLineHeight(), true), LoadResStr("IDS_TEXT_LOBBYICON"), fDefSetPicture)); - pCheckSetBigIcon->SetToolTip(LoadResStr("IDS_DESC_CHANGESTHEIMAGEYOUSEEINTH2")); -} - void C4PortraitSelDlg::OnClosed(bool fOK) { // remember location @@ -647,28 +635,14 @@ void C4PortraitSelDlg::OnIdle() #endif } -bool C4PortraitSelDlg::SelectPortrait(C4GUI::Screen *pOnScreen, StdStrBuf *pSelection, bool *pfSetPicture, bool *pfSetBigIcon) +bool C4PortraitSelDlg::SelectPortrait(C4GUI::Screen *pOnScreen, StdStrBuf *pSelection) { - // copy some default potraits to UserPath (but only try this once, no real error handling) - if (!Config.General.UserPortraitsWritten) - { - Log("Copying default portraits to user path..."); - C4Group hGroup; - if (Reloc.Open(hGroup, C4CFN_Graphics)) - { - hGroup.Extract("Portrait1.png", Config.AtUserDataPath("Clonk.png")); - hGroup.Close(); - } - Config.General.UserPortraitsWritten = true; - } // let the user select a portrait by showing a modal selection dialog - C4PortraitSelDlg *pDlg = new C4PortraitSelDlg(NULL, *pfSetPicture, *pfSetBigIcon); + C4PortraitSelDlg *pDlg = new C4PortraitSelDlg(NULL); bool fResult; if ((fResult = pOnScreen->ShowModalDlg(pDlg, false))) { pSelection->Take(pDlg->GetSelection(NULL, false)); - *pfSetPicture = pDlg->IsSetPicture(); - *pfSetBigIcon = pDlg->IsSetBigIcon(); } delete pDlg; return fResult; diff --git a/src/gui/C4FileSelDlg.h b/src/gui/C4FileSelDlg.h index 8f738f517..3e12df6e0 100644 --- a/src/gui/C4FileSelDlg.h +++ b/src/gui/C4FileSelDlg.h @@ -238,9 +238,6 @@ private: }; private: - C4GUI::CheckBox *pCheckSetPicture, *pCheckSetBigIcon; - bool fDefSetPicture, fDefSetBigIcon; - LoaderThread ImageLoader; protected: @@ -248,8 +245,6 @@ protected: virtual const char *GetFileMask() const { return C4CFN_ImageFiles; } virtual bool HasNoneItem() const { return true; } // if true, a special item can be selected virtual bool HasPreviewArea() const { return false; } // no preview area. Preview images directly - virtual bool HasExtraOptions() const { return true; } - virtual void AddExtraOptions(const C4Rect &rcOptionsRect); virtual int32_t GetFileSelColWidth() const { return ImagePreviewSize; } // width of each file selection element virtual C4FileSelDlg::ListItem *CreateListItem(const char *szFilename); @@ -259,12 +254,9 @@ protected: virtual void OnIdle(); public: - C4PortraitSelDlg(C4FileSel_BaseCB *pSelCallback, bool fSetPicture, bool fSetBigIcon); + C4PortraitSelDlg(C4FileSel_BaseCB *pSelCallback); - bool IsSetPicture() const { return pCheckSetPicture ? pCheckSetPicture->GetChecked() : fDefSetPicture; } - bool IsSetBigIcon() const { return pCheckSetBigIcon ? pCheckSetBigIcon->GetChecked() : fDefSetBigIcon; } - - static bool SelectPortrait(C4GUI::Screen *pOnScreen, StdStrBuf *pSelection, bool *pfSetPicture, bool *pfSetBigIcon); + static bool SelectPortrait(C4GUI::Screen *pOnScreen, StdStrBuf *pSelection); }; #endif // INC_C4FileSelDlg diff --git a/src/gui/C4GameMessage.cpp b/src/gui/C4GameMessage.cpp index 865e424ef..fe4f0c594 100644 --- a/src/gui/C4GameMessage.cpp +++ b/src/gui/C4GameMessage.cpp @@ -42,7 +42,7 @@ C4GameMessage::~C4GameMessage() delete pFrameDeco; } -void C4GameMessage::Init(int32_t iType, const StdStrBuf & sText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID, const char *szPortraitDef, uint32_t dwFlags, int width) +void C4GameMessage::Init(int32_t iType, const StdStrBuf & sText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID, C4PropList *pSrc, uint32_t dwFlags, int width) { // safety! if (pTarget && !pTarget->Status) pTarget = NULL; @@ -56,7 +56,10 @@ void C4GameMessage::Init(int32_t iType, const StdStrBuf & sText, C4Object *pTarg Delay=Max(C4GM_MinDelay, Text.getLength() * TextMsgDelayFactor); DecoID=idDecoID; this->dwFlags=dwFlags; - if (szPortraitDef && *szPortraitDef) PortraitDef.Copy(szPortraitDef); else PortraitDef.Clear(); + PictureDef=NULL; + if (pSrc) + if (pSrc->GetDef() || pSrc->GetObject()) + PictureDef = pSrc; // Permanent message if ('@' == Text[0]) { @@ -103,8 +106,8 @@ bool C4GameMessage::Execute() } int32_t DrawMessageOffset = -35; // For finding the optimum place to draw startup info & player messages... -int32_t PortraitWidth = 64; -int32_t PortraitIndent = 10; +int32_t PictureWidth = 64; +int32_t PictureIndent = 10; void C4GameMessage::Draw(C4TargetFacet &cgo, int32_t iPlayer) { @@ -120,7 +123,7 @@ void C4GameMessage::Draw(C4TargetFacet &cgo, int32_t iPlayer) if (~dwFlags & C4GM_NoBreak) { // Word wrap to cgo width - if (PortraitDef) + if (PictureDef) { if (!wdt) wdt = BoundBy(cgo.Wdt/2, 50, Min(500, cgo.Wdt-10)); int32_t iUnbrokenTextWidth = ::GraphicsResource.FontRegular.GetTextWidth(Text.getData(), true); @@ -144,7 +147,7 @@ void C4GameMessage::Draw(C4TargetFacet &cgo, int32_t iPlayer) int32_t iDrawX = cgo.X+x; int32_t iDrawY = cgo.Y+y; // draw message - if (PortraitDef) + if (PictureDef) { // message with portrait // bottom-placed portrait message: Y-Positioning 0 refers to bottom of viewport @@ -155,7 +158,7 @@ void C4GameMessage::Draw(C4TargetFacet &cgo, int32_t iPlayer) // draw decoration if (pFrameDeco) { - C4Rect rect(iDrawX-cgo.TargetX, iDrawY-cgo.TargetY, iTextWdt + PortraitWidth + PortraitIndent + pFrameDeco->iBorderLeft + pFrameDeco->iBorderRight, Max(iTextHgt, PortraitWidth) + pFrameDeco->iBorderTop + pFrameDeco->iBorderBottom); + C4Rect rect(iDrawX-cgo.TargetX, iDrawY-cgo.TargetY, iTextWdt + PictureWidth + PictureIndent + pFrameDeco->iBorderLeft + pFrameDeco->iBorderRight, Max(iTextHgt, PictureWidth) + pFrameDeco->iBorderTop + pFrameDeco->iBorderBottom); if (dwFlags & C4GM_Bottom) { rect.y -= rect.Hgt; iDrawY -= rect.Hgt; } else if (dwFlags & C4GM_VCenter) { rect.y -= rect.Hgt/2; iDrawY -= rect.Hgt/2; } if (dwFlags & C4GM_Right) { rect.x -= rect.Wdt; iDrawX -= rect.Wdt; } @@ -166,17 +169,21 @@ void C4GameMessage::Draw(C4TargetFacet &cgo, int32_t iPlayer) } else iDrawY -= iTextHgt; - // draw portrait - C4FacetSurface fctPortrait; - Game.DrawTextSpecImage(fctPortrait, PortraitDef.getData()); - C4Facet facet(cgo.Surface, iDrawX, iDrawY, PortraitWidth, PortraitWidth); - fctPortrait.Draw(facet); + // draw picture + // can only be def or object because has been checked on assignment + + C4Facet facet(cgo.Surface, iDrawX, iDrawY, PictureWidth, PictureWidth); + if(PictureDef->GetObject()) + PictureDef->GetObject()->DrawPicture(facet); + else if (PictureDef->GetDef()) + PictureDef->GetDef()->Draw(facet); + // draw message - lpDDraw->TextOut(sText.getData(),::GraphicsResource.FontRegular,1.0,cgo.Surface,iDrawX+PortraitWidth+PortraitIndent,iDrawY,ColorDw,ALeft); + lpDDraw->TextOut(sText.getData(),::GraphicsResource.FontRegular,1.0,cgo.Surface,iDrawX+PictureWidth+PictureIndent,iDrawY,ColorDw,ALeft); } else { - // message without portrait + // message without picture iDrawX += cgo.Wdt/2; iDrawY += 2 * cgo.Hgt / 3 + 50; if (!(dwFlags & C4GM_Bottom)) iDrawY += DrawMessageOffset; @@ -298,12 +305,12 @@ void C4GameMessageList::Execute() } } -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) +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, C4PropList *pSrc, uint32_t dwFlags, int32_t width) { - return New(iType, StdStrBuf(szText), pTarget, iPlayer, iX, iY, dwClr, idDecoID, szPortraitDef, dwFlags, width); + return New(iType, StdStrBuf(szText), pTarget, iPlayer, iX, iY, dwClr, idDecoID, pSrc, dwFlags, width); } -bool C4GameMessageList::New(int32_t iType, const StdStrBuf & sText, 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) +bool C4GameMessageList::New(int32_t iType, const StdStrBuf & sText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID, C4PropList *pSrc, uint32_t dwFlags, int32_t width) { if (!(dwFlags & C4GM_Multiple)) { @@ -322,7 +329,7 @@ bool C4GameMessageList::New(int32_t iType, const StdStrBuf & sText, C4Object *pT // Add new message C4GameMessage *msgNew = new C4GameMessage; - msgNew->Init(iType, sText,pTarget,iPlayer,iX,iY,dwClr, idDecoID, szPortraitDef, dwFlags, width); + msgNew->Init(iType, sText,pTarget,iPlayer,iX,iY,dwClr, idDecoID, pSrc, dwFlags, width); msgNew->Next=First; First=msgNew; diff --git a/src/gui/C4GameMessage.h b/src/gui/C4GameMessage.h index 11e6fac86..8ba2b04a9 100644 --- a/src/gui/C4GameMessage.h +++ b/src/gui/C4GameMessage.h @@ -66,11 +66,12 @@ protected: C4Object *Target; StdCopyStrBuf Text; C4GameMessage *Next; - C4ID DecoID; StdStrBuf PortraitDef; + C4ID DecoID; + C4PropList *PictureDef; // can be either a definition or object C4GUI::FrameDecoration *pFrameDeco; uint32_t dwFlags; protected: - void Init(int32_t iType, const StdStrBuf & Text, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwCol, C4ID idDecoID, const char *szPortraitDef, uint32_t dwFlags, int width); + void Init(int32_t iType, const StdStrBuf & Text, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwCol, C4ID idDecoID, C4PropList *pSrc, uint32_t dwFlags, int width); void Append(const char *szText, bool fNoDuplicates = false); bool Execute(); const char *WordWrap(int32_t iMaxWidth); @@ -95,8 +96,8 @@ public: void ClearPlayers(int32_t iPlayer, int32_t dwPositioningFlags); 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, uint32_t dwClr, C4ID idDecoID=C4ID::None, const char *szPortraitDef=NULL, uint32_t dwFlags=0u, int32_t width=0); + 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, C4PropList *pSrc=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, uint32_t dwClr, C4ID idDecoID=C4ID::None, C4PropList *pSrc=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, uint32_t bCol, bool fNoDuplicates = false); }; diff --git a/src/gui/C4MainMenu.cpp b/src/gui/C4MainMenu.cpp index 50b4b27c0..704378fc3 100644 --- a/src/gui/C4MainMenu.cpp +++ b/src/gui/C4MainMenu.cpp @@ -91,31 +91,13 @@ bool C4MainMenu::ActivateNewPlayer(int32_t iPlayer) // Load player info C4PlayerInfoCore C4P; if (!C4P.Load(hGroup)) { hGroup.Close(); continue; } - // Load custom portrait - C4FacetSurface fctPortrait; - //if (Config.Graphics.ShowPortraits) - // if (!fctPortrait.Load(hGroup, C4CFN_BigIcon, C4FCT_Full, C4FCT_Full, false, true)) - // if (!fctPortrait.Load(hGroup, C4CFN_Portrait, C4FCT_Full, C4FCT_Full, false, true)) - // fctPortrait.Load(hGroup, C4CFN_Portrait_Old, C4FCT_Full, C4FCT_Full, false, true); // Close group hGroup.Close(); // Add player item sprintf(szCommand, "JoinPlayer:%s", szFilename); StdStrBuf sItemText; sItemText.Format(LoadResStr("IDS_MENU_NEWPLAYER"), C4P.PrefName); - // No custom portrait: use default player image - if (!fctPortrait.Surface) - { - fctPortrait.Create(C4SymbolSize, C4SymbolSize); - GfxR->fctPlayerClr.DrawClr(fctPortrait, true, 0xff); - } - // Create color overlay for portrait - C4FacetSurface fctPortraitClr; - fctPortraitClr.CreateClrByOwner(fctPortrait.Surface); - // Create menu symbol from colored portrait C4FacetSurface fctSymbol; - fctSymbol.Create(C4SymbolSize, C4SymbolSize); - fctPortraitClr.DrawClr(fctSymbol, true, C4P.PrefColorDw); // Add menu item Add(sItemText.getData(), fctSymbol, szCommand); // Reset symbol facet (menu holds on to the surface) diff --git a/src/gui/C4PlayerInfoListBox.cpp b/src/gui/C4PlayerInfoListBox.cpp index 11ca27ac2..47725a057 100644 --- a/src/gui/C4PlayerInfoListBox.cpp +++ b/src/gui/C4PlayerInfoListBox.cpp @@ -289,7 +289,7 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateIcon(C4PlayerInfo *pInfo, C4Play if (!fIconSet) { // no custom icon: create default by player color - pIcon->GetMFacet().Create(C4GUI_IconWdt,C4GUI_IconHgt); + pIcon->GetMFacet().Create(64,64); // the bigicon is bigger than the normal 40x40 icon ::GraphicsResource.fctPlayerClr.DrawClr(pIcon->GetMFacet(), true, dwPlayerClr); } fIconSet = true; diff --git a/src/gui/C4StartupOptionsDlg.cpp b/src/gui/C4StartupOptionsDlg.cpp index 847bfdc34..f22a365b0 100644 --- a/src/gui/C4StartupOptionsDlg.cpp +++ b/src/gui/C4StartupOptionsDlg.cpp @@ -94,7 +94,6 @@ C4StartupOptionsDlg::ResChangeConfirmDlg::ResChangeConfirmDlg() iResChangeSwitchTime = 12; // However, some people need more time // Those can be identified by their configuration settings - if (Config.Graphics.SaveDefaultPortraits) iResChangeSwitchTime += 2; if (SEqualNoCase(Config.GetRegistrationData("Nick"), "flgr")) iResChangeSwitchTime *= 10; // get positions C4GUI::ComponentAligner caMain(GetClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent, true); diff --git a/src/gui/C4StartupPlrSelDlg.cpp b/src/gui/C4StartupPlrSelDlg.cpp index 114dac828..aa9ed3525 100644 --- a/src/gui/C4StartupPlrSelDlg.cpp +++ b/src/gui/C4StartupPlrSelDlg.cpp @@ -67,21 +67,6 @@ StdStrBuf DateString(int iTime) pLocalTime->tm_min); } -// Fixme: This should use the already open group from C4GraphicsResource -static bool GetPortrait(char **ppBytes, size_t *ipSize) -{ - // select random portrait from Graphics.ocg - C4Group GfxGroup; - int iCount; - StdStrBuf EntryName; - if (!Reloc.Open(GfxGroup, C4CFN_Graphics)) return false; - if ((iCount = GfxGroup.EntryCount("Portrait*.png")) < 1) return false; - EntryName.Format("Portrait%d.png", SafeRandom(iCount) + 1); - if (!GfxGroup.LoadEntry(EntryName.getData(), ppBytes, ipSize)) return false; - GfxGroup.Close(); - return true; -} - // ------------------------------------------------ // --- C4StartupPlrSelDlg::ListItem C4StartupPlrSelDlg::ListItem::ListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBeforeElement, bool fActivated) @@ -152,46 +137,6 @@ void C4StartupPlrSelDlg::ListItem::SetIcon(C4GUI::Icons icoNew) pIcon->SetIcon(icoNew); } -void C4StartupPlrSelDlg::ListItem::LoadPortrait(C4Group &rGrp, bool fUseDefault) -{ - bool fPortraitLinked = false; - if (!rGrp.FindEntry(C4CFN_Portrait) || !fctPortraitBase.Load(rGrp, C4CFN_Portrait)) - { - // no custom portrait: Link to some default if desired - if (!fUseDefault) return; - SetDefaultPortrait(); - fPortraitLinked = true; - } - if (!fPortraitLinked) CreateColoredPortrait(); -} - -void C4StartupPlrSelDlg::ListItem::CreateColoredPortrait() -{ - if (fctPortrait.CreateClrByOwner(fctPortraitBase.Surface)) - { - fctPortrait.Wdt=fctPortraitBase.Wdt; - fctPortrait.Hgt=fctPortraitBase.Hgt; - } -} - -void C4StartupPlrSelDlg::ListItem::SetDefaultPortrait() -{ - fctPortrait.Set(::GraphicsResource.fctPlayerClr); -} - -void C4StartupPlrSelDlg::ListItem::GrabPortrait(C4FacetSurface *pFromFacet) -{ - if (pFromFacet && pFromFacet->Surface) - { - fctPortraitBase.GrabFrom(*pFromFacet); - CreateColoredPortrait(); - } - else - { - SetDefaultPortrait(); - } -} - void C4StartupPlrSelDlg::ListItem::UpdateOwnPos() { // parent for client rect @@ -248,8 +193,6 @@ void C4StartupPlrSelDlg::PlayerListItem::Load(const StdStrBuf &rsFilename) ::GraphicsResource.fctPlayerClr.DrawClr(fctIcon, true, Core.PrefColorDw); } GrabIcon(fctIcon); - // load portrait - LoadPortrait(PlrGroup, true); // done loading if (!PlrGroup.Close()) throw LoadError(FormatString("Error loading player file from %s: Error closing group: %s", rsFilename.getData(), PlrGroup.GetError())); @@ -385,8 +328,6 @@ void C4StartupPlrSelDlg::CrewListItem::Load(C4Group &rGrp, const StdStrBuf &rsFi if (C4RankSystem::DrawRankSymbol(&fctIcon, Core.Rank, &::GraphicsResource.fctRank, ::GraphicsResource.iNumRanks, true)) GrabIcon(fctIcon); } - // load portrait; empty by default - LoadPortrait(CrewGroup, false); // backup group loaded from - assumes it stays valid! pParentGrp = &rGrp; // load success! @@ -549,10 +490,7 @@ C4StartupPlrSelDlg::C4StartupPlrSelDlg() : C4StartupDlg("W"), eMode(PSDM_Player) iBottomButtonWidth = (caButtonArea.GetWidth() - iButtonXSpacing * (iButtonCount-1)) / iButtonCount; C4Rect rcMain = caMain.GetAll(); C4Rect rcPlrList = C4Rect(rcMain.Wdt/10, rcMain.Hgt*10/36, rcMain.Wdt*25/81, rcMain.Hgt*2/3); - C4Rect rcInfoWindow = C4Rect(rcMain.Wdt*371/768, rcMain.Hgt*197/451, rcMain.Wdt*121/384, rcMain.Hgt*242/451); - int iPictureWidth = Min(rcMain.Wdt*121/384, 200); - int iPictureHeight = iPictureWidth * 3 / 4; - C4Rect rcPictureArea = C4Rect(rcMain.Wdt*613/768 - iPictureWidth, rcMain.Hgt*197/451 - iPictureHeight, iPictureWidth, iPictureHeight); + C4Rect rcInfoWindow = C4Rect(rcMain.Wdt*371/768, rcMain.Hgt*10/36, rcMain.Wdt*121/384, rcMain.Hgt*2/3); AddElement(pPlrListBox = new C4GUI::ListBox(rcPlrList)); pPlrListBox->SetToolTip(LoadResStr("IDS_DLGTIP_PLAYERFILES")); @@ -563,7 +501,6 @@ C4StartupPlrSelDlg::C4StartupPlrSelDlg() : C4StartupDlg("W"), eMode(PSDM_Player) AddElement(pSelectionInfo = new C4GUI::TextWindow(rcInfoWindow)); pSelectionInfo->SetDecoration(false, false, &C4Startup::Get()->Graphics.sfctBookScroll, true); pSelectionInfo->UpdateHeight(); - AddElement(pPortraitPict = new C4GUI::Picture(rcPictureArea, true)); // bottom line buttons - positioning done in UpdateBottomButtons by UpdatePlayerList C4Rect rcDefault(0,0,10,10); @@ -783,15 +720,11 @@ void C4StartupPlrSelDlg::UpdateSelection() if (!pSel) { pSelectionInfo->ClearText(true); - pPortraitPict->GetMFacet().Clear(); // 2do: disable buttons return; } // info text for selection pSel->SetSelectionInfo(pSelectionInfo); - // portrait for selection - pPortraitPict->SetFacet(pSel->GetPortrait()); - pPortraitPict->SetDrawColor(pSel->GetColorDw()); } void C4StartupPlrSelDlg::OnItemCheckChange(C4GUI::Element *pCheckBox) @@ -1096,8 +1029,7 @@ void C4StartupPlrSelDlg::ResortCrew() /* ---- Player property dlg ---- */ C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(C4StartupPlrSelDlg::PlayerListItem * pForPlayer, C4StartupPlrSelDlg *pParentDlg) - : Dialog(C4Startup::Get()->Graphics.fctPlrPropBG.Wdt, C4Startup::Get()->Graphics.fctPlrPropBG.Hgt, "", false), pMainDlg(pParentDlg), pForPlayer(pForPlayer), - fClearPicture(false), fClearBigIcon(false) + : Dialog(C4Startup::Get()->Graphics.fctPlrPropBG.Wdt, C4Startup::Get()->Graphics.fctPlrPropBG.Hgt, "", false), pMainDlg(pParentDlg), pForPlayer(pForPlayer), fClearBigIcon(false) { if (pForPlayer) { @@ -1243,20 +1175,6 @@ C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(C4StartupPlrSelDlg::PlayerL // Cancel C4GUI::Button *pBtnAbort = new C4GUI::CancelIconButton(C4Rect(317-GetMarginLeft(), 16-GetMarginTop(), 21, 21), C4GUI::Ico_None); AddElement(pBtnAbort); //pBtnAbort->SetToolTip(LoadResStr("IDS_DLGTIP_CANCEL")); - // New player - if (!pForPlayer) - { - // Set initial portrait and bigicon - C4Group hGroup; - StdStrBuf strPortrait; strPortrait.Format("Portrait%d.png", 1 + Random(5)); - if (Reloc.Open(hGroup, C4CFN_Graphics)) - { - hGroup.Extract(strPortrait.getData(), Config.AtTempPath("Portrait.png")); - hGroup.Close(); - SetNewPicture(Config.AtTempPath("Portrait.png"), true, true); - EraseItem(Config.AtTempPath("Portrait.png")); - } - } // when called from player selection screen: input dlg always closed in the end // otherwise, modal proc will delete if (pMainDlg) SetDelOnClose(); @@ -1395,19 +1313,16 @@ void C4StartupPlrPropertiesDlg::OnClosed(bool fOK) { if (!pForPlayer->MoveFilename(Filename.getData())) GetScreen()->ShowMessage(LoadResStr("IDS_FAIL_RENAME"), "", C4GUI::Ico_Error); - // update picture/bigicon - if (fClearPicture || fClearBigIcon || fctNewPicture.Surface || fctNewBigIcon.Surface) + // update bigicon + if (fClearBigIcon || fctNewBigIcon.Surface) { C4Group PlrGroup; if (PlrGroup.Open(Config.AtUserDataPath(Filename.getData()))) { - if (fClearPicture || fctNewPicture.Surface) PlrGroup.Delete(C4CFN_Portrait); if (fClearBigIcon || fctNewBigIcon.Surface) PlrGroup.Delete(C4CFN_BigIcon); - if (fctNewPicture.Surface) fctNewPicture.GetFace().SavePNG(PlrGroup, C4CFN_Portrait); if (fctNewBigIcon.Surface) fctNewBigIcon.GetFace().SavePNG(PlrGroup, C4CFN_BigIcon); if (PlrGroup.Close()) fSucc = true; if (fClearBigIcon || fctNewBigIcon.Surface) pForPlayer->GrabCustomIcon(fctNewBigIcon); - if (fClearPicture || fctNewPicture.Surface) pForPlayer->GrabPortrait(&fctNewPicture); } } else @@ -1427,20 +1342,6 @@ void C4StartupPlrPropertiesDlg::OnClosed(bool fOK) if (PlrGroup.FindEntry(C4CFN_PlayerInfoCore)) return; // Save info core C4P.Save(PlrGroup); - // Add portrait - if (fctNewPicture.Surface) - { - fctNewPicture.GetFace().SavePNG(PlrGroup, C4CFN_Portrait); - } - else if (!fClearPicture) - { - // default picture - char *pBytes; size_t iSize; - if (GetPortrait(&pBytes,&iSize)) - { - PlrGroup.Add(C4CFN_Portrait, pBytes, iSize, false, true); - } - } // Add BigIcon if (fctNewBigIcon.Surface) { @@ -1483,17 +1384,17 @@ bool C4StartupPlrPropertiesDlg::SetNewPicture(C4Surface &srcSfc, C4FacetSurface } } -void C4StartupPlrPropertiesDlg::SetNewPicture(const char *szFromFilename, bool fSetPicture, bool fSetBigIcon) +void C4StartupPlrPropertiesDlg::SetNewPicture(const char *szFromFilename) { if (!szFromFilename) { - // If szFromFilename==NULL, clear picture/bigicon - if (fSetPicture) { fClearPicture = true; fctNewPicture.Clear(); } - if (fSetBigIcon) { fClearBigIcon = true; fctNewBigIcon.Clear(); } + // If szFromFilename==NULL, clear bigicon + fClearBigIcon = true; + fctNewBigIcon.Clear(); } - else if (fSetPicture || fSetBigIcon) + else { - // else set new picture/bigicon by loading and scaling if necessary. + // else set new bigicon by loading and scaling if necessary. C4Surface sfcNewPic; C4Group SrcGrp; StdStrBuf sParentPath; @@ -1504,8 +1405,7 @@ void C4StartupPlrPropertiesDlg::SetNewPicture(const char *szFromFilename, bool f if (sfcNewPic.Load(SrcGrp, GetFilename(szFromFilename))) { fSucc = true; - if (fSetPicture) if (!SetNewPicture(sfcNewPic, &fctNewPicture, C4MaxPictureSize, false)) fSucc = false; - if (fSetBigIcon) if (!SetNewPicture(sfcNewPic, &fctNewBigIcon, C4MaxBigIconSize, true)) fSucc = false; + if (!SetNewPicture(sfcNewPic, &fctNewBigIcon, C4MaxBigIconSize, true)) fSucc = false; } } if (!fSucc) @@ -1515,15 +1415,15 @@ void C4StartupPlrPropertiesDlg::SetNewPicture(const char *szFromFilename, bool f } } // update icon - if (fSetBigIcon) UpdateBigIcon(); + UpdateBigIcon(); } void C4StartupPlrPropertiesDlg::OnPictureBtn(C4GUI::Control *pBtn) { - StdStrBuf sNewPic; bool fSetPicture=true, fSetBigIcon=true; - if (C4PortraitSelDlg::SelectPortrait(GetScreen(), &sNewPic, &fSetPicture, &fSetBigIcon)) + StdStrBuf sNewPic; + if (C4PortraitSelDlg::SelectPortrait(GetScreen(), &sNewPic)) { - SetNewPicture(sNewPic.getData(), fSetPicture, fSetBigIcon); + SetNewPicture(sNewPic.getData()); } } diff --git a/src/gui/C4StartupPlrSelDlg.h b/src/gui/C4StartupPlrSelDlg.h index f6a921196..1fa55f8ed 100644 --- a/src/gui/C4StartupPlrSelDlg.h +++ b/src/gui/C4StartupPlrSelDlg.h @@ -47,11 +47,11 @@ private: C4GUI::Icon *pIcon; // item icon private: class C4KeyBinding *pKeyCheck; // space activates/deactivates selected player - C4FacetSurface fctPortrait, fctPortraitBase; // big portrait StdStrBuf Filename; // file info was loaded from public: ListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBeforeElement=NULL, bool fActivated=false); + const C4FacetSurface &GetIconFacet() const { return pIcon->GetFacet(); } virtual ~ListItem(); protected: @@ -59,10 +59,6 @@ private: C4GUI::ContextMenu *ContextMenu(C4GUI::Element *pEl, int32_t iX, int32_t iY) { return ContextMenu(); } - void LoadPortrait(C4Group &rGrp, bool fUseDefault); - void CreateColoredPortrait(); - void SetDefaultPortrait(); - virtual void UpdateOwnPos(); // recalculate item positioning bool KeyCheck() { pCheck->ToggleCheck(true); return true; } virtual bool IsFocusOnClick() { return false; } // do not focus; keep focus on listbox @@ -74,7 +70,6 @@ private: public: ListItem *GetNext() const { return static_cast(BaseClass::GetNext()); } - const C4Facet &GetPortrait() const { return fctPortrait; } virtual uint32_t GetColorDw() const = 0; // get drawing color for portrait bool IsActivated() const { return pCheck->GetChecked(); } void SetActivated(bool fToVal) { pCheck->SetChecked(fToVal); } @@ -83,7 +78,6 @@ private: const StdStrBuf &GetFilename() const { return Filename; } virtual StdStrBuf GetDelWarning() = 0; void GrabIcon(C4FacetSurface &rFromFacet); - void GrabPortrait(C4FacetSurface *pFromFacet); virtual bool CheckNameHotkey(const char * c); // return whether this item can be selected by entering given char @@ -170,7 +164,6 @@ private: class C4KeyBinding *pKeyBack, *pKeyProperties, *pKeyCrew, *pKeyDelete, *pKeyRename, *pKeyNew; class C4GUI::ListBox *pPlrListBox; C4GUI::TextWindow *pSelectionInfo; - class C4GUI::Picture *pPortraitPict; Mode eMode; // in crew mode: @@ -254,8 +247,8 @@ protected: C4GUI::Label *ctrl_name_lbl; C4PlayerInfoCore C4P; // player info core copy currently being edited C4FacetSurface fctOldBigIcon; - C4FacetSurface fctNewPicture, fctNewBigIcon; // if assigned, save new picture/bigicon - bool fClearPicture, fClearBigIcon; // if true, delete current picture/bigicon + C4FacetSurface fctNewBigIcon; // if assigned, save new picture/bigicon + bool fClearBigIcon; // if true, delete current picture/bigicon virtual const char *GetID() { return "PlrPropertiesDlg"; } void DrawElement(C4TargetFacet &cgo); @@ -283,7 +276,7 @@ private: void UpdateBigIcon(); bool SetNewPicture(C4Surface &srcSfc, C4FacetSurface *trgFct, int32_t iMaxSize, bool fColorize); - void SetNewPicture(const char *szFromFilename, bool fSetPicture, bool fSetBigIcon); // set new picture/bigicon by loading and scaling if necessary. If szFromFilename==NULL, clear picture/bigicon + void SetNewPicture(const char *szFromFilename); // set new bigicon by loading and scaling if necessary. If szFromFilename==NULL, clear bigicon public: C4StartupPlrPropertiesDlg(C4StartupPlrSelDlg::PlayerListItem * pForPlayer, C4StartupPlrSelDlg *pMainDlg); diff --git a/src/network/C4Network2Res.cpp b/src/network/C4Network2Res.cpp index d6cf653a1..b6e8b754b 100644 --- a/src/network/C4Network2Res.cpp +++ b/src/network/C4Network2Res.cpp @@ -1174,8 +1174,6 @@ bool C4Network2Res::OptimizeStandalone(bool fSilent) C4Group Grp; if (!Grp.Open(szStandalone)) { if (!fSilent) Log("OptimizeStandalone: could not open player file!"); return false; } - // remove portrais - Grp.Delete(C4CFN_Portraits, true); // remove bigicon, if the file size is too large size_t iBigIconSize=0; if (Grp.FindEntry(C4CFN_BigIcon, NULL, &iBigIconSize)) diff --git a/src/res/ocp.ico b/src/res/ocp.ico index 28b6a0298..3442abe8f 100644 Binary files a/src/res/ocp.ico and b/src/res/ocp.ico differ