Merge remote-tracking branch 'origin/hg/develop' into kaetemi-develop

feature/nel-dll
kaetemi 6 years ago
commit 08908452d5

@ -43,8 +43,9 @@ namespace NLGUI
std::string key; std::string key;
std::string value; std::string value;
char op; // =, ~, |, ^, $, * char op; // =, ~, |, ^, $, *
SAttribute(const std::string &k, const std::string &v, char o) bool caseSensitive;
:key(k),value(v),op(o) SAttribute(const std::string &k, const std::string &v, char o, bool cs)
:key(k),value(v),op(o), caseSensitive(cs)
{} {}
}; };
@ -69,7 +70,8 @@ namespace NLGUI
// add attribute to selector // add attribute to selector
// ' ' op means 'key exists, ignore value' // ' ' op means 'key exists, ignore value'
void addAttribute(const std::string &key, const std::string &val = "", char op = ' '); // cs case-sensitive true|false
void addAttribute(const std::string &key, const std::string &val = "", char op = ' ', bool cs = true);
// add pseudo class to selector, eg 'first-child' // add pseudo class to selector, eg 'first-child'
void addPseudoClass(const std::string &key); void addPseudoClass(const std::string &key);

@ -282,9 +282,11 @@ template <class T> T trimQuotes (const T &str)
typename T::size_type size = str.size(); typename T::size_type size = str.size();
if (size == 0) if (size == 0)
return str; return str;
if (str[0] != str[size-1] && (str[0] != '"' || str[0] != '\'')) if (str[0] != str[size-1])
return str; return str;
return str.substr(1, size - 1); if (str[0] != '"' && str[0] != '\'')
return str;
return str.substr(1, size - 2);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

@ -18,7 +18,7 @@
#define NLSOUND_AUDIO_DECODER_MP3_H #define NLSOUND_AUDIO_DECODER_MP3_H
#include <nel/misc/types_nl.h> #include <nel/misc/types_nl.h>
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */ #if !defined(NL_OS_WINDOWS) || (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
#include <nel/sound/audio_decoder.h> #include <nel/sound/audio_decoder.h>

File diff suppressed because it is too large Load Diff

@ -463,7 +463,7 @@ namespace NLGUI
{ {
if (sel[pos] == '\'' || sel[pos] == '"') if (sel[pos] == '\'' || sel[pos] == '"')
{ {
// value is quoted // skip over quoted value
start = pos; start = pos;
pos++; pos++;
while(pos < sel.size() && sel[pos] != sel[start]) while(pos < sel.size() && sel[pos] != sel[start])
@ -476,9 +476,6 @@ namespace NLGUI
} }
if (pos == sel.size()) break; if (pos == sel.size()) break;
value = sel.substr(start + 1, pos - start - 1);
break;
} }
else if (sel[pos] == '\\') else if (sel[pos] == '\\')
{ {
@ -486,7 +483,6 @@ namespace NLGUI
} }
else if (!quote && sel[pos] == ']') else if (!quote && sel[pos] == ']')
{ {
// unquoted value
value = sel.substr(start, pos - start); value = sel.substr(start, pos - start);
break; break;
} }
@ -494,17 +490,20 @@ namespace NLGUI
pos++; pos++;
} // while 'value' } // while 'value'
// TODO: scan for sel[pos] == ']'
if (pos == sel.size()) break; if (pos == sel.size()) break;
// whitespace between quote and ], ie '[ attr $= "val" ]'
if (sel[pos] != ']') bool cs = true;
// [value="attr" i]
if (value.size() > 2 && value[value.size()-2] == ' ')
{ {
while(pos < sel.size() && sel[pos] != ']') ucchar lastChar = value[value.size()-1];
pos++; if (lastChar == 'i' || lastChar == 'I' || lastChar == 's' || lastChar == 'S')
{
value = value.substr(0, value.size()-2);
cs = !((lastChar == 'i' || lastChar == 'I'));
} }
if (pos == sel.size()) break; }
current.addAttribute(key.toUtf8(), trimQuotes(value).toUtf8(), (char)op, cs);
current.addAttribute(key.toUtf8(), value.toUtf8(), (char)op);
} // op error } // op error
} // no value } // no value

@ -71,9 +71,17 @@ namespace NLGUI
} }
} }
void CCssSelector::addAttribute(const std::string &key, const std::string &val, char op) void CCssSelector::addAttribute(const std::string &key, const std::string &val, char op, bool cs)
{ {
Attr.push_back(SAttribute(key, val, op)); if (cs)
{
// case sensitive match
Attr.push_back(SAttribute(key, val, op, cs));
}
else
{
Attr.push_back(SAttribute(key, toLower(val), op, cs));
}
} }
void CCssSelector::addPseudoClass(const std::string &key) void CCssSelector::addPseudoClass(const std::string &key)
@ -135,6 +143,12 @@ namespace NLGUI
if (!elm.hasAttribute(Attr[i].key)) return false; if (!elm.hasAttribute(Attr[i].key)) return false;
std::string value = elm.getAttribute(Attr[i].key); std::string value = elm.getAttribute(Attr[i].key);
// case-insensitive compare, Attr.value is already lowercased
if (!Attr[i].caseSensitive)
{
value = toLower(value);
}
switch(Attr[i].op) switch(Attr[i].op)
{ {
case '=': case '=':

@ -103,7 +103,7 @@ IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC
{ {
return new CAudioDecoderVorbis(stream, loop); return new CAudioDecoderVorbis(stream, loop);
} }
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */ #if !defined(NL_OS_WINDOWS) || (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
else if (type_lower == "mp3") else if (type_lower == "mp3")
{ {
return new CAudioDecoderMP3(stream, loop); return new CAudioDecoderMP3(stream, loop);
@ -146,7 +146,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
nlwarning("Unable to open: '%s'", filepath.c_str()); nlwarning("Unable to open: '%s'", filepath.c_str());
} }
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */ #if !defined(NL_OS_WINDOWS) || (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
else if (type_lower == "mp3") else if (type_lower == "mp3")
{ {
CIFile ifile; CIFile ifile;

@ -17,7 +17,7 @@
#include "stdsound.h" #include "stdsound.h"
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */ #if !defined(NL_OS_WINDOWS) || (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
#include <nel/sound/audio_decoder_mp3.h> #include <nel/sound/audio_decoder_mp3.h>

@ -359,6 +359,10 @@ SoundGameMusicVolume_min = 0.0;
SoundGameMusicVolume_max = 1.0; SoundGameMusicVolume_max = 1.0;
SoundGameMusicVolume_step = 0.001; SoundGameMusicVolume_step = 0.001;
// MP3 player
MediaPlayerDirectory = "music";
MediaPlayerAutoPlay = false;
// MISC // MISC
PreDataPath = { "user", "patch", "data", "examples" }; PreDataPath = { "user", "patch", "data", "examples" };
NeedComputeVS = 0; NeedComputeVS = 0;

@ -472,6 +472,10 @@ CClientConfig::CClientConfig()
ColorShout = CRGBA(150,0,0,255); // Default Shout color. ColorShout = CRGBA(150,0,0,255); // Default Shout color.
ColorTalk = CRGBA(255,255,255,255); // Default Talk color. ColorTalk = CRGBA(255,255,255,255); // Default Talk color.
// MP3 player
MediaPlayerDirectory = "music";
MediaPlayerAutoPlay = false;
// PreDataPath.push_back("data/gamedev/language/"); // Default Path for the language data // PreDataPath.push_back("data/gamedev/language/"); // Default Path for the language data
// DataPath.push_back("data/"); // Default Path for the Data. // DataPath.push_back("data/"); // Default Path for the Data.
@ -1247,6 +1251,10 @@ void CClientConfig::setValues()
// Max track // Max track
READ_INT_FV(MaxTrack) READ_INT_FV(MaxTrack)
// MP3 Player
READ_STRING_FV(MediaPlayerDirectory);
READ_BOOL_FV(MediaPlayerAutoPlay);
///////////////// /////////////////
// USER COLORS // // USER COLORS //
// Shout Color // Shout Color

@ -366,6 +366,10 @@ struct CClientConfig
/// The max number of track we want to use. /// The max number of track we want to use.
uint MaxTrack; uint MaxTrack;
// MP3 Player
string MediaPlayerDirectory;
bool MediaPlayerAutoPlay;
/// Pre Data Path. /// Pre Data Path.
std::vector<string> PreDataPath; std::vector<string> PreDataPath;
/// Data Path. /// Data Path.

@ -23,6 +23,7 @@
#include "../input.h" #include "../input.h"
#include "../sound_manager.h" #include "../sound_manager.h"
#include "interface_manager.h" #include "interface_manager.h"
#include "../client_cfg.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -43,8 +44,6 @@ extern UDriver *Driver;
#define MP3_SAVE_SHUFFLE "UI:SAVE:MP3_SHUFFLE" #define MP3_SAVE_SHUFFLE "UI:SAVE:MP3_SHUFFLE"
#define MP3_SAVE_REPEAT "UI:SAVE:MP3_REPEAT" #define MP3_SAVE_REPEAT "UI:SAVE:MP3_REPEAT"
static const std::string MediaPlayerDirectory("music/");
CMusicPlayer MusicPlayer; CMusicPlayer MusicPlayer;
// *************************************************************************** // ***************************************************************************
@ -396,7 +395,7 @@ public:
// Recursive scan for files from media directory // Recursive scan for files from media directory
vector<string> filesToProcess; vector<string> filesToProcess;
string newPath = CPath::standardizePath(MediaPlayerDirectory); string newPath = CPath::standardizePath(ClientCfg.MediaPlayerDirectory);
CPath::getPathContent (newPath, true, false, true, filesToProcess); CPath::getPathContent (newPath, true, false, true, filesToProcess);
uint i; uint i;

@ -1081,6 +1081,8 @@ bool mainLoop()
ProgressBar.finish(); ProgressBar.finish();
bool musicTriggerAutoPlay = true;
// Main loop. If the window is no more Active -> Exit. // Main loop. If the window is no more Active -> Exit.
while( !UserEntity->permanentDeath() while( !UserEntity->permanentDeath()
&& !game_exit ) && !game_exit )
@ -2418,6 +2420,17 @@ bool mainLoop()
// Update ingame duration and stat report sending // Update ingame duration and stat report sending
updateStatReport (); updateStatReport ();
// Auto play once on character login
if (musicTriggerAutoPlay)
{
musicTriggerAutoPlay = false;
if (ClientCfg.SoundOn && ClientCfg.MediaPlayerAutoPlay)
{
MusicPlayer.stop();
CAHManager::getInstance()->runActionHandler("music_player", NULL, "play_songs");
MusicPlayer.play();
}
}
// Update the music player // Update the music player
MusicPlayer.update (); MusicPlayer.update ();
@ -2453,6 +2466,9 @@ bool mainLoop()
// we have just completed init main loop, after reselecting character // we have just completed init main loop, after reselecting character
// repeat the steps before the main loop itself // repeat the steps before the main loop itself
// new char, retrigger music autoplay
musicTriggerAutoPlay = true;
// pre main loop in mainLoop // pre main loop in mainLoop
resetIngameTime (); resetIngameTime ();

Loading…
Cancel
Save