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

This commit is contained in:
kaetemi 2019-05-13 03:59:12 +08:00
commit 08908452d5
13 changed files with 1065 additions and 646 deletions

View file

@ -43,8 +43,9 @@ namespace NLGUI
std::string key;
std::string value;
char op; // =, ~, |, ^, $, *
SAttribute(const std::string &k, const std::string &v, char o)
:key(k),value(v),op(o)
bool caseSensitive;
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
// ' ' 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'
void addPseudoClass(const std::string &key);

View file

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

View file

@ -18,7 +18,7 @@
#define NLSOUND_AUDIO_DECODER_MP3_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>

File diff suppressed because it is too large Load diff

View file

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

View file

@ -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)
@ -135,6 +143,12 @@ namespace NLGUI
if (!elm.hasAttribute(Attr[i].key)) return false;
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)
{
case '=':

View file

@ -103,7 +103,7 @@ IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC
{
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")
{
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());
}
#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")
{
CIFile ifile;

View file

@ -17,7 +17,7 @@
#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>

View file

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

View file

@ -472,6 +472,10 @@ CClientConfig::CClientConfig()
ColorShout = CRGBA(150,0,0,255); // Default Shout 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
// DataPath.push_back("data/"); // Default Path for the Data.
@ -1247,6 +1251,10 @@ void CClientConfig::setValues()
// Max track
READ_INT_FV(MaxTrack)
// MP3 Player
READ_STRING_FV(MediaPlayerDirectory);
READ_BOOL_FV(MediaPlayerAutoPlay);
/////////////////
// USER COLORS //
// Shout Color

View file

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

View file

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

View file

@ -1081,6 +1081,8 @@ bool mainLoop()
ProgressBar.finish();
bool musicTriggerAutoPlay = true;
// Main loop. If the window is no more Active -> Exit.
while( !UserEntity->permanentDeath()
&& !game_exit )
@ -2418,6 +2420,17 @@ bool mainLoop()
// Update ingame duration and stat report sending
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
MusicPlayer.update ();
@ -2453,6 +2466,9 @@ bool mainLoop()
// we have just completed init main loop, after reselecting character
// repeat the steps before the main loop itself
// new char, retrigger music autoplay
musicTriggerAutoPlay = true;
// pre main loop in mainLoop
resetIngameTime ();