Adding layout minShowTime argument to set the minimum amount of time for a splash screen to show.

This commit is contained in:
emb
2015-03-03 21:21:57 -06:00
parent 8f78cc0d16
commit b9126f2476
5 changed files with 25 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
<layout width="1920" height="1080" font="LoveloBlack.otf" loadFontSize="32" fontColor="dedede"> <layout width="1920" height="1080" font="LoveloBlack.otf" loadFontSize="32" fontColor="dedede" minShowTime="2">
<!--backgroundImage--> <!--backgroundImage-->
<image src="bkgnd.png" x="0" y="0" height="stretch" width="stretch" layer="0"/> <image src="bkgnd.png" x="0" y="0" height="stretch" width="stretch" layer="0"/>

View File

@@ -40,6 +40,7 @@ Page::Page(Configuration &config)
, SelectSoundChunk(NULL) , SelectSoundChunk(NULL)
, HasSoundedWhenActive(false) , HasSoundedWhenActive(false)
, FirstSoundPlayed(false) , FirstSoundPlayed(false)
, MinShowTime(0)
{ {
} }
@@ -286,6 +287,15 @@ void Page::RemoveSelectedItem()
} }
void Page::SetMinShowTime(float value)
{
MinShowTime = value;
}
float Page::GetMinShowTime()
{
return MinShowTime;
}
void Page::Highlight() void Page::Highlight()
{ {

View File

@@ -73,6 +73,8 @@ public:
void LaunchEnter(); void LaunchEnter();
void LaunchExit(); void LaunchExit();
std::string GetCollectionName(); std::string GetCollectionName();
void SetMinShowTime(float value);
float GetMinShowTime();
private: private:
void Highlight(); void Highlight();
@@ -100,6 +102,8 @@ private:
Sound *SelectSoundChunk; Sound *SelectSoundChunk;
bool HasSoundedWhenActive; bool HasSoundedWhenActive;
bool FirstSoundPlayed; bool FirstSoundPlayed;
float MinShowTime;
float ElapsedTime;
}; };

View File

@@ -113,6 +113,7 @@ Page *PageBuilder::BuildPage()
xml_attribute<> *fontXml = root->first_attribute("font"); xml_attribute<> *fontXml = root->first_attribute("font");
xml_attribute<> *fontColorXml = root->first_attribute("fontColor"); xml_attribute<> *fontColorXml = root->first_attribute("fontColor");
xml_attribute<> *fontSizeXml = root->first_attribute("loadFontSize"); xml_attribute<> *fontSizeXml = root->first_attribute("loadFontSize");
xml_attribute<> *minShowTimeXml = root->first_attribute("minShowTime");
int layoutHeight; int layoutHeight;
int layoutWidth; int layoutWidth;
@@ -165,6 +166,11 @@ Page *PageBuilder::BuildPage()
page = new Page(Config); page = new Page(Config);
if(minShowTimeXml)
{
page->SetMinShowTime(Utils::ConvertFloat(minShowTimeXml->value()));
}
// load sounds // load sounds
for(xml_node<> *sound = root->first_node("sound"); sound; sound = sound->next_sibling("sound")) for(xml_node<> *sound = root->first_node("sound"); sound; sound = sound->next_sibling("sound"))
{ {

View File

@@ -179,7 +179,7 @@ void RetroFE::Run()
if(!SDL::Initialize(Config)) return; if(!SDL::Initialize(Config)) return;
FC.Initialize(); FC.Initialize();
float preloadTime = 0;
bool videoEnable = true; bool videoEnable = true;
int videoLoop = 0; int videoLoop = 0;
Config.GetProperty("videoEnable", videoEnable); Config.GetProperty("videoEnable", videoEnable);
@@ -215,6 +215,7 @@ void RetroFE::Run()
bool splashMode = true; bool splashMode = true;
Launcher l(*this, Config); Launcher l(*this, Config);
preloadTime = static_cast<float>(SDL_GetTicks()) / 1000;
while (running) while (running)
{ {
@@ -242,7 +243,7 @@ void RetroFE::Run()
(void)SDL_PollEvent(&e); (void)SDL_PollEvent(&e);
} }
if(Initialized && splashMode) if(Initialized && splashMode && CurrentPage->GetMinShowTime() <= (CurrentTime - preloadTime))
{ {
SDL_WaitThread(InitializeThread, &initializeStatus); SDL_WaitThread(InitializeThread, &initializeStatus);
@@ -317,7 +318,7 @@ void RetroFE::Run()
if(running) if(running)
{ {
lastTime = CurrentTime; lastTime = CurrentTime;
CurrentTime = (float)SDL_GetTicks() / 1000; CurrentTime = static_cast<float>(SDL_GetTicks()) / 1000;
if (CurrentTime < lastTime) if (CurrentTime < lastTime)
{ {