Merge remote-tracking branch 'ryzomcore/atys' into feature/code-to-root-atys

feature/develop-atys
kaetemi 5 years ago
commit fc197880a4

@ -191,7 +191,7 @@ public:
/// Create a native music channel, only supported by the FMod driver. /// Create a native music channel, only supported by the FMod driver.
virtual IMusicChannel *createMusicChannel() { return NULL; } virtual IMusicChannel *createMusicChannel() { return NULL; }
/** Get music info. Returns false if the song is not found or the function is not implemented. /** Get music info. Returns false if the song is not found or the function is not implemented.
* \param filepath path to file, CPath::lookup done by driver * \param filepath full path to file
* \param artist returns the song artist (empty if not available) * \param artist returns the song artist (empty if not available)
* \param title returns the title (empty if not available) * \param title returns the title (empty if not available)
*/ */

@ -3269,77 +3269,79 @@ CRGBAF CBitmap::getColor (float x, float y) const
uint32 i; uint32 i;
bool isValid = true;
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
nlassert (nX[i] >= 0); if (nX[i] < 0 || nY[i] < 0 || nX[i] >= nWidth || nY[i] >= nHeight)
nlassert (nY[i] >= 0 ); isValid = false;
nlassert (nX[i] < nWidth);
nlassert (nY[i] < nHeight);
} }
// Decimal part of (x,y) if (isValid)
x = x - (float)nX[0];
y = y - (float)nY[0];
switch (this->PixelFormat)
{ {
case RGBA: // Decimal part of (x,y)
case DXTC1: x = x - (float)nX[0];
case DXTC1Alpha: y = y - (float)nY[0];
case DXTC3:
case DXTC5:
{
CRGBAF finalVal;
CRGBA val[4];
if (this->PixelFormat == RGBA) switch (this->PixelFormat)
{
case RGBA:
case DXTC1:
case DXTC1Alpha:
case DXTC3:
case DXTC5:
{ {
for (i = 0; i < 4; ++i) CRGBAF finalVal;
CRGBA val[4];
if (this->PixelFormat == RGBA)
{ {
val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0], for (i = 0; i < 4; ++i)
rBitmap[(nX[i]+nY[i]*nWidth)*4+1], {
rBitmap[(nX[i]+nY[i]*nWidth)*4+2], val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0],
rBitmap[(nX[i]+nY[i]*nWidth)*4+3]); rBitmap[(nX[i]+nY[i]*nWidth)*4+1],
rBitmap[(nX[i]+nY[i]*nWidth)*4+2],
rBitmap[(nX[i]+nY[i]*nWidth)*4+3]);
}
} }
} else
else
{
// slower version : get from DXT
for (i = 0; i < 4; ++i)
{ {
val[i] = getPixelColor(nX[i], nY[i]); // slower version : get from DXT
for (i = 0; i < 4; ++i)
{
val[i] = getPixelColor(nX[i], nY[i]);
}
} }
}
finalVal.R = getColorInterp (x, y, val[0].R, val[1].R, val[2].R, val[3].R); finalVal.R = getColorInterp (x, y, val[0].R, val[1].R, val[2].R, val[3].R);
finalVal.G = getColorInterp (x, y, val[0].G, val[1].G, val[2].G, val[3].G); finalVal.G = getColorInterp (x, y, val[0].G, val[1].G, val[2].G, val[3].G);
finalVal.B = getColorInterp (x, y, val[0].B, val[1].B, val[2].B, val[3].B); finalVal.B = getColorInterp (x, y, val[0].B, val[1].B, val[2].B, val[3].B);
finalVal.A = getColorInterp (x, y, val[0].A, val[1].A, val[2].A, val[3].A); finalVal.A = getColorInterp (x, y, val[0].A, val[1].A, val[2].A, val[3].A);
finalVal /= 255.f; finalVal /= 255.f;
return finalVal; return finalVal;
} }
break; break;
case Alpha: case Alpha:
case Luminance: case Luminance:
{ {
float finalVal; float finalVal;
float val[4]; float val[4];
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
val[i] = rBitmap[(nX[i]+nY[i]*nWidth)]; val[i] = rBitmap[(nX[i]+nY[i]*nWidth)];
finalVal = getColorInterp (x, y, val[0], val[1], val[2], val[3]); finalVal = getColorInterp (x, y, val[0], val[1], val[2], val[3]);
finalVal /= 255.f; finalVal /= 255.f;
if (this->PixelFormat == Alpha) if (this->PixelFormat == Alpha)
return CRGBAF (1.f, 1.f, 1.f, finalVal); return CRGBAF (1.f, 1.f, 1.f, finalVal);
else // Luminance else // Luminance
return CRGBAF (finalVal, finalVal, finalVal, 1.f); return CRGBAF (finalVal, finalVal, finalVal, 1.f);
}
break;
default: break;
} }
break;
default: break;
} }
return CRGBAF (0.0f, 0.0f, 0.0f, 0.0f); return CRGBAF (0.0f, 0.0f, 0.0f, 0.0f);

@ -110,10 +110,9 @@ IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC
bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, std::string &title, float &length) bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, std::string &title, float &length)
{ {
std::string lookup = CPath::lookup(filepath, false); if (filepath.empty() || !CFile::fileExists(filepath))
if (lookup.empty())
{ {
nlwarning("Music file %s does not exist!", filepath.c_str()); nlwarning("Music file '%s' does not exist!", filepath.c_str());
return false; return false;
} }
@ -121,7 +120,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
CIFile ifile; CIFile ifile;
ifile.setCacheFileOnOpen(false); ifile.setCacheFileOnOpen(false);
ifile.allowBNPCacheFileOnOpen(false); ifile.allowBNPCacheFileOnOpen(false);
if (ifile.open(lookup)) if (ifile.open(filepath))
return CAudioDecoderFfmpeg::getInfo(&ifile, artist, title, length); return CAudioDecoderFfmpeg::getInfo(&ifile, artist, title, length);
#else #else
std::string type = CFile::getExtension(filepath); std::string type = CFile::getExtension(filepath);
@ -132,7 +131,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
CIFile ifile; CIFile ifile;
ifile.setCacheFileOnOpen(false); ifile.setCacheFileOnOpen(false);
ifile.allowBNPCacheFileOnOpen(false); ifile.allowBNPCacheFileOnOpen(false);
if (ifile.open(lookup)) if (ifile.open(filepath))
return CAudioDecoderVorbis::getInfo(&ifile, artist, title, length); return CAudioDecoderVorbis::getInfo(&ifile, artist, title, length);
nlwarning("Unable to open: '%s'", filepath.c_str()); nlwarning("Unable to open: '%s'", filepath.c_str());
@ -143,7 +142,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
CIFile ifile; CIFile ifile;
ifile.setCacheFileOnOpen(false); ifile.setCacheFileOnOpen(false);
ifile.allowBNPCacheFileOnOpen(false); ifile.allowBNPCacheFileOnOpen(false);
if (ifile.open(lookup)) if (ifile.open(filepath))
return CAudioDecoderMP3::getInfo(&ifile, artist, title, length); return CAudioDecoderMP3::getInfo(&ifile, artist, title, length);
nlwarning("Unable to open: '%s'", filepath.c_str()); nlwarning("Unable to open: '%s'", filepath.c_str());

@ -496,36 +496,20 @@ bool getTag (std::string &result, const char *tag, FSOUND_STREAM *stream)
} }
/** Get music info. Returns false if the song is not found or the function is not implemented. /** Get music info. Returns false if the song is not found or the function is not implemented.
* \param filepath path to file, CPath::lookup done by driver * \param filepath full path to file
* \param artist returns the song artist (empty if not available) * \param artist returns the song artist (empty if not available)
* \param title returns the title (empty if not available) * \param title returns the title (empty if not available)
*/ */
bool CSoundDriverFMod::getMusicInfo(const std::string &filepath, std::string &artist, std::string &title, float &length) bool CSoundDriverFMod::getMusicInfo(const std::string &filepath, std::string &artist, std::string &title, float &length)
{ {
/* Open a stream, get the tag if it exists, close the stream */ if (filepath.empty() || !CFile::fileExists(filepath))
string pathName = CPath::lookup(filepath, false);
uint32 fileOffset = 0, fileSize = 0;
if (pathName.empty())
{ {
nlwarning("NLSOUND FMod Driver: Music file %s not found!", filepath.c_str()); nlwarning("NLSOUND FMod Driver: Music file %s not found!", filepath.c_str());
return false; return false;
} }
// if the file is in a bnp
if (pathName.find('@') != string::npos)
{
if (CBigFile::getInstance().getFileInfo(pathName, fileSize, fileOffset))
{
// set pathname to bnp
pathName = pathName.substr(0, pathName.find('@'));
}
else
{
nlwarning("NLSOUND FMod Driver: BNP BROKEN");
return false;
}
}
FSOUND_STREAM *stream = FSOUND_Stream_Open((const char *)CPath::lookup(filepath, false).c_str(), FSOUND_2D, (sint)fileOffset, (sint)fileSize); uint32 fileOffset = 0, fileSize = 0;
FSOUND_STREAM *stream = FSOUND_Stream_Open(filepath.c_str(), FSOUND_2D, (sint)fileOffset, (sint)fileSize);
if (stream) if (stream)
{ {
getTag(artist, "ARTIST", stream); getTag(artist, "ARTIST", stream);

@ -112,7 +112,7 @@ public:
virtual IMusicChannel *createMusicChannel(); virtual IMusicChannel *createMusicChannel();
/** Get music info. Returns false if the song is not found or the function is not implemented. /** Get music info. Returns false if the song is not found or the function is not implemented.
* \param filepath path to file, CPath::lookup done by driver * \param filepath full path to file
* \param artist returns the song artist (empty if not available) * \param artist returns the song artist (empty if not available)
* \param title returns the title (empty if not available) * \param title returns the title (empty if not available)
*/ */

@ -567,6 +567,11 @@ CDBCtrlSheet::~CDBCtrlSheet()
Driver->deleteTextureFile(_GuildSymb); Driver->deleteTextureFile(_GuildSymb);
_GuildSymb = NULL; _GuildSymb = NULL;
} }
if (_RegenText)
{
delete _RegenText;
_RegenText = NULL;
}
// ensure erase static // ensure erase static
if(this==_CurrMenuSheet) _CurrMenuSheet = NULL; if(this==_CurrMenuSheet) _CurrMenuSheet = NULL;

@ -1044,6 +1044,10 @@ void CInterfaceManager::initInGame()
gc->setTarget(gc->getSavedTarget()); gc->setTarget(gc->getSavedTarget());
} }
// rebuild mp3 player playlist if user reselected a char (songs are already scanned)
CAHManager::getInstance()->runActionHandler("music_player", NULL, "update_playlist");
CAHManager::getInstance()->runActionHandler("music_player", NULL, "stop");
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHATLOG_STATE", false); CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHATLOG_STATE", false);
if (node) if (node)
{ {

@ -2298,13 +2298,28 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
if(!instance.empty()) if(!instance.empty())
{ {
if (texture == "#season#" || texture.empty())
{
uint8 selectedTextureSet = (uint8)::computeCurrSeason();
instance.selectTextureSet(selectedTextureSet);
texture = "";
}
else if (texture[0] == '#')
{
uint8 selectedTextureSet;
fromString(texture.substr(1), selectedTextureSet);
instance.selectTextureSet(selectedTextureSet);
texture = "";
}
for(uint j=0;j<instance.getNumMaterials();j++) for(uint j=0;j<instance.getNumMaterials();j++)
{ {
if (!highlight) if (!highlight)
{ {
instance.getMaterial(j).setAmbient(CRGBA(0,0,0,255)); /*instance.getMaterial(j).setAmbient(CRGBA(0,0,0,255));
instance.getMaterial(j).setEmissive(CRGBA(255,255,255,255)); instance.getMaterial(j).setEmissive(CRGBA(255,255,255,255));
instance.getMaterial(j).setShininess(10.0f); instance.getMaterial(j).setShininess(10.0f);*/
} }
else else
{ {

@ -174,28 +174,30 @@ void CMusicPlayer::playSongs (const std::vector<std::string> &filenames)
// If pause, stop, else play will resume // If pause, stop, else play will resume
if (_State == Paused || _Songs.empty()) if (_State == Paused || _Songs.empty())
_State = Stopped; stop();
// get song title/duration using worker thread // get song title/duration using worker thread
MusicPlayerWorker.getSongsInfo(filenames); MusicPlayerWorker.getSongsInfo(filenames);
} }
// *************************************************************************** // ***************************************************************************
void CMusicPlayer::updatePlaylist(sint prevIndex) void CMusicPlayer::updatePlaylist(uint index, bool state)
{ {
CInterfaceElement *pIE; if (index >= _Songs.size()) return;
std::string rowId;
std::string rowId = toString("%s:s%d:bg", MP3_PLAYER_PLAYLIST_LIST, index);
CInterfaceElement *pIE = dynamic_cast<CInterfaceElement*>(CWidgetManager::getInstance()->getElementFromId(rowId));
if (pIE) pIE->setActive(state);
}
void CMusicPlayer::updatePlaylist(sint prevIndex)
{
if (prevIndex >= 0 && prevIndex < _Songs.size()) if (prevIndex >= 0 && prevIndex < _Songs.size())
{ {
rowId = toString("%s:s%d:bg", MP3_PLAYER_PLAYLIST_LIST, prevIndex); updatePlaylist(prevIndex, false);
pIE = dynamic_cast<CInterfaceElement*>(CWidgetManager::getInstance()->getElementFromId(rowId));
if (pIE) pIE->setActive(false);
} }
rowId = toString("%s:s%d:bg", MP3_PLAYER_PLAYLIST_LIST, _CurrentSongIndex); updatePlaylist(_CurrentSongIndex, true);
pIE = dynamic_cast<CInterfaceElement*>(CWidgetManager::getInstance()->getElementFromId(rowId));
if (pIE) pIE->setActive(true);
} }
// *************************************************************************** // ***************************************************************************
@ -361,7 +363,7 @@ void CMusicPlayer::play (sint index)
if (_Songs.empty()) if (_Songs.empty())
{ {
_State = Stopped; stop();
return; return;
} }
@ -432,11 +434,15 @@ void CMusicPlayer::stop ()
return; return;
// stop the music only if we are really playing (else risk to stop a background music!) // stop the music only if we are really playing (else risk to stop a background music!)
SoundMngr->stopMusic(0); if (_State != Stopped)
SoundMngr->stopMusic(0);
_State = Stopped; _State = Stopped;
_PlayStart = 0; _PlayStart = 0;
_PauseTime = 0; _PauseTime = 0;
clearPlayingInfo();
NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MP3_PLAYING")->setValueBool(false); NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MP3_PLAYING")->setValueBool(false);
} }
@ -472,12 +478,38 @@ void CMusicPlayer::next ()
} }
// *************************************************************************** // ***************************************************************************
void CMusicPlayer::updatePlayingInfo(const std::string info)
{
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text"));
if (pVT)
{
pVT->setText(ucstring::makeFromUtf8(info));
}
}
// ***************************************************************************
void CMusicPlayer::clearPlayingInfo()
{
if (_Songs.empty())
{
updatePlayingInfo(CI18N::get("uiNoFiles").toUtf8());
}
else
{
updatePlayingInfo("");
}
}
// ***************************************************************************
void CMusicPlayer::update () void CMusicPlayer::update ()
{ {
if(!SoundMngr) if(!SoundMngr)
{ {
_State = Stopped; if (_State != Stopped)
{
_State = Stopped;
clearPlayingInfo();
}
return; return;
} }
@ -488,8 +520,6 @@ void CMusicPlayer::update ()
if (_State == Playing) if (_State == Playing)
{ {
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text"));
if (pVT)
{ {
TTime dur = (CTime::getLocalTime() - _PlayStart) / 1000; TTime dur = (CTime::getLocalTime() - _PlayStart) / 1000;
uint min = (dur / 60) % 60; uint min = (dur / 60) % 60;
@ -499,7 +529,7 @@ void CMusicPlayer::update ()
std::string title(toString("%02d:%02d", min, sec)); std::string title(toString("%02d:%02d", min, sec));
if (hour > 0) title = toString("%02d:", hour) + title; if (hour > 0) title = toString("%02d:", hour) + title;
title += " " + _CurrentSong.Title; title += " " + _CurrentSong.Title;
pVT->setText(ucstring::makeFromUtf8(title)); updatePlayingInfo(title);
} }
if (SoundMngr->isMusicEnded ()) if (SoundMngr->isMusicEnded ())
@ -520,8 +550,13 @@ void CMusicPlayer::update ()
} }
else else
{ {
SoundMngr->stopMusic(0); // remove active highlight from playlist
_State = Stopped; updatePlaylist(_CurrentSongIndex, false);
stop();
// restart from top on next 'play'
_CurrentSongIndex = 0;
} }
} }
} }

@ -62,6 +62,10 @@ public:
void update (); void update ();
// update currently playing song info/duration on main gui
void updatePlayingInfo(const std::string info);
void clearPlayingInfo();
bool isRepeatEnabled() const; bool isRepeatEnabled() const;
bool isShuffleEnabled() const; bool isShuffleEnabled() const;
@ -71,6 +75,8 @@ public:
void shuffleAndRebuildPlaylist(); void shuffleAndRebuildPlaylist();
// Update playlist active row // Update playlist active row
void updatePlaylist(sint prevIndex = -1); void updatePlaylist(sint prevIndex = -1);
// set/remove playlist highlight
void updatePlaylist(uint index, bool state);
// Update single song title/duration on _Songs and on playlist // Update single song title/duration on _Songs and on playlist
void updateSong(const CSongs &song); void updateSong(const CSongs &song);

@ -240,8 +240,8 @@ void releaseMainLoopReselect()
// alredy called from farTPMainLoop() // alredy called from farTPMainLoop()
// --R2::getEditor().autoConfigRelease(IsInRingSession); // --R2::getEditor().autoConfigRelease(IsInRingSession);
// Pause any user played music // stop any user played music
MusicPlayer.pause(); MusicPlayer.stop();
// only really needed at exit // only really needed at exit
// --STRING_MANAGER::CStringManagerClient::instance()->flushStringCache(); // --STRING_MANAGER::CStringManagerClient::instance()->flushStringCache();
@ -390,8 +390,8 @@ void releaseMainLoop(bool closeConnection)
// Release R2 editor if applicable // Release R2 editor if applicable
R2::getEditor().autoConfigRelease(IsInRingSession); R2::getEditor().autoConfigRelease(IsInRingSession);
// Pause any user played music // stop any user played music
MusicPlayer.pause(); MusicPlayer.stop();
// flush the server string cache // flush the server string cache
STRING_MANAGER::CStringManagerClient::instance()->flushStringCache(); STRING_MANAGER::CStringManagerClient::instance()->flushStringCache();

Loading…
Cancel
Save